F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
ComQueueDepthArrayAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title ComQueueDepthArrayAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for ComQueueDepth array
5 // ======================================================================
6 
7 #include <cstdio>
8 #include <cstring>
9 
11 #include "Fw/Types/Assert.hpp"
12 #include "Fw/Types/StringUtils.hpp"
13 
14 namespace Svc {
15 
16  // ----------------------------------------------------------------------
17  // Constructors
18  // ----------------------------------------------------------------------
19 
22  Serializable()
23  {
24  // Construct using element-wise constructor
25  *this = ComQueueDepth(
26  0,
27  0
28  );
29  }
30 
32  ComQueueDepth(const ElementType (&a)[SIZE]) :
33  Serializable()
34  {
35  for (U32 index = 0; index < SIZE; index++) {
36  this->elements[index] = a[index];
37  }
38  }
39 
41  ComQueueDepth(const ElementType& e) :
42  Serializable()
43  {
44  for (U32 index = 0; index < SIZE; index++) {
45  this->elements[index] = e;
46  }
47  }
48 
51  const ElementType& e1,
52  const ElementType& e2
53  ) :
54  Serializable()
55  {
56  this->elements[0] = e1;
57  this->elements[1] = e2;
58  }
59 
61  ComQueueDepth(const ComQueueDepth& obj) :
62  Serializable()
63  {
64  for (U32 index = 0; index < SIZE; index++) {
65  this->elements[index] = obj.elements[index];
66  }
67  }
68 
69  // ----------------------------------------------------------------------
70  // Operators
71  // ----------------------------------------------------------------------
72 
74  operator[](const U32 i)
75  {
76  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
77  return this->elements[i];
78  }
79 
81  operator[](const U32 i) const
82  {
83  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
84  return this->elements[i];
85  }
86 
88  operator=(const ComQueueDepth& obj)
89  {
90  if (this == &obj) {
91  return *this;
92  }
93 
94  for (U32 index = 0; index < SIZE; index++) {
95  this->elements[index] = obj.elements[index];
96  }
97  return *this;
98  }
99 
101  operator=(const ElementType (&a)[SIZE])
102  {
103  for (U32 index = 0; index < SIZE; index++) {
104  this->elements[index] = a[index];
105  }
106  return *this;
107  }
108 
110  operator=(const ElementType& e)
111  {
112  for (U32 index = 0; index < SIZE; index++) {
113  this->elements[index] = e;
114  }
115  return *this;
116  }
117 
119  operator==(const ComQueueDepth& obj) const
120  {
121  for (U32 index = 0; index < SIZE; index++) {
122  if (!((*this)[index] == obj[index])) {
123  return false;
124  }
125  }
126  return true;
127  }
128 
130  operator!=(const ComQueueDepth& obj) const
131  {
132  return !(*this == obj);
133  }
134 
135 #ifdef BUILD_UT
136 
137  std::ostream& operator<<(std::ostream& os, const ComQueueDepth& obj) {
138  Fw::String s;
139  obj.toString(s);
140  os << s;
141  return os;
142  }
143 
144 #endif
145 
146  // ----------------------------------------------------------------------
147  // Member functions
148  // ----------------------------------------------------------------------
149 
151  serialize(Fw::SerializeBufferBase& buffer) const
152  {
154  for (U32 index = 0; index < SIZE; index++) {
155  status = buffer.serialize((*this)[index]);
156  if (status != Fw::FW_SERIALIZE_OK) {
157  return status;
158  }
159  }
160  return status;
161  }
162 
165  {
167  for (U32 index = 0; index < SIZE; index++) {
168  status = buffer.deserialize((*this)[index]);
169  if (status != Fw::FW_SERIALIZE_OK) {
170  return status;
171  }
172  }
173  return status;
174  }
175 
176 #if FW_ARRAY_TO_STRING
177 
178  void ComQueueDepth ::
179  toString(Fw::StringBase& sb) const
180  {
181  static const char *formatString = "[ "
182  "%" PRIu32 " "
183  "%" PRIu32 " ]";
184 
185  char outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE];
186  (void) snprintf(
187  outputString,
189  formatString,
190  this->elements[0],
191  this->elements[1]
192  );
193 
194  outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
195  sb = outputString;
196  }
197 
198 #endif
199 
200 }
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:21
#define FW_ARRAY_TO_STRING_BUFFER_SIZE
Size of string to store toString() string output.
Definition: FpConfig.h:321
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Array of queue depths for Fw::Com types.
ElementType & operator[](const U32 i)
Subscript operator.
bool operator==(const ComQueueDepth &obj) const
Equality operator.
@ SIZE
The size of the array.
U32 ElementType
The element type.
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialization.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialization.
ComQueueDepth & operator=(const ComQueueDepth &obj)
Copy assignment operator (object)
ComQueueDepth()
Constructor (default value)
bool operator!=(const ComQueueDepth &obj) const
Inequality operator.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
@ SIZE
Header size for F Prime frame header.