F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FrameContextSerializableAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FrameContextSerializableAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for FrameContext struct
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 
10 namespace ComCfg {
11 
12  // ----------------------------------------------------------------------
13  // Constructors
14  // ----------------------------------------------------------------------
15 
18  Serializable(),
19  m_comQueueIndex(0),
20  m_apid(ComCfg::Apid::FW_PACKET_UNKNOWN),
21  m_sequenceCount(0),
22  m_vcId(1)
23  {
24 
25  }
26 
29  FwIndexType comQueueIndex,
30  ComCfg::Apid::T apid,
31  U16 sequenceCount,
32  U8 vcId
33  ) :
34  Serializable(),
35  m_comQueueIndex(comQueueIndex),
36  m_apid(apid),
37  m_sequenceCount(sequenceCount),
38  m_vcId(vcId)
39  {
40 
41  }
42 
45  Serializable(),
46  m_comQueueIndex(obj.m_comQueueIndex),
47  m_apid(obj.m_apid),
48  m_sequenceCount(obj.m_sequenceCount),
49  m_vcId(obj.m_vcId)
50  {
51 
52  }
53 
54  // ----------------------------------------------------------------------
55  // Operators
56  // ----------------------------------------------------------------------
57 
60  {
61  if (this == &obj) {
62  return *this;
63  }
64 
65  set(obj.m_comQueueIndex, obj.m_apid, obj.m_sequenceCount, obj.m_vcId);
66  return *this;
67  }
68 
69  bool FrameContext ::
70  operator==(const FrameContext& obj) const
71  {
72  if (this == &obj) { return true; }
73  return (
74  (this->m_comQueueIndex == obj.m_comQueueIndex) &&
75  (this->m_apid == obj.m_apid) &&
76  (this->m_sequenceCount == obj.m_sequenceCount) &&
77  (this->m_vcId == obj.m_vcId)
78  );
79  }
80 
81  bool FrameContext ::
82  operator!=(const FrameContext& obj) const
83  {
84  return !(*this == obj);
85  }
86 
87 #ifdef BUILD_UT
88 
89  std::ostream& operator<<(std::ostream& os, const FrameContext& obj) {
90  Fw::String s;
91  obj.toString(s);
92  os << s.toChar();
93  return os;
94  }
95 
96 #endif
97 
98  // ----------------------------------------------------------------------
99  // Member functions
100  // ----------------------------------------------------------------------
101 
104  Fw::SerializeBufferBase& buffer,
105  Fw::Endianness mode
106  ) const
107  {
108  Fw::SerializeStatus status;
109 
110  status = buffer.serializeFrom(this->m_comQueueIndex, mode);
111  if (status != Fw::FW_SERIALIZE_OK) {
112  return status;
113  }
114  status = buffer.serializeFrom(this->m_apid, mode);
115  if (status != Fw::FW_SERIALIZE_OK) {
116  return status;
117  }
118  status = buffer.serializeFrom(this->m_sequenceCount, mode);
119  if (status != Fw::FW_SERIALIZE_OK) {
120  return status;
121  }
122  status = buffer.serializeFrom(this->m_vcId, mode);
123  if (status != Fw::FW_SERIALIZE_OK) {
124  return status;
125  }
126 
127  return status;
128  }
129 
132  Fw::SerializeBufferBase& buffer,
133  Fw::Endianness mode
134  )
135  {
136  Fw::SerializeStatus status;
137 
138  status = buffer.deserializeTo(this->m_comQueueIndex, mode);
139  if (status != Fw::FW_SERIALIZE_OK) {
140  return status;
141  }
142  status = buffer.deserializeTo(this->m_apid, mode);
143  if (status != Fw::FW_SERIALIZE_OK) {
144  return status;
145  }
146  status = buffer.deserializeTo(this->m_sequenceCount, mode);
147  if (status != Fw::FW_SERIALIZE_OK) {
148  return status;
149  }
150  status = buffer.deserializeTo(this->m_vcId, mode);
151  if (status != Fw::FW_SERIALIZE_OK) {
152  return status;
153  }
154 
155  return status;
156  }
157 
160  {
161  FwSizeType size = 0;
162  size += sizeof(FwIndexType);
164  size += sizeof(U16);
165  size += sizeof(U8);
166  return size;
167  }
168 
169 #if FW_SERIALIZABLE_TO_STRING
170 
171  void FrameContext ::
172  toString(Fw::StringBase& sb) const
173  {
174  Fw::String tmp;
175  sb = "( ";
176 
177  // Format comQueueIndex
178  sb += "comQueueIndex = ";
179  tmp.format("%" PRIi16 "", this->m_comQueueIndex);
180  sb += tmp;
181  sb += ", ";
182 
183  // Format apid
184  sb += "apid = ";
185  this->m_apid.toString(tmp);
186  sb += tmp;
187  sb += ", ";
188 
189  // Format sequenceCount
190  sb += "sequenceCount = ";
191  tmp.format("%" PRIu16 "", this->m_sequenceCount);
192  sb += tmp;
193  sb += ", ";
194 
195  // Format vcId
196  sb += "vcId = ";
197  tmp.format("%" PRIu8 "", this->m_vcId);
198  sb += tmp;
199  sb += " )";
200  }
201 
202 #endif
203 
204  // ----------------------------------------------------------------------
205  // Setter functions
206  // ----------------------------------------------------------------------
207 
208  void FrameContext ::
210  FwIndexType comQueueIndex,
211  ComCfg::Apid::T apid,
212  U16 sequenceCount,
213  U8 vcId
214  )
215  {
216  this->m_comQueueIndex = comQueueIndex;
217  this->m_apid = apid;
218  this->m_sequenceCount = sequenceCount;
219  this->m_vcId = vcId;
220  }
221 
222  void FrameContext ::
224  {
225  this->m_comQueueIndex = comQueueIndex;
226  }
227 
228  void FrameContext ::
230  {
231  this->m_apid = apid;
232  }
233 
234  void FrameContext ::
235  set_sequenceCount(U16 sequenceCount)
236  {
237  this->m_sequenceCount = sequenceCount;
238  }
239 
240  void FrameContext ::
242  {
243  this->m_vcId = vcId;
244  }
245 
246 }
Serialization/Deserialization operation was successful.
FrameContext()
Constructor (default value)
PlatformSizeType FwSizeType
const char * toChar() const
Definition: String.hpp:50
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)
deserialize 8-bit unsigned int
void set_apid(ComCfg::Apid::T apid)
Set member apid.
FwSizeType serializedSize() const
Get the dynamic serialized size of the struct.
bool operator!=(const FrameContext &obj) const
Inequality operator.
SerializeStatus
forward declaration for string
The size of the serial representation.
Definition: ApidEnumAc.hpp:67
T
The raw enum type.
Definition: ApidEnumAc.hpp:31
void set_sequenceCount(U16 sequenceCount)
Set member sequenceCount.
Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialization.
Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialization.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)
serialize 8-bit unsigned int
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void set_vcId(U8 vcId)
Set member vcId.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
bool operator==(const FrameContext &obj) const
Equality operator.
void set_comQueueIndex(FwIndexType comQueueIndex)
Set member comQueueIndex.
PlatformIndexType FwIndexType
Type used to pass context info between components during framing/deframing.
void set(FwIndexType comQueueIndex, ComCfg::Apid::T apid, U16 sequenceCount, U8 vcId)
Set all members.
Endianness
APIDs are 11 bits in the Space Packet protocol, so we use U16. Max value 7FF.
Definition: ApidEnumAc.hpp:17
FrameContext & operator=(const FrameContext &obj)
Copy assignment operator.