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