fpp/compiler/tools/fpp-to-cpp/test/port/KwdNamePortAc.ref.cpp
2025-12-01 10:00:55 -08:00

176 lines
3.5 KiB
C++
Vendored

// ======================================================================
// \title KwdNamePortAc.cpp
// \author Generated by fpp-to-cpp
// \brief cpp file for KwdName port
// ======================================================================
#include "Fw/Types/Assert.hpp"
#include "Fw/Types/ExternalString.hpp"
#include "KwdNamePortAc.hpp"
#if !FW_DIRECT_PORT_CALLS
namespace {
// ----------------------------------------------------------------------
// Port buffer class
// ----------------------------------------------------------------------
class KwdNamePortBuffer : public Fw::LinearBufferBase {
public:
Fw::Serializable::SizeType getCapacity() const {
return InputKwdNamePort::SERIALIZED_SIZE;
}
U8* getBuffAddr() {
return m_buff;
}
const U8* getBuffAddr() const {
return m_buff;
}
private:
U8 m_buff[InputKwdNamePort::SERIALIZED_SIZE];
};
}
// ----------------------------------------------------------------------
// Input Port Member functions
// ----------------------------------------------------------------------
InputKwdNamePort ::
InputKwdNamePort() :
Fw::InputPortBase(),
m_func(nullptr)
{
}
void InputKwdNamePort ::
init()
{
Fw::InputPortBase::init();
}
void InputKwdNamePort ::
addCallComp(
Fw::PassiveComponentBase* callComp,
CompFuncPtr funcPtr
)
{
FW_ASSERT(callComp != nullptr);
FW_ASSERT(funcPtr != nullptr);
this->m_comp = callComp;
this->m_func = funcPtr;
this->m_connObj = callComp;
}
void InputKwdNamePort ::
invoke(U32& time)
{
#if FW_PORT_TRACING == 1
this->trace();
#endif
FW_ASSERT(this->m_comp != nullptr);
FW_ASSERT(this->m_func != nullptr);
return this->m_func(this->m_comp, this->m_portNum, time);
}
#if FW_PORT_SERIALIZATION == 1
Fw::SerializeStatus InputKwdNamePort ::
invokeSerial(Fw::LinearBufferBase& _buffer)
{
Fw::SerializeStatus _status;
#if FW_PORT_TRACING == 1
this->trace();
#endif
FW_ASSERT(this->m_comp != nullptr);
FW_ASSERT(this->m_func != nullptr);
U32 time;
_status = _buffer.deserializeTo(time);
if (_status != Fw::FW_SERIALIZE_OK) {
return _status;
}
this->m_func(this->m_comp, this->m_portNum, time);
return Fw::FW_SERIALIZE_OK;
}
#endif
// ----------------------------------------------------------------------
// Output Port Member functions
// ----------------------------------------------------------------------
OutputKwdNamePort ::
OutputKwdNamePort() :
Fw::OutputPortBase(),
m_port(nullptr)
{
}
void OutputKwdNamePort ::
init()
{
Fw::OutputPortBase::init();
}
void OutputKwdNamePort ::
addCallPort(InputKwdNamePort* callPort)
{
FW_ASSERT(callPort != nullptr);
this->m_port = callPort;
this->m_connObj = callPort;
#if FW_PORT_SERIALIZATION == 1
this->m_serPort = nullptr;
#endif
}
void OutputKwdNamePort ::
invoke(U32& time) const
{
#if FW_PORT_TRACING == 1
this->trace();
#endif
#if FW_PORT_SERIALIZATION
FW_ASSERT((this->m_port != nullptr) || (this->m_serPort != nullptr));
if (this->m_port != nullptr) {
this->m_port->invoke(time);
}
else {
Fw::SerializeStatus _status;
KwdNamePortBuffer _buffer;
_status = _buffer.serializeFrom(time);
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
_status = this->m_serPort->invokeSerial(_buffer);
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
}
#else
FW_ASSERT(this->m_port != nullptr);
this->m_port->invoke(time);
#endif
}
#endif