F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
SendFileResponseSerializableAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title SendFileResponseSerializableAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for SendFileResponse struct
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  m_status(Svc::SendFileStatus::STATUS_OK),
24  m_context(0)
25  {
26 
27  }
28 
32  U32 context
33  ) :
34  Serializable(),
35  m_status(status),
36  m_context(context)
37  {
38 
39  }
40 
43  Serializable(),
44  m_status(obj.m_status),
45  m_context(obj.m_context)
46  {
47 
48  }
49 
50  // ----------------------------------------------------------------------
51  // Operators
52  // ----------------------------------------------------------------------
53 
55  operator=(const SendFileResponse& obj)
56  {
57  if (this == &obj) {
58  return *this;
59  }
60 
61  set(obj.m_status, obj.m_context);
62  return *this;
63  }
64 
66  operator==(const SendFileResponse& obj) const
67  {
68  return (
69  (this->m_status == obj.m_status) &&
70  (this->m_context == obj.m_context)
71  );
72  }
73 
75  operator!=(const SendFileResponse& obj) const
76  {
77  return !(*this == obj);
78  }
79 
80 #ifdef BUILD_UT
81 
82  std::ostream& operator<<(std::ostream& os, const SendFileResponse& obj) {
83  Fw::String s;
84  obj.toString(s);
85  os << s.toChar();
86  return os;
87  }
88 
89 #endif
90 
91  // ----------------------------------------------------------------------
92  // Member functions
93  // ----------------------------------------------------------------------
94 
97  {
98  Fw::SerializeStatus status;
99 
100  status = buffer.serialize(this->m_status);
101  if (status != Fw::FW_SERIALIZE_OK) {
102  return status;
103  }
104  status = buffer.serialize(this->m_context);
105  if (status != Fw::FW_SERIALIZE_OK) {
106  return status;
107  }
108 
109  return status;
110  }
111 
114  {
115  Fw::SerializeStatus status;
116 
117  status = buffer.deserialize(this->m_status);
118  if (status != Fw::FW_SERIALIZE_OK) {
119  return status;
120  }
121  status = buffer.deserialize(this->m_context);
122  if (status != Fw::FW_SERIALIZE_OK) {
123  return status;
124  }
125 
126  return status;
127  }
128 
129 #if FW_SERIALIZABLE_TO_STRING
130 
131  void SendFileResponse ::
132  toString(Fw::StringBase& sb) const
133  {
134  static const char* formatString =
135  "( "
136  "status = %s, "
137  "context = %" PRIu32 ""
138  " )";
139 
140  // Declare strings to hold any serializable toString() arguments
141  Fw::String statusStr;
142 
143  // Call toString for arrays and serializable types
144  this->m_status.toString(statusStr);
145 
146  char outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE];
147  (void) snprintf(
148  outputString,
150  formatString,
151  statusStr.toChar(),
152  this->m_context
153  );
154 
155  outputString[FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE-1] = 0; // NULL terminate
156  sb = outputString;
157  }
158 
159 #endif
160 
161  // ----------------------------------------------------------------------
162  // Setter functions
163  // ----------------------------------------------------------------------
164 
166  set(
167  Svc::SendFileStatus::T status,
168  U32 context
169  )
170  {
171  this->m_status = status;
172  this->m_context = context;
173  }
174 
177  {
178  this->m_status = status;
179  }
180 
182  setcontext(U32 context)
183  {
184  this->m_context = context;
185  }
186 
187 }
#define FW_SERIALIZABLE_TO_STRING_BUFFER_SIZE
Size of string to store toString() string output.
Definition: FpConfig.h:310
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
const char * toChar() const
gets char buffer
Definition: String.cpp:48
Fw::SerializeStatus serialize(Fw::SerializeBufferBase &buffer) const
Serialization.
void setstatus(Svc::SendFileStatus::T status)
Set member status.
void setcontext(U32 context)
Set member context.
Fw::SerializeStatus deserialize(Fw::SerializeBufferBase &buffer)
Deserialization.
SendFileResponse()
Constructor (default value)
void set(Svc::SendFileStatus::T status, U32 context)
Set all members.
bool operator==(const SendFileResponse &obj) const
Equality operator.
bool operator!=(const SendFileResponse &obj) const
Inequality operator.
SendFileResponse & operator=(const SendFileResponse &obj)
Copy assignment operator.
Send file status enum.
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.