this is a bit cleaner
This commit is contained in:
parent
a5871ed0b1
commit
0d66569687
@ -4,6 +4,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "MessageQueueIF.h"
|
||||
#include "definitions.h"
|
||||
#include "MessageQueueMessage.h"
|
||||
|
||||
/**
|
||||
@ -23,7 +24,7 @@ class QueueFactory {
|
||||
|
||||
MessageQueueIF* createMessageQueue(uint32_t messageDepth = 3,
|
||||
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE,
|
||||
void* args = nullptr);
|
||||
MqArgs* args = nullptr);
|
||||
|
||||
void deleteMessageQueue(MessageQueueIF* queue);
|
||||
|
||||
|
10
src/fsfw/ipc/definitions.h
Normal file
10
src/fsfw/ipc/definitions.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef FSFW_SRC_FSFW_IPC_DEFINITIONS_H_
|
||||
#define FSFW_SRC_FSFW_IPC_DEFINITIONS_H_
|
||||
#include <fsfw/objectmanager/SystemObjectIF.h>
|
||||
|
||||
struct MqArgs {
|
||||
object_id_t objectId = 0;
|
||||
void* args = nullptr;
|
||||
};
|
||||
|
||||
#endif /* FSFW_SRC_FSFW_IPC_DEFINITIONS_H_ */
|
@ -4,7 +4,7 @@
|
||||
#include "fsfw/osal/freertos/QueueMapManager.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, void* args)
|
||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* args)
|
||||
: maxMessageSize(maxMessageSize) {
|
||||
handle = xQueueCreate(messageDepth, maxMessageSize);
|
||||
if (handle == nullptr) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||
#include "fsfw/ipc/MessageQueueMessageIF.h"
|
||||
#include "fsfw/ipc/definitions.h"
|
||||
#include "queue.h"
|
||||
|
||||
/**
|
||||
@ -54,7 +55,7 @@ class MessageQueue : public MessageQueueIF {
|
||||
*/
|
||||
MessageQueue(size_t messageDepth = 3,
|
||||
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE,
|
||||
void* args = nullptr);
|
||||
MqArgs* args = nullptr);
|
||||
|
||||
/** Copying message queues forbidden */
|
||||
MessageQueue(const MessageQueue&) = delete;
|
||||
|
@ -22,7 +22,7 @@ QueueFactory::QueueFactory() {}
|
||||
|
||||
QueueFactory::~QueueFactory() {}
|
||||
|
||||
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) {
|
||||
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) {
|
||||
return new MessageQueue(messageDepth, maxMessageSize, args);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "fsfw/osal/host/QueueMapManager.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, void* args)
|
||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* args)
|
||||
: messageSize(maxMessageSize), messageDepth(messageDepth) {
|
||||
queueLock = MutexFactory::instance()->createMutex();
|
||||
auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "fsfw/internalerror/InternalErrorReporterIF.h"
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||
#include "fsfw/ipc/definitions.h"
|
||||
#include "fsfw/ipc/MutexIF.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
@ -55,7 +56,7 @@ class MessageQueue : public MessageQueueIF {
|
||||
*/
|
||||
MessageQueue(size_t messageDepth = 3,
|
||||
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE,
|
||||
void* args);
|
||||
MqArgs* args = nullptr);
|
||||
|
||||
/** Copying message queues forbidden */
|
||||
MessageQueue(const MessageQueue&) = delete;
|
||||
|
@ -27,7 +27,7 @@ QueueFactory::QueueFactory() {}
|
||||
|
||||
QueueFactory::~QueueFactory() {}
|
||||
|
||||
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) {
|
||||
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) {
|
||||
// A thread-safe queue can be implemented by using a combination
|
||||
// of std::queue and std::mutex. This uses dynamic memory allocation
|
||||
// which could be alleviated by using a custom allocator, external library
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "fsfw/osal/linux/unixUtility.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args)
|
||||
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args)
|
||||
: id(MessageQueueIF::NO_QUEUE),
|
||||
lastPartner(MessageQueueIF::NO_QUEUE),
|
||||
defaultDestination(MessageQueueIF::NO_QUEUE),
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "fsfw/internalerror/InternalErrorReporterIF.h"
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/ipc/definitions.h"
|
||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||
/**
|
||||
* @brief This class manages sending and receiving of message queue messages.
|
||||
@ -43,7 +44,7 @@ class MessageQueue : public MessageQueueIF {
|
||||
*/
|
||||
MessageQueue(uint32_t messageDepth = 3,
|
||||
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE,
|
||||
void* args = nullptr);
|
||||
MqArgs* args = nullptr);
|
||||
/**
|
||||
* @brief The destructor deletes the formerly created message queue.
|
||||
* @details This is accomplished by using the delete call provided by the operating system.
|
||||
|
@ -28,7 +28,7 @@ QueueFactory::QueueFactory() {}
|
||||
|
||||
QueueFactory::~QueueFactory() {}
|
||||
|
||||
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) {
|
||||
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) {
|
||||
return new MessageQueue(messageDepth, maxMessageSize, args);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "fsfw/osal/rtems/RtemsBasic.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size, void* args)
|
||||
MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size, MqArgs* args)
|
||||
: id(0), lastPartner(0), defaultDestination(NO_QUEUE), internalErrorReporter(nullptr) {
|
||||
rtems_name name = ('Q' << 24) + (queueCounter++ << 8);
|
||||
rtems_status_code status =
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "RtemsBasic.h"
|
||||
#include "fsfw/internalerror/InternalErrorReporterIF.h"
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
#include "fsfw/ipc/definitions.h"
|
||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||
|
||||
/**
|
||||
@ -35,7 +36,7 @@ class MessageQueue : public MessageQueueIF {
|
||||
*/
|
||||
MessageQueue(size_t message_depth = 3,
|
||||
size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE,
|
||||
void* args);
|
||||
MqArgs* args = nullptr);
|
||||
/**
|
||||
* @brief The destructor deletes the formerly created message queue.
|
||||
* @details This is accomplished by using the delete call provided by the operating system.
|
||||
|
@ -49,7 +49,7 @@ QueueFactory::QueueFactory() {}
|
||||
|
||||
QueueFactory::~QueueFactory() {}
|
||||
|
||||
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, void* args) {
|
||||
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) {
|
||||
return new MessageQueue(messageDepth, maxMessageSize, args);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user