F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TimeValueSerializableAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TimeValueSerializableAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for TimeValue struct
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
9 
10 namespace Fw {
11 
12  // ----------------------------------------------------------------------
13  // Constructors
14  // ----------------------------------------------------------------------
15 
18  Serializable(),
19  m_timeBase(TimeBase::TB_NONE),
20  m_timeContext(0),
21  m_seconds(0),
22  m_useconds(0)
23  {
24 
25  }
26 
29  TimeBase::T timeBase,
30  FwTimeContextStoreType timeContext,
31  U32 seconds,
32  U32 useconds
33  ) :
34  Serializable(),
35  m_timeBase(timeBase),
36  m_timeContext(timeContext),
37  m_seconds(seconds),
38  m_useconds(useconds)
39  {
40 
41  }
42 
44  TimeValue(const TimeValue& obj) :
45  Serializable(),
46  m_timeBase(obj.m_timeBase),
47  m_timeContext(obj.m_timeContext),
48  m_seconds(obj.m_seconds),
49  m_useconds(obj.m_useconds)
50  {
51 
52  }
53 
54  // ----------------------------------------------------------------------
55  // Operators
56  // ----------------------------------------------------------------------
57 
59  operator=(const TimeValue& obj)
60  {
61  if (this == &obj) {
62  return *this;
63  }
64 
65  set(obj.m_timeBase, obj.m_timeContext, obj.m_seconds, obj.m_useconds);
66  return *this;
67  }
68 
69  bool TimeValue ::
70  operator==(const TimeValue& obj) const
71  {
72  if (this == &obj) { return true; }
73  return (
74  (this->m_timeBase == obj.m_timeBase) &&
75  (this->m_timeContext == obj.m_timeContext) &&
76  (this->m_seconds == obj.m_seconds) &&
77  (this->m_useconds == obj.m_useconds)
78  );
79  }
80 
81  bool TimeValue ::
82  operator!=(const TimeValue& obj) const
83  {
84  return !(*this == obj);
85  }
86 
87 #ifdef BUILD_UT
88 
89  std::ostream& operator<<(std::ostream& os, const TimeValue& obj) {
90  Fw::String s;
91  obj.toString(s);
92  os << s.toChar();
93  return os;
94  }
95 
96 #endif
97 
98  // ----------------------------------------------------------------------
99  // Member functions
100  // ----------------------------------------------------------------------
101 
104  Fw::SerialBufferBase& buffer,
105  Fw::Endianness mode
106  ) const
107  {
108  Fw::SerializeStatus status;
109 
110  status = buffer.serializeFrom(this->m_timeBase, mode);
111  if (status != Fw::FW_SERIALIZE_OK) {
112  return status;
113  }
114  status = buffer.serializeFrom(this->m_timeContext, mode);
115  if (status != Fw::FW_SERIALIZE_OK) {
116  return status;
117  }
118  status = buffer.serializeFrom(this->m_seconds, mode);
119  if (status != Fw::FW_SERIALIZE_OK) {
120  return status;
121  }
122  status = buffer.serializeFrom(this->m_useconds, mode);
123  if (status != Fw::FW_SERIALIZE_OK) {
124  return status;
125  }
126 
127  return status;
128  }
129 
132  Fw::SerialBufferBase& buffer,
133  Fw::Endianness mode
134  )
135  {
136  Fw::SerializeStatus status;
137 
138  status = buffer.deserializeTo(this->m_timeBase, mode);
139  if (status != Fw::FW_SERIALIZE_OK) {
140  return status;
141  }
142  status = buffer.deserializeTo(this->m_timeContext, mode);
143  if (status != Fw::FW_SERIALIZE_OK) {
144  return status;
145  }
146  status = buffer.deserializeTo(this->m_seconds, mode);
147  if (status != Fw::FW_SERIALIZE_OK) {
148  return status;
149  }
150  status = buffer.deserializeTo(this->m_useconds, mode);
151  if (status != Fw::FW_SERIALIZE_OK) {
152  return status;
153  }
154 
155  return status;
156  }
157 
160  {
161  FwSizeType size = 0;
163  size += sizeof(FwTimeContextStoreType);
164  size += sizeof(U32);
165  size += sizeof(U32);
166  return size;
167  }
168 
169 #if FW_SERIALIZABLE_TO_STRING
170 
171  void TimeValue ::
172  toString(Fw::StringBase& sb) const
173  {
174  Fw::String tmp;
175  sb = "( ";
176 
177  // Format timeBase
178  sb += "timeBase = ";
179  this->m_timeBase.toString(tmp);
180  sb += tmp;
181  sb += ", ";
182 
183  // Format timeContext
184  sb += "timeContext = ";
185  tmp.format("%" PRIu8 "", this->m_timeContext);
186  sb += tmp;
187  sb += ", ";
188 
189  // Format seconds
190  sb += "seconds = ";
191  tmp.format("%" PRIu32 "", this->m_seconds);
192  sb += tmp;
193  sb += ", ";
194 
195  // Format useconds
196  sb += "useconds = ";
197  tmp.format("%" PRIu32 "", this->m_useconds);
198  sb += tmp;
199  sb += " )";
200  }
201 
202 #endif
203 
204  // ----------------------------------------------------------------------
205  // Setter functions
206  // ----------------------------------------------------------------------
207 
208  void TimeValue ::
210  TimeBase::T timeBase,
211  FwTimeContextStoreType timeContext,
212  U32 seconds,
213  U32 useconds
214  )
215  {
216  this->m_timeBase = timeBase;
217  this->m_timeContext = timeContext;
218  this->m_seconds = seconds;
219  this->m_useconds = useconds;
220  }
221 
222  void TimeValue ::
224  {
225  this->m_timeBase = timeBase;
226  }
227 
228  void TimeValue ::
230  {
231  this->m_timeContext = timeContext;
232  }
233 
234  void TimeValue ::
235  set_seconds(U32 seconds)
236  {
237  this->m_seconds = seconds;
238  }
239 
240  void TimeValue ::
241  set_useconds(U32 useconds)
242  {
243  this->m_useconds = useconds;
244  }
245 
246 }
FwSizeType serializedSize() const
Get the dynamic serialized size of the struct.
Serialization/Deserialization operation was successful.
PlatformSizeType FwSizeType
bool operator==(const TimeValue &obj) const
Equality operator.
const char * toChar() const
Convert to a C-style char*.
Definition: String.hpp:50
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialization.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
U8 FwTimeContextStoreType
The type used to serialize a time context value.
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialization.
T
The raw enum type.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
void set_seconds(U32 seconds)
Set member seconds.
TimeValue & operator=(const TimeValue &obj)
Copy assignment operator.
void set(TimeBase::T timeBase, FwTimeContextStoreType timeContext, U32 seconds, U32 useconds)
Set all members.
TimeValue()
Constructor (default value)
FwTimeContextStoreType m_timeContext
bool operator!=(const TimeValue &obj) const
Inequality operator.
The size of the serial representation.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
Data structure for Time.
void set_timeBase(TimeBase::T timeBase)
Set member timeBase.
void set_timeContext(FwTimeContextStoreType timeContext)
Set member timeContext.
Implementation of malloc based allocator.
Endianness
Define enumeration for Time base types.
void set_useconds(U32 useconds)
Set member useconds.