ML Reference
|
Class to define and to manage field sensors. More...
#include <mlFieldSensor.h>
Public Types | |
enum | Strength { NO_NOTIFICATION = 0 , NO_CHANGE = 1 , CHANGED = 2 } |
Enumeration type describing the strength of notifications. More... | |
Public Member Functions | |
FieldSensor (MLSensorCB *callbackFunction, void *userData) | |
Creates a field sensor with callback function callbackFunction and a parameter userData . More... | |
virtual | ~FieldSensor () |
Destructor: Disconnects field sensor from the connected field. More... | |
void | callback (Strength notificationStrength=CHANGED) |
Executes the callback function set by the constructor. More... | |
void | attachField (Field *field) |
Attaches a field sensor to a the field field. More... | |
void | detachField () |
Detaches the field sensor from the most recently attached field. More... | |
Field * | getField () const |
Returns the field connected to the field sensor. More... | |
Strength | getNotificationStrength () const |
Returns the notification level, i.e., how strong the current notification is. More... | |
Friends | |
class | Field |
Class to define and to manage field sensors.
A field sensor contains a reference to a callback function and a callback function argument.
Definition at line 38 of file mlFieldSensor.h.
Enumeration type describing the strength of notifications.
Definition at line 44 of file mlFieldSensor.h.
ml::FieldSensor::FieldSensor | ( | MLSensorCB * | callbackFunction, |
void * | userData | ||
) |
Creates a field sensor with callback function callbackFunction
and a parameter userData
.
The method callback executes the callback function. Note: userData
is usually a pointer to the instance of a class and callbackFunction
is a static function of that class.
|
virtual |
Destructor: Disconnects field sensor from the connected field.
void ml::FieldSensor::attachField | ( | Field * | field | ) |
Attaches a field sensor to a the field field.
If the field value changes, callback() of the sensor is called. A previously attached field will automatically be detached before attaching the new one.
Executes the callback function set by the constructor.
While the callback is executed with getNotificationStrength(), the value passed to this callback can be retrieved. Outside of it, it always will be NO_NOTIFICATION.
void ml::FieldSensor::detachField | ( | ) |
Detaches the field sensor from the most recently attached field.
The callback() method is not called anymore if the field is changed. After this call, getField() will return NULL.
Field* ml::FieldSensor::getField | ( | ) | const |
Returns the field connected to the field sensor.
Strength ml::FieldSensor::getNotificationStrength | ( | ) | const |
Returns the notification level, i.e., how strong the current notification is.
Level CHANGED or higher usually means 'changed object' and level NO_CHANGE usually means only notification. It is always returned as NO_NOTIFICATION if not called from within a callback.
|
friend |
Definition at line 85 of file mlFieldSensor.h.