IBoxAlgorithm Class Reference

Algorithm to create/process/transform OpenViBE dataThis class should be derived by any plugin that is related to data processing. It can be data acquisition/production from an hardware device or from a file. It can be data processing/transforming, moving time information into frequency space for example. It can be data classification generating discrete classification events better than continuous data flow. More...

Inheritance diagram for IBoxAlgorithm:
IPluginObject IObject

List of all members.

Public Member Functions

Behavioral configuration
virtual OpenViBE::uint64 getClockFrequency (OpenViBE::Kernel::IBoxAlgorithmContext &rBoxAlgorithmContext)
 Gets the clock frequency to call this algorithm.
Initialization / Uninitialization
virtual OpenViBE::boolean initialize (OpenViBE::Kernel::IBoxAlgorithmContext &rBoxAlgorithmContext)
 Prepares plugin object.
virtual OpenViBE::boolean uninitialize (OpenViBE::Kernel::IBoxAlgorithmContext &rBoxAlgorithmContext)
 Unprepares the object so it can be deleted.
Several event processing callbacks
virtual OpenViBE::boolean processEvent (OpenViBE::Kernel::IBoxAlgorithmContext &rBoxAlgorithmContext, OpenViBE::Kernel::IMessageEvent &rMessageEvent)
 Reaction to an event launched by another box.
virtual OpenViBE::boolean processSignal (OpenViBE::Kernel::IBoxAlgorithmContext &rBoxAlgorithmContext, OpenViBE::Kernel::IMessageSignal &rMessageSignal)
 Reaction to a signal.
virtual OpenViBE::boolean processClock (OpenViBE::Kernel::IBoxAlgorithmContext &rBoxAlgorithmContext, OpenViBE::Kernel::IMessageClock &rMessageClock)
 Reaction to a clock tick.
virtual OpenViBE::boolean processInput (OpenViBE::Kernel::IBoxAlgorithmContext &rBoxAlgorithmContext, OpenViBE::uint32 ui32InputIndex)
 Reaction to an input update.
Algorithm processing
virtual OpenViBE::boolean process (OpenViBE::Kernel::IBoxAlgorithmContext &rBoxAlgorithmContext)=0
 Processing function.

Detailed Description

Algorithm to create/process/transform OpenViBE data

This class should be derived by any plugin that is related to data processing. It can be data acquisition/production from an hardware device or from a file. It can be data processing/transforming, moving time information into frequency space for example. It can be data classification generating discrete classification events better than continuous data flow.

Author:
Yann Renard (INRIA/IRISA)
Date:
2006-06-19 This is the heart of the extension mechanism of the OpenViBE platform.
See also:
OpenViBE::Kernel::IBoxAlgorithmDesc
Todo:
details about building new plugins

Member Function Documentation

virtual OpenViBE::uint64 getClockFrequency ( OpenViBE::Kernel::IBoxAlgorithmContext rBoxAlgorithmContext) [inline, virtual]

Gets the clock frequency to call this algorithm.

Parameters:
rBoxAlgorithmContext[in] : The current box state
Returns:
The clock frequency to call this algorithm
Note:
Default implementation returns 0

This function is used for algorithms that are triggered on clock signals. The frequency is given in Hz, with 32:32 fixed point representation thus returning (1<<32) will make the algorithm to be called every second, returning (100<<32) will make the algorithm being called 100 times a second, returning (1<<31) will make the algorithm be called once every two seconds and so on...

Note:
Returning 0 means the algorithm should not be clock activated.
See also:
processClock
virtual OpenViBE::boolean initialize ( OpenViBE::Kernel::IBoxAlgorithmContext rBoxAlgorithmContext) [inline, virtual]

Prepares plugin object.

Parameters:
rBoxAlgorithmContext[in] : the plugin object context
Returns:
true when this object successfully initialized or false if it didn't succeed to initialize.
Note:
Default implementation simply returns true.

After a successfull initialization, the caller knows the object can safely be used... On failure, this object should be ready to be uninitialized and then released.

See also:
uninitialize
virtual OpenViBE::boolean uninitialize ( OpenViBE::Kernel::IBoxAlgorithmContext rBoxAlgorithmContext) [inline, virtual]

Unprepares the object so it can be deleted.

Parameters:
rBoxAlgorithmContext[in] : the plugin object context
Returns:
true when this object sucessfully uninitialized or false if didn't succeed to uninitialize.
Note:
Default implementation simply returns true.

If this function returns false, it means it could not uninitialize the object members correctly. Thus, the object won't be released and none of its method will be called anymore for security. Note that this results in memory leaks. This is why this method should return true as often as possible.

See also:
initialize
virtual OpenViBE::boolean processEvent ( OpenViBE::Kernel::IBoxAlgorithmContext rBoxAlgorithmContext,
OpenViBE::Kernel::IMessageEvent rMessageEvent 
) [inline, virtual]

Reaction to an event launched by another box.

Parameters:
rBoxAlgorithmContext[in] : the box algorithm context to use
rMessageEvent[in] : the message the box just received
Returns:
true when the message is processed.
false when the message is not processed.
Note:
Default implementation returns false

This function is called by the OpenViBE kernel when another box tries to send an event message to this box. This event message is described in the rMessageEvent parameter and can be interpreted by this algorithm.

See also:
OpenViBE::IBoxAlgorithmContext
virtual OpenViBE::boolean processSignal ( OpenViBE::Kernel::IBoxAlgorithmContext rBoxAlgorithmContext,
OpenViBE::Kernel::IMessageSignal rMessageSignal 
) [inline, virtual]

Reaction to a signal.

Parameters:
rBoxAlgorithmContext[in] : the box algorithm context to use
rMessageSignal[in] : the signal the box just received
Returns:
true when the message is processed.
false when the message is not processed.
Note:
Default implementation returns false

This function is called by the OpenViBE kernel when it has sent a signal. Signal are special messages, mainly sent by the kernel to all of the OpenViBE boxes in order to tell them it is about to start, processing, stop processing, load a new scenario and so on...

See also:
OpenViBE::Kernel::IBoxAlgorithmContext
virtual OpenViBE::boolean processClock ( OpenViBE::Kernel::IBoxAlgorithmContext rBoxAlgorithmContext,
OpenViBE::Kernel::IMessageClock rMessageClock 
) [inline, virtual]

Reaction to a clock tick.

Parameters:
rBoxAlgorithmContext[in] : the box algorithm context to use
rMessageClock[in] : the clock message the box received
Returns:
true when the message is processed.
false when the message is not processed.
Note:
Default implementation returns false

This function is called by the OpenViBE kernel when it has sent clock messages. Clock messages are used for processes that should be executed regularly and which can not be triggered thanks to their inputs (for example acquisition modules). They also can be used for example when viewing inputs on smaller range than what input sends periodically, thus needing a moving 'viewed-window' on lastly received data.

See also:
OpenViBE::Kernel::IBoxAlgorithmContext
getClockFrequency
virtual OpenViBE::boolean processInput ( OpenViBE::Kernel::IBoxAlgorithmContext rBoxAlgorithmContext,
OpenViBE::uint32  ui32InputIndex 
) [inline, virtual]

Reaction to an input update.

Parameters:
rBoxAlgorithmContext[in] : the box algorithm context to use
ui32InputIndex[in] : the index of the input which has ben updated
Returns:
true when the message is processed.
false when the message is not processed.
Note:
Default implementation returns false

This function is called by the OpenViBE kernel each time an input of this box is updated. This allows the algorithm to decide to call the process function and eventually to the received data.

See also:
OpenViBE::Kernel::IBoxAlgorithmContext
virtual OpenViBE::boolean process ( OpenViBE::Kernel::IBoxAlgorithmContext rBoxAlgorithmContext) [pure virtual]

Processing function.

Parameters:
rBoxAlgorithmContext[in] : the box algorithm context to use
Returns:
true on success, false when something went wrong.

This function is used to process the arrived data and eventually generate results. See OpenViBE global architecture to understand how the commponents interact and how an OpenViBE box works internally.

The processing function may use the provided context in order to read its inputs and write its outputs... Also it could use the provided context to send messages/events to other boxes. Finally, it may use the provided context in order to perform rendering tasks !

See also:
OpenViBE::Kernel::IBoxAlgorithmContext