F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ChannelTelemetryArrayArrayAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ChannelTelemetryArrayArrayAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ChannelTelemetryArray array
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 
10 namespace Svc {
11 
12  namespace Ccsds {
13 
14  namespace Cfdp {
15 
16  // ----------------------------------------------------------------------
17  // Constructors
18  // ----------------------------------------------------------------------
19 
22  Serializable(),
23  elements()
24  {
25 
26  }
27 
30  Serializable()
31  {
32  *this = a;
33  }
34 
37  Serializable()
38  {
39  *this = e;
40  }
41 
43  ChannelTelemetryArray(const std::initializer_list<ElementType>& il) :
44  Serializable()
45  {
46  *this = il;
47  }
48 
51  Serializable()
52  {
53  *this = obj;
54  }
55 
56  // ----------------------------------------------------------------------
57  // Operators
58  // ----------------------------------------------------------------------
59 
62  {
63  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
64  return this->elements[i];
65  }
66 
68  operator[](const FwSizeType i) const
69  {
70  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
71  return this->elements[i];
72  }
73 
76  {
77  if (this != &obj) {
78  for (FwSizeType index = 0; index < SIZE; index++) {
79  this->elements[index] = obj.elements[index];
80  }
81  }
82  return *this;
83  }
84 
86  operator=(const ElementType (&a)[SIZE])
87  {
88  for (FwSizeType index = 0; index < SIZE; index++) {
89  this->elements[index] = a[index];
90  }
91  return *this;
92  }
93 
95  operator=(const std::initializer_list<ElementType>& il)
96  {
97  // Check that the initializer has the expected size
98  FW_ASSERT(il.size() == SIZE, static_cast<FwAssertArgType>(il.size()), static_cast<FwAssertArgType>(SIZE));
99  FwSizeType i = 0;
100  for (const auto& e : il) {
101  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
102  this->elements[i] = e;
103  i++;
104  }
105  return *this;
106  }
107 
110  {
111  for (FwSizeType index = 0; index < SIZE; index++) {
112  this->elements[index] = e;
113  }
114  return *this;
115  }
116 
119  {
120  for (FwSizeType index = 0; index < SIZE; index++) {
121  if (!((*this)[index] == obj[index])) {
122  return false;
123  }
124  }
125  return true;
126  }
127 
130  {
131  return !(*this == obj);
132  }
133 
134 #ifdef BUILD_UT
135 
136  std::ostream& operator<<(std::ostream& os, const ChannelTelemetryArray& obj) {
137  Fw::String s;
138  obj.toString(s);
139  os << s;
140  return os;
141  }
142 
143 #endif
144 
145  // ----------------------------------------------------------------------
146  // Public member functions
147  // ----------------------------------------------------------------------
148 
151  Fw::SerialBufferBase& buffer,
152  Fw::Endianness mode
153  ) const
154  {
156  for (FwSizeType index = 0; index < SIZE; index++) {
157  status = buffer.serializeFrom((*this)[index], mode);
158  if (status != Fw::FW_SERIALIZE_OK) {
159  return status;
160  }
161  }
162  return status;
163  }
164 
167  Fw::SerialBufferBase& buffer,
168  Fw::Endianness mode
169  )
170  {
172  for (FwSizeType index = 0; index < SIZE; index++) {
173  status = buffer.deserializeTo((*this)[index], mode);
174  if (status != Fw::FW_SERIALIZE_OK) {
175  return status;
176  }
177  }
178  return status;
179  }
180 
183  {
184  FwSizeType size = 0;
185  for (FwSizeType index = 0; index < SIZE; index++) {
186  size += this->elements[index].serializedSize();
187  }
188  return size;
189  }
190 
191 #if FW_SERIALIZABLE_TO_STRING
192 
193  void ChannelTelemetryArray ::
194  toString(Fw::StringBase& sb) const
195  {
196  // Clear the output string
197  sb = "";
198 
199  // Array prefix
200  sb += "[ ";
201 
202  for (FwSizeType index = 0; index < SIZE; index++) {
203  // Array data
204  Fw::String tmp;
205  this->elements[index].toString(tmp);
206 
207  if (index > 0) {
208  sb += ", ";
209  }
210  sb += tmp;
211  }
212 
213  // Array suffix
214  sb += " ]";
215  }
216 
217 #endif
218 
219  }
220 
221  }
222 
223 }
ChannelTelemetryArray & operator=(const ChannelTelemetryArray &obj)
Copy assignment operator (object)
Serialization/Deserialization operation was successful.
PlatformSizeType FwSizeType
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
FwSizeType serializedSize() const
Get the dynamic serialized size of the struct.
SerializeStatus
forward declaration for string
bool operator!=(const ChannelTelemetryArray &obj) const
Inequality operator.
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
ElementType & operator[](const FwSizeType i)
Subscript operator.
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialization.
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialization.
Structure for the telemetry array of CFDP channels.
RateGroupDivider component implementation.
FwSizeType serializedSize() const
Get the dynamic serialized size of the array.
bool operator==(const ChannelTelemetryArray &obj) const
Equality operator.
Endianness
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.