F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
LogSeverityEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LogSeverityEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for LogSeverity enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
11 
12 namespace Fw {
13 
14  // ----------------------------------------------------------------------
15  // Operators
16  // ----------------------------------------------------------------------
17 
18  LogSeverity& LogSeverity ::
20  {
21  this->e = obj.e;
22 #ifdef BUILD_UT
23  this->m_serializeValueIsSet = obj.m_serializeValueIsSet;
24  this->m_serializeValue = obj.m_serializeValue;
25 #endif
26  return *this;
27  }
28 
30  operator=(enum T e1)
31  {
32  FW_ASSERT(isValid(e1), static_cast<FwAssertArgType>(e1));
33  this->e = e1;
34 #ifdef BUILD_UT
35  this->m_serializeValueIsSet = false;
36  this->m_serializeValue = 0;
37 #endif
38  return *this;
39  }
40 
41 #ifdef BUILD_UT
42 
43  std::ostream& operator<<(std::ostream& os, const LogSeverity& obj) {
44  Fw::String s;
45  obj.toString(s);
46  os << s;
47  return os;
48  }
49 
50 #endif
51 
52  // ----------------------------------------------------------------------
53  // Member functions
54  // ----------------------------------------------------------------------
55 
56  bool LogSeverity ::
57  isValid() const
58  {
59  return LogSeverity::isValid(this->e);
60  }
61 
64  Fw::SerialBufferBase& buffer,
65  Fw::Endianness mode
66  ) const
67  {
68  SerialType es = static_cast<SerialType>(this->e);
69 #ifdef BUILD_UT
70  // Unit testing only: On request, override the enum value
71  // with the numeric value, which is allowed to be invalid
72  if (this->m_serializeValueIsSet) {
73  es = this->m_serializeValue;
74  }
75 #endif
76  const Fw::SerializeStatus status = buffer.serializeFrom(es, mode);
77  return status;
78  }
79 
82  Fw::SerialBufferBase& buffer,
83  Fw::Endianness mode
84  )
85  {
86  SerialType es;
87  Fw::SerializeStatus status = buffer.deserializeTo(es, mode);
88  if ((status == Fw::FW_SERIALIZE_OK) && !LogSeverity::isValid(es)) {
90  }
91  if (status == Fw::FW_SERIALIZE_OK) {
92  this->e = static_cast<enum T>(es);
93  }
94  return status;
95  }
96 
97 #if FW_SERIALIZABLE_TO_STRING
98 
99  void LogSeverity ::
100  toString(Fw::StringBase& sb) const
101  {
102  Fw::String s;
103  switch (e) {
104  case FATAL:
105  s = "FATAL";
106  break;
107  case WARNING_HI:
108  s = "WARNING_HI";
109  break;
110  case WARNING_LO:
111  s = "WARNING_LO";
112  break;
113  case COMMAND:
114  s = "COMMAND";
115  break;
116  case ACTIVITY_HI:
117  s = "ACTIVITY_HI";
118  break;
119  case ACTIVITY_LO:
120  s = "ACTIVITY_LO";
121  break;
122  case DIAGNOSTIC:
123  s = "DIAGNOSTIC";
124  break;
125  default:
126  s = "[invalid]";
127  break;
128  }
129  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
130  }
131 
132 #endif
133 
134 #ifdef BUILD_UT
135 
136  void LogSeverity ::
137  setSerializeValue(SerialType serializeValue)
138  {
139  this->m_serializeValue = serializeValue;
140  this->m_serializeValueIsSet = true;
141  }
142 
143 #endif
144 
145  // ----------------------------------------------------------------------
146  // Static functions
147  // ----------------------------------------------------------------------
148 
149  bool LogSeverity ::
150  isValid(SerialType serialTypeValue)
151  {
152  return ((serialTypeValue >= FATAL) && (serialTypeValue <= DIAGNOSTIC));
153  }
154 
155 }
Serialization/Deserialization operation was successful.
T
The raw enum type.
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.
Software diagnostic events.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
Less important informational events.
An activity related to commanding.
A less serious but recoverable event.
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialize raw enum value from SerialType.
U8 SerialType
The serial representation type.
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialize raw enum value to SerialType.
A serious but recoverable event.
const char * toChar() const
Convert to a C-style char*.
Enum representing event severity.
enum T e
The raw enum value.
LogSeverity & operator=(const LogSeverity &obj)
Copy assignment operator (object)
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
Important informational events.
A fatal non-recoverable event.
Implementation of malloc based allocator.
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