![]() |
stromx
0.8.0
|
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 AbstractFactory * | factory () 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 |
| Operator * | addOperator (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) |
| Thread * | addThread () |
| 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 () |
The core data processing pipeline of stromx.
| stromx::runtime::Stream::Stream | ( | ) |
Constructs a stream object
| 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.
| observer | A pointer to the observer is stored but not onwned by the operator. |
| WrongArgument | If observer is a null pointer. |
| 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.
| WrongArgument | If the operator pointer op is null. |
| WrongArgument | If the object referenced by the pointer op has already been added to the stream. |
| WrongState | If the stream is not INACTIVE. |
| Thread * stromx::runtime::Stream::addThread | ( | ) |
Creates a thread, adds it to the stream and returns a pointer to it.
| 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.
| WrongArgument | If the operators sourceOp or targetOp do not belong to the stream. |
| WrongArgument | If the operators sourceOp or targetOp do not have inputs outputId or inputId, respectively. |
| WrongState | If the operators sourceOp or targetOp are not initialized. |
| WrongState | If the stream is not INACTIVE. |
| 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.
| WrongArgument | If the operator targetOp does not belong to the stream. |
| WrongArgument | If the operator targetOp does not have an input inputId. |
| WrongState | If the operator targetOp is not initialized. |
| 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.
| WrongState | If the status of op is not Operator::INITIALIZED. |
| 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.
| 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.
| WrongArgument | If the operator targetOp does not belong to the stream. |
| WrongArgument | If the operator targetOp does not have an input inputId. |
| WrongState | If the stream is not inactive. |
| WrongState | If the operator targetOp is not initialized. |
|
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.
| 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.
| WrongState | If the stream is not INACTIVE. |
| WrongArgument | If the operator pointer op is null. |
| WrongArgument | If the operator referenced by the pointer op is not part of the stream. |
| 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.
| WrongArgument | If the thread thr is a null pointer. |
| WrongArgument | If the thread is not part of the stream. |
| const std::vector< Operator * > & stromx::runtime::Stream::initializedOperators | ( | ) | const |
Returns a list of the initialized operators of the stream
| 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.
| WrongState | If the status of op is not Operator::NONE. |
| 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.
| WrongState | If the stream is active of paused. |
|
inline |
Returns the name of the stream.
| const std::vector< Operator * > & stromx::runtime::Stream::operators | ( | ) | const |
Returns a list of the operators of the stream
| 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.
| WrongState | If the stream is not active. |
| void stromx::runtime::Stream::removeObserver | ( | const ExceptionObserver *const | observer | ) |
Removes an observer from the set of current observers of the stream.
| observer | The observer to be removed. |
| WrongArgument | If the observer has not been added to the stream before. |
| 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.
| op | The operator which is deleted. This pointer is invalid after the function has been called. |
| WrongState | If the stream is not INACTIVE. |
| WrongArgument | If the operator pointer op is null. |
| WrongArgument | If the operator referenced by the pointer op is not known by the stream. |
| void stromx::runtime::Stream::removeThread | ( | Thread *const | thread | ) |
Removes the thread thr from the stream and deletes it.
| thread | The thread which is deleted. This pointer is invalid after this function has been called. |
| WrongArgument | If the thread thr is a null pointer or does not belong to the stream. |
| 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.
| WrongState | If the stream is not paused. |
| 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.
| WrongState | If the stream is not INACTIVE. |
| WrongArgument | If the operator pointer op is null or is not part of the stream. |
| WrongArgument | If the id does not reference a valid connector or parameter. |
| WrongArgument | If the arguments type and behavior are not compatible with the original type of the connector or parameter. |
| 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.
| 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.
| factory | A pointer to the factory is stored but not owned by the operator. Pass null to reset the factory of this operator. |
| WrongState | If the stream is not inactive. |
|
inline |
Sets the name of the stream.
| 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.
| WrongState | If the stream is not INACTIVE. |
| WrongArgument | If the operator pointer op is null. |
| WrongArgument | If the operator referenced by the pointer op is not part of the stream. |
| WrongArgument | If the operator referenced by the pointer op was not hidden before. |
| 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.
| WrongArgument | If the thread thr is a null pointer. |
| WrongArgument | If the thread thrhas not been hidden before. |
| void stromx::runtime::Stream::start | ( | ) |
Activates each operator of the stream and starts all threads.
| WrongState | If the stream is not inactive. |
| OperatorError | If an exception was thrown during the activation of an operator. |
|
inline |
Returns the current state of the stream.
| 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.
| const std::vector< Thread * > & stromx::runtime::Stream::threads | ( | ) | const |
Returns the threads of the stream.
1.8.12