SNode.C
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
iot::mqtt::ControlPacket Class Referenceabstract

#include <ControlPacket.h>

Inheritance diagram for iot::mqtt::ControlPacket:
Collaboration diagram for iot::mqtt::ControlPacket:

Public Member Functions

 ControlPacket (uint8_t type, const std::string &name)
 
 ControlPacket (const ControlPacket &)=default
 
 ControlPacket (ControlPacket &&)=default
 
virtual ~ControlPacket ()
 
ControlPacketoperator= (const ControlPacket &)=default
 
ControlPacketoperator= (ControlPacket &&)=default
 
virtual std::vector< char > serializeVP () const =0
 
std::vector< char > serialize () const
 
const std::string & getName () const
 
uint8_t getType () const
 
uint8_t getFlags () const
 

Protected Attributes

uint8_t flags = 0
 

Private Attributes

std::string name
 
uint8_t type = 0
 

Detailed Description

Definition at line 91 of file ControlPacket.h.

Constructor & Destructor Documentation

◆ ControlPacket() [1/3]

iot::mqtt::ControlPacket::ControlPacket ( uint8_t  type,
const std::string &  name 
)

Definition at line 70 of file ControlPacket.cpp.

71 : name(name)
72 , type(type) {
73 switch (type) {
74 case MQTT_CONNECT:
76 break;
77 case MQTT_CONNACK:
79 break;
80 case MQTT_PUBLISH:
81 // no flags for MQTT_PUBLISH_FLAGS
82 break;
83 case MQTT_PUBACK:
85 break;
86 case MQTT_PUBREC:
88 break;
89 case MQTT_PUBREL:
91 break;
92 case MQTT_PUBCOMP:
94 break;
95 case MQTT_SUBSCRIBE:
97 break;
98 case MQTT_SUBACK:
100 break;
101 case MQTT_UNSUBSCRIBE:
103 break;
104 case MQTT_UNSUBACK:
106 break;
107 case MQTT_PINGREQ:
109 break;
110 case MQTT_PINGRESP:
112 break;
113 case MQTT_DISCONNECT:
115 break;
116 }
117 }
#define MQTT_CONNACK
Definition Connack.h:57
#define MQTT_CONNECT
Definition Connect.h:58
#define MQTT_DISCONNECT
Definition Disconnect.h:55
#define MQTT_PINGREQ
Definition Pingreq.h:55
#define MQTT_PINGRESP
Definition Pingresp.h:55
#define MQTT_PUBACK
Definition Puback.h:57
#define MQTT_PUBCOMP
Definition Pubcomp.h:57
#define MQTT_PUBLISH
Definition Publish.h:58
#define MQTT_PUBREC
Definition Pubrec.h:57
#define MQTT_PUBREL
Definition Pubrel.h:57
#define MQTT_SUBACK
Definition Suback.h:58
#define MQTT_SUBSCRIBE
Definition Subscribe.h:59
#define MQTT_UNSUBACK
Definition Unsuback.h:57
#define MQTT_UNSUBSCRIBE
Definition Unsubscribe.h:59
#define MQTT_CONNECT_FLAGS
#define MQTT_PUBREL_FLAGS
#define MQTT_PUBCOMP_FLAGS
#define MQTT_SUBSCRIBE_FLAGS
#define MQTT_SUBACK_FLAGS
#define MQTT_DISCONNECT_FLAGS
#define MQTT_PUBACK_FLAGS
#define MQTT_UNSUBSCRIBE_FLAGS
#define MQTT_CONNACK_FLAGS
#define MQTT_PINGREQ_FLAGS
#define MQTT_PUBREC_FLAGS
#define MQTT_UNSUBACK_FLAGS
#define MQTT_PINGRESP_FLAGS

References flags, name, and type.

Referenced by iot::mqtt::packets::Connack::Connack(), iot::mqtt::packets::Connect::Connect(), iot::mqtt::packets::Disconnect::Disconnect(), iot::mqtt::packets::Pingreq::Pingreq(), iot::mqtt::packets::Pingresp::Pingresp(), iot::mqtt::packets::Puback::Puback(), iot::mqtt::packets::Pubcomp::Pubcomp(), iot::mqtt::packets::Publish::Publish(), iot::mqtt::packets::Pubrec::Pubrec(), iot::mqtt::packets::Pubrel::Pubrel(), iot::mqtt::packets::Suback::Suback(), iot::mqtt::packets::Subscribe::Subscribe(), iot::mqtt::packets::Unsuback::Unsuback(), and iot::mqtt::packets::Unsubscribe::Unsubscribe().

Here is the caller graph for this function:

◆ ControlPacket() [2/3]

iot::mqtt::ControlPacket::ControlPacket ( const ControlPacket )
default

◆ ControlPacket() [3/3]

iot::mqtt::ControlPacket::ControlPacket ( ControlPacket &&  )
default

◆ ~ControlPacket()

iot::mqtt::ControlPacket::~ControlPacket ( )
virtual

Definition at line 119 of file ControlPacket.cpp.

119 {
120 }

Member Function Documentation

◆ getFlags()

uint8_t iot::mqtt::ControlPacket::getFlags ( ) const

Definition at line 141 of file ControlPacket.cpp.

141 {
142 return flags;
143 }

References flags.

◆ getName()

const std::string & iot::mqtt::ControlPacket::getName ( ) const

Definition at line 122 of file ControlPacket.cpp.

122 {
123 return name;
124 }

References name.

Referenced by iot::mqtt::Mqtt::printVP(), and iot::mqtt::Mqtt::send().

Here is the caller graph for this function:

◆ getType()

uint8_t iot::mqtt::ControlPacket::getType ( ) const

Definition at line 137 of file ControlPacket.cpp.

137 {
138 return type;
139 }

References type.

◆ operator=() [1/2]

ControlPacket & iot::mqtt::ControlPacket::operator= ( const ControlPacket )
default

◆ operator=() [2/2]

ControlPacket & iot::mqtt::ControlPacket::operator= ( ControlPacket &&  )
default

◆ serialize()

std::vector< char > iot::mqtt::ControlPacket::serialize ( ) const

Definition at line 126 of file ControlPacket.cpp.

126 {
127 std::vector<char> variablHeaderPayload = serializeVP();
128
129 const FixedHeader fixedHeader(type, flags, static_cast<uint32_t>(variablHeaderPayload.size()));
130
131 std::vector<char> packet = fixedHeader.serialize();
132 packet.insert(packet.end(), variablHeaderPayload.begin(), variablHeaderPayload.end());
133
134 return packet;
135 }
virtual std::vector< char > serializeVP() const =0

References iot::mqtt::FixedHeader::FixedHeader(), flags, iot::mqtt::FixedHeader::serialize(), serializeVP(), and type.

Referenced by iot::mqtt::Mqtt::send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ serializeVP()

virtual std::vector< char > iot::mqtt::ControlPacket::serializeVP ( ) const
pure virtual

Member Data Documentation

◆ flags

◆ name

std::string iot::mqtt::ControlPacket::name
private

Definition at line 110 of file ControlPacket.h.

Referenced by ControlPacket(), and getName().

◆ type

uint8_t iot::mqtt::ControlPacket::type = 0
private

Definition at line 111 of file ControlPacket.h.

Referenced by ControlPacket(), getType(), and serialize().


The documentation for this class was generated from the following files: