EMIPLIB
Public Member Functions | Protected Member Functions

MIPComponentChain Class Reference

A chain of components. More...

#include <mipcomponentchain.h>

Inheritance diagram for MIPComponentChain:
Inheritance graph
[legend]
Collaboration diagram for MIPComponentChain:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MIPComponentChain (const std::string &chainName)
 Create a chain with a specific name.
bool start ()
 Start the chain.
bool stop ()
 Stops the chain.
bool clearChain ()
 Clears the component chain.
bool setChainStart (MIPComponent *pStartComponent)
 Set the start of the chain.
bool addConnection (MIPComponent *pPullComponent, MIPComponent *pPushCompontent, bool feedback=false, uint32_t allowedMessageTypes=MIPMESSAGE_TYPE_ALL, uint32_t allowedSubmessageTypes=MIPMESSAGE_TYPE_ALL)
 Add a link between two components.
bool deleteConnection (MIPComponent *pPullComponent, MIPComponent *pPushCompontent, bool feedback=false, uint32_t allowedMessageTypes=MIPMESSAGE_TYPE_ALL, uint32_t allowedSubmessageTypes=MIPMESSAGE_TYPE_ALL)
 Removes a connection previously added by the addConnection function.
std::string getName () const
 Returns the name of the component chain.
bool rebuild ()
 Rebuilds a running chain.

Protected Member Functions

virtual void onThreadExit (bool error, const std::string &errorComponent, const std::string &errorDescription)
 Function called when the background thread exits.

Detailed Description

This class describes a collection of links which exist between specific components. When the chain is started, messages will be passed over these links. The messages are described by classes derived from MIPMessage, components are implemented in classes derived from MIPComponent.


Member Function Documentation

bool MIPComponentChain::addConnection ( MIPComponent pPullComponent,
MIPComponent pPushCompontent,
bool  feedback = false,
uint32_t  allowedMessageTypes = MIPMESSAGE_TYPE_ALL,
uint32_t  allowedSubmessageTypes = MIPMESSAGE_TYPE_ALL 
)

With this function, a link from pPullComponent to pPushCompontent is created. This means that at a certain point in the chain, messages will be extracted from pPullComponent using its implementation of MIPComponent::pull and will be fed to pPushComponent using its MIPComponent::push implementation.

Note that no copies are made of these components, the actual components specified by the MIPComponent pointers are used in the chain. For this reason, as long as the chain will be used, these MIPComponent objects must exist.

Messages can be filtered both on type and on subtype. By default, all messages are allowed over a link between components, but it is also possible to only allow specific kinds of messages to be passed over that link. Filtering can be done using the parameters allowedMessageTypes and allowedSubmessageTypes. For example, to only allow LPC compressed audio messages to be passed over a connection, allowedMessageTypes should be set to MIPMESSAGE_TYPE_AUDIO_ENCODED and allowedSubmessageTypes should be set to MIPENCODEDAUDIOMESSAGE_TYPE_LPC.

If the feedback flag is set to true, a MIPFeedback message will be passed over this link. This way, it is possible to provide feedback (about introduced delay for example) to components higher up in the chain.

bool MIPComponentChain::clearChain ( )

Removes all components from the component chain.

bool MIPComponentChain::deleteConnection ( MIPComponent pPullComponent,
MIPComponent pPushCompontent,
bool  feedback = false,
uint32_t  allowedMessageTypes = MIPMESSAGE_TYPE_ALL,
uint32_t  allowedSubmessageTypes = MIPMESSAGE_TYPE_ALL 
)
std::string MIPComponentChain::getName ( ) const [inline]

Returns the name of the component chain, as was specified in the constructor.

virtual void MIPComponentChain::onThreadExit ( bool  error,
const std::string &  errorComponent,
const std::string &  errorDescription 
) [inline, protected, virtual]

This function is called when the background thread exits. This can happen if the MIPComponentChain::stop function is called, or when an error occured in the chain. The error flag indicates if the thread exited due to an error and if so, the errorComponent parameter contains the name of the component which caused the error. The errorDescription parameter then containts the error string obtained from that component's MIPComponent::getErrorString function.

bool MIPComponentChain::rebuild ( )
bool MIPComponentChain::setChainStart ( MIPComponent pStartComponent)

Informs the chain to which component the initial message should be sent. It is this component which will determine the timing in the chain.

bool MIPComponentChain::start ( )

This function analyses the connections which were added previously and starts a background thread which will distribute the messages over the links in the chain. The chain itself sends a MIPSystemMessage with subtype MIPSYSTEMMESSAGE_WAITTIME to the component set by MIPComponentChain::setChainStart, instructing it to wait until it is time to process the rest of the chain. Therefore, it is the first component of the chain which performs the timing.

bool MIPComponentChain::stop ( )

This function stops the background thread in which the messages are distributed.


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