F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
StatusEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title StatusEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for Status enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
11 
12 namespace Svc {
13 
14  namespace Ccsds {
15 
16  namespace Cfdp {
17 
18  // ----------------------------------------------------------------------
19  // Operators
20  // ----------------------------------------------------------------------
21 
23  operator=(const Status& obj)
24  {
25  this->e = obj.e;
26 #ifdef BUILD_UT
27  this->m_serializeValueIsSet = obj.m_serializeValueIsSet;
28  this->m_serializeValue = obj.m_serializeValue;
29 #endif
30  return *this;
31  }
32 
35  {
36  FW_ASSERT(isValid(e1), static_cast<FwAssertArgType>(e1));
37  this->e = static_cast<enum T>(e1);
38 #ifdef BUILD_UT
39  this->m_serializeValueIsSet = false;
40  this->m_serializeValue = 0;
41 #endif
42  return *this;
43  }
44 
46  operator=(enum T e1)
47  {
48  FW_ASSERT(isValid(e1), static_cast<FwAssertArgType>(e1));
49  this->e = e1;
50 #ifdef BUILD_UT
51  this->m_serializeValueIsSet = false;
52  this->m_serializeValue = 0;
53 #endif
54  return *this;
55  }
56 
57 #ifdef BUILD_UT
58 
59  std::ostream& operator<<(std::ostream& os, const Status& obj) {
60  Fw::String s;
61  obj.toString(s);
62  os << s;
63  return os;
64  }
65 
66 #endif
67 
68  // ----------------------------------------------------------------------
69  // Member functions
70  // ----------------------------------------------------------------------
71 
72  bool Status ::
73  isValid() const
74  {
75  return Status::isValid(this->e);
76  }
77 
80  Fw::SerialBufferBase& buffer,
81  Fw::Endianness mode
82  ) const
83  {
84  SerialType es = static_cast<SerialType>(this->e);
85 #ifdef BUILD_UT
86  // Unit testing only: On request, override the enum value
87  // with the numeric value, which is allowed to be invalid
88  if (this->m_serializeValueIsSet) {
89  es = this->m_serializeValue;
90  }
91 #endif
92  const Fw::SerializeStatus status = buffer.serializeFrom(es, mode);
93  return status;
94  }
95 
98  Fw::SerialBufferBase& buffer,
99  Fw::Endianness mode
100  )
101  {
102  SerialType es;
103  Fw::SerializeStatus status = buffer.deserializeTo(es, mode);
104  if ((status == Fw::FW_SERIALIZE_OK) && !Status::isValid(es)) {
106  }
107  if (status == Fw::FW_SERIALIZE_OK) {
108  this->e = static_cast<enum T>(es);
109  }
110  return status;
111  }
112 
113 #if FW_SERIALIZABLE_TO_STRING
114 
115  void Status ::
116  toString(Fw::StringBase& sb) const
117  {
118  Fw::String s;
119  switch (e) {
120  case SUCCESS:
121  s = "SUCCESS";
122  break;
123  case ERROR:
124  s = "ERROR";
125  break;
126  case PDU_METADATA_ERROR:
127  s = "PDU_METADATA_ERROR";
128  break;
129  case SHORT_PDU_ERROR:
130  s = "SHORT_PDU_ERROR";
131  break;
133  s = "REC_PDU_FSIZE_MISMATCH_ERROR";
134  break;
136  s = "REC_PDU_BAD_EOF_ERROR";
137  break;
139  s = "SEND_PDU_NO_BUF_AVAIL_ERROR";
140  break;
141  default:
142  s = "[invalid]";
143  break;
144  }
145  sb.format("%s (%" PRIi32 ")", s.toChar(), e);
146  }
147 
148 #endif
149 
150 #ifdef BUILD_UT
151 
152  void Status ::
153  setSerializeValue(SerialType serializeValue)
154  {
155  this->m_serializeValue = serializeValue;
156  this->m_serializeValueIsSet = true;
157  }
158 
159 #endif
160 
161  // ----------------------------------------------------------------------
162  // Static functions
163  // ----------------------------------------------------------------------
164 
165  bool Status ::
166  isValid(SerialType serialTypeValue)
167  {
168  return ((serialTypeValue >= SUCCESS) && (serialTypeValue <= SEND_PDU_NO_BUF_AVAIL_ERROR));
169  }
170 
171  }
172 
173  }
174 
175 }
Serialization/Deserialization operation was successful.
Receive PDU: Invalid EOF packet.
I32 SerialType
The serial representation type.
Deserialization data had incorrect values (unexpected data types)
T
The raw enum type.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialize raw enum value from SerialType.
SerializeStatus
forward declaration for string
enum T e
The raw enum value.
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
bool isValid() const
Check raw enum value for validity.
Generic CFDP error return code.
const char * toChar() const
Convert to a C-style char*.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
Receive PDU: EOF file size mismatch.
CFDP operation has been successful.
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialize raw enum value to SerialType.
RateGroupDivider component implementation.
Endianness
Send PDU: No send buffer available, throttling limit reached.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Status & operator=(const Status &obj)
Copy assignment operator (object)
ComCfg::Apid::SerialType SerialType
Definition: TestUtils.cpp:14