F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
SaMapArrayAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title SaMapArrayAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for SaMap array
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 
10 namespace SdlsCfg {
11 
12  // ----------------------------------------------------------------------
13  // Constructors
14  // ----------------------------------------------------------------------
15 
16  SaMap ::
17  SaMap() :
18  Serializable(),
19  elements()
20  {
22  }
23 
24  SaMap ::
25  SaMap(const ElementType (&a)[SIZE]) :
26  Serializable()
27  {
28  *this = a;
29  }
30 
31  SaMap ::
32  SaMap(const ElementType& e) :
33  Serializable()
34  {
35  *this = e;
36  }
37 
38  SaMap ::
39  SaMap(const std::initializer_list<ElementType>& il) :
40  Serializable()
41  {
42  *this = il;
43  }
44 
45  SaMap ::
46  SaMap(const SaMap& obj) :
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 
71  operator=(const SaMap& obj)
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 
82  operator=(const ElementType (&a)[SIZE])
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 
104  SaMap& SaMap ::
106  {
107  for (FwSizeType index = 0; index < SIZE; index++) {
108  this->elements[index] = e;
109  }
110  return *this;
111  }
112 
113  bool SaMap ::
114  operator==(const SaMap& 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 SaMap ::
125  operator!=(const SaMap& obj) const
126  {
127  return !(*this == obj);
128  }
129 
130 #ifdef BUILD_UT
131 
132  std::ostream& operator<<(std::ostream& os, const SaMap& 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  FwSizeType size = 0;
181  for (FwSizeType index = 0; index < SIZE; index++) {
182  size += this->elements[index].serializedSize();
183  }
184  return size;
185  }
186 
187 #if FW_SERIALIZABLE_TO_STRING
188 
189  void SaMap ::
190  toString(Fw::StringBase& sb) const
191  {
192  // Clear the output string
193  sb = "";
194 
195  // Array prefix
196  sb += "[ ";
197 
198  for (FwSizeType index = 0; index < SIZE; index++) {
199  // Array data
200  Fw::String tmp;
201  this->elements[index].toString(tmp);
202 
203  if (index > 0) {
204  sb += ", ";
205  }
206  sb += tmp;
207  }
208 
209  // Array suffix
210  sb += " ]";
211  }
212 
213 #endif
214 
215 }
Serialization/Deserialization operation was successful.
bool operator!=(const SaMap &obj) const
Inequality operator.
FwSizeType serializedSize() const
Get the dynamic serialized size of the struct.
PlatformSizeType FwSizeType
Fw::SerializeStatus deserializeFrom(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialization.
The size of the array.
FwSizeType serializedSize() const
Get the dynamic serialized size of the array.
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
ElementType & operator[](const FwSizeType i)
Subscript operator.
A single security association index to port index mapping entry.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
SaMap & operator=(const SaMap &obj)
Copy assignment operator (object)
bool operator==(const SaMap &obj) const
Equality operator.
Endianness
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Fw::SerializeStatus serializeTo(Fw::SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialization.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
SaMap()
Constructor (default value)