fprime/Fw/Comp/QueuedComponentBase.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

51 lines
1.4 KiB
C++

#include <Fw/Comp/QueuedComponentBase.hpp>
#include <Fw/Types/Assert.hpp>
#include <Fw/Types/EightyCharString.hpp>
#include <FpConfig.hpp>
#include <stdio.h>
namespace Fw {
QueuedComponentBase::QueuedComponentBase(const char* name) : PassiveComponentBase(name),m_msgsDropped(0) {
}
QueuedComponentBase::~QueuedComponentBase() {
}
void QueuedComponentBase::init(NATIVE_INT_TYPE instance) {
PassiveComponentBase::init(instance);
}
#if FW_OBJECT_TO_STRING == 1 && FW_OBJECT_NAMES == 1
void QueuedComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) {
(void)snprintf(buffer, size,"QueueComp: %s", this->m_objName);
buffer[size-1] = 0;
}
#endif
Os::Queue::QueueStatus QueuedComponentBase::createQueue(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize) {
Fw::EightyCharString queueName;
#if FW_OBJECT_NAMES == 1
queueName = this->m_objName;
#else
char queueNameChar[FW_QUEUE_NAME_MAX_SIZE];
(void)snprintf(queueNameChar,sizeof(queueNameChar),"CompQ_%d",Os::Queue::getNumQueues());
queueName = queueNameChar;
#endif
return this->m_queue.create(queueName, depth, msgSize);
}
NATIVE_INT_TYPE QueuedComponentBase::getNumMsgsDropped(void) {
return this->m_msgsDropped;
}
void QueuedComponentBase::incNumMsgDropped(void) {
this->m_msgsDropped++;
}
}