Files

139 lines
3.4 KiB
C++

/**
* @file include/ActivMiddleware/ActivAgentApplication/TimerService.h
*
* @brief Header file for the timer service class.
*/
#if (!defined ACTIV_AGENT_APPLICATION_TIMER_SERVICE_H)
#define ACTIV_AGENT_APPLICATION_TIMER_SERVICE_H
#include "ActivMiddleware/ActivAgentApplication/External.h"
//! Activ namespace.
namespace Activ
{
class TimerServiceImpl;
/**
* @brief Timer service class.
*/
class TimerService : private ManagedEndPoint, public Component
{
public:
using Component::GetApplication;
/**
* @brief Settings.
*/
class Settings
{
public:
/**
* @brief Default constructor.
*/
ACTIV_AGENT_APPLICATION_API Settings();
/**
* @brief Destructor.
*/
ACTIV_AGENT_APPLICATION_API ~Settings();
/**
* @brief Read settings from an ini file section.
*
* @param sectionIterator iterator to an ini file section.
*
* @throw Exception
*/
ACTIV_AGENT_APPLICATION_API void Read(const IniFileParser::ConstSectionIterator &sectionIterator);
/**
* @brief Heap properties for timer service, default buckets above.
*/
IHeap::Settings m_heapSettings;
/**
* @brief For TimerServiceApi::AdjustSystemTime(), threshold in milliseconds at which to set
* absolute time rather than adjust gradually. Default 60000.
*/
uint32_t m_adjustSystemTimeThreshold;
/**
* @brief Tick timeout; how often to check timers in microseconds.
*/
UInt m_tickTimeoutUs;
/**
* @brief Initial tick chime adjustment threshold; the threshold below which tick chimes will have a randomized start
* tick (milliseconds). Default 10000.
*/
uint64_t m_initialTickChimeAdjustmentThreshold;
/**
* @brief ManagedEndPoint settings for the service.
*/
ManagedEndPoint::Settings m_managedEndPointSettings;
};
/**
* @brief Timer service ui component.
*/
class UiComponent ACTIV_FINAL : public Activ::UiComponent
{
public:
/**
* @brief Constructor.
*
* @param timerService the timer service to have the ui.
* @param uiServiceName name of the ui service.
*
* @throw Exception.
*/
ACTIV_AGENT_APPLICATION_API UiComponent(TimerService &timerService, const String &uiServiceName);
private:
virtual void Run(UiUser &uiUser) ACTIV_OVERRIDE;
TimerService & m_timerService;
// Last member.
Component::Enabler m_componentEnabler;
};
/**
* @brief Constructor.
*
* The constructor creates an endpoint and heap in the system and runs a single thread.
*
* @param application the application the service is to run in.
* @param serviceName the name of the timer service.
* @param settings settings for the timer service.
*
* @throw Exception
*/
ACTIV_AGENT_APPLICATION_API TimerService(Application &application, const String &serviceName, const Settings &settings);
/**
* @brief Destructor.
*/
ACTIV_AGENT_APPLICATION_API ~TimerService();
protected:
ACTIV_AGENT_APPLICATION_API virtual bool CanThreadExit() ACTIV_OVERRIDE;
ACTIV_AGENT_APPLICATION_API virtual StatusCode OnRequest(HeapMessage &request) ACTIV_OVERRIDE;
ACTIV_AGENT_APPLICATION_API virtual StatusCode OnMessage(HeapMessage &message) ACTIV_OVERRIDE;
// ManagedEndPoint overrides
ACTIV_AGENT_APPLICATION_API virtual void Process() ACTIV_OVERRIDE;
private:
Boost::scoped_ptr<TimerServiceImpl> m_pImpl;
friend class TimerServiceImpl;
};
} // namespace Activ
#endif // (!defined ACTIV_AGENT_APPLICATION_TIMER_SERVICE_H)