Files

67 lines
1.6 KiB
C++

/**
* @file include/ActivMiddleware/ActivBase/SharedSemaphoreFactory.h
*
* @brief Header file for the shared semaphore factory class.
*/
#if (!defined ACTIV_BASE_SHARED_SEMAPHORE_FACTORY_H)
#define ACTIV_BASE_SHARED_SEMAPHORE_FACTORY_H
#include "ActivMiddleware/ActivBase/External.h"
#include "ActivMiddleware/ActivBase/ISemaphore.h"
#include "ActivMiddleware/ActivBase/Timeout.h"
#include "ActivMiddleware/Misc/Singleton.h"
//! Activ namespace.
namespace Activ
{
/**
* @brief Shared semaphore factory class.
*/
class SharedSemaphoreFactory : public Singleton<SharedSemaphoreFactory>
{
public:
/**
* @brief Create a named shared semaphore.
*
* @param name semaphore name.
*
* @return pointer to an object providing an ISemaphore interface.
*
* @throw Exception
*/
ACTIV_BASE_API ISemaphore *Create(const String &name);
/**
* @brief Open an existing named shared semaphore.
*
* @param name semaphore name.
* @param timeout how long to wait for the object to exist, in ms.
*
* @return pointer to an object providing an ISemaphore interface.
*
* @throw Exception
*/
ACTIV_BASE_API ISemaphore *Open(const String &name, Timeout &timeout = Timeout::GetInfinite());
/**
* @brief Get a reference to the singleton instance.
*
* @return Reference.
*/
ACTIV_BASE_API static SharedSemaphoreFactory &GetInstance();
private:
/**
* @brief Default constructor.
*/
ACTIV_BASE_API SharedSemaphoreFactory();
friend class Singleton<SharedSemaphoreFactory>;
};
} // namespace Activ
#endif // (!defined ACTIV_BASE_SHARED_SEMAPHORE_FACTORY_H)