Essentia
2.1-beta6-dev
|
#include <network.h>
Public Member Functions | |
Network (streaming::Algorithm *generator, bool takeOwnership=true) | |
~Network () | |
void | run () |
void | runPrepare () |
bool | runStep () |
void | update () |
void | reset () |
void | clear () |
void | deleteAlgorithms () |
streaming::Algorithm * | findAlgorithm (const std::string &name) |
NetworkNode * | visibleNetworkRoot () |
NetworkNode * | executionNetworkRoot () |
const std::vector< streaming::Algorithm * > & | linearExecutionOrder () const |
void | printBufferFillState () |
Static Public Member Functions | |
static std::vector< streaming::Algorithm * > | innerVisibleAlgorithms (streaming::Algorithm *algo) |
Static Public Attributes | |
static Network * | lastCreated |
Protected Member Functions | |
void | buildVisibleNetwork () |
void | buildExecutionNetwork () |
void | topologicalSortExecutionNetwork () |
void | checkConnections () |
void | checkBufferSizes () |
void | clearVisibleNetwork () |
void | clearExecutionNetwork () |
Protected Attributes | |
bool | _takeOwnership |
streaming::Algorithm * | _generator |
NetworkNode * | _visibleNetworkRoot |
NetworkNode * | _executionNetworkRoot |
std::vector< streaming::Algorithm * > | _toposortedNetwork |
AlgoSet | _algos |
A Network is a structure that holds all algorithms that have been connected together and is able to run them.
It contains 2 networks of algorithms:
The main functionality of the Network, once it is built, is to run the generator node at the root of the Network (an audio loader, usually) and carry the data through all the other algorithms automatically.
Network | ( | streaming::Algorithm * | generator, |
bool | takeOwnership = true |
||
) |
Builds an execution Network using the given Algorithm. This will only work if the given algorithm is a generator, ie: it has no input ports.
generator | the root generator node to which all the network is connected |
takeOwnership | whether to take ownership of the algorithms and delete them when this Network object is destroyed |
~Network | ( | ) |
|
protected |
Build the network execution, ie: the network of single algorithms in the order in which they should be executed. All composite algorithms should have been expanded and the only remaining composites in there should be those that call themselves as part of a declareProcessStep()
call in the declareProcessOrder() method.
Referenced by Network::executionNetworkRoot(), and Network::update().
|
protected |
Build the network of visibly connected algorithms (ie: do not enter composite algorithms) and stores its root in _visibleNetworkRoot
.
Referenced by Network::update().
|
protected |
Check for all the connections that the source buffer size (phantom size, actually) is at least as big as the preferred size of the connected sink. If not, it automatically resizes the source buffer.
|
protected |
Check that all the algorithms inputs/outputs are connected somewhere, so as to make sure that no buffer is being filled without anybody to empty it, which would cause the whole network to be blocked. This function returns normally if it didn't find any problems, otherwise it throws an exception.
void clear | ( | ) |
Clear the network to an empty state (ie: no algorithms contained in it, delete previous algorithms if Network had ownership of them). This is the recommended way to proceed (do not use deleteAlgorithms() unless you really know what you're doing).
|
protected |
Delete all the NetworkNodes used in the execution network. Do not touch the algorithms pointed to by these nodes.
|
protected |
Delete all the NetworkNodes used in the visible network. Do not touch the algorithms pointed to by these nodes.
void deleteAlgorithms | ( | ) |
Delete all the algorithms contained in this network. Be careful as this method will indeed delete all the algorithms in the Network, even if it didn't take ownership over them.
|
inline |
streaming::Algorithm* findAlgorithm | ( | const std::string & | name | ) |
Find and return an algorithm by its name. Throw an exception if no algorithm was found with the given name.
|
static |
Helper function that returns the list of visibly connected algorithms starting from the given one, without crossing the borders of a possibly encompassing AlgorithmComposite (ie: all returned algorithms are inside the composite).
|
inline |
Return a list of algorithms which have been topologically sorted. You can assume that each node in there will have either 1 or 0 children.
References Network::_toposortedNetwork.
void printBufferFillState | ( | ) |
Prints the fill state of all the buffers in the network.
void reset | ( | ) |
Reset all the algorithms contained in this network. (This in effect calls their reset() method)
void run | ( | ) |
Executes all the algorithms in the network until all the tokens given by the source generator are processed by all the algorithms.
Internally it just calls runPrepare and then runStep repeatedly.
void runPrepare | ( | ) |
Does the preparation needed to process the tokens of the network
bool runStep | ( | ) |
Processes all tokens generated with one call of process() on the generator.
Returns False if there are no more tokens to process.
|
protected |
Perform a topological sort of the execution network and store it internally.
Referenced by Network::update().
|
inline |
Rebuilds the visible and execution network.
References Network::buildExecutionNetwork(), Network::buildVisibleNetwork(), and Network::topologicalSortExecutionNetwork().
|
inline |
References Network::_visibleNetworkRoot.
|
protected |
Execution dependencies are stored inside the network nodes themselves, and might enter/exit CompositeAlgorithms boundaries. This variable does not do that and only keeps the simple list of algorithms, for the purpose of resetting/deleting them.
|
protected |
Referenced by Network::executionNetworkRoot().
|
protected |
|
protected |
|
protected |
Referenced by Network::linearExecutionOrder().
|
protected |
Referenced by Network::executionNetworkRoot(), and Network::visibleNetworkRoot().
|
static |
Last instance of Network created, 0 if it has been deleted or if no network has been created yet.