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 
29 {
30  FW_ASSERT(isValid(e1), static_cast<FwAssertArgType>(e1));
31  this->e = static_cast<enum T>(e1);
32 #ifdef BUILD_UT
33  this->m_serializeValueIsSet = false;
34  this->m_serializeValue = 0;
35 #endif
36  return *this;
37 }
38 
40  operator=(enum T e1)
41 {
42  FW_ASSERT(isValid(e1), static_cast<FwAssertArgType>(e1));
43  this->e = e1;
44 #ifdef BUILD_UT
45  this->m_serializeValueIsSet = false;
46  this->m_serializeValue = 0;
47 #endif
48  return *this;
49 }
50 
51 #ifdef BUILD_UT
52 
53 std::ostream& operator<<(std::ostream& os, const TimeBase& obj) {
54  Fw::String s;
55  obj.toString(s);
56  os << s;
57  return os;
58 }
59 
60 #endif
61 
62 // ----------------------------------------------------------------------
63 // Member functions
64 // ----------------------------------------------------------------------
65 
66 bool TimeBase ::
67  isValid() const
68 {
69  return TimeBase::isValid(this->e);
70 }
71 
74  Fw::SerialBufferBase& buffer,
75  Fw::Endianness mode
76  ) const
77 {
78  SerialType es = static_cast<SerialType>(this->e);
79 #ifdef BUILD_UT
80  // Unit testing only: On request, override the enum value
81  // with the numeric value, which is allowed to be invalid
82  if (this->m_serializeValueIsSet) {
83  es = this->m_serializeValue;
84  }
85 #endif
86  const Fw::SerializeStatus status = buffer.serializeFrom(es, mode);
87  return status;
88 }
89 
92  Fw::SerialBufferBase& buffer,
93  Fw::Endianness mode
94  )
95 {
96  SerialType es;
97  Fw::SerializeStatus status = buffer.deserializeTo(es, mode);
98  if ((status == Fw::FW_SERIALIZE_OK) && !TimeBase::isValid(es)) {
100  }
101  if (status == Fw::FW_SERIALIZE_OK) {
102  this->e = static_cast<enum T>(es);
103  }
104  return status;
105 }
106 
107 #if FW_SERIALIZABLE_TO_STRING
108 
109 void TimeBase ::
110  toString(Fw::StringBase& sb) const
111 {
112  Fw::String s;
113  switch (e) {
114  case TB_NONE:
115  s = "TB_NONE";
116  break;
117  case TB_PROC_TIME:
118  s = "TB_PROC_TIME";
119  break;
120  case TB_WORKSTATION_TIME:
121  s = "TB_WORKSTATION_TIME";
122  break;
123  case TB_SC_TIME:
124  s = "TB_SC_TIME";
125  break;
126  case TB_DONT_CARE:
127  s = "TB_DONT_CARE";
128  break;
129  default:
130  s = "[invalid]";
131  break;
132  }
133  sb.format("%s (%" PRIu16 ")", s.toChar(), e);
134 }
135 
136 #endif
137 
138 #ifdef BUILD_UT
139 
140 void TimeBase ::
141  setSerializeValue(SerialType serializeValue)
142 {
143  this->m_serializeValue = serializeValue;
144  this->m_serializeValueIsSet = true;
145 }
146 
147 #endif
148 
149 // ----------------------------------------------------------------------
150 // Static functions
151 // ----------------------------------------------------------------------
152 
153 bool TimeBase ::
154  isValid(SerialType serialTypeValue)
155 {
156  return (serialTypeValue <= TB_SC_TIME)
157  || (serialTypeValue == TB_DONT_CARE);
158 }
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