F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
StatementSerializableAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title StatementSerializableAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for Statement struct
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
9 
10 namespace Svc {
11 
12  namespace Fpy {
13 
14  // ----------------------------------------------------------------------
15  // Constructors
16  // ----------------------------------------------------------------------
17 
20  Serializable(),
21  m_type(Svc::Fpy::StatementType::DIRECTIVE),
22  m_opCode(0),
23  m_argBuf()
24  {
25 
26  }
27 
31  FwOpcodeType opCode,
32  const Fw::StatementArgBuffer& argBuf
33  ) :
34  Serializable(),
35  m_type(type),
36  m_opCode(opCode),
37  m_argBuf(argBuf)
38  {
39 
40  }
41 
43  Statement(const Statement& obj) :
44  Serializable(),
45  m_type(obj.m_type),
46  m_opCode(obj.m_opCode),
47  m_argBuf(obj.m_argBuf)
48  {
49 
50  }
51 
52  // ----------------------------------------------------------------------
53  // Operators
54  // ----------------------------------------------------------------------
55 
57  operator=(const Statement& obj)
58  {
59  if (this == &obj) {
60  return *this;
61  }
62 
63  set(obj.m_type, obj.m_opCode, obj.m_argBuf);
64  return *this;
65  }
66 
67  bool Statement ::
68  operator==(const Statement& obj) const
69  {
70  if (this == &obj) { return true; }
71  return (
72  (this->m_type == obj.m_type) &&
73  (this->m_opCode == obj.m_opCode) &&
74  (this->m_argBuf == obj.m_argBuf)
75  );
76  }
77 
78  bool Statement ::
79  operator!=(const Statement& obj) const
80  {
81  return !(*this == obj);
82  }
83 
84 #ifdef BUILD_UT
85 
86  std::ostream& operator<<(std::ostream& os, const Statement& obj) {
87  Fw::String s;
88  obj.toString(s);
89  os << s.toChar();
90  return os;
91  }
92 
93 #endif
94 
95  // ----------------------------------------------------------------------
96  // Member functions
97  // ----------------------------------------------------------------------
98 
101  {
102  Fw::SerializeStatus status;
103 
104  status = buffer.serialize(this->m_type);
105  if (status != Fw::FW_SERIALIZE_OK) {
106  return status;
107  }
108  status = buffer.serialize(this->m_opCode);
109  if (status != Fw::FW_SERIALIZE_OK) {
110  return status;
111  }
112  status = buffer.serialize(this->m_argBuf);
113  if (status != Fw::FW_SERIALIZE_OK) {
114  return status;
115  }
116 
117  return status;
118  }
119 
122  {
123  Fw::SerializeStatus status;
124 
125  status = buffer.deserialize(this->m_type);
126  if (status != Fw::FW_SERIALIZE_OK) {
127  return status;
128  }
129  status = buffer.deserialize(this->m_opCode);
130  if (status != Fw::FW_SERIALIZE_OK) {
131  return status;
132  }
133  status = buffer.deserialize(this->m_argBuf);
134  if (status != Fw::FW_SERIALIZE_OK) {
135  return status;
136  }
137 
138  return status;
139  }
140 
141 #if FW_SERIALIZABLE_TO_STRING
142 
143  void Statement ::
144  toString(Fw::StringBase& sb) const
145  {
146  static const char* formatString =
147  "( "
148  "type = %s, "
149  "opCode = %s, "
150  "argBuf = %s"
151  " )";
152 
153  // Declare strings to hold any serializable toString() arguments
154  Fw::String typeStr;
155  Fw::String argBufStr;
156 
157  // Call toString for arrays and serializable types
158  this->m_type.toString(typeStr);
159  this->m_argBuf.toString(argBufStr);
160 
161  sb.format(
162  formatString,
163  typeStr.toChar(),
164  this->m_opCode,
165  argBufStr.toChar()
166  );
167  }
168 
169 #endif
170 
171  // ----------------------------------------------------------------------
172  // Setter functions
173  // ----------------------------------------------------------------------
174 
175  void Statement ::
178  FwOpcodeType opCode,
179  const Fw::StatementArgBuffer& argBuf
180  )
181  {
182  this->m_type = type;
183  this->m_opCode = opCode;
184  this->m_argBuf = argBuf;
185  }
186 
187  void Statement ::
189  {
190  this->m_type = type;
191  }
192 
193  void Statement ::
195  {
196  this->m_opCode = opCode;
197  }
198 
199  void Statement ::
201  {
202  this->m_argBuf = argBuf;
203  }
204 
205  }
206 
207 }
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialization.
Serialization/Deserialization operation was successful.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialization.
void settype(Svc::Fpy::StatementType::T type)
Set member type.
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
const char * toChar() const
Definition: String.hpp:50
bool operator!=(const Statement &obj) const
Inequality operator.
Fw::StatementArgBuffer m_argBuf
void setargBuf(const Fw::StatementArgBuffer &argBuf)
Set member argBuf.
SerializeStatus
forward declaration for string
Statement()
Constructor (default value)
U32 FwOpcodeType
The type of a command opcode.
Statement & operator=(const Statement &obj)
Copy assignment operator.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void setopCode(FwOpcodeType opCode)
Set member opCode.
void set(Svc::Fpy::StatementType::T type, FwOpcodeType opCode, const Fw::StatementArgBuffer &argBuf)
Set all members.
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
RateGroupDivider component implementation.
bool operator==(const Statement &obj) const
Equality operator.
Svc::Fpy::StatementType m_type