Files

72 lines
1.8 KiB
C++

/**
* @file include/ActivMiddleware/ActivBase/Posix/SharedSocketEventFactory.h
*
* @brief Header file for the shared socket based event factory class.
*/
#if (!defined ACTIV_BASE_POSIX_SHARED_SOCKET_EVENT_FACTORY_H)
#define ACTIV_BASE_POSIX_SHARED_SOCKET_EVENT_FACTORY_H
#include "ActivMiddleware/ActivBase/External.h"
#include "ActivMiddleware/ActivBase/IEvent.h"
#include "ActivMiddleware/ActivBase/Timeout.h"
#include "ActivMiddleware/Misc/Singleton.h"
//! Activ namespace.
namespace Activ
{
/**
* @brief Shared socket based event factory class.
*/
class SharedSocketEventFactory : public Singleton<SharedSocketEventFactory>
{
public:
/**
* @brief Create an event.
*
* @param name the event name.
* @param flags creation flags.
* @param initialState whether the event is initially set upon creation.
*
* @return pointer to an object providing an IEvent interface.
*
* @throw Exception
*/
ACTIV_BASE_API IEvent *Create(const String &name, const IEvent::Flags::Type flags = IEvent::Flags::None(),
const bool initialState = false);
/**
* @brief Open an existing event.
*
* @param name the event name.
* @param timeout how long to wait for the object to exist, in ms.
*
* @return pointer to an object providing an IEvent interface.
*
* @throw Exception
*/
ACTIV_BASE_API IEvent *Open(const String &name, Timeout &timeout = Timeout::GetInfinite());
/**
* @brief Get a reference to the singleton instance.
*
* @return Reference.
*/
ACTIV_BASE_API static SharedSocketEventFactory &GetInstance();
private:
//! Default constructor.
ACTIV_BASE_API SharedSocketEventFactory();
#if (defined ACTIV_PLATFORM_LINUX)
const bool m_shouldUseEventFd;
#endif
friend class Singleton<SharedSocketEventFactory>;
};
} // namespace Activ
#endif // (!defined ACTIV_BASE_POSIX_SHARED_SOCKET_EVENT_FACTORY_H)