CLAM-Development  1.4.0
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
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 Types inherited from CLAM::Processing
enum  ExecState { Unconfigured = 0, Ready, Running }
 Processing Object possible execution states. More...

Public Member Functions

 Control2Data (const Config &c=Config())
virtual ~Control2Data ()
bool Do ()
 Already implemented Do operation.
const ProcessingConfigGetConfig () const
 Returns internal configuration method.
- Public Member Functions inherited from CLAM::Processing
bool Configure (const ProcessingConfig &config)
 Configuration change method.
void Start (void)
 Method to turn the object into running state.
void Stop (void)
 Method to put the object out of running state When in execution mode, this method must be called before any further call to Configure() methods.
 Processing ()
virtual ~Processing ()
virtual bool CanProcessInplace ()
 Override this method if your processing cannot process inplace.
bool CanConsumeAndProduce ()
 Check that Supervised Do() can be safely called.
void ConsumeAndProduce ()
 Acknoledges data tokens in published ports as read/writen by calling Produce() for all registered OutPorts and Consume() to all registered InPorts.
std::string GetExecStateString () const
bool IsConfigured () const
bool IsRunning () const
void RegisterOutPort (OutPortBase *out)
void RegisterInPort (InPortBase *in)
void RegisterOutControl (OutControlBase *out)
void RegisterInControl (InControlBase *in)
void SetParent (Processing *p)
void SetNetworkBackLink (Network *network)
virtual bool ModifiesPortsAndControlsAtConfiguration ()
 This method is used to determine if a given processing can change its interface of ports/controls after its construction (i.e.
bool HasInPort (const std::string &name)
bool HasOutPort (const std::string &name)
bool HasInControl (const std::string &name)
bool HasOutControl (const std::string &name)
InPortBaseGetInPort (const std::string &name)
OutPortBaseGetOutPort (const std::string &name)
InControlBaseGetInControl (const std::string &name)
OutControlBaseGetOutControl (const std::string &name)
InPortBaseGetInPort (unsigned index)
OutPortBaseGetOutPort (unsigned index)
InControlBaseGetInControl (unsigned index)
OutControlBaseGetOutControl (unsigned index)
unsigned GetNInPorts () const
unsigned GetNOutPorts () const
unsigned GetNInControls () const
unsigned GetNOutControls () const
const std::string & GetConfigErrorMessage () const
 Returns a string describing configuration errors if any.
virtual bool IsSyncSource () const
 Wether the processing is a sync source such as audio i/o device, or an audio callback hook (i.e.
virtual bool SupportsVariableAudioSize () const
 This method reports whether the processing supports dynamic buffer-size host.

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 Member Functions inherited from CLAM::Processing
virtual bool ConcreteStart ()
 Processing objects have to redefine this method when starting them implies some internal changes.
virtual bool ConcreteStop ()
 Processing objects have to redefine this method when stoping them implies some internal changes.
unsigned BackendBufferSize ()
 Given by the NetworkPlayer (backend) if exists.
unsigned BackendSampleRate ()
 Given by the NetworkPlayer (backend) if exists.
InControlRegistryGetInControls ()
 Accessor to published Controls manager.
OutControlRegistryGetOutControls ()
 Accessor to published Controls manager.
InPortRegistryGetInPorts ()
 Accessor to published Ports manager.
OutPortRegistryGetOutPorts ()
 Accessor to published Portss manager.
bool AddConfigErrorMessage (const std::string &msg)
 Use this method to append a configuration errors to the processing when implementing ConcreteConfigure.
bool AbleToExecute (void) const
 In debug-mode checks that the processing is configured and started.
template<typename ConcreteConfig >
void CopyAsConcreteConfig (ConcreteConfig &concrete, const ProcessingConfig &abstract) const
 Helper template to convert a reference to a ProcessingConfig to the concrete ProcessingConfig specified on the first parameter.
void SetExecState (ExecState state)

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.
- Protected Attributes inherited from CLAM::Processing
ProcessingCompositempParent
 Pointer to the parent (composite) processing object, or 0.
Network_network
 The parent network if any.

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 33 of file Control2Data.cxx.

References CLAM::Processing::Configure().

virtual CLAM::Control2Data::~Control2Data ( )
inlinevirtual

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:
ncontrolsis the number of controls that the converter has.

Definition at line 73 of file Control2Data.cxx.

References mDataMutex, and mDataQueues.

Referenced by ConcreteConfigure().

bool CLAM::Control2Data::ConcreteConfigure ( const ProcessingConfig c)
protectedvirtual
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:
idis the identifier of the control
valis the value of the control event

Definition at line 145 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 56 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 121 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:
idis the identifier of the control to which the event is sent
datais teh value of the event

Definition at line 92 of file Control2Data.cxx.

References mDataMutex, and mDataQueues.

Referenced by ConcreteConfigure(), and ControlCallbackId().

virtual bool CLAM::Control2Data::GenerateOutputData ( int  id,
TControlData  val 
)
protectedpure 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
inlineprotectedvirtual

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 86 of file Control2Data.cxx.

References mConfig.

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

Returns list of controls that are being enqueued.

Definition at line 104 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 133 of file Control2Data.cxx.

References mDataMutex, and mDataQueues.

Referenced by Do().


Member Data Documentation

Config CLAM::Control2Data::mConfig
protected

Internal configuration.

Definition at line 137 of file Control2Data.hxx.

Referenced by ConcreteConfigure(), and GetConfig().

Mutex CLAM::Control2Data::mControl2DataDoMutex
protected

Mutex object for ensuring multithread capabilities.

Definition at line 145 of file Control2Data.hxx.

Referenced by Do().

Mutex CLAM::Control2Data::mDataMutex
protected

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().

InControlArray CLAM::Control2Data::mInArray
protected

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().

FloatInControl CLAM::Control2Data::mStop
protected

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: