mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 17:47:10 -06:00
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.
51 lines
1.4 KiB
C++
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++;
|
|
}
|
|
|
|
}
|