MeVisLab Toolbox Reference
ml::FieldSensor Class 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 callback and a parameter userData.
 
virtual ~FieldSensor ()
 Destructor: Disconnects field sensor from the connected field and clear.
 
void callback (Strength notificationStrength=CHANGED)
 Executes the callback function set by the constructor.
 
void attachField (Field *field)
 Attaches a field sensor to a the field field.
 
void detachField ()
 Detaches the field sensor from the most recently attached field.
 
FieldgetField () const
 Returns the field connected to the field sensor.
 
Strength getNotificationStrength () const
 Returns the notification level, i.e., how strong the current notification is.
 

Friends

class Field
 

Detailed Description

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.

Member Enumeration Documentation

◆ Strength

Enumeration type describing the strength of notifications.

Enumerator
NO_NOTIFICATION 

Default when sensor is asked outside a notification.

NO_CHANGE 

Subject (i.e., the field) is notified but not changed.

CHANGED 

Subject (i.e., the field) is notified and/or changed.

Definition at line 44 of file mlFieldSensor.h.

Constructor & Destructor Documentation

◆ FieldSensor()

ml::FieldSensor::FieldSensor ( MLSensorCB * callbackFunction,
void * userData )

Creates a field sensor with callback function callback 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.

◆ ~FieldSensor()

virtual ml::FieldSensor::~FieldSensor ( )
virtual

Destructor: Disconnects field sensor from the connected field and clear.

Member Function Documentation

◆ attachField()

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.

◆ callback()

void ml::FieldSensor::callback ( Strength notificationStrength = CHANGED)

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 it always will be NO_NOTIFICATION.

◆ detachField()

void ml::FieldSensor::detachField ( )

Detaches the field sensor from the most recently attached field.

The callback() method is not called any more if the field is changed. After this call getField() will return NULL.

◆ getField()

Field * ml::FieldSensor::getField ( ) const

Returns the field connected to the field sensor.

◆ getNotificationStrength()

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. Is is returned always NO_NOTIFICATION if not called from within a callback call.

Friends And Related Symbol Documentation

◆ Field

friend class Field
friend

Definition at line 86 of file mlFieldSensor.h.


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