F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
VersionEnumEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title VersionEnumEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for VersionEnum enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
10 #include "Fw/Types/Assert.hpp"
12 
13 namespace Svc {
14 
15  namespace VersionCfg {
16 
17  // ----------------------------------------------------------------------
18  // Operators
19  // ----------------------------------------------------------------------
20 
22  operator=(const VersionEnum& obj)
23  {
24  this->e = obj.e;
25  return *this;
26  }
27 
29  operator=(T e1)
30  {
31  this->e = e1;
32  return *this;
33  }
34 
35 #ifdef BUILD_UT
36 
37  std::ostream& operator<<(std::ostream& os, const VersionEnum& obj) {
38  Fw::String s;
39  obj.toString(s);
40  os << s;
41  return os;
42  }
43 
44 #endif
45 
46  // ----------------------------------------------------------------------
47  // Member functions
48  // ----------------------------------------------------------------------
49 
51  isValid() const
52  {
53  return ((e >= PROJECT_VERSION_00) && (e <= PROJECT_VERSION_09));
54  }
55 
58  {
59  const Fw::SerializeStatus status = buffer.serialize(
60  static_cast<SerialType>(this->e)
61  );
62  return status;
63  }
64 
67  {
68  SerialType es;
69  Fw::SerializeStatus status = buffer.deserialize(es);
70  if (status == Fw::FW_SERIALIZE_OK) {
71  this->e = static_cast<T>(es);
72  if (!this->isValid()) {
74  }
75  }
76  return status;
77  }
78 
79 #if FW_SERIALIZABLE_TO_STRING
80 
81  void VersionEnum ::
82  toString(Fw::StringBase& sb) const
83  {
84  Fw::String s;
85  switch (e) {
86  case PROJECT_VERSION_00:
87  s = "PROJECT_VERSION_00";
88  break;
89  case PROJECT_VERSION_01:
90  s = "PROJECT_VERSION_01";
91  break;
92  case PROJECT_VERSION_02:
93  s = "PROJECT_VERSION_02";
94  break;
95  case PROJECT_VERSION_03:
96  s = "PROJECT_VERSION_03";
97  break;
98  case PROJECT_VERSION_04:
99  s = "PROJECT_VERSION_04";
100  break;
101  case PROJECT_VERSION_05:
102  s = "PROJECT_VERSION_05";
103  break;
104  case PROJECT_VERSION_06:
105  s = "PROJECT_VERSION_06";
106  break;
107  case PROJECT_VERSION_07:
108  s = "PROJECT_VERSION_07";
109  break;
110  case PROJECT_VERSION_08:
111  s = "PROJECT_VERSION_08";
112  break;
113  case PROJECT_VERSION_09:
114  s = "PROJECT_VERSION_09";
115  break;
116  default:
117  s = "[invalid]";
118  break;
119  }
120  sb.format("%s (%" PRIu32 ")", s.toChar(), e);
121  }
122 
123 #elif FW_ENABLE_TEXT_LOGGING
124 
125  void VersionEnum ::
126  toString(Fw::StringBase& sb) const
127  {
128  sb.format("%" PRIu32 "", e);
129  }
130 
131 #endif
132 
133  }
134 
135 }
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
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialize raw enum value to SerialType.
U32 SerialType
The serial representation type.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialize raw enum value from SerialType.
bool isValid() const
Check raw enum value for validity.
VersionEnum & operator=(const VersionEnum &obj)
Copy assignment operator (object)
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.