AAO DRAMA/DRAMA2 C++ Interface
|
An abstract class which implements a DRAMA Parameter monitor in a thread.
The user can use an object implementing this class in an Action or UFace thread to monitor parameters in another task.
The constructor takes an initialiser list of the parameters to be monitored.
The user must implement the "ParameterChanged()" method to handle parameter changes.
The user must invoke the Run())method to run the monitor.
Monitors can be canceled if needed via the Cancel() method.
#include "threadmonitor.hh"
Public Member Functions | |
Monitor (std::weak_ptr< Task > theTask, std::initializer_list< std::string > pars) | |
Create a Monitor object. More... | |
Monitor (const Monitor &source)=delete | |
Copy constructor - deleted. More... | |
virtual | ~Monitor () |
Destructor. More... | |
void | Cancel () |
Cancel the monitor. More... | |
int | GetMonitorId () const |
Return the monitor ID. More... | |
bool | IsCancelling () const |
Indicate if the monitor is being canceled. More... | |
bool | IsRunning () const |
Indicate if the monitor is running. More... | |
Monitor & | operator= (const Monitor &rhs)=delete |
Assignment operator - deleted. More... | |
template<typename EventProcType = MonitorMessageHandler> | |
void | Run (Path *thePath, thread::TMessHandler *action) |
Run a monitor operation - handler by type. More... | |
void | Run (Path *thePath, thread::TMessHandler *action, MonitorMessageHandler *evtProcessor) |
Run a monitor operation - handler by address. More... | |
Protected Member Functions | |
virtual std::shared_ptr< Task > | GetTask () const |
Get a reference to the task we are part of. More... | |
virtual void | ParameterChanged (const sds::IdPtr &arg)=0 |
Abstract method invoked when a parameter is changed. More... | |
|
inline |
|
delete |
Copy constructor - deleted.
It makes no sense to copy these objects.
|
inlinevirtual |
Destructor.
void drama::thread::Monitor::Cancel | ( | ) |
Cancel the monitor.
Can be invoked to cancel the monitor. This method requires the DRAMA Lock, but can otherwise be executed from anywhere in the program.
Will throw an exception if the monitor is not running. Will return immediately if a cancel is already underway.
Note that canceling is done by creating a new thread. This will require the DRAMA lock to send and process the message. As a result, the cancel may not occur for some time.
|
inline |
Return the monitor ID.
Valid monitor IDs are from zero up. If the value is -1, then the monitor has not been started (note, this can happen even if IsRunning() returns true, in the window between the sending of the monitor message and the returning of the Monitor ID. This is a small window, but it does exist.
|
inlineprotectedvirtual |
Get a reference to the task we are part of.
User implementations of Monitor may need this in ParameterChanged, in particular, to grab the DRAMA Lock.
|
inline |
Indicate if the monitor is being canceled.
|
inline |
Indicate if the monitor is running.
Assignment operator - deleted.
It makes no sense to assign these objects.
|
protectedpure virtual |
Abstract method invoked when a parameter is changed.
This method is invoked each time a parameter changes. User sub-classes must implement this method, to handle the change as it prefers.
arg | A pointer to the SDS structure with the new parameter value. The name of the item is the name of the parameter which has changed. Note, this SDS item will be deleted some time after this function returns when the sds::IdPtr releases, so don't try to save the referenced ID or an ID to any component, the item will disappear. Instead, copy the sds::IdPtr (a shared pointer), the data or copy the SDS item into a new SDS item. |
Implemented in drama::thread::MonitorByType, and drama::thread::MonitorToParam.
|
inline |
Run a monitor operation - handler by type.
This method will send a DRAMA "MONITOR START" message to the task, the path to which is supplied. The parameters being monitored would have been specified in constructor.
The thread will block until the monitor completes.
thePath | The path to the task we wish to monitor. |
action | A pointer to the threaded action (or uface handler) which is executing this operation. |
eventProcessor | The type of the object to be used to process events. Must be a sub-class of MonitorMessageHandler. One of these will be constructed with "this" passed to the constructor. |
void drama::thread::Monitor::Run | ( | Path * | thePath, |
thread::TMessHandler * | action, | ||
MonitorMessageHandler * | evtProcessor | ||
) |
Run a monitor operation - handler by address.
This method will send a DRAMA "MONITOR START" message to the task, the path to which is supplied. The parameters being monitored would have been specified in constructor.
The thread will block until the monitor completes.
thePath | The path to the task we wish to monitor. |
action | A pointer to the threaded action (or uface handler) which is executing this operation. |
evtProcessor | An object to use to process events. |
Click here for the DRAMA home page and here for the AAO home page.
For more information, contact tjf@aao.gov.au Generated on Mon Feb 22 2016 15:57:53 for AAO DRAMA/DRAMA2 C++ Interface by