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