fsfw/src/fsfw/osal/host/SemaphoreFactory.cpp

40 lines
1.3 KiB
C++
Raw Normal View History

#include "fsfw/tasks/SemaphoreFactory.h"
2022-02-02 10:29:30 +01:00
#include "fsfw/serviceinterface/ServiceInterface.h"
2020-09-05 20:18:52 +02:00
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;
2022-02-02 10:29:30 +01:00
SemaphoreFactory::SemaphoreFactory() {}
2020-09-05 20:18:52 +02:00
2022-02-02 10:29:30 +01:00
SemaphoreFactory::~SemaphoreFactory() { delete factoryInstance; }
2020-09-05 20:18:52 +02:00
SemaphoreFactory* SemaphoreFactory::instance() {
2022-02-02 10:29:30 +01:00
if (factoryInstance == nullptr) {
factoryInstance = new SemaphoreFactory();
}
return SemaphoreFactory::factoryInstance;
2020-09-05 20:18:52 +02:00
}
SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) {
2022-02-02 10:29:30 +01:00
// Just gonna wait for full C++20 for now.
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2022-02-02 10:29:30 +01:00
sif::error << "SemaphoreFactory: Binary Semaphore not implemented yet."
" Returning nullptr!\n"
<< std::flush;
#endif
2022-02-02 10:29:30 +01:00
return nullptr;
2020-09-05 20:18:52 +02:00
}
2022-02-02 10:29:30 +01:00
SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount, uint8_t initCount,
uint32_t arguments) {
// Just gonna wait for full C++20 for now.
2021-01-03 14:16:52 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2022-02-02 10:29:30 +01:00
sif::error << "SemaphoreFactory: Counting Semaphore not implemented yet."
" Returning nullptr!\n"
<< std::flush;
#endif
2022-02-02 10:29:30 +01:00
return nullptr;
2020-09-05 20:18:52 +02:00
}
2022-02-02 10:29:30 +01:00
void SemaphoreFactory::deleteSemaphore(SemaphoreIF* semaphore) { delete semaphore; }