F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
10 #include "Fw/Types/Assert.hpp"
12 
13 namespace Fw {
14 
15  // ----------------------------------------------------------------------
16  // Operators
17  // ----------------------------------------------------------------------
18 
20  operator=(const LogSeverity& obj)
21  {
22  this->e = obj.e;
23  return *this;
24  }
25 
27  operator=(T e1)
28  {
29  this->e = e1;
30  return *this;
31  }
32 
33 #ifdef BUILD_UT
34 
35  std::ostream& operator<<(std::ostream& os, const LogSeverity& obj) {
36  Fw::String s;
37  obj.toString(s);
38  os << s;
39  return os;
40  }
41 
42 #endif
43 
44  // ----------------------------------------------------------------------
45  // Member functions
46  // ----------------------------------------------------------------------
47 
49  isValid() const
50  {
51  return ((e >= FATAL) && (e <= DIAGNOSTIC));
52  }
53 
56  {
57  const Fw::SerializeStatus status = buffer.serialize(
58  static_cast<SerialType>(this->e)
59  );
60  return status;
61  }
62 
65  {
66  SerialType es;
67  Fw::SerializeStatus status = buffer.deserialize(es);
68  if (status == Fw::FW_SERIALIZE_OK) {
69  this->e = static_cast<T>(es);
70  if (!this->isValid()) {
72  }
73  }
74  return status;
75  }
76 
77 #if FW_SERIALIZABLE_TO_STRING
78 
79  void LogSeverity ::
80  toString(Fw::StringBase& sb) const
81  {
82  Fw::String s;
83  switch (e) {
84  case FATAL:
85  s = "FATAL";
86  break;
87  case WARNING_HI:
88  s = "WARNING_HI";
89  break;
90  case WARNING_LO:
91  s = "WARNING_LO";
92  break;
93  case COMMAND:
94  s = "COMMAND";
95  break;
96  case ACTIVITY_HI:
97  s = "ACTIVITY_HI";
98  break;
99  case ACTIVITY_LO:
100  s = "ACTIVITY_LO";
101  break;
102  case DIAGNOSTIC:
103  s = "DIAGNOSTIC";
104  break;
105  default:
106  s = "[invalid]";
107  break;
108  }
109  sb.format("%s (%" PRIi32 ")", s.toChar(), e);
110  }
111 
112 #elif FW_ENABLE_TEXT_LOGGING
113 
114  void LogSeverity ::
115  toString(Fw::StringBase& sb) const
116  {
117  sb.format("%" PRIi32 "", e);
118  }
119 
120 #endif
121 
122 }
Enum representing event severity.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialize raw enum value from SerialType.
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialize raw enum value to SerialType.
T e
The raw enum value.
bool isValid() const
Check raw enum value for validity.
I32 SerialType
The serial representation type.
T
The raw enum type.
@ WARNING_HI
A serious but recoverable event.
@ ACTIVITY_HI
Important informational events.
@ FATAL
A fatal non-recoverable event.
@ WARNING_LO
A less serious but recoverable event.
@ DIAGNOSTIC
Software diagnostic events.
@ ACTIVITY_LO
Less important informational events.
@ COMMAND
An activity related to commanding.
LogSeverity & operator=(const LogSeverity &obj)
Copy assignment operator (object)
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
const char * toChar() const
Definition: String.hpp:50
SerializeStatus
forward declaration for string
@ FW_DESERIALIZE_FORMAT_ERROR
Deserialization data had incorrect values (unexpected data types)
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.