MythTV  master
udppacket.h
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * Copyright (c) 2012 Digital Nirvana, Inc.
3  * Distributed as part of MythTV under GPL v2 and later.
4  */
5 
6 #ifndef UDP_PACKET_H
7 #define UDP_PACKET_H
8 
9 #include <cinttypes>
10 
11 #include <QByteArray>
12 
20 class UDPPacket
21 {
22  public:
23  UDPPacket(const UDPPacket&) = default;
24  explicit UDPPacket(uint64_t key) : m_key(key) { }
25  UDPPacket(void) = default;
26  virtual ~UDPPacket() = default;
27 
28  UDPPacket& operator=(const UDPPacket&) = default;
29 
32  virtual bool IsValid(void) const { return true; }
33 
34  uint64_t GetKey(void) const { return m_key; }
35 
36  QByteArray &GetDataReference(void) { return m_data; }
37  QByteArray GetData(void) const { return m_data; }
38 
39  protected:
41  uint64_t m_key { 0ULL };
42  QByteArray m_data;
43 };
44 
45 #endif // UDP_PACKET_H
UDPPacket::UDPPacket
UDPPacket(uint64_t key)
Definition: udppacket.h:24
UDPPacket::operator=
UDPPacket & operator=(const UDPPacket &)=default
UDPPacket::GetData
QByteArray GetData(void) const
Definition: udppacket.h:37
UDPPacket::m_data
QByteArray m_data
Definition: udppacket.h:42
UDPPacket::m_key
uint64_t m_key
Key used to ensure we avoid extra memory allocation in m_data QByteArray.
Definition: udppacket.h:41
UDPPacket::~UDPPacket
virtual ~UDPPacket()=default
UDPPacket::GetDataReference
QByteArray & GetDataReference(void)
Definition: udppacket.h:36
UDPPacket::IsValid
virtual bool IsValid(void) const
IsValid() must return true before any data access methods are called, other than GetDataReference() a...
Definition: udppacket.h:32
UDPPacket
UDP Packet.
Definition: udppacket.h:20
UDPPacket::GetKey
uint64_t GetKey(void) const
Definition: udppacket.h:34
UDPPacket::UDPPacket
UDPPacket(void)=default