F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TimeBaseEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TimeBaseEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for TimeBase enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
11 
12 // ----------------------------------------------------------------------
13 // Operators
14 // ----------------------------------------------------------------------
15 
17  operator=(const TimeBase& obj)
18 {
19  this->e = obj.e;
20 #ifdef BUILD_UT
21  this->m_serializeValueIsSet = obj.m_serializeValueIsSet;
22  this->m_serializeValue = obj.m_serializeValue;
23 #endif
24  return *this;
25 }
26 
28  operator=(enum T e1)
29 {
30  FW_ASSERT(isValid(e1), static_cast<FwAssertArgType>(e1));
31  this->e = e1;
32 #ifdef BUILD_UT
33  this->m_serializeValueIsSet = false;
34  this->m_serializeValue = 0;
35 #endif
36  return *this;
37 }
38 
39 #ifdef BUILD_UT
40 
41 std::ostream& operator<<(std::ostream& os, const TimeBase& obj) {
42  Fw::String s;
43  obj.toString(s);
44  os << s;
45  return os;
46 }
47 
48 #endif
49 
50 // ----------------------------------------------------------------------
51 // Member functions
52 // ----------------------------------------------------------------------
53 
54 bool TimeBase ::
55  isValid() const
56 {
57  return TimeBase::isValid(this->e);
58 }
59 
62  Fw::SerialBufferBase& buffer,
63  Fw::Endianness mode
64  ) const
65 {
66  SerialType es = static_cast<SerialType>(this->e);
67 #ifdef BUILD_UT
68  // Unit testing only: On request, override the enum value
69  // with the numeric value, which is allowed to be invalid
70  if (this->m_serializeValueIsSet) {
71  es = this->m_serializeValue;
72  }
73 #endif
74  const Fw::SerializeStatus status = buffer.serializeFrom(es, mode);
75  return status;
76 }
77 
80  Fw::SerialBufferBase& buffer,
81  Fw::Endianness mode
82  )
83 {
84  SerialType es;
85  Fw::SerializeStatus status = buffer.deserializeTo(es, mode);
86  if ((status == Fw::FW_SERIALIZE_OK) && !TimeBase::isValid(es)) {
88  }
89  if (status == Fw::FW_SERIALIZE_OK) {
90  this->e = static_cast<enum T>(es);
91  }
92  return status;
93 }
94 
95 #if FW_SERIALIZABLE_TO_STRING
96 
97 void TimeBase ::
98  toString(Fw::StringBase& sb) const
99 {
100  Fw::String s;
101  switch (e) {
102  case TB_NONE:
103  s = "TB_NONE";
104  break;
105  case TB_PROC_TIME:
106  s = "TB_PROC_TIME";
107  break;
108  case TB_WORKSTATION_TIME:
109  s = "TB_WORKSTATION_TIME";
110  break;
111  case TB_SC_TIME:
112  s = "TB_SC_TIME";
113  break;
114  case TB_DONT_CARE:
115  s = "TB_DONT_CARE";
116  break;
117  default:
118  s = "[invalid]";
119  break;
120  }
121  sb.format("%s (%" PRIu16 ")", s.toChar(), e);
122 }
123 
124 #endif
125 
126 #ifdef BUILD_UT
127 
128 void TimeBase ::
129  setSerializeValue(SerialType serializeValue)
130 {
131  this->m_serializeValue = serializeValue;
132  this->m_serializeValueIsSet = true;
133 }
134 
135 #endif
136 
137 // ----------------------------------------------------------------------
138 // Static functions
139 // ----------------------------------------------------------------------
140 
141 bool TimeBase ::
142  isValid(SerialType serialTypeValue)
143 {
144  return (serialTypeValue <= TB_SC_TIME)
145  || (serialTypeValue == TB_DONT_CARE);
146 }
Serialization/Deserialization operation was successful.
Don&#39;t care value for sequences. If FwTimeBaseStoreType is changed, value should be changed (Required)...
Deserialization data had incorrect values (unexpected data types)
No time base has been established (Required)
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
T
The raw enum type.
bool isValid() const
Check raw enum value for validity.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
Time as reported on workstation where software is running. For testing. (Required) ...
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialize raw enum value from SerialType.
TimeBase & operator=(const TimeBase &obj)
Copy assignment operator (object)
const char * toChar() const
Convert to a C-style char*.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialize raw enum value to SerialType.
Indicates time is processor cycle time. Not tied to external time.
enum T e
The raw enum value.
Endianness
Time as reported by the spacecraft clock.
Define enumeration for Time base types.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
U16 SerialType
The serial representation type.
ComCfg::Apid::SerialType SerialType
Definition: TestUtils.cpp:14