F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
SuspendResumeEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title SuspendResumeEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for SuspendResume 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 
22  SuspendResume& SuspendResume ::
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 SuspendResume& 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 SuspendResume ::
73  isValid() const
74  {
75  return SuspendResume::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) && !SuspendResume::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 SuspendResume ::
116  toString(Fw::StringBase& sb) const
117  {
118  Fw::String s;
119  switch (e) {
120  case SUSPEND:
121  s = "SUSPEND";
122  break;
123  case RESUME:
124  s = "RESUME";
125  break;
126  default:
127  s = "[invalid]";
128  break;
129  }
130  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
131  }
132 
133 #endif
134 
135 #ifdef BUILD_UT
136 
137  void SuspendResume ::
138  setSerializeValue(SerialType serializeValue)
139  {
140  this->m_serializeValue = serializeValue;
141  this->m_serializeValueIsSet = true;
142  }
143 
144 #endif
145 
146  // ----------------------------------------------------------------------
147  // Static functions
148  // ----------------------------------------------------------------------
149 
150  bool SuspendResume ::
151  isValid(SerialType serialTypeValue)
152  {
153  return (serialTypeValue <= RESUME);
154  }
155 
156  }
157 
158  }
159 
160 }
Serialization/Deserialization operation was successful.
SuspendResume & operator=(const SuspendResume &obj)
Copy assignment operator (object)
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.
const char * toChar() const
Convert to a C-style char*.
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
bool isValid() const
Check raw enum value for validity.
RateGroupDivider component implementation.
U8 SerialType
The serial representation type.
Endianness
#define FW_ASSERT(...)
Definition: Assert.hpp:14
ComCfg::Apid::SerialType SerialType
Definition: TestUtils.cpp:14