F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PvnEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PvnEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for Pvn enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
10 #include "Fw/Types/Assert.hpp"
12 
13 namespace ComCfg {
14 
15  // ----------------------------------------------------------------------
16  // Operators
17  // ----------------------------------------------------------------------
18 
19  Pvn& Pvn ::
20  operator=(const Pvn& obj)
21  {
22  this->e = obj.e;
23  return *this;
24  }
25 
26  Pvn& Pvn ::
27  operator=(enum 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 Pvn& 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 Pvn ::
49  isValid() const
50  {
51  return ((e >= SPACE_PACKET_PROTOCOL) && (e <= SPACE_PACKET_PROTOCOL))
53  }
54 
57  Fw::SerialBufferBase& buffer,
58  Fw::Endianness mode
59  ) const
60  {
61  const Fw::SerializeStatus status = buffer.serializeFrom(
62  static_cast<SerialType>(this->e),
63  mode
64  );
65  return status;
66  }
67 
70  Fw::SerialBufferBase& buffer,
71  Fw::Endianness mode
72  )
73  {
74  SerialType es;
75  Fw::SerializeStatus status = buffer.deserializeTo(es, mode);
76  if (status == Fw::FW_SERIALIZE_OK) {
77  this->e = static_cast<enum T>(es);
78  if (!this->isValid()) {
80  }
81  }
82  return status;
83  }
84 
85 #if FW_SERIALIZABLE_TO_STRING
86 
87  void Pvn ::
88  toString(Fw::StringBase& sb) const
89  {
90  Fw::String s;
91  switch (e) {
93  s = "SPACE_PACKET_PROTOCOL";
94  break;
96  s = "ENCAPSULATION_PACKET_PROTOCOL";
97  break;
99  s = "INVALID_UNINITIALIZED";
100  break;
101  default:
102  s = "[invalid]";
103  break;
104  }
105  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
106  }
107 
108 #elif FW_ENABLE_TEXT_LOGGING
109 
110  void Pvn ::
111  toString(Fw::StringBase& sb) const
112  {
113  sb.format("%" PRIu8 "", e);
114  }
115 
116 #endif
117 
118 }
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialize raw enum value from SerialType.
Definition: PvnEnumAc.cpp:69
Serialization/Deserialization operation was successful.
Fully Featured CCSDS Space Packet Protocol.
Definition: PvnEnumAc.hpp:33
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialize raw enum value to SerialType.
Definition: PvnEnumAc.cpp:56
Anything equal or higher value is invalid and should not be used.
Definition: PvnEnumAc.hpp:37
T
The raw enum type.
Definition: PvnEnumAc.hpp:31
bool isValid() const
Check raw enum value for validity.
Definition: PvnEnumAc.cpp:49
Deserialization data had incorrect values (unexpected data types)
Pvn & operator=(const Pvn &obj)
Copy assignment operator (object)
Definition: PvnEnumAc.cpp:20
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
U8 SerialType
The serial representation type.
Definition: PvnEnumAc.hpp:28
const char * toChar() const
Convert to a C-style char*.
Packet Version Numbers are 3 bits with only 2 currently valid values.
Definition: PvnEnumAc.hpp:17
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
enum T e
The raw enum value.
Definition: PvnEnumAc.hpp:165
Bare-bones CCSDS Encapsulation Packet Protocol.
Definition: PvnEnumAc.hpp:35
Endianness