F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileReadPortAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FileReadPortAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for FileRead port
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
10 
11 namespace Svc {
12 
13  namespace {
14 
15  // ----------------------------------------------------------------------
16  // Port buffer class
17  // ----------------------------------------------------------------------
18 
19  class FileReadPortBuffer : public Fw::LinearBufferBase {
20 
21  public:
22 
23  Fw::Serializable::SizeType getCapacity() const {
25  }
26 
27  U8* getBuffAddr() {
28  return m_buff;
29  }
30 
31  const U8* getBuffAddr() const {
32  return m_buff;
33  }
34 
35  private:
36 
38 
39  };
40 
41  }
42 
43  // ----------------------------------------------------------------------
44  // Input Port Member functions
45  // ----------------------------------------------------------------------
46 
49  Fw::InputPortBase(),
50  m_func(nullptr)
51  {
52 
53  }
54 
57  {
59  }
60 
63  Fw::PassiveComponentBase* callComp,
64  CompFuncPtr funcPtr
65  )
66  {
67  FW_ASSERT(callComp != nullptr);
68  FW_ASSERT(funcPtr != nullptr);
69 
70  this->m_comp = callComp;
71  this->m_func = funcPtr;
72  this->m_connObj = callComp;
73  }
74 
77  const Fw::StringBase& path,
78  Fw::Buffer& buffer
79  )
80  {
81 #if FW_PORT_TRACING == 1
82  this->trace();
83 #endif
84 
85  FW_ASSERT(this->m_comp != nullptr);
86  FW_ASSERT(this->m_func != nullptr);
87 
88  return this->m_func(this->m_comp, this->m_portNum, path, buffer);
89  }
90 
91 #if FW_PORT_SERIALIZATION == 1
92 
93  Fw::SerializeStatus InputFileReadPort ::
94  invokeSerial(Fw::LinearBufferBase& _buffer)
95  {
96  Fw::SerializeStatus _status;
97 
98 #if FW_PORT_TRACING == 1
99  this->trace();
100 #endif
101 
102  FW_ASSERT(this->m_comp != nullptr);
103  FW_ASSERT(this->m_func != nullptr);
104 
105  char __fprime_ac_path_buffer[Fw::StringBase::BUFFER_SIZE(200)];
106  Fw::ExternalString path(__fprime_ac_path_buffer, sizeof __fprime_ac_path_buffer);
107  _status = _buffer.deserializeTo(path);
108  if (_status != Fw::FW_SERIALIZE_OK) {
109  return _status;
110  }
111 
112  Fw::Buffer buffer;
113  _status = _buffer.deserializeTo(buffer);
114  if (_status != Fw::FW_SERIALIZE_OK) {
115  return _status;
116  }
117 
118  this->m_func(this->m_comp, this->m_portNum, path, buffer);
119 
120  return Fw::FW_SERIALIZE_OK;
121  }
122 
123 #endif
124 
125  // ----------------------------------------------------------------------
126  // Output Port Member functions
127  // ----------------------------------------------------------------------
128 
131  Fw::OutputPortBase(),
132  m_port(nullptr)
133  {
134 
135  }
136 
139  {
141  }
142 
145  {
146  FW_ASSERT(callPort != nullptr);
147 
148  this->m_port = callPort;
149  this->m_connObj = callPort;
150 
151 #if FW_PORT_SERIALIZATION == 1
152  this->m_serPort = nullptr;
153 #endif
154  }
155 
158  const Fw::StringBase& path,
159  Fw::Buffer& buffer
160  ) const
161  {
162 #if FW_PORT_TRACING == 1
163  this->trace();
164 #endif
165 
166 #if FW_PORT_SERIALIZATION
167  FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
168 
169  if (this->m_port != nullptr) {
170  this->m_port->invoke(path, buffer);
171  }
172  else {
173  Fw::SerializeStatus _status;
174  FileReadPortBuffer _buffer;
175 
176  _status = _buffer.serializeFrom(path);
177  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
178 
179  _status = _buffer.serializeFrom(buffer);
180  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
181 
182  _status = this->m_serPort->invokeSerial(_buffer);
183  FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
184  }
185 #else
186  FW_ASSERT(this->m_port != nullptr);
187  this->m_port->invoke(path, buffer);
188 #endif
189  }
190 
191 }
Serialization/Deserialization operation was successful.
FwIndexType m_portNum
InputFileReadPort()
Constructor.
SerializeStatus
forward declaration for string
Input FileRead port.
The size of the serial representations of the port arguments.
void init() override
FwSizeType SizeType
void addCallPort(InputFileReadPort *callPort)
Register an input port.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
A string backed by an external buffer.
void invoke(const Fw::StringBase &path, Fw::Buffer &buffer)
Invoke a port interface.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
OutputFileReadPort()
Constructor.
PassiveComponentBase * m_comp
void invoke(const Fw::StringBase &path, Fw::Buffer &buffer) const
Invoke a port interface.
void init() override
RateGroupDivider component implementation.
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
Implementation of malloc based allocator.
static constexpr SizeType BUFFER_SIZE(SizeType maxLength)
Get the size of a null-terminated string buffer.
Fw::ObjBase * m_connObj
Definition: PortBase.hpp:34
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void init()
Initialization function.
void init()
Initialization function.