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  {
105  Fw::SerializeStatus status;
106 
107  status = buffer.serializeFrom(this->m_timeBase);
108  if (status != Fw::FW_SERIALIZE_OK) {
109  return status;
110  }
111  status = buffer.serializeFrom(this->m_timeContext);
112  if (status != Fw::FW_SERIALIZE_OK) {
113  return status;
114  }
115  status = buffer.serializeFrom(this->m_seconds);
116  if (status != Fw::FW_SERIALIZE_OK) {
117  return status;
118  }
119  status = buffer.serializeFrom(this->m_useconds);
120  if (status != Fw::FW_SERIALIZE_OK) {
121  return status;
122  }
123 
124  return status;
125  }
126 
129  {
130  Fw::SerializeStatus status;
131 
132  status = buffer.deserializeTo(this->m_timeBase);
133  if (status != Fw::FW_SERIALIZE_OK) {
134  return status;
135  }
136  status = buffer.deserializeTo(this->m_timeContext);
137  if (status != Fw::FW_SERIALIZE_OK) {
138  return status;
139  }
140  status = buffer.deserializeTo(this->m_seconds);
141  if (status != Fw::FW_SERIALIZE_OK) {
142  return status;
143  }
144  status = buffer.deserializeTo(this->m_useconds);
145  if (status != Fw::FW_SERIALIZE_OK) {
146  return status;
147  }
148 
149  return status;
150  }
151 
154  {
155  FwSizeType size = 0;
157  size += sizeof(FwTimeContextStoreType);
158  size += sizeof(U32);
159  size += sizeof(U32);
160  return size;
161  }
162 
163 #if FW_SERIALIZABLE_TO_STRING
164 
165  void TimeValue ::
166  toString(Fw::StringBase& sb) const
167  {
168  Fw::String tmp;
169  sb = "( ";
170 
171  // Format timeBase
172  sb += "timeBase = ";
173  this->m_timeBase.toString(tmp);
174  sb += tmp;
175  sb += ", ";
176 
177  // Format timeContext
178  sb += "timeContext = ";
179  tmp.format("%" PRIu8 "", this->m_timeContext);
180  sb += tmp;
181  sb += ", ";
182 
183  // Format seconds
184  sb += "seconds = ";
185  tmp.format("%" PRIu32 "", this->m_seconds);
186  sb += tmp;
187  sb += ", ";
188 
189  // Format useconds
190  sb += "useconds = ";
191  tmp.format("%" PRIu32 "", this->m_useconds);
192  sb += tmp;
193  sb += " )";
194  }
195 
196 #endif
197 
198  // ----------------------------------------------------------------------
199  // Setter functions
200  // ----------------------------------------------------------------------
201 
202  void TimeValue ::
204  TimeBase::T timeBase,
205  FwTimeContextStoreType timeContext,
206  U32 seconds,
207  U32 useconds
208  )
209  {
210  this->m_timeBase = timeBase;
211  this->m_timeContext = timeContext;
212  this->m_seconds = seconds;
213  this->m_useconds = useconds;
214  }
215 
216  void TimeValue ::
218  {
219  this->m_timeBase = timeBase;
220  }
221 
222  void TimeValue ::
224  {
225  this->m_timeContext = timeContext;
226  }
227 
228  void TimeValue ::
229  set_seconds(U32 seconds)
230  {
231  this->m_seconds = seconds;
232  }
233 
234  void TimeValue ::
235  set_useconds(U32 useconds)
236  {
237  this->m_useconds = useconds;
238  }
239 
240 }
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
Definition: String.hpp:50
U8 FwTimeContextStoreType
The type used to serialize a time context value.
T
The raw enum type.
SerializeStatus
forward declaration for string
void set_seconds(U32 seconds)
Set member seconds.
Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase &buffer)
Deserialization.
Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase &buffer) const
Serialization.
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.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
Data structure for Time.
void set_timeBase(TimeBase::T timeBase)
Set member timeBase.
void set_timeContext(FwTimeContextStoreType timeContext)
Set member timeContext.
forward declaration
SerializeStatus serializeFrom(U8 val)
serialize 8-bit unsigned int
Define enumeration for Time base types.
The size of the serial representation.
void set_useconds(U32 useconds)
Set member useconds.
SerializeStatus deserializeTo(U8 &val)
deserialize 8-bit unsigned int