SNode.C
Loading...
Searching...
No Matches
iot::mqtt_fast::ControlPacketFactory Class Reference

#include <ControlPacketFactory.h>

Collaboration diagram for iot::mqtt_fast::ControlPacketFactory:

Public Member Functions

 ControlPacketFactory (core::socket::SocketContext *socketContext)
 
std::size_t construct ()
 
bool isComplete () const
 
bool isError () const
 
iot::mqtt_fast::types::BinarygetPacket ()
 
uint8_t getPacketType ()
 
uint8_t getPacketFlags ()
 
uint64_t getRemainingLength ()
 
void reset ()
 

Private Attributes

bool completed = false
 
bool error = false
 
int state = 0
 
iot::mqtt_fast::types::Int_1 typeFlags
 
iot::mqtt_fast::types::Int_V remainingLength
 
iot::mqtt_fast::types::Binary data
 

Detailed Description

Definition at line 40 of file ControlPacketFactory.h.

Constructor & Destructor Documentation

◆ ControlPacketFactory()

iot::mqtt_fast::ControlPacketFactory::ControlPacketFactory ( core::socket::SocketContext * socketContext)
explicit

Definition at line 30 of file ControlPacketFactory.cpp.

31 : typeFlags(socketContext)
32 , remainingLength(socketContext)
33 , data(socketContext) {
34 }
iot::mqtt_fast::types::Binary data
iot::mqtt_fast::types::Int_V remainingLength
iot::mqtt_fast::types::Int_1 typeFlags

References ControlPacketFactory(), iot::mqtt_fast::types::Int_1::Int_1(), iot::mqtt_fast::types::Int_V::Int_V(), remainingLength, and typeFlags.

Referenced by ControlPacketFactory().

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

Member Function Documentation

◆ construct()

std::size_t iot::mqtt_fast::ControlPacketFactory::construct ( )

Definition at line 36 of file ControlPacketFactory.cpp.

36 {
37 std::size_t consumed = 0;
38
39 switch (state) {
40 case 0: // Type - Flags
41 consumed = typeFlags.construct();
42 if (typeFlags.isComplete()) {
43 state++;
44 } else {
46 }
47 break;
48 case 1: // Remaining length
49 consumed = remainingLength.construct();
53 state++;
54 } else {
56 }
57 break;
58 case 2: // Var-Header + Payload
59 consumed = data.construct();
60 if (data.isComplete()) {
61 completed = true;
62 state++;
63 } else {
64 error = data.isError();
65 }
66 break;
67 }
68
69 return consumed;
70 }
std::size_t construct() override
Definition Binary.cpp:44
void setLength(std::vector< char >::size_type length)
Definition Binary.cpp:34
std::size_t construct() override
Definition Int_1.cpp:32
uint32_t getValue() const
Definition Int_V.cpp:55
std::size_t construct() override
Definition Int_V.cpp:32

References completed, iot::mqtt_fast::types::Int_1::construct(), iot::mqtt_fast::types::Int_V::construct(), error, iot::mqtt_fast::types::Int_V::getValue(), iot::mqtt_fast::types::TypeBase::isComplete(), iot::mqtt_fast::types::TypeBase::isError(), remainingLength, state, and typeFlags.

Here is the call graph for this function:

◆ getPacket()

iot::mqtt_fast::types::Binary & iot::mqtt_fast::ControlPacketFactory::getPacket ( )

Definition at line 80 of file ControlPacketFactory.cpp.

80 {
81 return data;
82 }

◆ getPacketFlags()

uint8_t iot::mqtt_fast::ControlPacketFactory::getPacketFlags ( )

Definition at line 88 of file ControlPacketFactory.cpp.

88 {
89 return static_cast<uint8_t>(typeFlags.getValue() & 0x0F);
90 }

References iot::mqtt_fast::types::Int_1::getValue(), and typeFlags.

Referenced by iot::mqtt_fast::ControlPacket::ControlPacket(), and iot::mqtt_fast::packets::Publish::Publish().

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

◆ getPacketType()

uint8_t iot::mqtt_fast::ControlPacketFactory::getPacketType ( )

Definition at line 84 of file ControlPacketFactory.cpp.

84 {
85 return static_cast<uint8_t>(typeFlags.getValue() >> 0x04);
86 }

References iot::mqtt_fast::types::Int_1::getValue(), and typeFlags.

Referenced by iot::mqtt_fast::ControlPacket::ControlPacket().

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

◆ getRemainingLength()

uint64_t iot::mqtt_fast::ControlPacketFactory::getRemainingLength ( )

Definition at line 92 of file ControlPacketFactory.cpp.

92 {
93 return data.getValue().size();
94 }
std::vector< char > & getValue()
Definition Binary.cpp:54

◆ isComplete()

bool iot::mqtt_fast::ControlPacketFactory::isComplete ( ) const

Definition at line 72 of file ControlPacketFactory.cpp.

72 {
73 return completed;
74 }

References completed.

◆ isError()

bool iot::mqtt_fast::ControlPacketFactory::isError ( ) const

Definition at line 76 of file ControlPacketFactory.cpp.

76 {
77 return error;
78 }

References error.

◆ reset()

void iot::mqtt_fast::ControlPacketFactory::reset ( )

Definition at line 96 of file ControlPacketFactory.cpp.

96 {
97 completed = false;
98 error = false;
99 state = 0;
100
103 data.reset();
104 }
void reset() override
Definition Int_1.cpp:45
void reset() override
Definition Int_V.cpp:59

References completed, error, remainingLength, iot::mqtt_fast::types::Int_1::reset(), iot::mqtt_fast::types::Int_V::reset(), state, and typeFlags.

Here is the call graph for this function:

Member Data Documentation

◆ completed

bool iot::mqtt_fast::ControlPacketFactory::completed = false
private

Definition at line 55 of file ControlPacketFactory.h.

Referenced by construct(), isComplete(), and reset().

◆ data

iot::mqtt_fast::types::Binary iot::mqtt_fast::ControlPacketFactory::data
private

Definition at line 61 of file ControlPacketFactory.h.

◆ error

bool iot::mqtt_fast::ControlPacketFactory::error = false
private

Definition at line 56 of file ControlPacketFactory.h.

Referenced by construct(), isError(), and reset().

◆ remainingLength

iot::mqtt_fast::types::Int_V iot::mqtt_fast::ControlPacketFactory::remainingLength
private

Definition at line 60 of file ControlPacketFactory.h.

Referenced by construct(), ControlPacketFactory(), and reset().

◆ state

int iot::mqtt_fast::ControlPacketFactory::state = 0
private

Definition at line 57 of file ControlPacketFactory.h.

Referenced by construct(), and reset().

◆ typeFlags

iot::mqtt_fast::types::Int_1 iot::mqtt_fast::ControlPacketFactory::typeFlags
private

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