F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DpStateEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DpStateEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for DpState enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
10 #include "Fw/Types/Assert.hpp"
11 #include "Fw/Dp/DpStateEnumAc.hpp"
12 
13 namespace Fw {
14 
15  // ----------------------------------------------------------------------
16  // Operators
17  // ----------------------------------------------------------------------
18 
19  DpState& DpState ::
20  operator=(const DpState& obj)
21  {
22  this->e = obj.e;
23  return *this;
24  }
25 
28  {
29  this->e = e1;
30  return *this;
31  }
32 
33 #ifdef BUILD_UT
34 
35  std::ostream& operator<<(std::ostream& os, const DpState& 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 
48  bool DpState ::
49  isValid() const
50  {
51  return ((e >= UNTRANSMITTED) && (e <= TRANSMITTED));
52  }
53 
56  {
57  const Fw::SerializeStatus status = buffer.serializeFrom(
58  static_cast<SerialType>(this->e)
59  );
60  return status;
61  }
62 
65  {
66  SerialType es;
67  Fw::SerializeStatus status = buffer.deserializeTo(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 DpState ::
80  toString(Fw::StringBase& sb) const
81  {
82  Fw::String s;
83  switch (e) {
84  case UNTRANSMITTED:
85  s = "UNTRANSMITTED";
86  break;
87  case PARTIAL:
88  s = "PARTIAL";
89  break;
90  case TRANSMITTED:
91  s = "TRANSMITTED";
92  break;
93  default:
94  s = "[invalid]";
95  break;
96  }
97  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
98  }
99 
100 #elif FW_ENABLE_TEXT_LOGGING
101 
102  void DpState ::
103  toString(Fw::StringBase& sb) const
104  {
105  sb.format("%" PRIu8 "", e);
106  }
107 
108 #endif
109 
110 }
Serialization/Deserialization operation was successful.
bool isValid() const
Check raw enum value for validity.
DpState & operator=(const DpState &obj)
Copy assignment operator (object)
T
The raw enum type.
T e
The raw enum value.
const char * toChar() const
Definition: String.hpp:50
U8 SerialType
The serial representation type.
Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase &buffer) const
Serialize raw enum value to SerialType.
Deserialization data had incorrect values (unexpected data types)
SerializeStatus
forward declaration for string
The transmitted state.
The untransmitted state.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
SerializeStatus serializeFrom(U8 val)
serialize 8-bit unsigned int
Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase &buffer)
Deserialize raw enum value from SerialType.
SerializeStatus deserializeTo(U8 &val)
deserialize 8-bit unsigned int