From 291a8d4ea30b1e18aaa1236fe7a65be14c869994 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 16 Jul 2021 12:33:19 +0200 Subject: [PATCH] added semaphore factory --- src/osal/rtems/CMakeLists.txt | 1 + src/osal/rtems/SemaphoreFactory.cpp | 34 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/osal/rtems/SemaphoreFactory.cpp diff --git a/src/osal/rtems/CMakeLists.txt b/src/osal/rtems/CMakeLists.txt index ac728b2f..734566a3 100644 --- a/src/osal/rtems/CMakeLists.txt +++ b/src/osal/rtems/CMakeLists.txt @@ -14,6 +14,7 @@ target_sources(${LIB_FSFW_NAME} RTEMSTaskBase.cpp TaskFactory.cpp BinarySemaphore.cpp + SemaphoreFactory.cpp ) diff --git a/src/osal/rtems/SemaphoreFactory.cpp b/src/osal/rtems/SemaphoreFactory.cpp new file mode 100644 index 00000000..cec4b833 --- /dev/null +++ b/src/osal/rtems/SemaphoreFactory.cpp @@ -0,0 +1,34 @@ +#include "fsfw/osal/rtems/BinarySemaphore.h" +//#include "fsfw/osal/rtems/CountingSemaphore.h" + +#include "fsfw/tasks/SemaphoreFactory.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; + +SemaphoreFactory::SemaphoreFactory() { +} + +SemaphoreFactory::~SemaphoreFactory() { + delete factoryInstance; +} + +SemaphoreFactory* SemaphoreFactory::instance() { + if (factoryInstance == nullptr){ + factoryInstance = new SemaphoreFactory(); + } + return SemaphoreFactory::factoryInstance; +} + +SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t argument) { + return new BinarySemaphore(); +} + +SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t maxCount, + uint8_t initCount, uint32_t argument) { + return nullptr; +} + +void SemaphoreFactory::deleteSemaphore(SemaphoreIF* semaphore) { + delete semaphore; +}