Pothos
0.4.1-gb758ed46
The Pothos dataflow programming software suite
|
#include <Block.hpp>
Public Member Functions | |
Block (void) | |
Default constructor. More... | |
virtual | ~Block (void) |
Virtual destructor. More... | |
void | setThreadPool (const ThreadPool &threadPool) |
Set the thread pool used by this block. More... | |
const ThreadPool & | getThreadPool (void) const |
Get the thread pool used by this block. More... | |
std::vector< PortInfo > | inputPortInfo (void) |
std::vector< PortInfo > | outputPortInfo (void) |
InputPort * | input (const std::string &name) const |
InputPort * | input (const size_t index) const |
OutputPort * | output (const std::string &name) const |
OutputPort * | output (const size_t index) const |
const std::vector< InputPort * > & | inputs (void) const |
const std::vector< OutputPort * > & | outputs (void) const |
const std::map< std::string, InputPort * > & | allInputs (void) const |
const std::map< std::string, OutputPort * > & | allOutputs (void) const |
const WorkInfo & | workInfo (void) const |
bool | isActive (void) const |
InputPort * | setupInput (const std::string &name, const DType &dtype="", const std::string &domain="") |
InputPort * | setupInput (const size_t index, const DType &dtype="", const std::string &domain="") |
OutputPort * | setupOutput (const std::string &name, const DType &dtype="", const std::string &domain="") |
OutputPort * | setupOutput (const size_t index, const DType &dtype="", const std::string &domain="") |
void | registerCallable (const std::string &name, const Callable &call) |
void | registerSignal (const std::string &name) |
void | registerSlot (const std::string &name) |
void | registerProbe (const std::string &name, const std::string &signalName="", const std::string &slotName="") |
void | yield (void) |
template<typename... ArgsType> | |
void | emitSignal (const std::string &name, ArgsType &&...args) |
Object | opaqueCallMethod (const std::string &name, const Object *inputArgs, const size_t numArgs) const |
Public Member Functions inherited from Pothos::Connectable | |
virtual | ~Connectable (void) |
virtual destructor for inheritance More... | |
void | setName (const std::string &name) |
const std::string & | getName (void) const |
std::vector< std::string > | inputPortNames (void) |
std::vector< std::string > | outputPortNames (void) |
Public Member Functions inherited from Pothos::CallInterface | |
virtual | ~CallInterface (void) |
template<typename ReturnType , typename... ArgsType> | |
ReturnType | call (ArgsType &&...args) const |
Call a bound method/function with a return type and variable args. More... | |
template<typename... ArgsType> | |
Object | callObject (ArgsType &&...args) const |
Call a bound method/function with an Object return and variable args. More... | |
template<typename... ArgsType> | |
void | callVoid (ArgsType &&...args) const |
Call a bound method/function with a void return and variable args. More... | |
Public Member Functions inherited from Pothos::Util::UID | |
UID (void) | |
Default constructor. More... | |
const std::string & | uid (void) const |
Get the UID as a string. More... | |
Public Member Functions inherited from Pothos::Util::RefHolder | |
virtual | ~RefHolder (void) |
Virtual destructor for derived classes. More... | |
void | holdRef (const Object &container) |
Store a copy of this object container. More... | |
void | dropRef (const Object &container) |
Drop a copy of this object container. More... | |
Public Attributes | |
std::shared_ptr< WorkerActor > | _actor |
Protected Member Functions | |
virtual void | work (void) |
virtual void | activate (void) |
virtual void | deactivate (void) |
virtual void | propagateLabels (const InputPort *input) |
virtual Object | opaqueCallHandler (const std::string &name, const Object *inputArgs, const size_t numArgs) |
virtual std::shared_ptr< BufferManager > | getInputBufferManager (const std::string &name, const std::string &domain) |
virtual std::shared_ptr< BufferManager > | getOutputBufferManager (const std::string &name, const std::string &domain) |
Protected Member Functions inherited from Pothos::CallRegistry | |
virtual | ~CallRegistry (void) |
Virtual destructor for subclassing. More... | |
template<typename... ArgsType, typename ReturnType , typename ClassType , typename InstanceType > | |
void | registerCall (InstanceType *instance, const std::string &name, ReturnType(ClassType::*method)(ArgsType...)) |
template<typename... ArgsType, typename ReturnType , typename ClassType , typename InstanceType > | |
void | registerCall (InstanceType *instance, const std::string &name, ReturnType(ClassType::*method)(ArgsType...) const) |
virtual | ~CallInterface (void) |
template<typename ReturnType , typename... ArgsType> | |
ReturnType | call (ArgsType &&...args) const |
Call a bound method/function with a return type and variable args. More... | |
template<typename... ArgsType> | |
Object | callObject (ArgsType &&...args) const |
Call a bound method/function with an Object return and variable args. More... | |
template<typename... ArgsType> | |
void | callVoid (ArgsType &&...args) const |
Call a bound method/function with a void return and variable args. More... | |
Protected Member Functions inherited from Pothos::Util::UID | |
UID (void) | |
Default constructor. More... | |
const std::string & | uid (void) const |
Get the UID as a string. More... | |
Protected Member Functions inherited from Pothos::Util::RefHolder | |
virtual | ~RefHolder (void) |
Virtual destructor for derived classes. More... | |
void | holdRef (const Object &container) |
Store a copy of this object container. More... | |
void | dropRef (const Object &container) |
Drop a copy of this object container. More... | |
Friends | |
class | WorkerActor |
Block is an interface for creating custom computational processing. Users should subclass Block, setup the input and output ports, and overload the work() method for a custom computational task.
The outputs of a Block can be connected to the inputs of another. Any resources produced at the Block's output ports will be make available to the other Block's connected input ports.
|
explicit |
Default constructor.
|
virtual |
Virtual destructor.
|
protectedvirtual |
The activate() method, called when the topology execution begins. Override this call to implement a custom topology activation hook.
|
inline |
Get all input ports. These ports can be accessed with the port name string.
|
inline |
Get all output ports. These ports can be accessed with the port name string.
|
protectedvirtual |
The deactivate() method, called when the topology execution ends. Override this call to implement a custom topology deactivation hook.
void Pothos::Block::emitSignal | ( | const std::string & | name, |
ArgsType &&... | args | ||
) |
Emit a signal to all subscribed slots.
name | the name of a registered signal |
args | a variable number of arguments |
|
protectedvirtual |
Get a buffer manager for this input port. The user may overload this call to install a custom buffer manager.
The domain parameter describes the memory used by the upstream blocks. Knowing the domain allows the implementer of getInputBufferManager to
PortDomainError | when the domain is incompatible |
name | the name of an input port on this block |
domain | the domain of the upstream blocks |
|
protectedvirtual |
Get a buffer manager for this output port. The user may overload this call to install a custom buffer manager.
The domain parameter describes the memory used by the downstream blocks. Knowing the domain allows the implementer of getOutputBufferManager to
PortDomainError | when the domain is incompatible |
name | the name of an output port on this block |
domain | the domain of the downstream blocks |
const ThreadPool& Pothos::Block::getThreadPool | ( | void | ) | const |
Get the thread pool used by this block.
|
inline |
Get the input port at the specified port name.
|
inline |
Get the input port at the specified port index.
|
virtual |
Get a vector of info about all of the input ports available.
Implements Pothos::Connectable.
|
inline |
Get the indexable input ports. These ports have a port name which is an integer. Indexable ports can be accessed with O(1) access time.
bool Pothos::Block::isActive | ( | void | ) | const |
Is the block in an active state? This is a thread-safe way for a block's methods to determine if the processing is currently active.
|
protectedvirtual |
The opaque call handler handles dispatching calls to registered methods. The user may overload this call to install their own custom handler.
BlockCallNotFound | when no call registered for the provided name |
Exception | when the registered call itself throws an exception |
name | the name of a call registered to this Block with registerCall() |
inputArgs | an array of input arguments wrapped in type Object |
numArgs | the number of arguments in the array inputArgs |
|
virtual |
Call a method on a derived instance with opaque input and return types.
name | the name of the method as a string |
inputArgs | an array of input arguments |
numArgs | the size of the input array |
Implements Pothos::Connectable.
|
inline |
Get the output port at the specified port name.
|
inline |
Get the output port at the specified port index.
|
virtual |
Get a vector of info about all of the output ports available.
Implements Pothos::Connectable.
|
inline |
Get the indexable output ports. These ports have a port name which is an integer. Indexable ports can be accessed with O(1) access time.
|
protectedvirtual |
The work() thread calls the propagateLabels() method after work() when labels are available to propagate to downstream consumers.
Default behavior: All labels with an index less than the number of consumed elements will be propagated to all output ports. Subclasses may override this call to customize its behavior.
Only the work() thread is allowed to call this method, therefore users should never directly invoke this method.
Access the labels iterator with the call to input->labels(). This iterator will contain only labels from the consumed elements. Forward labels to the output ports using postLabel() on an output port object.
input | a pointer to the input port with labels |
|
virtual |
Export a function call on this block to set/get parameters. This call will automatically register a slot of the same name.
name | the name of the callable |
call | the bound callable method |
Implements Pothos::CallRegistry.
void Pothos::Block::registerProbe | ( | const std::string & | name, |
const std::string & | signalName = "" , |
||
const std::string & | slotName = "" |
||
) |
Register a probe given the name of a registered call. A probe creates a special slot that will probe the registered call, and creates a triggered signal that will emit the return value of that call.
name | the name of a registered call |
signalName | the name of the triggered signal or empty for automatic |
slotName | the name of the probe slot or empty for automatic |
void Pothos::Block::registerSignal | ( | const std::string & | name | ) |
Register that this block has a signal of the given name. A signal is capable of emitting messages to a slot. The name should not overlap with the name of an output port.
name | the name of the signal |
void Pothos::Block::registerSlot | ( | const std::string & | name | ) |
Register that this block has a slot of the given name. A slot is capable of accepting messages from a signal. The name should not overlap with the name of an input port. Note: do not call the registerSlot function in C++, as registerCallable() automatically registers a slot.
name | the name of the slot |
void Pothos::Block::setThreadPool | ( | const ThreadPool & | threadPool | ) |
Set the thread pool used by this block.
InputPort* Pothos::Block::setupInput | ( | const std::string & | name, |
const DType & | dtype = "" , |
||
const std::string & | domain = "" |
||
) |
Configure an input port with the given data type. The data type parameter specifies the size in bytes per input element. The data type is only relevant when the port is used for streaming data. The domain parameter is used to specify the type of memory consumed. The domain will be passed into another block's getOutputBufferManager() call.
name | the name of this input port |
dtype | the data type for elements |
domain | the expected memory domain |
InputPort* Pothos::Block::setupInput | ( | const size_t | index, |
const DType & | dtype = "" , |
||
const std::string & | domain = "" |
||
) |
Configure an input port with the given data type. This call is equivalent to setupInput(std::to_string(index), ...);
index | the index number of this input port |
dtype | the data type for elements |
domain | the expected memory domain |
OutputPort* Pothos::Block::setupOutput | ( | const std::string & | name, |
const DType & | dtype = "" , |
||
const std::string & | domain = "" |
||
) |
Configure an output port with the given data type. The data type parameter specifies the size in bytes per output element. The data type is only relevant when the port is used for streaming data. The domain parameter is used to specify the type of memory produced. The domain will be passed into another block's getInputBufferManager() call.
name | the name of this output port |
dtype | the data type for elements |
domain | the expected memory domain |
OutputPort* Pothos::Block::setupOutput | ( | const size_t | index, |
const DType & | dtype = "" , |
||
const std::string & | domain = "" |
||
) |
Configure an output port with the given data type. This call is equivalent to setupOutput(std::to_string(index), ...);
index | the index number of this output port |
dtype | the data type for elements |
domain | the expected memory domain |
|
protectedvirtual |
The work() method, called when resources are available. Subclasses must override this call when creating a worker.
When work() is invoked, the user's code can access the port, consume input resources, and produce output resources.
Only the work() thread is allowed to call this method, therefore users should never directly invoke this method.
|
inline |
Get information about a work session that is not port-specific. The info is valid during calls to work() and propagateLabels().
void Pothos::Block::yield | ( | void | ) |
Notify the scheduler that the work() method will yeild the thread context. Call this method when the work() function will not produce or consume, so that the scheduler will call work() again without an external stimulus. Only call this method from within a call to the work() function. A typical use case for calling yield are blocks that must wait on a resource. Such blocks cannot hold the thread context for more than the allowed time, and must therefore return from the work() call without producing output.
|
friend |
std::shared_ptr<WorkerActor> Pothos::Block::_actor |