CLAM::Control2Data Class Reference

This processing object is mainly an aggregate of input control data It works by asynchronously receiving messages, keeping them enqueued and synchronously converting them to a Processing Data, at Do() time. More...

#include <Control2Data.hxx>

List of all members.

Public Types

typedef Control2DataConfig Config

Public Member Functions

 Control2Data (const Config &c=Config())
virtual ~Control2Data ()
bool Do ()
 Already implemented Do operation.
const ProcessingConfigGetConfig () const
 Returns internal configuration method.

Protected Types

typedef std::queue< TControlDataTQueue
 typedef used for convenience
typedef std::list< intIdxList
 typedef used for convenience

Protected Member Functions

virtual bool GenerateOutputData (int id, TControlData val)=0
 This pure virtual operation should be implemented in the derived classes.
void BufferQueueInit (int ncontrols)
 Initialization for queues of control events.
void EnqueueControl (unsigned id, TControlData data)
 Add new control event to internal queue.
TControlData PopControl (unsigned id)
 Read and remove last control event for a given control id.
bool Empty (unsigned id)
 Whether the queue for a particular event is empty or not.
IdxList GetQueues ()
 Returns list of controls that are being enqueued.
void ControlCallbackId (int id, TControlData val)
 Callback that will be called when a particular control receives an event and that will be in charge of enqueing the event.
virtual bool ConcreteConfigure (const ProcessingConfig &)
 Concrete configuration for particular Processing.
const char * GetClassName () const
 Compulsory method for Processing derived classes.

Protected Attributes

InControlArray mInArray
 Array of input control arrays that is initialized in the ConcreteConfigure method.
FloatInControl mStop
 Special input control to be able to stop the process in response to an external control event.
Config mConfig
 Internal configuration.
std::vector< TQueuemDataQueues
 Vector of queues containing events for each control.
Mutex mDataMutex
 Mutex object for ensuring multithread capabilities.
Mutex mControl2DataDoMutex
 Mutex object for ensuring multithread capabilities.

Detailed Description

This processing object is mainly an aggregate of input control data It works by asynchronously receiving messages, keeping them enqueued and synchronously converting them to a Processing Data, at Do() time.

It is an abstract class because the responsability for the concrete processing of controls and conversion to a particular processing data is deferred to subclasses.

Note that if mulithreading is enabled, the EnqueueControl calls can be done from different threads than the execution method. A lock for the mDataQueue structure ensures it.

Definition at line 65 of file Control2Data.hxx.


Member Typedef Documentation

Reimplemented from CLAM::Processing.

Definition at line 68 of file Control2Data.hxx.

typedef std::list<int> CLAM::Control2Data::IdxList [protected]

typedef used for convenience

Definition at line 85 of file Control2Data.hxx.

typedef std::queue<TControlData> CLAM::Control2Data::TQueue [protected]

typedef used for convenience

Definition at line 83 of file Control2Data.hxx.


Constructor & Destructor Documentation

CLAM::Control2Data::Control2Data ( const Config c = Config()  ) 

Definition at line 32 of file Control2Data.cxx.

References CLAM::Processing::Configure().

virtual CLAM::Control2Data::~Control2Data (  )  [inline, virtual]

Definition at line 70 of file Control2Data.hxx.


Member Function Documentation

void CLAM::Control2Data::BufferQueueInit ( int  ncontrols  )  [protected]

Initialization for queues of control events.

Parameters:
ncontrols is the number of controls that the converter has.

Definition at line 72 of file Control2Data.cxx.

References mDataMutex, and mDataQueues.

Referenced by ConcreteConfigure().

bool CLAM::Control2Data::ConcreteConfigure ( const ProcessingConfig c  )  [protected, virtual]
void CLAM::Control2Data::ControlCallbackId ( int  id,
TControlData  val 
) [protected]

Callback that will be called when a particular control receives an event and that will be in charge of enqueing the event.

Parameters:
id is the identifier of the control
val is the value of the control event

Definition at line 144 of file Control2Data.cxx.

References EnqueueControl().

bool CLAM::Control2Data::Do ( void   )  [virtual]

Already implemented Do operation.

This operation is in charge of reading the enqueued events and producing the processing data output. But for doing so it relies on the particular implementation of the GenerateOutputData operation.

Implements CLAM::Processing.

Definition at line 55 of file Control2Data.cxx.

References GenerateOutputData(), CLAM::InControl< ControlDataType >::GetLastValue(), GetQueues(), mControl2DataDoMutex, mStop, and PopControl().

bool CLAM::Control2Data::Empty ( unsigned  id  )  [protected]

Whether the queue for a particular event is empty or not.

Definition at line 120 of file Control2Data.cxx.

References mDataMutex, and mDataQueues.

void CLAM::Control2Data::EnqueueControl ( unsigned  id,
TControlData  data 
) [protected]

Add new control event to internal queue.

Parameters:
id is the identifier of the control to which the event is sent
data is teh value of the event

Definition at line 91 of file Control2Data.cxx.

References mDataMutex, and mDataQueues.

Referenced by ConcreteConfigure(), and ControlCallbackId().

virtual bool CLAM::Control2Data::GenerateOutputData ( int  id,
TControlData  val 
) [protected, pure virtual]

This pure virtual operation should be implemented in the derived classes.

It is responsible for implementing the concrete behaviour of how to covert the controls into a particular processing data

Implemented in CLAM::MIDI2Melody.

Referenced by Do().

const char* CLAM::Control2Data::GetClassName (  )  const [inline, protected, virtual]

Compulsory method for Processing derived classes.

Implements CLAM::Processing.

Definition at line 121 of file Control2Data.hxx.

const ProcessingConfig & CLAM::Control2Data::GetConfig (  )  const [virtual]

Returns internal configuration method.

Reimplemented from CLAM::Processing.

Definition at line 85 of file Control2Data.cxx.

References mConfig.

Control2Data::IdxList CLAM::Control2Data::GetQueues (  )  [protected]

Returns list of controls that are being enqueued.

Definition at line 103 of file Control2Data.cxx.

References mDataQueues.

Referenced by Do().

TControlData CLAM::Control2Data::PopControl ( unsigned  id  )  [protected]

Read and remove last control event for a given control id.

Definition at line 132 of file Control2Data.cxx.

References mDataMutex, and mDataQueues.

Referenced by Do().


Member Data Documentation

Internal configuration.

Definition at line 137 of file Control2Data.hxx.

Referenced by ConcreteConfigure(), and GetConfig().

Mutex object for ensuring multithread capabilities.

Definition at line 145 of file Control2Data.hxx.

Referenced by Do().

Mutex object for ensuring multithread capabilities.

Definition at line 143 of file Control2Data.hxx.

Referenced by BufferQueueInit(), Empty(), EnqueueControl(), and PopControl().

std::vector<TQueue> CLAM::Control2Data::mDataQueues [protected]

Vector of queues containing events for each control.

Definition at line 140 of file Control2Data.hxx.

Referenced by BufferQueueInit(), Empty(), EnqueueControl(), GetQueues(), and PopControl().

Array of input control arrays that is initialized in the ConcreteConfigure method.

Number of controls is indicated in the configuration

Definition at line 129 of file Control2Data.hxx.

Referenced by ConcreteConfigure().

Special input control to be able to stop the process in response to an external control event.

Definition at line 134 of file Control2Data.hxx.

Referenced by ConcreteConfigure(), and Do().


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.3