Inviwo 0.9.12-pre
Inviwo documentation
|
#include <processornetwork.h>
Public Member Functions | |
ProcessorNetwork (InviwoApplication *application) | |
ProcessorNetwork (const ProcessorNetwork &)=delete | |
ProcessorNetwork (ProcessorNetwork &&)=delete | |
ProcessorNetwork & | operator= (const ProcessorNetwork &)=delete |
ProcessorNetwork & | operator= (ProcessorNetwork &&)=delete |
Processor * | addProcessor (std::shared_ptr< Processor > processor) |
Adds a Processor to the ProcessorNetwork. | |
template<typename T , class = typename std::enable_if_t<std::is_base_of_v<Processor, T>, void>> | |
T * | addProcessor (std::shared_ptr< T > processor) |
Adds a Processor to the ProcessorNetwork. s. | |
template<typename T , class = typename std::enable_if_t<std::is_base_of_v<Processor, T>, void>, typename... Args> | |
std::shared_ptr< T > | emplaceProcessor (Args &&... args) |
Emplace a Processor into the ProcessorNetwork. | |
Processor * | getProcessorByIdentifier (std::string_view identifier) const |
Returns the Processor from the ProcessorNetwork, which has the given identifier. | |
template<class T > | |
std::vector< T * > | getProcessorsByType () const |
Returns a vector of Processors which are of type T. | |
std::vector< Processor * > | getProcessors () const |
Get all processors in the network. | |
template<typename C > | |
void | forEachProcessor (C callback) |
Apply a function to each processor in the network. | |
auto | processorRange () const |
void | addConnection (Outport *sourcePort, Inport *destPort) |
Add a PortConnection to the ProcessorNetwork. | |
void | addConnection (const PortConnection &connection) |
Add a PortConnection to the ProcessorNetwork. | |
bool | canConnect (const Outport *sourcePort, const Inport *destPort) const |
void | removeConnection (Outport *sourcePort, Inport *destPort) |
Removes a PortConnection from the ProcessorNetwork. | |
void | removeConnection (const PortConnection &connection) |
Removes a PortConnection from the ProcessorNetwork. | |
bool | isConnected (Outport *sourcePort, Inport *destPort) const |
Checks whether two port are connected. | |
bool | isConnected (const PortConnection &connection) const |
Checks whether two port are connected. | |
const std::vector< PortConnection > & | getConnections () const |
Get all connections in the network. | |
template<typename C > | |
void | forEachConnection (C callback) |
Apply a function to each connection in the network. | |
auto | connectionRange () const |
bool | isPortInNetwork (Port *port) const |
Check if port is owned by a processor in this ProcessorNetwork. | |
void | addLink (Property *source, Property *destination) |
Create and add Property Link to the network. | |
void | addLink (const PropertyLink &link) |
Create and add Property Link to the network. | |
bool | canLink (const Property *source, const Property *destination) const |
Check if source can be linked to destination. | |
void | removeLink (Property *source, Property *destination) |
void | removeLink (const PropertyLink &link) |
bool | isLinked (Property *source, Property *destination) const |
bool | isLinked (const PropertyLink &link) const |
std::vector< PropertyLink > | getLinks () const |
Get all connections in the network. | |
template<typename C > | |
void | forEachLink (C callback) |
Apply a function to each property link in the network. | |
auto | linkRange () const |
bool | isLinkedBidirectional (Property *source, Property *destination) const |
std::vector< Property * > | getPropertiesLinkedTo (Property *property) |
std::vector< PropertyLink > | getLinksBetweenProcessors (Processor *p1, Processor *p2) |
Property * | getProperty (std::string_view path) const |
Get Property by path. | |
Port * | getPort (std::string_view path) const |
Get Port by path. | |
Inport * | getInport (std::string_view path) const |
Get Inport by path. | |
Outport * | getOutport (std::string_view path) const |
Get Outport by path. | |
bool | isPropertyInNetwork (Property *prop) const |
InviwoApplication * | getApplication () const |
void | evaluateLinksFromProperty (Property *) |
bool | isEmpty () const |
bool | isInvalidating () const |
bool | isLinking () const |
void | lock () |
void | unlock () |
bool | islocked () const |
virtual void | serialize (Serializer &s) const override |
virtual void | deserialize (Deserializer &d) override |
bool | isDeserializing () const |
void | clear () |
bool | empty () const |
size_t | size () const |
void | accept (NetworkVisitor &visor) |
Accept a NetworkVisitor, the visitor will visit each Processor of the Network in an undefined order. The Visitor will then visit each processors Properties and so on. | |
int | runningBackgroundJobs () const |
Public Member Functions inherited from inviwo::Serializable | |
Public Member Functions inherited from inviwo::ProcessorNetworkObservable | |
void | notifyObserversProcessorNetworkChanged () |
void | notifyObserversProcessorNetworkEvaluateRequest () |
void | notifyObserversProcessorNetworkUnlocked () |
void | notifyObserversProcessorNetworkWillAddProcessor (Processor *processor) |
void | notifyObserversProcessorNetworkDidAddProcessor (Processor *processor) |
void | notifyObserversProcessorNetworkWillRemoveProcessor (Processor *processor) |
void | notifyObserversProcessorNetworkDidRemoveProcessor (Processor *processor) |
void | notifyObserversProcessorNetworkWillAddConnection (const PortConnection &connection) |
void | notifyObserversProcessorNetworkDidAddConnection (const PortConnection &connection) |
void | notifyObserversProcessorNetworkWillRemoveConnection (const PortConnection &connection) |
void | notifyObserversProcessorNetworkDidRemoveConnection (const PortConnection &connection) |
void | notifyObserversProcessorNetworkWillAddLink (const PropertyLink &propertyLink) |
void | notifyObserversProcessorNetworkDidAddLink (const PropertyLink &propertyLink) |
void | notifyObserversProcessorNetworkWillRemoveLink (const PropertyLink &propertyLink) |
void | notifyObserversProcessorNetworkDidRemoveLink (const PropertyLink &propertyLink) |
void | notifyObserversProcessorBackgroundJobsChanged (Processor *p, int diff, int total) |
Public Member Functions inherited from inviwo::Observable< ProcessorNetworkObserver > | |
Observable (const Observable< ProcessorNetworkObserver > &other) | |
Observable (Observable< ProcessorNetworkObserver > &&other) noexcept | |
Observable< ProcessorNetworkObserver > & | operator= (const Observable< ProcessorNetworkObserver > &other) |
Observable< ProcessorNetworkObserver > & | operator= (Observable< ProcessorNetworkObserver > &&other) noexcept |
void | addObserver (ProcessorNetworkObserver *observer) |
void | removeObserver (ProcessorNetworkObserver *observer) |
virtual void | startBlockingNotifications () override final |
virtual void | stopBlockingNotifications () override final |
Public Member Functions inherited from inviwo::ObservableInterface | |
Public Member Functions inherited from inviwo::ProcessorObserver | |
virtual void | onProcessorPortAdded (Processor *, Port *) |
virtual void | onProcessorAboutToProcess (Processor *) |
virtual void | onProcessorFinishedProcess (Processor *) |
virtual void | onProcessorSourceChanged (Processor *) |
virtual void | onProcessorSinkChanged (Processor *) |
virtual void | onProcessorReadyChanged (Processor *) |
virtual void | onProcessorActiveConnectionsChanged (Processor *) |
Public Member Functions inherited from inviwo::Observer | |
Observer (const Observer &other) | |
Observer (Observer &&other) | |
Observer & | operator= (Observer &&other) |
Observer & | operator= (const Observer &other) |
virtual | ~Observer () |
void | removeObservation (ObservableInterface *observable) |
void | removeObservations () |
Public Member Functions inherited from inviwo::PropertyOwnerObserver | |
virtual void | onWillAddProperty (PropertyOwner *owner, Property *property, size_t index) |
virtual void | onDidAddProperty (Property *property, size_t index) |
virtual void | onDidRemoveProperty (PropertyOwner *owner, Property *property, size_t index) |
Public Member Functions inherited from inviwo::ProcessorMetaDataObserver |
Static Public Member Functions | |
static int | getVersion () |
std::shared_ptr< Processor > | removeProcessor (Processor *processor) |
Removes a Processor from the ProcessorNetwork. | |
std::shared_ptr< Processor > | removeProcessor (std::string_view processor) |
Removes a Processor from the ProcessorNetwork. | |
Additional Inherited Members | |
Public Attributes inherited from inviwo::ProcessorObserver | |
friend | ProcessorObservable |
Public Attributes inherited from inviwo::PropertyOwnerObserver | |
friend | PropertyOwnerObservable |
Protected Member Functions inherited from inviwo::Observable< ProcessorNetworkObserver > | |
void | forEachObserver (C callback) |
Protected Member Functions inherited from inviwo::ObservableInterface | |
void | addObservationHelper (Observer *observer) |
void | removeObservationHelper (Observer *observer) |
Protected Member Functions inherited from inviwo::Observer | |
void | addObservation (ObservableInterface *observable) |
Protected Attributes inherited from inviwo::Observer | |
std::unordered_set< ObservableInterface * > | observables_ |
This class manages the current processor network. It can be thought of as a container of Processor instances, which Port instances are connected through PortConnection instances, and which Property instances are linked through ProcessorLink instances. To manage Processors, PortConnections and ProcessorLinks, add and remove methods are available for all these entities. The network should be only modified by using these methods. Typically, these methods are called by the NetworkEditor, which enables the user to edit ProcessorNetworks.
When the ProcessorNetwork has been changed, it is flagged as modified. This mechanism is used by the ProcessorNetworkEvaluator to identify if the ProcessorNetwork needs to be analyzed before processing.
In the model view controller design pattern, the ProcessorNetwork represents the model, which means that no graphical representations are generated for the added entities. Adding and removing of the graphical representations is done in the NetworkEditor.
void inviwo::ProcessorNetwork::addConnection | ( | const PortConnection & | connection | ) |
Add a PortConnection to the ProcessorNetwork.
This involves creating the connection between the two specified ports, as well as adding this connection to the ProcessorNetwork.
[in] | connection | The connection to add |
Add a PortConnection to the ProcessorNetwork.
This involves creating the connection between the two specified ports, as well as adding this connection to the ProcessorNetwork.
[in] | sourcePort | The outport. |
[in] | destPort | The inport. |
void inviwo::ProcessorNetwork::addLink | ( | const PropertyLink & | link | ) |
Create and add Property Link to the network.
Adds a link between two properties, that are owned by processor network.
[in] | link | The property link to add. |
Adds a Processor to the ProcessorNetwork.
The identifiers of all processors in the ProcessorNetwork should be unique, if the identifier is not unique, a replacement identifier will be set using util::findUniqueIdentifier. The processor's network will be set to this, and any registered widget will be consructed and added to the processor.
[in] | processor | The Processor to be added. |
|
inline |
Adds a Processor to the ProcessorNetwork. s.
[in] | processor | The Processor to be added. |
bool inviwo::ProcessorNetwork::canConnect | ( | const Outport * | sourcePort, |
const Inport * | destPort ) const |
Check if sourcePort can be connected to destPort
void inviwo::ProcessorNetwork::clear | ( | ) |
Clears the network objects processors, port connections, property links etc.,
|
inline |
Returns a range of all connections (PortConnection&), in unspecified order.
|
overridevirtual |
Implements inviwo::Serializable.
|
inline |
Emplace a Processor into the ProcessorNetwork.
T | the processor type to add |
args | Additional arguments to pass to the processor constructor. |
void inviwo::ProcessorNetwork::forEachConnection | ( | C | callback | ) |
Apply a function to each connection in the network.
callback | A function that matches the signature void(PortConnection&) |
void inviwo::ProcessorNetwork::forEachLink | ( | C | callback | ) |
Apply a function to each property link in the network.
callback | A function that matched the signature void(PropertyLink&) |
void inviwo::ProcessorNetwork::forEachProcessor | ( | C | callback | ) |
Apply a function to each processor in the network.
callback | A function that matches the signature void(Processor*) |
Inport * inviwo::ProcessorNetwork::getInport | ( | std::string_view | path | ) | const |
Get Inport by path.
path | string of dot separated identifiers starting with a processor identifier followed by a port identifier. |
std::vector< PropertyLink > inviwo::ProcessorNetwork::getLinks | ( | ) | const |
Get all connections in the network.
Outport * inviwo::ProcessorNetwork::getOutport | ( | std::string_view | path | ) | const |
Get Outport by path.
path | string of dot separated identifiers starting with a processor identifier followed by a port identifier. |
Port * inviwo::ProcessorNetwork::getPort | ( | std::string_view | path | ) | const |
Get Port by path.
path | string of dot separated identifiers starting with a processor identifier followed by a port identifier. |
Processor * inviwo::ProcessorNetwork::getProcessorByIdentifier | ( | std::string_view | identifier | ) | const |
Returns the Processor from the ProcessorNetwork, which has the given identifier.
In case no Processor with the given identifier is contained in the network, a null pointer is returned.
identifier | The identifier of the Processor to be accessed. |
identifier
std::vector< Processor * > inviwo::ProcessorNetwork::getProcessors | ( | ) | const |
Get all processors in the network.
std::vector< T * > inviwo::ProcessorNetwork::getProcessorsByType | ( | ) | const |
Returns a vector of Processors which are of type T.
In case no Processors match T an empty vector is returned.
T | The type of processors to look for. |
Property * inviwo::ProcessorNetwork::getProperty | ( | std::string_view | path | ) | const |
Get Property by path.
path | string of dot separated identifiers starting with a processor identifier followed by property identifiers. |
bool inviwo::ProcessorNetwork::isConnected | ( | const PortConnection & | connection | ) | const |
Checks whether two port are connected.
[in] | connection | The connection to look for |
Checks whether two port are connected.
[in] | sourcePort | The outport. |
[in] | destPort | The inport. |
bool inviwo::ProcessorNetwork::isLinked | ( | const PropertyLink & | link | ) | const |
Check whether Property Link exists Checks if there is a link between two properties, that are owned by processor network.
[in] | link | The property link to look for |
bool inviwo::ProcessorNetwork::isPortInNetwork | ( | Port * | port | ) | const |
Check if port
is owned by a processor in this ProcessorNetwork.
This will retrieve the identifier of the ports
owner and see if this network has a processor with that identifier
|
inline |
Returns a range of all links (PropertyLink&), in unspecified order.
|
inline |
Returns a range of all processors (Processor&), in unspecified order.
void inviwo::ProcessorNetwork::removeConnection | ( | const PortConnection & | connection | ) |
Removes a PortConnection from the ProcessorNetwork.
This involves breaking the connection between the two specified Ports, as well as removing this connection from the ProcessorNetwork.
[in] | connection | The connection to remove. |
Removes a PortConnection from the ProcessorNetwork.
This involves breaking the connection between the two specified Ports, as well as removing this connection from the ProcessorNetwork.
[in] | sourcePort | The outport. |
[in] | destPort | The inport. |
void inviwo::ProcessorNetwork::removeLink | ( | const PropertyLink & | link | ) |
Remove and delete Property Link from the network Removes a link between two properties, that are owned by processor network.
[in] | link | The property link to remove. |
Removes a Processor from the ProcessorNetwork.
To ensure that the network does not end up in a corrupt state, this method first removes and deletes all PortConnections and ProcessorLinks, which are related to the Processor to be removed. The processor's network and widget is also reset to nullptr.
[in] | processor | The Processor to be removed. |
std::shared_ptr< Processor > inviwo::ProcessorNetwork::removeProcessor | ( | std::string_view | processor | ) |
Removes a Processor from the ProcessorNetwork.
To ensure that the network does not end up in a corrupt state, this method first removes and deletes all PortConnections and ProcessorLinks, which are related to the Processor to be removed. The processor's network and widget is also reset to nullptr.
[in] | processor | The Processor to be removed. |
|
overridevirtual |
Implements inviwo::Serializable.