fsfw/src/fsfw/tasks/SemaphoreFactory.h

51 lines
1.6 KiB
C
Raw Normal View History

2020-09-18 13:15:14 +02:00
#ifndef FSFW_TASKS_SEMAPHOREFACTORY_H_
#define FSFW_TASKS_SEMAPHOREFACTORY_H_
2021-07-14 00:54:39 +02:00
#include "fsfw/tasks/SemaphoreIF.h"
2020-09-18 13:15:14 +02:00
/**
* Creates Semaphore.
* This class is a "singleton" interface, i.e. it provides an
* interface, but also is the base class for a singleton.
*/
class SemaphoreFactory {
2022-02-02 10:29:30 +01:00
public:
virtual ~SemaphoreFactory();
/**
* Returns the single instance of SemaphoreFactory.
* The implementation of #instance is found in its subclasses.
* Thus, we choose link-time variability of the instance.
*/
static SemaphoreFactory* instance();
2020-09-18 13:15:14 +02:00
2022-02-02 10:29:30 +01:00
/**
* Create a binary semaphore.
* Creator function for a binary semaphore which may only be acquired once
* @param argument Can be used to pass implementation specific information.
* @return Pointer to newly created semaphore class instance.
*/
SemaphoreIF* createBinarySemaphore(uint32_t arguments = 0);
/**
* Create a counting semaphore.
* Creator functons for a counting semaphore which may be acquired multiple
* times.
* @param count Semaphore can be taken count times.
* @param initCount Initial count value.
* @param argument Can be used to pass implementation specific information.
* @return
*/
SemaphoreIF* createCountingSemaphore(const uint8_t maxCount, uint8_t initCount,
uint32_t arguments = 0);
2020-09-18 13:15:14 +02:00
2022-02-02 10:29:30 +01:00
void deleteSemaphore(SemaphoreIF* semaphore);
2020-09-18 13:15:14 +02:00
2022-02-02 10:29:30 +01:00
private:
/**
* External instantiation is not allowed.
*/
SemaphoreFactory();
static SemaphoreFactory* factoryInstance;
2020-09-18 13:15:14 +02:00
};
#endif /* FSFW_TASKS_SEMAPHOREFACTORY_H_ */