F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
EppProtocolIdEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title EppProtocolIdEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for EppProtocolId enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
11 
12 namespace Svc {
13 
14  namespace Ccsds {
15 
16  // ----------------------------------------------------------------------
17  // Operators
18  // ----------------------------------------------------------------------
19 
20  EppProtocolId& EppProtocolId ::
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 EppProtocolId& 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 EppProtocolId ::
71  isValid() const
72  {
73  return EppProtocolId::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) && !EppProtocolId::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 EppProtocolId ::
114  toString(Fw::StringBase& sb) const
115  {
116  Fw::String s;
117  switch (e) {
118  case Idle:
119  s = "Idle";
120  break;
121  case Extended:
122  s = "Extended";
123  break;
124  case MissionSpecific:
125  s = "MissionSpecific";
126  break;
127  default:
128  s = "[invalid]";
129  break;
130  }
131  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
132  }
133 
134 #endif
135 
136 #ifdef BUILD_UT
137 
138  void EppProtocolId ::
139  setSerializeValue(SerialType serializeValue)
140  {
141  this->m_serializeValue = serializeValue;
142  this->m_serializeValueIsSet = true;
143  }
144 
145 #endif
146 
147  // ----------------------------------------------------------------------
148  // Static functions
149  // ----------------------------------------------------------------------
150 
151  bool EppProtocolId ::
152  isValid(SerialType serialTypeValue)
153  {
154  return (serialTypeValue == Idle)
155  || ((serialTypeValue >= Extended) && (serialTypeValue <= MissionSpecific));
156  }
157 
158  }
159 
160 }
Serialization/Deserialization operation was successful.
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.
0b110 - Extended Protocol ID Field Driven
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
EppProtocolId & operator=(const EppProtocolId &obj)
Copy assignment operator (object)
U8 SerialType
The serial representation type.
0b000 - Encapsulation Idle Packet
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
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialize raw enum value to SerialType.
Protocol IDs for EPP encapsulation packets per CCSDS 133.1-B-3 Section 4.1.2.3.3. ...
RateGroupDivider component implementation.
enum T e
The raw enum value.
Endianness
#define FW_ASSERT(...)
Definition: Assert.hpp:14
bool isValid() const
Check raw enum value for validity.
ComCfg::Apid::SerialType SerialType
Definition: TestUtils.cpp:14