AAO DRAMA/DRAMA2 C++ Interface
Public Member Functions | Protected Member Functions | List of all members
drama::thread::MonitorByType Class Reference

Detailed Description

A class implementing Monitor which invokes particular methods for parameters of given base types.

Methods are provided for each of basic SDS type - signed integers, unsigned integers, real and string.

Any other parameter type (including structured items and array types (other then strings) result in ComplexParamChanged() being invoked.

For each of these, the provided implementation will throw an exception. The user should sub-class this class and implement their own methods for each parameter type they are expecting.

If a sub-class implements the string value method, but not methods for integers, unsigned integers or real numbers, then the number will be converted to a string and passed to the string method.

Inherits the Monitor class constructors.

Author
Tony Farrell, AAO
Revision
1.45
Date
22-Feb-2016 14:09:57+11
Examples:
monitor2.cpp.

#include "threadmonitor.hh"

Inheritance diagram for drama::thread::MonitorByType:
drama::thread::Monitor

Public Member Functions

virtual ~MonitorByType ()
 Destructor. More...
 
- Public Member Functions inherited from drama::thread::Monitor
 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...
 
Monitoroperator= (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 void ParamChanged (const std::string &name, long value)
 Method invoked when the value of a signed integer type parameter has been changed. More...
 
virtual void ParamChanged (const std::string &name, unsigned long value)
 Method invoked when the value of an unsigned integer type parameter has been changed. More...
 
virtual void ParamChanged (const std::string &name, double value)
 Method invoked when the value of a real type parameter has been changed. More...
 
virtual void ParamChanged (const std::string &name, const std::string &value)
 Method invoked when the value of a string type parameter has been changed. More...
 
virtual void ParamChanged (const std::string &name, const sds::IdPtr &value)
 Method invoked when the value of complex parameter has been changed. More...
 
virtual void ParameterChanged (const sds::IdPtr &arg) override final
 Method invoked when a parameter is changed. More...
 
- Protected Member Functions inherited from drama::thread::Monitor
virtual std::shared_ptr< TaskGetTask () const
 Get a reference to the task we are part of. More...
 

Constructor & Destructor Documentation

virtual drama::thread::MonitorByType::~MonitorByType ( )
virtual

Destructor.

Member Function Documentation

virtual void drama::thread::MonitorByType::ParamChanged ( const std::string &  name,
long  value 
)
protectedvirtual

Method invoked when the value of a signed integer type parameter has been changed.

Invoked for any non-array parameter of SDS type SDS_BYTE, SDS_CHAR, SDS_INT, SDS_SHORT or SDS_I64.

But it will not be invoked for SDS_I64 if sizeof(long) is not at least 64 bits. Such a case suggests a design error (trying read 64 bit parameters from a 32 bit machine) so a DRAMA exception is thrown in those cases, with the DRAMA code DRAMA2__MON_INVTYPE64

The default implementation of this method will throw a DRAMA exception with the DRAMA code DRAMA2__MON_UNSUPTYPE. It is expected that the user will subclass this class to implement the required behaviors. But - if the sub-class has implemented the string version of ParamChanged(), that will be used in cases where the integer version is not implemented.

Parameters
nameThe name of the parameter the value of which has changed.
valueThe new value of the parameter.
Examples:
monitor2.cpp.
virtual void drama::thread::MonitorByType::ParamChanged ( const std::string &  name,
unsigned long  value 
)
protectedvirtual

Method invoked when the value of an unsigned integer type parameter has been changed.

Invoked for any non-array parameter of SDS type SDS_UBYTE, SDS_UINT, SDS_USHORT, SDS_UI64.

But it will not be invoked for SDS_UI64 if sizeof(unsigned long) is not at least 64 bits. Such a case suggests design error (trying read 64 bit parameters from a 32 bit machine) so a DRAMA exception is thrown in those cases, with the DRAMA code DRAMA2__MON_INVTYPE64

The default implementation of this method will throw a DRAMA exception with the DRAMA code DRAMA2__MON_UNSUPTYPE. It is expected that the user will subclass this class to implement the required behaviors. But - if the sub-class has implemented the string version of ParamChanged(), that will be used in cases where the unsigned integer version is not implemented.

Parameters
nameThe name of the parameter the value of which has changed.
valueThe new value of the parameter.
virtual void drama::thread::MonitorByType::ParamChanged ( const std::string &  name,
double  value 
)
protectedvirtual

Method invoked when the value of a real type parameter has been changed.

Invoked for any non-array parameter of SDS type SDS_FLOAT or SDS_DOUBLE.

The default implementation of this method will throw a DRAMA exception with the DRAMA code DRAMA2__MON_UNSUPTYPE. It is expected that the user will subclass this class to implement the required behaviors. But - if the sub-class has implemented the string version of ParamChanged(), that will be used in cases where the real version is not implemented.

Parameters
nameThe name of the parameter the value of which has changed.
valueThe new value of the parameter.
virtual void drama::thread::MonitorByType::ParamChanged ( const std::string &  name,
const std::string &  value 
)
protectedvirtual

Method invoked when the value of a string type parameter has been changed.

Invoked for parameter, the value of which is a single dimensional array of type SDS_CHAR.

The default implementation of this method will throw a DRAMA exception with the DRAMA code DRAMA2__MON_UNSUPTYPE. It is expected that the user will subclass this class to implement the required behaviors.

Parameters
nameThe name of the parameter the value of which has changed.
valueThe new value of the parameter.
virtual void drama::thread::MonitorByType::ParamChanged ( const std::string &  name,
const sds::IdPtr value 
)
protectedvirtual

Method invoked when the value of complex parameter has been changed.

This method is invoked for any parameter the type of which is not a simple integer, unsigned integer, real number or string.

The default implementation of this method will throw a DRAMA exception with the DRAMA code DRAMA2__MON_UNSUPTYPE. It is expected that the user will subclass this class to implement the required behaviors.

Parameters
nameThe name of the parameter the value of which has changed.
valueSDS reference to the new value of the parameter.
virtual void drama::thread::MonitorByType::ParameterChanged ( const sds::IdPtr arg)
finaloverrideprotectedvirtual

Method invoked when a parameter is changed.

This method is invoked each time a parameter changes. This is the MonitorToParam class implementation of the abstract method in the Monitor class.

This method is not normally invoked by user code and is not overridden by sub-classes. If you want to override this, it is suggested you implement an alternative sub-class of Monitor.

Parameters
argA pointer to the SDS structure with the new parameter value.

Implements drama::thread::Monitor.


The documentation for this class was generated from the following file:

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 doxygen 1.8.10