F´ Flight Software - C/C++ Documentation  devel
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 <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 = BuffQueueDepth(
26  0
27  );
28  }
29 
31  BuffQueueDepth(const ElementType (&a)[SIZE]) :
32  Serializable()
33  {
34  for (U32 index = 0; index < SIZE; index++) {
35  this->elements[index] = a[index];
36  }
37  }
38 
40  BuffQueueDepth(const ElementType& e1) :
41  Serializable()
42  {
43  this->elements[0] = e1;
44  }
45 
47  BuffQueueDepth(const BuffQueueDepth& obj) :
48  Serializable()
49  {
50  for (U32 index = 0; index < SIZE; index++) {
51  this->elements[index] = obj.elements[index];
52  }
53  }
54 
55  // ----------------------------------------------------------------------
56  // Operators
57  // ----------------------------------------------------------------------
58 
60  operator[](const U32 i)
61  {
62  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
63  return this->elements[i];
64  }
65 
67  operator[](const U32 i) const
68  {
69  FW_ASSERT(i < SIZE, static_cast<FwAssertArgType>(i), static_cast<FwAssertArgType>(SIZE));
70  return this->elements[i];
71  }
72 
74  operator=(const BuffQueueDepth& obj)
75  {
76  if (this == &obj) {
77  return *this;
78  }
79 
80  for (U32 index = 0; index < SIZE; index++) {
81  this->elements[index] = obj.elements[index];
82  }
83  return *this;
84  }
85 
87  operator=(const ElementType (&a)[SIZE])
88  {
89  for (U32 index = 0; index < SIZE; index++) {
90  this->elements[index] = a[index];
91  }
92  return *this;
93  }
94 
96  operator=(const ElementType& e)
97  {
98  for (U32 index = 0; index < SIZE; index++) {
99  this->elements[index] = e;
100  }
101  return *this;
102  }
103 
105  operator==(const BuffQueueDepth& obj) const
106  {
107  for (U32 index = 0; index < SIZE; index++) {
108  if (!((*this)[index] == obj[index])) {
109  return false;
110  }
111  }
112  return true;
113  }
114 
116  operator!=(const BuffQueueDepth& obj) const
117  {
118  return !(*this == obj);
119  }
120 
121 #ifdef BUILD_UT
122 
123  std::ostream& operator<<(std::ostream& os, const BuffQueueDepth& obj) {
124  Fw::String s;
125  obj.toString(s);
126  os << s;
127  return os;
128  }
129 
130 #endif
131 
132  // ----------------------------------------------------------------------
133  // Member functions
134  // ----------------------------------------------------------------------
135 
137  serialize(Fw::SerializeBufferBase& buffer) const
138  {
140  for (U32 index = 0; index < SIZE; index++) {
141  status = buffer.serialize((*this)[index]);
142  if (status != Fw::FW_SERIALIZE_OK) {
143  return status;
144  }
145  }
146  return status;
147  }
148 
151  {
153  for (U32 index = 0; index < SIZE; index++) {
154  status = buffer.deserialize((*this)[index]);
155  if (status != Fw::FW_SERIALIZE_OK) {
156  return status;
157  }
158  }
159  return status;
160  }
161 
162 #if FW_ARRAY_TO_STRING
163 
164  void BuffQueueDepth ::
165  toString(Fw::StringBase& sb) const
166  {
167  static const char *formatString = "[ "
168  "%" PRIu32 " ]";
169 
170  char outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE];
171  (void) snprintf(
172  outputString,
174  formatString,
175  this->elements[0]
176  );
177 
178  outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
179  sb = outputString;
180  }
181 
182 #endif
183 
184 }
#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::Buffer types.
U32 ElementType
The element type.
@ SIZE
The size of the array.
bool operator==(const BuffQueueDepth &obj) const
Equality operator.
bool operator!=(const BuffQueueDepth &obj) const
Inequality operator.
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialization.
BuffQueueDepth()
Constructor (default value)
BuffQueueDepth & operator=(const BuffQueueDepth &obj)
Copy assignment operator (object)
ElementType & operator[](const U32 i)
Subscript operator.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialization.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
@ SIZE
Header size for F Prime frame header.