F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
DpRecordSerializableAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DpRecordSerializableAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for DpRecord struct
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
9 
10 namespace Svc {
11 
12  // ----------------------------------------------------------------------
13  // Constructors
14  // ----------------------------------------------------------------------
15 
17  DpRecord() :
18  Serializable(),
19  m_id(0),
20  m_tSec(0),
21  m_tSub(0),
22  m_priority(0),
23  m_size(0),
24  m_state(Fw::DpState::UNTRANSMITTED)
25  {
26 
27  }
28 
30  DpRecord(
31  U32 id,
32  U32 tSec,
33  U32 tSub,
34  U32 priority,
35  U64 size,
36  Fw::DpState::T state
37  ) :
38  Serializable(),
39  m_id(id),
40  m_tSec(tSec),
41  m_tSub(tSub),
42  m_priority(priority),
43  m_size(size),
44  m_state(state)
45  {
46 
47  }
48 
50  DpRecord(const DpRecord& obj) :
51  Serializable(),
52  m_id(obj.m_id),
53  m_tSec(obj.m_tSec),
54  m_tSub(obj.m_tSub),
55  m_priority(obj.m_priority),
56  m_size(obj.m_size),
57  m_state(obj.m_state)
58  {
59 
60  }
61 
62  // ----------------------------------------------------------------------
63  // Operators
64  // ----------------------------------------------------------------------
65 
67  operator=(const DpRecord& obj)
68  {
69  if (this == &obj) {
70  return *this;
71  }
72 
73  set(obj.m_id, obj.m_tSec, obj.m_tSub, obj.m_priority, obj.m_size, obj.m_state);
74  return *this;
75  }
76 
78  operator==(const DpRecord& obj) const
79  {
80  return (
81  (this->m_id == obj.m_id) &&
82  (this->m_tSec == obj.m_tSec) &&
83  (this->m_tSub == obj.m_tSub) &&
84  (this->m_priority == obj.m_priority) &&
85  (this->m_size == obj.m_size) &&
86  (this->m_state == obj.m_state)
87  );
88  }
89 
91  operator!=(const DpRecord& obj) const
92  {
93  return !(*this == obj);
94  }
95 
96 #ifdef BUILD_UT
97 
98  std::ostream& operator<<(std::ostream& os, const DpRecord& obj) {
99  Fw::String s;
100  obj.toString(s);
101  os << s.toChar();
102  return os;
103  }
104 
105 #endif
106 
107  // ----------------------------------------------------------------------
108  // Member functions
109  // ----------------------------------------------------------------------
110 
112  serialize(Fw::SerializeBufferBase& buffer) const
113  {
114  Fw::SerializeStatus status;
115 
116  status = buffer.serialize(this->m_id);
117  if (status != Fw::FW_SERIALIZE_OK) {
118  return status;
119  }
120  status = buffer.serialize(this->m_tSec);
121  if (status != Fw::FW_SERIALIZE_OK) {
122  return status;
123  }
124  status = buffer.serialize(this->m_tSub);
125  if (status != Fw::FW_SERIALIZE_OK) {
126  return status;
127  }
128  status = buffer.serialize(this->m_priority);
129  if (status != Fw::FW_SERIALIZE_OK) {
130  return status;
131  }
132  status = buffer.serialize(this->m_size);
133  if (status != Fw::FW_SERIALIZE_OK) {
134  return status;
135  }
136  status = buffer.serialize(this->m_state);
137  if (status != Fw::FW_SERIALIZE_OK) {
138  return status;
139  }
140 
141  return status;
142  }
143 
146  {
147  Fw::SerializeStatus status;
148 
149  status = buffer.deserialize(this->m_id);
150  if (status != Fw::FW_SERIALIZE_OK) {
151  return status;
152  }
153  status = buffer.deserialize(this->m_tSec);
154  if (status != Fw::FW_SERIALIZE_OK) {
155  return status;
156  }
157  status = buffer.deserialize(this->m_tSub);
158  if (status != Fw::FW_SERIALIZE_OK) {
159  return status;
160  }
161  status = buffer.deserialize(this->m_priority);
162  if (status != Fw::FW_SERIALIZE_OK) {
163  return status;
164  }
165  status = buffer.deserialize(this->m_size);
166  if (status != Fw::FW_SERIALIZE_OK) {
167  return status;
168  }
169  status = buffer.deserialize(this->m_state);
170  if (status != Fw::FW_SERIALIZE_OK) {
171  return status;
172  }
173 
174  return status;
175  }
176 
177 #if FW_SERIALIZABLE_TO_STRING
178 
179  void DpRecord ::
180  toString(Fw::StringBase& sb) const
181  {
182  static const char* formatString =
183  "( "
184  "id = %" PRIu32 ", "
185  "tSec = %" PRIu32 ", "
186  "tSub = %" PRIu32 ", "
187  "priority = %" PRIu32 ", "
188  "size = %" PRIu64 ", "
189  "state = %s"
190  " )";
191 
192  // Declare strings to hold any serializable toString() arguments
193  Fw::String stateStr;
194 
195  // Call toString for arrays and serializable types
196  this->m_state.toString(stateStr);
197 
198  sb.format(
199  formatString,
200  this->m_id,
201  this->m_tSec,
202  this->m_tSub,
203  this->m_priority,
204  this->m_size,
205  stateStr.toChar()
206  );
207  }
208 
209 #endif
210 
211  // ----------------------------------------------------------------------
212  // Setter functions
213  // ----------------------------------------------------------------------
214 
216  set(
217  U32 id,
218  U32 tSec,
219  U32 tSub,
220  U32 priority,
221  U64 size,
222  Fw::DpState::T state
223  )
224  {
225  this->m_id = id;
226  this->m_tSec = tSec;
227  this->m_tSub = tSub;
228  this->m_priority = priority;
229  this->m_size = size;
230  this->m_state = state;
231  }
232 
234  setid(U32 id)
235  {
236  this->m_id = id;
237  }
238 
240  settSec(U32 tSec)
241  {
242  this->m_tSec = tSec;
243  }
244 
246  settSub(U32 tSub)
247  {
248  this->m_tSub = tSub;
249  }
250 
252  setpriority(U32 priority)
253  {
254  this->m_priority = priority;
255  }
256 
258  setsize(U64 size)
259  {
260  this->m_size = size;
261  }
262 
265  {
266  this->m_state = state;
267  }
268 
269 }
T
The raw enum type.
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
const char * toChar() const
Definition: String.hpp:50
Data structure representing a data product.
DpRecord()
Constructor (default value)
void set(U32 id, U32 tSec, U32 tSub, U32 priority, U64 size, Fw::DpState::T state)
Set all members.
void setstate(Fw::DpState::T state)
Set member state.
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialization.
void setpriority(U32 priority)
Set member priority.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialization.
void setid(U32 id)
Set member id.
void setsize(U64 size)
Set member size.
DpRecord & operator=(const DpRecord &obj)
Copy assignment operator.
void settSec(U32 tSec)
Set member tSec.
bool operator==(const DpRecord &obj) const
Equality operator.
bool operator!=(const DpRecord &obj) const
Inequality operator.
void settSub(U32 tSub)
Set member tSub.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
#define U64(C)
Definition: sha.h:176