Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::ProcessorNetwork Class Reference

#include <processornetwork.h>

+ Inheritance diagram for inviwo::ProcessorNetwork:

Public Member Functions

 ProcessorNetwork (InviwoApplication *application)
 
 ProcessorNetwork (const ProcessorNetwork &)=delete
 
 ProcessorNetwork (ProcessorNetwork &&)=delete
 
ProcessorNetworkoperator= (const ProcessorNetwork &)=delete
 
ProcessorNetworkoperator= (ProcessorNetwork &&)=delete
 
ProcessoraddProcessor (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.
 
ProcessorgetProcessorByIdentifier (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< PropertyLinkgetLinks () 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< PropertyLinkgetLinksBetweenProcessors (Processor *p1, Processor *p2)
 
PropertygetProperty (std::string_view path) const
 Get Property by path.
 
PortgetPort (std::string_view path) const
 Get Port by path.
 
InportgetInport (std::string_view path) const
 Get Inport by path.
 
OutportgetOutport (std::string_view path) const
 Get Outport by path.
 
bool isPropertyInNetwork (Property *prop) const
 
InviwoApplicationgetApplication () 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)
 
Observeroperator= (Observer &&other)
 
Observeroperator= (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< ProcessorremoveProcessor (Processor *processor)
 Removes a Processor from the ProcessorNetwork.
 
std::shared_ptr< ProcessorremoveProcessor (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_
 

Detailed Description

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.

Member Function Documentation

◆ addConnection() [1/2]

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.

Parameters
[in]connectionThe connection to add
See also
removeConnection()

◆ addConnection() [2/2]

void inviwo::ProcessorNetwork::addConnection ( Outport * sourcePort,
Inport * destPort )

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.

Parameters
[in]sourcePortThe outport.
[in]destPortThe inport.
See also
removeConnection()

◆ addLink() [1/2]

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.

Parameters
[in]linkThe property link to add.

◆ addLink() [2/2]

void inviwo::ProcessorNetwork::addLink ( Property * source,
Property * destination )

Create and add Property Link to the network.

Adds a link between two properties, that are owned by processor network.

Parameters
[in]sourceProperty at which link starts
[in]destinationProperty at which link ends

◆ addProcessor() [1/2]

Processor * inviwo::ProcessorNetwork::addProcessor ( std::shared_ptr< Processor > processor)

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.

Note
A processor should only ever be added to one network at a time
Parameters
[in]processorThe Processor to be added.
Returns
A pointer to the added processor
See also
removeProcessor(), Processor::setIdentifier()

◆ addProcessor() [2/2]

template<typename T , class = typename std::enable_if_t<std::is_base_of_v<Processor, T>, void>>
T * inviwo::ProcessorNetwork::addProcessor ( std::shared_ptr< T > processor)
inline

Adds a Processor to the ProcessorNetwork. s.

See also
ProcessorNetwork::addProcessor(std::shared_ptr<Processor>)
Parameters
[in]processorThe Processor to be added.
Returns
A pointer to the added processor of type T

◆ canConnect()

bool inviwo::ProcessorNetwork::canConnect ( const Outport * sourcePort,
const Inport * destPort ) const

Check if sourcePort can be connected to destPort

◆ clear()

void inviwo::ProcessorNetwork::clear ( )

Clears the network objects processors, port connections, property links etc.,

◆ connectionRange()

auto inviwo::ProcessorNetwork::connectionRange ( ) const
inline

Returns a range of all connections (PortConnection&), in unspecified order.

◆ deserialize()

virtual void inviwo::ProcessorNetwork::deserialize ( Deserializer & d)
overridevirtual

Implements inviwo::Serializable.

◆ emplaceProcessor()

template<typename T , class = typename std::enable_if_t<std::is_base_of_v<Processor, T>, void>, typename... Args>
std::shared_ptr< T > inviwo::ProcessorNetwork::emplaceProcessor ( Args &&... args)
inline

Emplace a Processor into the ProcessorNetwork.

See also
ProcessorNetwork::addProcessor(std::shared_ptr<Processor>)
Template Parameters
Tthe processor type to add
Parameters
argsAdditional arguments to pass to the processor constructor.

◆ forEachConnection()

template<typename C >
void inviwo::ProcessorNetwork::forEachConnection ( C callback)

Apply a function to each connection in the network.

Parameters
callbackA function that matches the signature void(PortConnection&)

◆ forEachLink()

template<typename C >
void inviwo::ProcessorNetwork::forEachLink ( C callback)

Apply a function to each property link in the network.

Parameters
callbackA function that matched the signature void(PropertyLink&)

◆ forEachProcessor()

template<typename C >
void inviwo::ProcessorNetwork::forEachProcessor ( C callback)

Apply a function to each processor in the network.

Parameters
callbackA function that matches the signature void(Processor*)

◆ getInport()

Inport * inviwo::ProcessorNetwork::getInport ( std::string_view path) const

Get Inport by path.

Parameters
pathstring of dot separated identifiers starting with a processor identifier followed by a port identifier.
Returns
the port or nullptr if not found

◆ getLinks()

std::vector< PropertyLink > inviwo::ProcessorNetwork::getLinks ( ) const

Get all connections in the network.

Note
This will have to allocate a new vector, consider using forEachLink instead.

◆ getOutport()

Outport * inviwo::ProcessorNetwork::getOutport ( std::string_view path) const

Get Outport by path.

Parameters
pathstring of dot separated identifiers starting with a processor identifier followed by a port identifier.
Returns
the port or nullptr if not found

◆ getPort()

Port * inviwo::ProcessorNetwork::getPort ( std::string_view path) const

Get Port by path.

Parameters
pathstring of dot separated identifiers starting with a processor identifier followed by a port identifier.
Returns
the port or nullptr if not found

◆ getProcessorByIdentifier()

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.

Parameters
identifierThe identifier of the Processor to be accessed.
Returns
A pointer to the processor or nullptr if there was no processor with the given identifier
See also
getProcessorsByType(), Processor::setIdentifier(), Processor::getIdentifier()

◆ getProcessors()

std::vector< Processor * > inviwo::ProcessorNetwork::getProcessors ( ) const

Get all processors in the network.

Note
This will have to allocate a new vector, consider using forEachProcessor instead.
Returns
a vector of pointers to vectors.

◆ getProcessorsByType()

template<class T >
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.

Note
This will have to allocate a new vector, consider using forEachProcessor instead.
Template Parameters
TThe type of processors to look for.
See also
getProcessorByIdentifier()

◆ getProperty()

Property * inviwo::ProcessorNetwork::getProperty ( std::string_view path) const

Get Property by path.

Parameters
pathstring of dot separated identifiers starting with a processor identifier followed by property identifiers.
Returns
the property or nullptr if not found

◆ isConnected() [1/2]

bool inviwo::ProcessorNetwork::isConnected ( const PortConnection & connection) const

Checks whether two port are connected.

Parameters
[in]connectionThe connection to look for
Returns
True if the two ports are connected
See also
addConnection()

◆ isConnected() [2/2]

bool inviwo::ProcessorNetwork::isConnected ( Outport * sourcePort,
Inport * destPort ) const

Checks whether two port are connected.

Parameters
[in]sourcePortThe outport.
[in]destPortThe inport.
Returns
Weather the two port are connected
See also
addConnection()

◆ isLinked() [1/2]

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.

Parameters
[in]linkThe property link to look for
Returns
True if link exists otherwise returns false

◆ isLinked() [2/2]

bool inviwo::ProcessorNetwork::isLinked ( Property * source,
Property * destination ) const

Check whether Property Link exists Checks if there is a link between two properties, that are owned by processor network.

Parameters
[in]sourceProperty at which link starts
[in]destinationProperty at which link ends
Returns
True if link exists otherwise returns false

◆ isLinkedBidirectional()

bool inviwo::ProcessorNetwork::isLinkedBidirectional ( Property * source,
Property * destination ) const

Is Property Link bidirectional Searches for bidirectional link between start and end properties In other words property that goes from end to start

Parameters
[in]sourceProperty at which link starts
[in]destinationProperty at which link ends
Returns
void

◆ isPortInNetwork()

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

◆ linkRange()

auto inviwo::ProcessorNetwork::linkRange ( ) const
inline

Returns a range of all links (PropertyLink&), in unspecified order.

◆ processorRange()

auto inviwo::ProcessorNetwork::processorRange ( ) const
inline

Returns a range of all processors (Processor&), in unspecified order.

◆ removeConnection() [1/2]

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.

Parameters
[in]connectionThe connection to remove.
See also
addConnection()

◆ removeConnection() [2/2]

void inviwo::ProcessorNetwork::removeConnection ( Outport * sourcePort,
Inport * destPort )

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.

Parameters
[in]sourcePortThe outport.
[in]destPortThe inport.
See also
addConnection()

◆ removeLink() [1/2]

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.

Parameters
[in]linkThe property link to remove.

◆ removeLink() [2/2]

void inviwo::ProcessorNetwork::removeLink ( Property * source,
Property * destination )

Remove and delete Property Link from the network Removes a link between two properties, that are owned by processor network.

Parameters
[in]sourceProperty at which link starts
[in]destinationProperty at which link ends

◆ removeProcessor() [1/2]

std::shared_ptr< Processor > inviwo::ProcessorNetwork::removeProcessor ( Processor * 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.

Parameters
[in]processorThe Processor to be removed.
Returns
The removed processor, or nullptr if the processor was not found
See also
addProcessor()

◆ removeProcessor() [2/2]

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.

Parameters
[in]processorThe Processor to be removed.
Returns
The removed processor, or nullptr if the processor was not found
See also
addProcessor()

◆ serialize()

virtual void inviwo::ProcessorNetwork::serialize ( Serializer & s) const
overridevirtual

Implements inviwo::Serializable.


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