stromx  0.8.0
Public Types | Public Member Functions | List of all members
stromx::runtime::Stream Class Reference

The core data processing pipeline of stromx. More...

#include <Stream.h>

Public Types

enum  Status { INACTIVE, ACTIVE, DEACTIVATING, PAUSED }
 

Public Member Functions

 Stream ()
 
const std::string & name () const
 
void setName (const std::string &name)
 
Status status () const
 
const std::vector< Operator * > & operators () const
 
const std::vector< Operator * > & initializedOperators () const
 
const AbstractFactoryfactory () const
 
void setFactory (const AbstractFactory *const factory)
 
void connect (Operator *const sourceOp, const unsigned int outputId, Operator *const targetOp, const unsigned int inputId)
 
void disconnect (Operator *const targetOp, const unsigned int inputId)
 
const OutputConnector connectionSource (const Operator *const targetOp, const unsigned int inputId) const
 
OperatoraddOperator (OperatorKernel *const op)
 
void hideOperator (Operator *const op)
 
void showOperator (Operator *const op)
 
void removeOperator (Operator *const op)
 
void initializeOperator (Operator *const op)
 
void deinitializeOperator (Operator *const op)
 
void setConnectorType (Operator *const op, const unsigned int id, const Description::Type type, const Description::UpdateBehavior behavior=Description::PERSISTENT)
 
ThreadaddThread ()
 
void hideThread (Thread *const thread)
 
void showThread (Thread *const thread)
 
void removeThread (Thread *const thread)
 
const std::vector< Thread * > & threads () const
 
void addObserver (const ExceptionObserver *const observer)
 
void removeObserver (const ExceptionObserver *const observer)
 
unsigned int delay () const
 
void setDelay (const unsigned int delay)
 
void start ()
 
void stop ()
 
void join ()
 
void pause ()
 
void resume ()
 

Detailed Description

The core data processing pipeline of stromx.

Member Enumeration Documentation

§ Status

The possible states of a stream.

Enumerator
INACTIVE 

The stream is inactive.

ACTIVE 

The stream is active.

DEACTIVATING 

The stream was stopped and is waiting to become inactive.

PAUSED 

The stream was paused and is waiting to be resumed or stopped.

Constructor & Destructor Documentation

§ Stream()

stromx::runtime::Stream::Stream ( )

Constructs a stream object

Member Function Documentation

§ addObserver()

void stromx::runtime::Stream::addObserver ( const ExceptionObserver *const  observer)

Adds an observer to the stream. The observer is notified if an exception occurs while executing or deactivating an operator.

Parameters
observerA pointer to the observer is stored but not onwned by the operator.
Exceptions
WrongArgumentIf observer is a null pointer.

§ addOperator()

Operator * stromx::runtime::Stream::addOperator ( OperatorKernel *const  op)

Converts the operator kernel op to an operator and adds it to the stream. The ownership of the operator is transfered to the stream, i.e. it must not be deleted by the caller. Returns a pointer to the new operator.

Exceptions
WrongArgumentIf the operator pointer op is null.
WrongArgumentIf the object referenced by the pointer op has already been added to the stream.
WrongStateIf the stream is not INACTIVE.

§ addThread()

Thread * stromx::runtime::Stream::addThread ( )

Creates a thread, adds it to the stream and returns a pointer to it.

Returns
A pointer to the created thread. The thread is owned by the stream and must not be deleted by the caller.

§ connect()

void stromx::runtime::Stream::connect ( Operator *const  sourceOp,
const unsigned int  outputId,
Operator *const  targetOp,
const unsigned int  inputId 
)

Connects the output outputId of the operator sourceOp to the input inputId of the operator targetOp. The operators must be initialized.

Exceptions
WrongArgumentIf the operators sourceOp or targetOp do not belong to the stream.
WrongArgumentIf the operators sourceOp or targetOp do not have inputs outputId or inputId, respectively.
WrongStateIf the operators sourceOp or targetOp are not initialized.
WrongStateIf the stream is not INACTIVE.

§ connectionSource()

const OutputConnector stromx::runtime::Stream::connectionSource ( const Operator *const  targetOp,
const unsigned int  inputId 
) const

Returns the output which is connected to the input inputId of the operator targetOp. The operator must be initialized.

Returns
A valid output if the input is connected to another operator. The returned output is invalid if no output is connected to the input.
Exceptions
WrongArgumentIf the operator targetOp does not belong to the stream.
WrongArgumentIf the operator targetOp does not have an input inputId.
WrongStateIf the operator targetOp is not initialized.

§ deinitializeOperator()

void stromx::runtime::Stream::deinitializeOperator ( Operator *const  op)

Deinitializes the operator op if its status is Operator::INITIALIZED. After a successful call the status is Operator::NONE.

Exceptions
WrongStateIf the status of op is not Operator::INITIALIZED.

§ delay()

unsigned int stromx::runtime::Stream::delay ( ) const

Returns the current processing delay in milliseconds. The threads of the stream delay the processing of an operator input by this amount of time.

See also
setDelay()

§ disconnect()

void stromx::runtime::Stream::disconnect ( Operator *const  targetOp,
const unsigned int  inputId 
)

Disconnects the input inputId of the operator targetOp from any output. The operator must be initialized.

Exceptions
WrongArgumentIf the operator targetOp does not belong to the stream.
WrongArgumentIf the operator targetOp does not have an input inputId.
WrongStateIf the stream is not inactive.
WrongStateIf the operator targetOp is not initialized.

§ factory()

const AbstractFactory* stromx::runtime::Stream::factory ( ) const
inline

Returns the current factory of the stream. The factory is passed to each operator kernel during the execution and can be used by the operator kernel to instantiate new data objects or operators. Returns null if no current factory is set. If the stream was instantiated by a factory the operator factory is initially set to the instantiating factory.

§ hideOperator()

void stromx::runtime::Stream::hideOperator ( Operator *const  op)

Removes the operator op from the stream and disconnects it from all other connected sources and targets. In addition, if the operator op is used by any thread it is automatically removed from this thread. However, a reference to the operator is still been held by the stream and operator can be shown again later on. A hidden operator is not considered part of the stream and is not written to the file if the stream is persisted.

See also
showOperator()
Exceptions
WrongStateIf the stream is not INACTIVE.
WrongArgumentIf the operator pointer op is null.
WrongArgumentIf the operator referenced by the pointer op is not part of the stream.

§ hideThread()

void stromx::runtime::Stream::hideThread ( Thread *const  thread)

Removes the thread thr from the stream and but keeps a reference to it. A hidden thread is not considered part of the stream and is not written to the file if the stream is persisted.

See also
showThread()
Exceptions
WrongArgumentIf the thread thr is a null pointer.
WrongArgumentIf the thread is not part of the stream.

§ initializedOperators()

const std::vector< Operator * > & stromx::runtime::Stream::initializedOperators ( ) const

Returns a list of the initialized operators of the stream

§ initializeOperator()

void stromx::runtime::Stream::initializeOperator ( Operator *const  op)

Initializes the operator op if its status is Operator::NONE. After a successful call the status is Operator::INITIALIZED.

Exceptions
WrongStateIf the status of op is not Operator::NONE.

§ join()

void stromx::runtime::Stream::join ( )

Waits for the stream to stop and deactivates all operators. Exceptions which occur during the deactivation of an operator are sent to installed observers but ignored otherwise.

Exceptions
WrongStateIf the stream is active of paused.

§ name()

const std::string& stromx::runtime::Stream::name ( ) const
inline

Returns the name of the stream.

§ operators()

const std::vector< Operator * > & stromx::runtime::Stream::operators ( ) const

Returns a list of the operators of the stream

§ pause()

void stromx::runtime::Stream::pause ( )

Pauses the stream, i.e. each thread of the stream is paused. In contrast to stop() and join() the operators of the stream are not deactivated but remain in their current state.

Exceptions
WrongStateIf the stream is not active.

§ removeObserver()

void stromx::runtime::Stream::removeObserver ( const ExceptionObserver *const  observer)

Removes an observer from the set of current observers of the stream.

Parameters
observerThe observer to be removed.
Exceptions
WrongArgumentIf the observer has not been added to the stream before.
See also
addObserver()

§ removeOperator()

void stromx::runtime::Stream::removeOperator ( Operator *const  op)

Removes the operator op from the stream and disconnects it from all other connected sources and targets. In addition, if the operator op is used by any thread it is automatically removed from this thread. Finally, the operator is not deleted.

Parameters
opThe operator which is deleted. This pointer is invalid after the function has been called.
Exceptions
WrongStateIf the stream is not INACTIVE.
WrongArgumentIf the operator pointer op is null.
WrongArgumentIf the operator referenced by the pointer op is not known by the stream.

§ removeThread()

void stromx::runtime::Stream::removeThread ( Thread *const  thread)

Removes the thread thr from the stream and deletes it.

Parameters
threadThe thread which is deleted. This pointer is invalid after this function has been called.
Exceptions
WrongArgumentIf the thread thr is a null pointer or does not belong to the stream.

§ resume()

void stromx::runtime::Stream::resume ( )

Resumes a paused stream, i.e. each thread of the stream is resumed. The execution of the stream starts in the very same state which it was paused in.

Exceptions
WrongStateIf the stream is not paused.

§ setConnectorType()

void stromx::runtime::Stream::setConnectorType ( Operator *const  op,
const unsigned int  id,
const Description::Type  type,
const Description::UpdateBehavior  behavior = Description::PERSISTENT 
)

Sets the effective type of the connector/parameter id of the operator op. With this function an input or output connector can be configured to act as an operator parameter. A parameter whose original type is that of a connector can be configured to act as the respective connector.

Exceptions
WrongStateIf the stream is not INACTIVE.
WrongArgumentIf the operator pointer op is null or is not part of the stream.
WrongArgumentIf the id does not reference a valid connector or parameter.
WrongArgumentIf the arguments type and behavior are not compatible with the original type of the connector or parameter.

§ setDelay()

void stromx::runtime::Stream::setDelay ( const unsigned int  delay)

Sets the current processing delay in milliseconds. The threads of the stream delay the processing of an operator input by this amount of time. Normally the processing delay should be set to 0 to ensure all input data is processed as soon as it becomes available. For debugging it might however make sense to choose a positive processing delay.

See also
setDelay()

§ setFactory()

void stromx::runtime::Stream::setFactory ( const AbstractFactory *const  factory)

Sets the factory of the stream. This overwrites the factory property of all operators of the stream. The factory is passed to each operator kernel during the execution and can be used by the operator kernel to instantiate new data objects or operators. Returns null if no current factory is set. If the stream was instantiated by a factory the operator factory is initially set to the instantiating factory.

Parameters
factoryA pointer to the factory is stored but not owned by the operator. Pass null to reset the factory of this operator.
Exceptions
WrongStateIf the stream is not inactive.

§ setName()

void stromx::runtime::Stream::setName ( const std::string &  name)
inline

Sets the name of the stream.

§ showOperator()

void stromx::runtime::Stream::showOperator ( Operator *const  op)

Adds the hidden operator op back to the stream. Note that the original connections to and from the operator are recreated. Also, the operator is not added to any threads.

See also
hideOperator()
Exceptions
WrongStateIf the stream is not INACTIVE.
WrongArgumentIf the operator pointer op is null.
WrongArgumentIf the operator referenced by the pointer op is not part of the stream.
WrongArgumentIf the operator referenced by the pointer op was not hidden before.

§ showThread()

void stromx::runtime::Stream::showThread ( Thread *const  thread)

Adds the hidden thread thr to the stream. Note that the operators which originally belonged to the thread are not added again.

See also
showThread()
Exceptions
WrongArgumentIf the thread thr is a null pointer.
WrongArgumentIf the thread thrhas not been hidden before.

§ start()

void stromx::runtime::Stream::start ( )

Activates each operator of the stream and starts all threads.

Exceptions
WrongStateIf the stream is not inactive.
OperatorErrorIf an exception was thrown during the activation of an operator.

§ status()

Status stromx::runtime::Stream::status ( ) const
inline

Returns the current state of the stream.

§ stop()

void stromx::runtime::Stream::stop ( )

Signals all threads of the stream to stop if the stream is active or paused. If active the stream is deactivating after a call to this function. Use join() to wait for the threads to stop.

§ threads()

const std::vector< Thread * > & stromx::runtime::Stream::threads ( ) const

Returns the threads of the stream.


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