F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
ProcTypeEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ProcTypeEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ProcType enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
10 #include "Fw/Types/Assert.hpp"
12 
13 namespace Fw {
14 
15  namespace DpCfg {
16 
17  // ----------------------------------------------------------------------
18  // Operators
19  // ----------------------------------------------------------------------
20 
22  operator=(const ProcType& 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 ProcType& 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 >= PROC_TYPE_ZERO) && (e <= PROC_TYPE_ONE))
54  || ((e >= PROC_TYPE_TWO) && (e <= PROC_TYPE_TWO));
55  }
56 
59  {
60  const Fw::SerializeStatus status = buffer.serialize(
61  static_cast<SerialType>(this->e)
62  );
63  return status;
64  }
65 
68  {
69  SerialType es;
70  Fw::SerializeStatus status = buffer.deserialize(es);
71  if (status == Fw::FW_SERIALIZE_OK) {
72  this->e = static_cast<T>(es);
73  if (!this->isValid()) {
75  }
76  }
77  return status;
78  }
79 
80 #if FW_SERIALIZABLE_TO_STRING
81 
82  void ProcType ::
83  toString(Fw::StringBase& sb) const
84  {
85  Fw::String s;
86  switch (e) {
87  case PROC_TYPE_ZERO:
88  s = "PROC_TYPE_ZERO";
89  break;
90  case PROC_TYPE_ONE:
91  s = "PROC_TYPE_ONE";
92  break;
93  case PROC_TYPE_TWO:
94  s = "PROC_TYPE_TWO";
95  break;
96  default:
97  s = "[invalid]";
98  break;
99  }
100  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
101  }
102 
103 #elif FW_ENABLE_TEXT_LOGGING
104 
105  void ProcType ::
106  toString(Fw::StringBase& sb) const
107  {
108  sb.format("%" PRIu8 "", e);
109  }
110 
111 #endif
112 
113  }
114 
115 }
bool isValid() const
Check raw enum value for validity.
T e
The raw enum value.
U8 SerialType
The serial representation type.
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialize raw enum value to SerialType.
T
The raw enum type.
@ PROC_TYPE_ZERO
Processing type 0.
@ PROC_TYPE_TWO
Processing type 2.
@ PROC_TYPE_ONE
Processing type 1.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialize raw enum value from SerialType.
ProcType & operator=(const ProcType &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.