fprime/Svc/ComSplitter/ComSplitter.cpp
Joshua Anderson 3cccd731d9
Refactor FW_OBJECT_NAMES switches and fix building without object names
Instead of adding the name argument to a constructor when FW_OBJECT_NAMES
is enabled, always supply a name argument.

Add a marco that conditionally sets the name to "" if FW_OBJECT_NAMES is not set.
This cleans up a lot of the conditional compilation switches that weren't being tested
and would silently break, while still stripping the strings from the binary.
2020-10-07 17:19:05 -07:00

61 lines
1.4 KiB
C++

// ----------------------------------------------------------------------
//
// ComSplitter.cpp
//
// ----------------------------------------------------------------------
#include <Svc/ComSplitter/ComSplitter.hpp>
#include "Fw/Types/BasicTypes.hpp"
namespace Svc {
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
ComSplitter ::
ComSplitter(const char* compName) :
ComSplitterComponentBase(compName)
{
}
ComSplitter ::
~ComSplitter(void)
{
}
void ComSplitter ::
init(NATIVE_INT_TYPE instance)
{
ComSplitterComponentBase::init(instance);
}
// ----------------------------------------------------------------------
// Handler implementations
// ----------------------------------------------------------------------
void ComSplitter ::
comIn_handler(
NATIVE_INT_TYPE portNum,
Fw::ComBuffer &data,
U32 context
)
{
FW_ASSERT(portNum == 0);
NATIVE_INT_TYPE numPorts = getNum_comOut_OutputPorts();
FW_ASSERT(numPorts > 0);
for(NATIVE_INT_TYPE i = 0; i < numPorts; i++) {
if( isConnected_comOut_OutputPort(i) ) {
// Need to make a copy because we are passing by reference!:
Fw::ComBuffer dataToSend = data;
comOut_out(i, dataToSend, 0);
}
}
}
};