F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AArrayAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title A
3 // \author Auto-generated
4 // \brief cpp file for A
5 //
6 // \copyright
7 // Copyright 2020 California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged. Any commercial use must be negotiated with the Office
10 // of Technology Transfer at the California Institute of Technology.
11 //
12 // This software may be subject to U.S. export control laws and
13 // regulations. By accepting this document, the user agrees to comply
14 // with all U.S. export laws and regulations. User has the
15 // responsibility to obtain export licenses, or other export authority
16 // as may be required before exporting such information to foreign
17 // countries or providing access to foreign persons.
18 // ======================================================================
19 
20 #include <string.h>
21 #include <stdio.h>
22 
23 #include "Fw/Types/Assert.hpp"
24 
25 #include "AArrayAc.hpp"
26 
27 
28 
29  // ----------------------------------------------------------------------
30  // Constructors
31  // ----------------------------------------------------------------------
32 
33  A ::
34  A(void) :
35  Serializable()
36  {
37  *this = A(
38  T(),
39  T(),
40  T());
41  }
42 
43  A ::
44  A(const ElementType (&a)[SIZE]) :
45  Serializable()
46  {
47  for(U32 index = 0; index < SIZE; index++)
48  {
49  this->elements[index] = a[index];
50  }
51  }
52 
53  A ::
54  A(const ElementType& e) :
55  Serializable()
56  {
57  for(U32 index = 0; index < SIZE; index++)
58  {
59  this->elements[index] = e;
60  }
61  }
62 
63  A ::
65  const ElementType (&e1),
66  const ElementType (&e2),
67  const ElementType (&e3)
68  ) :
69  Serializable()
70  {
71  this->elements[0] = e1;
72  this->elements[1] = e2;
73  this->elements[2] = e3;
74  }
75 
76  A ::
77  A(const A& other) :
78  Serializable()
79  {
80  for(U32 index = 0; index < SIZE; index++)
81  {
82  this->elements[index] = other.elements[index];
83  }
84  }
85 
86  // ----------------------------------------------------------------------
87  // Public functions
88  // ----------------------------------------------------------------------
89 
90 
92  operator[](const U32 i)
93  {
94  FW_ASSERT(i < SIZE);
95  return this->elements[i];
96  }
97 
98  const A::ElementType& A ::
99  operator[](const U32 i) const
100  {
101  FW_ASSERT(i < SIZE);
102  return this->elements[i];
103  }
104 
105 
106  const A& A ::
107  operator=(const A& other)
108  {
109  for(U32 index = 0; index < SIZE; index++) {
110  this->elements[index] = other.elements[index];
111  }
112  return *this;
113  }
114 
115  const A& A ::
117  {
118  for(U32 index = 0; index < SIZE; index++) {
119  this->elements[index] = a[index];
120  }
121  return *this;
122  }
123 
124  const A& A ::
126  {
127  for(U32 index = 0; index < SIZE; index++) {
128  this->elements[index] = e;
129  }
130  return *this;
131  }
132 
133  bool A ::
134  operator==(const A& other) const
135  {
136  for (U32 i = 0; i < SIZE; ++i) {
137  if (!((*this)[i] == other[i])) {
138  return false;
139  }
140  }
141  return true;
142  }
143 
144  bool A ::
145  operator!=(const A& other) const
146  {
147  return !(*this == other);
148  }
149 
150 #if 0
151 
152 void A::toString(Fw::StringBase& text) const {
153 
154  static const char * formatString = "[ "
155  "%s, "
156  "%s, "
157  "%s ]";
158 
159  // Need to instantiate toString for arrays and serializable types
161  this->elements[0].toString(str0);
163  this->elements[1].toString(str1);
165  this->elements[2].toString(str2);
166 
167  // declare strings to hold any serializable toString() arguments
168 
169  char outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE];
170  (void)snprintf(outputString,FW_ARRAY_TO_STRING_BUFFER_SIZE,formatString
171  ,str0.toChar()
172  ,str1.toChar()
173  ,str2.toChar()
174  );
175  outputString[FW_ARRAY_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
176 
177  text = outputString;
178 }
179 
180 #endif
181 
182 #if 0
183  std::ostream& operator<<(std::ostream& os, const A& obj) {
185  obj.toString(temp);
186 
187  os << temp;
188  return os;
189  }
190 #endif
191 
194  {
196  for (U32 i = 0; i < SIZE; ++i) {
197  status = buffer.serialize((*this)[i]);
198  if (status != Fw::FW_SERIALIZE_OK) {
199  return status;
200  }
201  }
202  return status;
203  }
204 
207  {
209  for (U32 i = 0; i < SIZE; ++i) {
210  status = buffer.deserialize((*this)[i]);
211  if (status != Fw::FW_SERIALIZE_OK) {
212  return status;
213  }
214  }
215  return status;
216  }
217 
A
Definition: AArrayAc.hpp:28
Fw::EightyCharString::toChar
const char * toChar(void) const
gets char buffer
Definition: EightyCharString.cpp:48
A::SIZE
@ SIZE
Definition: AArrayAc.hpp:39
Fw::SerializeBufferBase
Definition: Serializable.hpp:43
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
Fw::SerializeBufferBase::serialize
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Serializable.cpp:69
Fw::StringBase
Definition: StringType.hpp:23
A::operator==
bool operator==(const A &other) const
Equality operator.
Definition: AArrayAc.cpp:134
Fw::EightyCharString
Definition: EightyCharString.hpp:10
Svc::FpFrameHeader::SIZE
@ SIZE
Header size for F Prime frame header.
Definition: FprimeProtocol.hpp:29
A::deserialize
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialization.
Definition: AArrayAc.cpp:206
T
Definition: T.hpp:9
A::serialize
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialization.
Definition: AArrayAc.cpp:193
FW_ARRAY_TO_STRING_BUFFER_SIZE
#define FW_ARRAY_TO_STRING_BUFFER_SIZE
Size of string to store toString() string output.
Definition: FpConfig.hpp:305
A::operator=
const A & operator=(const A &other)
Assignment operator.
Definition: AArrayAc.cpp:107
AArrayAc.hpp
A::A
A(void)
Construct a A with default initialization.
Definition: AArrayAc.cpp:34
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
A::operator[]
ElementType & operator[](const U32 i)
Subscript operator.
Definition: AArrayAc.cpp:92
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:294
A::operator!=
bool operator!=(const A &other) const
Inequality operator.
Definition: AArrayAc.cpp:145
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15