F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
SdlsStatusEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title SdlsStatusEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for SdlsStatus 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  SdlsStatus& SdlsStatus ::
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 SdlsStatus& 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 SdlsStatus ::
71  isValid() const
72  {
73  return SdlsStatus::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) && !SdlsStatus::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 SdlsStatus ::
114  toString(Fw::StringBase& sb) const
115  {
116  Fw::String s;
117  switch (e) {
118  case SUCCESS:
119  s = "SUCCESS";
120  break;
121  case UNKNOWN_SA:
122  s = "UNKNOWN_SA";
123  break;
124  case UNKNOWN_PORT:
125  s = "UNKNOWN_PORT";
126  break;
127  case ENCRYPTION_FAILURE:
128  s = "ENCRYPTION_FAILURE";
129  break;
130  case DECRYPTION_FAILURE:
131  s = "DECRYPTION_FAILURE";
132  break;
133  case KEY_ERROR:
134  s = "KEY_ERROR";
135  break;
136  default:
137  s = "[invalid]";
138  break;
139  }
140  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
141  }
142 
143 #endif
144 
145 #ifdef BUILD_UT
146 
147  void SdlsStatus ::
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 SdlsStatus ::
161  isValid(SerialType serialTypeValue)
162  {
163  return (serialTypeValue <= KEY_ERROR);
164  }
165 
166  }
167 
168 }
Serialization/Deserialization operation was successful.
Security association index has no known mapping.
bool isValid() const
Check raw enum value for validity.
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.
Status of an SDLS (Space Data Link Security) encryption/decryption request.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
Mapped port index is out of range or unconnected.
U8 SerialType
The serial representation type.
const char * toChar() const
Convert to a C-style char*.
SdlsStatus & operator=(const SdlsStatus &obj)
Copy assignment operator (object)
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialize raw enum value to SerialType.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
T
The raw enum type.
RateGroupDivider component implementation.
Endianness
Request completed successfully.
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialize raw enum value from SerialType.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
ComCfg::Apid::SerialType SerialType
Definition: TestUtils.cpp:14