1#ifndef _DRAMA2_THREADMONITOR_INC
2#define _DRAMA2_THREADMONITOR_INC
74 class MonitorMessageHandler :
public MessageEventHandler {
79 MonitorMessageHandler(Monitor &
theMon) : _theMonitor(
theMon) {}
145 std::weak_ptr<Task> _theTask;
147 Path *_thePath =
nullptr;
148 thread::TMessHandler *_action =
nullptr;
150 std::vector <std::string> _params;
155 std::future<void> _cancelFuture;
180 std::initializer_list<std::string>
pars):
201 std::vector<std::string>
pars):
227 template <
typename EventProcType = MonitorMessageHandler>
233 "EventProcType must be a sub-class of drama::thread::MonitorMessageHandler");
366 virtual std::shared_ptr<Task>
GetTask()
const {
367 return std::shared_ptr<Task>(_theTask);
388 class MonitorToParam :
public Monitor {
409 virtual std::string
Transform(
const std::string &
in);
459 class MonitorByType :
public Monitor {
463 enum class RtnSupType { checkNeeded, yes, viaString, no };
473 RtnSupType _intRoutineSupported = RtnSupType::checkNeeded;
474 RtnSupType _uintRoutineSupported = RtnSupType::checkNeeded;
475 RtnSupType _realRoutineSupported = RtnSupType::checkNeeded;
480 void DoIntParam(
const std::string &name,
const sds::IdPtr &arg);
481 void DoUintParam(
const std::string &name,
const sds::IdPtr &arg);
482 void DoRealParam(
const std::string &name,
const sds::IdPtr &arg);
Message event handling objects.
Definition path.hh:194
A Class which provides access to DRAMA's message sending facilities.
Definition path.hh:689
virtual void ParamChanged(const std::string &name, const sds::IdPtr &value)
Method invoked when the value of complex parameter has been changed.
virtual void ParamChanged(const std::string &name, unsigned long value)
Method invoked when the value of an unsigned integer type parameter has been changed.
virtual ~MonitorByType()
Destructor.
virtual void ParameterChanged(const sds::IdPtr &arg) override final
Method invoked when a parameter is changed.
virtual void ParamChanged(const std::string &name, double value)
Method invoked when the value of a real type parameter has been changed.
virtual void ParamChanged(const std::string &name, const std::string &value)
Method invoked when the value of a string type parameter has been changed.
virtual void ParamChanged(const std::string &name, long value)
Method invoked when the value of a signed integer type parameter has been changed.
A class implementing Monitor which invokes particular methods for parameters of given base types.
Definition threadmonitor.hh:486
virtual bool KickReceived(thread::ProcessInfo messInfo, const sds::IdPtr &arg) override
Invoked if an action waiting on a monitor message receives a kick message during the wait.
void TriggerReceived(thread::ProcessInfo messInfo, StatusType status, const sds::IdPtr &arg) override final
Invoked if a trigger message is received.
Handle replies to DRAMA Monitor Messages.
Definition threadmonitor.hh:101
virtual void ParameterChanged(const sds::IdPtr &arg) override final
Method invoked when a parameter is changed.
virtual std::string Transform(const std::string &in)
Transform method, default implementation.
virtual ~MonitorToParam()
Destructor.
A class implementing Monitor which copies the value of a monitored parameter into one of the same nam...
Definition threadmonitor.hh:415
virtual ~Monitor()
Destructor.
Definition threadmonitor.hh:334
Monitor(std::weak_ptr< Task > theTask, std::initializer_list< std::string > pars)
Create a Monitor object.
Definition threadmonitor.hh:206
int GetMonitorId() const
Return the monitor ID.
Definition threadmonitor.hh:361
Monitor(const Monitor &source)=delete
Copy constructor - deleted.
void Run(Path *thePath, thread::TMessHandler *action, MonitorMessageHandler *evtProcessor)
Run a monitor operation - handler by address.
virtual std::shared_ptr< Task > GetTask() const
Get a reference to the task we are part of.
Definition threadmonitor.hh:393
void Cancel()
Cancel the monitor.
bool IsRunning() const
Indicate if the monitor is running.
Definition threadmonitor.hh:340
void Run(Path *thePath, thread::TMessHandler *action)
Run a monitor operation - handler by type.
Definition threadmonitor.hh:255
Monitor(std::weak_ptr< Task > theTask, std::vector< std::string > pars)
Create a Monitor object.
Definition threadmonitor.hh:227
Monitor & operator=(const Monitor &rhs)=delete
Assignment operator - deleted.
virtual void ParameterChanged(const sds::IdPtr &arg)=0
Abstract method invoked when a parameter is changed.
bool IsCancelling() const
Indicate if the monitor is being canceled.
Definition threadmonitor.hh:347
An abstract class which implements a DRAMA Parameter monitor in a thread.
Definition threadmonitor.hh:167
A class with information used by the TransEvtProcessor methods.
Definition thread.hh:147
This interface class must be implemented by classes which have threads waiting for messages.
Definition thread.hh:308
DRAMA 2 include file - Message Handler class definition.
std::shared_ptr< Id > IdPtr
A shared pointer for sds::Id items.
Definition sds.hh:3318
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93
DRAMA 2 include file - Code common to DRAMA 2 features supporting threading.