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  {
20  *this = Svc::BuffQueueDepth(0);
21  }
22 
25  Serializable()
26  {
27  *this = a;
28  }
29 
32  Serializable()
33  {
34  *this = e;
35  }
36 
38  BuffQueueDepth(const std::initializer_list<ElementType>& il) :
39  Serializable()
40  {
41  *this = il;
42  }
43 
46  Serializable()
47  {
48  *this = obj;
49  }
50 
51  // ----------------------------------------------------------------------
52  // Operators
53  // ----------------------------------------------------------------------
54 
57  {
58  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
59  return this->elements[i];
60  }
61 
63  operator[](const FwSizeType i) const
64  {
65  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
66  return this->elements[i];
67  }
68 
71  {
72  if (this != &obj) {
73  for (FwSizeType index = 0; index < SIZE; index++) {
74  this->elements[index] = obj.elements[index];
75  }
76  }
77  return *this;
78  }
79 
82  {
83  for (FwSizeType index = 0; index < SIZE; index++) {
84  this->elements[index] = a[index];
85  }
86  return *this;
87  }
88 
90  operator=(const std::initializer_list<ElementType>& il)
91  {
92  // Since we are required to use C++11, this has to be a runtime check
93  // In C++14, it can be a static check
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  {
149  for (FwSizeType index = 0; index < SIZE; index++) {
150  status = buffer.serializeFrom((*this)[index]);
151  if (status != Fw::FW_SERIALIZE_OK) {
152  return status;
153  }
154  }
155  return status;
156  }
157 
160  {
162  for (FwSizeType index = 0; index < SIZE; index++) {
163  status = buffer.deserializeTo((*this)[index]);
164  if (status != Fw::FW_SERIALIZE_OK) {
165  return status;
166  }
167  }
168  return status;
169  }
170 
173  {
174  return SERIALIZED_SIZE;
175  }
176 
177 #if FW_SERIALIZABLE_TO_STRING
178 
179  void BuffQueueDepth ::
180  toString(Fw::StringBase& sb) const
181  {
182  // Clear the output string
183  sb = "";
184 
185  // Array prefix
186  if (sb.length() + 2 <= sb.maxLength()) {
187  sb += "[ ";
188  } else {
189  return;
190  }
191 
192  for (FwSizeType index = 0; index < SIZE; index++) {
193  Fw::String tmp;
194  tmp.format("%" PRIu32 "", this->elements[index]);
195 
196  FwSizeType size = tmp.length() + (index > 0 ? 2 : 0);
197  if ((size + sb.length()) <= sb.maxLength()) {
198  if (index > 0) {
199  sb += ", ";
200  }
201  sb += tmp;
202  } else {
203  break;
204  }
205  }
206 
207  // Array suffix
208  if (sb.length() + 2 <= sb.maxLength()) {
209  sb += " ]";
210  }
211  }
212 
213 #endif
214 
215 }
Serialization/Deserialization operation was successful.
Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase &buffer) const
Serialization.
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.
SerializeStatus
forward declaration for string
SizeType maxLength() const
Get the maximum length of a string that the buffer can hold (which is capacity - 1) ...
Definition: StringBase.cpp:128
ElementType & operator[](const FwSizeType i)
Subscript operator.
Array of queue depths for Fw::Buffer types.
Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase &buffer)
Deserialization.
SizeType length() const
Get length of string.
Definition: StringBase.cpp:121
BuffQueueDepth & operator=(const BuffQueueDepth &obj)
Copy assignment operator (object)
The size of the serial representation.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
Header size for F Prime frame header.
BuffQueueDepth()
Constructor (default value)
RateGroupDivider component implementation.
SerializeStatus serializeFrom(U8 val)
serialize 8-bit unsigned int
#define FW_ASSERT(...)
Definition: Assert.hpp:14
bool operator!=(const BuffQueueDepth &obj) const
Inequality operator.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
SerializeStatus deserializeTo(U8 &val)
deserialize 8-bit unsigned int