mirror of
https://github.com/nasa/fpp.git
synced 2025-12-12 15:59:33 -06:00
368 lines
7.4 KiB
C++
368 lines
7.4 KiB
C++
// ======================================================================
|
|
// \title StringPortAc.cpp
|
|
// \author Generated by fpp-to-cpp
|
|
// \brief cpp file for String port
|
|
// ======================================================================
|
|
|
|
#include "Fw/Types/Assert.hpp"
|
|
#include "Fw/Types/StringUtils.hpp"
|
|
#include "StringPortAc.hpp"
|
|
|
|
// ----------------------------------------------------------------------
|
|
// StringSize80 class
|
|
// ----------------------------------------------------------------------
|
|
|
|
StringSize80 ::
|
|
StringSize80() :
|
|
StringBase()
|
|
{
|
|
this->m_buf[0] = 0;
|
|
}
|
|
|
|
StringSize80 ::
|
|
StringSize80(const char* src) :
|
|
StringBase()
|
|
{
|
|
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
|
|
}
|
|
|
|
StringSize80 ::
|
|
StringSize80(const Fw::StringBase& src) :
|
|
StringBase()
|
|
{
|
|
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
|
|
}
|
|
|
|
StringSize80 ::
|
|
StringSize80(const StringSize80& src) :
|
|
StringBase()
|
|
{
|
|
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
|
|
}
|
|
|
|
StringSize80 ::
|
|
~StringSize80()
|
|
{
|
|
|
|
}
|
|
|
|
StringSize80& StringSize80 ::
|
|
operator=(const StringSize80& other)
|
|
{
|
|
if (this == &other) {
|
|
return *this;
|
|
}
|
|
|
|
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
|
|
return *this;
|
|
}
|
|
|
|
StringSize80& StringSize80 ::
|
|
operator=(const Fw::StringBase& other)
|
|
{
|
|
if (this == &other) {
|
|
return *this;
|
|
}
|
|
|
|
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
|
|
return *this;
|
|
}
|
|
|
|
StringSize80& StringSize80 ::
|
|
operator=(const char* other)
|
|
{
|
|
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
|
|
return *this;
|
|
}
|
|
|
|
const char* StringSize80 ::
|
|
toChar() const
|
|
{
|
|
return this->m_buf;
|
|
}
|
|
|
|
NATIVE_UINT_TYPE StringSize80 ::
|
|
getCapacity() const
|
|
{
|
|
return sizeof(this->m_buf);
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// StringSize100 class
|
|
// ----------------------------------------------------------------------
|
|
|
|
StringSize100 ::
|
|
StringSize100() :
|
|
StringBase()
|
|
{
|
|
this->m_buf[0] = 0;
|
|
}
|
|
|
|
StringSize100 ::
|
|
StringSize100(const char* src) :
|
|
StringBase()
|
|
{
|
|
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
|
|
}
|
|
|
|
StringSize100 ::
|
|
StringSize100(const Fw::StringBase& src) :
|
|
StringBase()
|
|
{
|
|
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
|
|
}
|
|
|
|
StringSize100 ::
|
|
StringSize100(const StringSize100& src) :
|
|
StringBase()
|
|
{
|
|
Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));
|
|
}
|
|
|
|
StringSize100 ::
|
|
~StringSize100()
|
|
{
|
|
|
|
}
|
|
|
|
StringSize100& StringSize100 ::
|
|
operator=(const StringSize100& other)
|
|
{
|
|
if (this == &other) {
|
|
return *this;
|
|
}
|
|
|
|
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
|
|
return *this;
|
|
}
|
|
|
|
StringSize100& StringSize100 ::
|
|
operator=(const Fw::StringBase& other)
|
|
{
|
|
if (this == &other) {
|
|
return *this;
|
|
}
|
|
|
|
Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
|
|
return *this;
|
|
}
|
|
|
|
StringSize100& StringSize100 ::
|
|
operator=(const char* other)
|
|
{
|
|
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
|
|
return *this;
|
|
}
|
|
|
|
const char* StringSize100 ::
|
|
toChar() const
|
|
{
|
|
return this->m_buf;
|
|
}
|
|
|
|
NATIVE_UINT_TYPE StringSize100 ::
|
|
getCapacity() const
|
|
{
|
|
return sizeof(this->m_buf);
|
|
}
|
|
|
|
namespace {
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Port _buffer class
|
|
// ----------------------------------------------------------------------
|
|
|
|
class StringPortBuffer : public Fw::SerializeBufferBase {
|
|
|
|
public:
|
|
|
|
NATIVE_UINT_TYPE getBuffCapacity() const {
|
|
return InputStringPort::SERIALIZED_SIZE;
|
|
}
|
|
|
|
U8* getBuffAddr() {
|
|
return m_buff;
|
|
}
|
|
|
|
const U8* getBuffAddr() const {
|
|
return m_buff;
|
|
}
|
|
|
|
private:
|
|
|
|
U8 m_buff[InputStringPort::SERIALIZED_SIZE];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Input Port Member functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
InputStringPort ::
|
|
InputStringPort() :
|
|
Fw::InputPortBase(),
|
|
m_func(nullptr)
|
|
{
|
|
|
|
}
|
|
|
|
void InputStringPort ::
|
|
init()
|
|
{
|
|
Fw::InputPortBase::init();
|
|
}
|
|
|
|
void InputStringPort ::
|
|
addCallComp(
|
|
Fw::PassiveComponentBase* callComp,
|
|
CompFuncPtr funcPtr
|
|
)
|
|
{
|
|
FW_ASSERT(callComp);
|
|
FW_ASSERT(funcPtr);
|
|
|
|
this->m_comp = callComp;
|
|
this->m_func = funcPtr;
|
|
this->m_connObj = callComp;
|
|
}
|
|
|
|
void InputStringPort ::
|
|
invoke(
|
|
const StringSize80& str80,
|
|
StringSize80& str80Ref,
|
|
const StringSize100& str100,
|
|
StringSize100& str100Ref
|
|
)
|
|
{
|
|
#if FW_PORT_TRACING == 1
|
|
this->trace();
|
|
#endif
|
|
|
|
FW_ASSERT(this->m_comp);
|
|
FW_ASSERT(this->m_func);
|
|
|
|
return this->m_func(this->m_comp, this->m_portNum, str80, str80Ref, str100, str100Ref);
|
|
}
|
|
|
|
#if FW_PORT_SERIALIZATION == 1
|
|
|
|
Fw::SerializeStatus InputStringPort ::
|
|
invokeSerial(Fw::SerializeBufferBase& _buffer)
|
|
{
|
|
Fw::SerializeStatus _status;
|
|
|
|
#if FW_PORT_SERIALIZATION == 1
|
|
this->trace();
|
|
#endif
|
|
|
|
FW_ASSERT(this->m_comp);
|
|
FW_ASSERT(this->m_func);
|
|
|
|
StringSize80 str80;
|
|
_status = _buffer.deserialize(str80);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
StringSize80 str80Ref;
|
|
_status = _buffer.deserialize(str80Ref);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
StringSize100 str100;
|
|
_status = _buffer.deserialize(str100);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
StringSize100 str100Ref;
|
|
_status = _buffer.deserialize(str100Ref);
|
|
if (_status != Fw::FW_SERIALIZE_OK) {
|
|
return _status;
|
|
}
|
|
|
|
this->m_func(this->m_comp, this->m_portNum, str80, str80Ref, str100, str100Ref);
|
|
|
|
return Fw::FW_SERIALIZE_OK;
|
|
}
|
|
|
|
#endif
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Output Port Member functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
OutputStringPort ::
|
|
OutputStringPort() :
|
|
Fw::OutputPortBase(),
|
|
m_port(nullptr)
|
|
{
|
|
|
|
}
|
|
|
|
void OutputStringPort ::
|
|
init()
|
|
{
|
|
Fw::OutputPortBase::init();
|
|
}
|
|
|
|
void OutputStringPort ::
|
|
addCallPort(InputStringPort* callPort)
|
|
{
|
|
FW_ASSERT(callPort);
|
|
|
|
this->m_port = callPort;
|
|
this->m_connObj = callPort;
|
|
|
|
#if FW_PORT_SERIALIZATION == 1
|
|
this->m_serPort = nullptr;
|
|
#endif
|
|
}
|
|
|
|
void OutputStringPort ::
|
|
invoke(
|
|
const StringSize80& str80,
|
|
StringSize80& str80Ref,
|
|
const StringSize100& str100,
|
|
StringSize100& str100Ref
|
|
)
|
|
{
|
|
#if FW_PORT_TRACING == 1
|
|
this->trace();
|
|
#endif
|
|
|
|
#if FW_PORT_SERIALIZATION
|
|
FW_ASSERT(this->m_port || this->m_serPort);
|
|
#else
|
|
FW_ASSERT(this->m_port);
|
|
#endif
|
|
if (this->m_port) {
|
|
this->m_port->invoke(str80, str80Ref, str100, str100Ref);
|
|
#if FW_PORT_SERIALIZATION
|
|
} else if (this->m_serPort) {
|
|
Fw::SerializeStatus _status;
|
|
StringPortBuffer _buffer;
|
|
|
|
_status = _buffer.serialize(str80);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = _buffer.serialize(str80Ref);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = _buffer.serialize(str100);
|
|
FW_ASSERT(_status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(_status));
|
|
|
|
_status = _buffer.serialize(str100Ref);
|
|
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
|
|
}
|
|
#endif
|
|
}
|