F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
BuffQueueDepthArrayAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title BuffQueueDepthArrayAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for BuffQueueDepth array
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 
10 namespace Svc {
11 
12  // ----------------------------------------------------------------------
13  // Constructors
14  // ----------------------------------------------------------------------
15 
18  Serializable(),
19  elements()
20  {
21 
22  }
23 
26  Serializable()
27  {
28  *this = a;
29  }
30 
33  Serializable()
34  {
35  *this = e;
36  }
37 
39  BuffQueueDepth(const std::initializer_list<ElementType>& il) :
40  Serializable()
41  {
42  *this = il;
43  }
44 
47  Serializable()
48  {
49  *this = obj;
50  }
51 
52  // ----------------------------------------------------------------------
53  // Operators
54  // ----------------------------------------------------------------------
55 
58  {
59  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
60  return this->elements[i];
61  }
62 
64  operator[](const FwSizeType i) const
65  {
66  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
67  return this->elements[i];
68  }
69 
72  {
73  if (this != &obj) {
74  for (FwSizeType index = 0; index < SIZE; index++) {
75  this->elements[index] = obj.elements[index];
76  }
77  }
78  return *this;
79  }
80 
83  {
84  for (FwSizeType index = 0; index < SIZE; index++) {
85  this->elements[index] = a[index];
86  }
87  return *this;
88  }
89 
91  operator=(const std::initializer_list<ElementType>& il)
92  {
93  // Check that the initializer has the expected size
94  FW_ASSERT(il.size() == SIZE, static_cast<FwAssertArgType>(il.size()), static_cast<FwAssertArgType>(SIZE));
95  FwSizeType i = 0;
96  for (const auto& e : il) {
97  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
98  this->elements[i] = e;
99  i++;
100  }
101  return *this;
102  }
103 
106  {
107  for (FwSizeType index = 0; index < SIZE; index++) {
108  this->elements[index] = e;
109  }
110  return *this;
111  }
112 
113  bool BuffQueueDepth ::
114  operator==(const BuffQueueDepth& obj) const
115  {
116  for (FwSizeType index = 0; index < SIZE; index++) {
117  if (!((*this)[index] == obj[index])) {
118  return false;
119  }
120  }
121  return true;
122  }
123 
124  bool BuffQueueDepth ::
125  operator!=(const BuffQueueDepth& obj) const
126  {
127  return !(*this == obj);
128  }
129 
130 #ifdef BUILD_UT
131 
132  std::ostream& operator<<(std::ostream& os, const BuffQueueDepth& obj) {
133  Fw::String s;
134  obj.toString(s);
135  os << s;
136  return os;
137  }
138 
139 #endif
140 
141  // ----------------------------------------------------------------------
142  // Public member functions
143  // ----------------------------------------------------------------------
144 
147  Fw::SerialBufferBase& buffer,
148  Fw::Endianness mode
149  ) const
150  {
152  for (FwSizeType index = 0; index < SIZE; index++) {
153  status = buffer.serializeFrom((*this)[index], mode);
154  if (status != Fw::FW_SERIALIZE_OK) {
155  return status;
156  }
157  }
158  return status;
159  }
160 
163  Fw::SerialBufferBase& buffer,
164  Fw::Endianness mode
165  )
166  {
168  for (FwSizeType index = 0; index < SIZE; index++) {
169  status = buffer.deserializeTo((*this)[index], mode);
170  if (status != Fw::FW_SERIALIZE_OK) {
171  return status;
172  }
173  }
174  return status;
175  }
176 
179  {
180  return SERIALIZED_SIZE;
181  }
182 
183 #if FW_SERIALIZABLE_TO_STRING
184 
185  void BuffQueueDepth ::
186  toString(Fw::StringBase& sb) const
187  {
188  // Clear the output string
189  sb = "";
190 
191  // Array prefix
192  if (sb.length() + 2 <= sb.maxLength()) {
193  sb += "[ ";
194  } else {
195  return;
196  }
197 
198  for (FwSizeType index = 0; index < SIZE; index++) {
199  Fw::String tmp;
200  tmp.format("%" PRIu32 "", this->elements[index]);
201 
202  FwSizeType size = tmp.length() + (index > 0 ? 2 : 0);
203  if ((size + sb.length()) <= sb.maxLength()) {
204  if (index > 0) {
205  sb += ", ";
206  }
207  sb += tmp;
208  } else {
209  break;
210  }
211  }
212 
213  // Array suffix
214  if (sb.length() + 2 <= sb.maxLength()) {
215  sb += " ]";
216  }
217  }
218 
219 #endif
220 
221 }
Serialization/Deserialization operation was successful.
PlatformSizeType FwSizeType
bool operator==(const BuffQueueDepth &obj) const
Equality operator.
FwSizeType serializedSize() const
Get the dynamic serialized size of the array.
U32 ElementType
The element type.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
ElementType & operator[](const FwSizeType i)
Subscript operator.
Array of queue depths for Fw::Buffer types.
BuffQueueDepth & operator=(const BuffQueueDepth &obj)
Copy assignment operator (object)
Header size for F Prime frame header.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:39
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialization.
BuffQueueDepth()
Constructor (default value)
SizeType maxLength() const
Get the maximum length of a string that the buffer can hold (which is capacity - 1) ...
The size of the serial representation.
RateGroupDivider component implementation.
virtual SizeType length() const
Get the length of the string.
Endianness
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialization.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
bool operator!=(const BuffQueueDepth &obj) const
Inequality operator.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.