Workspace 6.21.5
Public Member Functions | Static Public Member Functions | List of all members
Connection Class Reference

Represents a connection of an output to an input. More...

#include <Workspace/DataExecution/Connections/connection.h>

Inheritance diagram for Connection:
[legend]

Public Member Functions

bool canSerialize () const override
 
void destinationModified ()
 
void destroy ()
 
QList< QUuid > getAnchorIds () const
 
QAction * getConfigureAction (QObject *parent)
 
bool getCopySource () const
 
InputScalargetDestination ()
 
const InputScalargetDestination () const
 
UpdatablegetFromPath (const QString &path, Workspace &relativeTo, QStringList &errors) const override
 
QString getIdPath (bool scoped=true) const override
 
QString getShortDescription () const
 
OutputgetSource ()
 
const OutputgetSource () const
 
QString getTagName () const
 
bool getUpToDate () const override
 
int indexOfAnchor (const QUuid &id) const
 
void insertAnchor (const QUuid &id, int index=-1)
 
bool isConnectedToAsynchronous () const override
 
bool isEnabled () const
 
bool isValid () const
 
bool isWaitingForAsynchronousUpdate () const override
 
bool load (const SerializedItem &item) override
 
bool rebuild ()
 
void removeAnchorAtIndex (int index)
 
bool save (SerializedItem &item) const override
 
void setCopySource (bool b)
 
void setEnabled (bool enable)
 
void setUpToDate (bool b) override
 
bool update (Updater *updater=nullptr) override
 
- Public Member Functions inherited from WorkspaceElement
 ~WorkspaceElement () override
 
const WorkspacegetWorkspace () const override
 
WorkspacegetWorkspace () override
 
virtual void workspaceChanged (Workspace *oldWorkspace)
 
- Public Member Functions inherited from Updatable
 ~Updatable () override
 
virtual bool comesFromExternal () const
 
QString getEnclosingScope () const
 
virtual UpdatablegetFromPath (const QString &path, Workspace &relativeTo, QStringList &errors) const =0
 
const QString & getGlobalName () const
 
virtual QString getIdPath (bool scoped=true) const =0
 
virtual WorkspacegetRootWorkspace ()
 
virtual const WorkspacegetRootWorkspace () const
 
QString getScopedGlobalName () const
 
virtual bool getUpToDate () const =0
 
virtual const WorkspacegetWorkspace () const =0
 
virtual WorkspacegetWorkspace ()=0
 
virtual void idPathChanged ()
 
virtual bool isConnectedToAsynchronous () const =0
 
virtual bool isWaitingForAsynchronousUpdate () const =0
 
void setGlobalName (const QString &name)
 
virtual void setUpToDate (bool b)=0
 
virtual bool update (Updater *updater=nullptr)=0
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 
- Public Member Functions inherited from Serialize
virtual ~Serialize ()=default
 
virtual bool canSerialize () const =0
 
virtual bool load (const SerializedItem &item)=0
 
virtual bool save (SerializedItem &item) const =0
 
- Public Member Functions inherited from TextLogger
 TextLogger ()
 
 TextLogger (const DataExecution::IOBase &io)
 
 TextLogger (const DataExecution::Operation &operation)
 
 TextLogger (const TextLogger &logger)
 
 TextLogger (TextLogger &&logger)
 
virtual ~TextLogger ()
 
void logLine (const Application::LogManager::MessageCategory &category, const QString &msg) const
 
void logLine (const QString &msg) const
 
void logText (const Application::LogManager::MessageCategory &category, const QString &msg) const
 
void logText (const QString &msg) const
 
TextLoggeroperator= (TextLogger)
 

Static Public Member Functions

static Connectioncreate (Output &source, InputScalar &destination, bool copy=false, bool enable=true)
 
- Static Public Member Functions inherited from Updatable
static InputScalarfindInputScalarGlobalName (const QString &scopedGlobalName, Workspace &relativeTo)
 
static IOBasefindIOBaseGlobalName (const QString &scopedGlobalName, Workspace &relativeTo)
 
static OperationfindOperationGlobalName (const QString &scopedGlobalName, Workspace &relativeTo)
 

Additional Inherited Members

- Protected Member Functions inherited from WorkspaceElement
 WorkspaceElement ()
 
- Protected Member Functions inherited from Updatable
 Updatable ()
 
 Updatable (const Updatable &up)
 
void notifyUpdated ()
 
Updatableoperator= (const Updatable &up)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Detailed Description

Connections are made between an output and an input. Where the input is an array input, the connection is associated with the array input but is made to an element of that input array.

The connection handles conversion between types and passing the input a copy of the output if copying is requested.

Member Function Documentation

◆ canSerialize()

bool canSerialize ( ) const
overridevirtual
Returns
True if this object can be serialized.

For objects that can be serialized, the save and load functions will be used to do the serialization. If this function returns false, both load() and save() must also return false.

Implements Serialize.

◆ create()

Connection & create ( Output source,
InputScalar destination,
bool  copy = false,
bool  enable = true 
)
static
Parameters
sourceData for the connection will be taken from this output.
destinationThis will be updated with the data from the source.
copyIf true, the destination will receive a copy of the source. If false, the destination will be directly linked to the source and will share its data, where this is possible. This can be changed later with a call to setCopySource.
enableWhether the connection should be enabled initially (true) or not (false). See setEnabled() / isEnabled() for more information on how the enabled state effect the operation of the connection.
Precondition
We assume that the caller has already validated that we are allowed to create a connection between the specified source and destination.
Returns
A new connection object which can only be deleted by calling its destroy function. This strategy allows a workspace to assume it can always safely delete a connection when required. Clients who need to be notified when a connection is destroyed by a workspace can create an observer for this purpose. See RemoveConnectionEvent for more details.

◆ destinationModified()

void destinationModified ( )

◆ destroy()

void destroy ( )

The only way to delete a connection. If the connection is part of a workspace, it will be removed from that workspace just before it is deleted (the connection is still valid at that point). After this function returns, the connection object is no longer valid and all references to it should be discarded.

See also
create

◆ getAnchorIds()

QList< QUuid > getAnchorIds ( ) const
Returns
A copy of the list of anchor ids used by this connection. The anchors will be returned in the order that the connection passes through them, starting from the source end of the connection.

◆ getConfigureAction()

QAction * getConfigureAction ( QObject *  parent)
Returns
An action object that, when triggered, will present a dialog to the user for configuring aspects of this connection. The intended use of this function is to allow TypeAdaptor subclasses to provide a way to fine tune how they do the type adapting through their connectConversionAction() function.

◆ getCopySource()

bool getCopySource ( ) const
Returns
True if the destination will receive a copy of the source.

Note that even if this function returns false, it is possible that the destination is not a direct connection to the source. This can occur when the destination type requires an adaptor from the source type. In such instances, the conversion may require an intermediate object to serve as the destination, in which case the source has effectively been copied. Note, however, that some adaptors do not require such a copy, namely an adaptor between a destination which is a base class of the source. You should think of this as an indication of whether there is a chance that the destination may be able to avoid a copy rather than whether or not there actually is a copy.

◆ getDestination() [1/2]

InputScalar & getDestination ( )
Returns
The destination of this connection.

◆ getDestination() [2/2]

const InputScalar & getDestination ( ) const
Returns
The destination of this connection.

◆ getFromPath()

Updatable * getFromPath ( const QString &  path,
Workspace relativeTo,
QStringList errors 
) const
overridevirtual
Returns
This always returns false because global names and ID paths do not apply to workspace connections.

Implements Updatable.

◆ getIdPath()

QString getIdPath ( bool  scoped = true) const
overridevirtual
Returns
This always returns an empty string because workspace connections do not have ID paths.

Implements Updatable.

◆ getShortDescription()

QString getShortDescription ( ) const
Returns
A string suitable for the title of a context menu or as a line of status bar text. The string will contain the names of the source and destination output/input, but nothing about the operations owning them.

◆ getSource() [1/2]

Output & getSource ( )
Returns
The source for this connection.

◆ getSource() [2/2]

const Output & getSource ( ) const
Returns
The source for this connection.

◆ getTagName()

QString getTagName ( ) const
Returns
The tag name to use for this object when it is serialized.

◆ getUpToDate()

bool getUpToDate ( ) const
overridevirtual
Returns
True if this operation is up to date.

Implements Updatable.

◆ indexOfAnchor()

int indexOfAnchor ( const QUuid &  id) const
Parameters
idThe anchor id whose index is being sought.
Returns
The index of the specified anchor id or -1 if the connection is not using that anchor.

◆ insertAnchor()

void insertAnchor ( const QUuid &  id,
int  index = -1 
)
Parameters
idThe ID of the anchor to be inserted into the list.
indexWhere in the list of anchor ID's to insert this one. If this is negative or is past the end of the list, the anchor with the specified id will be appended to the list.

This function will raise an AddToAnchorEvent notification before returning.

◆ isConnectedToAsynchronous()

bool isConnectedToAsynchronous ( ) const
overridevirtual
Returns
True if the updatable object is connected to an asynchronous updatable.
See also
isWaitingForAsynchronousUpdate(), update()

Implements Updatable.

◆ isEnabled()

bool isEnabled ( ) const

Gets whether the connection is temporarily enabled (true) or disabled (false).

Returns
true when the connection is enabled and false when the connection is disabled.

When a connection is disabled it doesn't pass data or propogate execution (as if the connection were not there).

◆ isValid()

bool isValid ( ) const
Returns
True if the connection is valid. Invalid connections are called null connections. A null connection allows the relationship between the source and destination to be preserved, even if the data types don't match. They cause all attempts at executing anything relying on the connection to fail.

◆ isWaitingForAsynchronousUpdate()

bool isWaitingForAsynchronousUpdate ( ) const
overridevirtual
Returns
True if the updatable object is waiting for an asynchronous update.
See also
update()

Implements Updatable.

◆ load()

bool load ( const SerializedItem item)
overridevirtual
Parameters
itemSupplies the state to be loaded into this object.

This function will load the state of this object from item. For many object types, this is most easily implemented in terms of the object's input operator (>>).

It would be reasonable for subclass implementations to assume that the data provided in item is in the same form as would have been saved from a call to save.

Returns
If the state of the object could not be loaded, the function returns false. A return value of true implies that the object state was successfully loaded. If canSerialize() returns false, this function must do nothing except return false as well.

Implements Serialize.

◆ rebuild()

bool rebuild ( )

This function will rebuild the connection between the current source and destination, taking into account the current settings for copying and the data types at each end of the connection.

Returns
True if the connection was successfully remade. If it fails, the function will return false and set the connection to a null connection. Any attempt to update a null connection will fail.

◆ removeAnchorAtIndex()

void removeAnchorAtIndex ( int  index)
Parameters
indexThe index of the anchor to remove. If index is not a valid index, this function does nothing.

This function will raise a RemoveFromAnchorEvent notification just before the anchor at the specified index is removed from the connection's internal list of anchors.

◆ save()

bool save ( SerializedItem item) const
overridevirtual
Parameters
itemWhere to save the state of this object.

This function will serialise the object by saving it to item. For most object types, this is most easily implemented in terms of the object's output operator (<<).

It is allowable for an object to only serialize part of itself. This would be useful if the data it represents has a set of defaults and only those values different to the defaults need to be serialized. Such an implementation then needs to be careful how it handles the complimentary load member function.

Returns
If an object could not be serialised or if the underlying object type does not support serialisation, this function should return false. A return value of true implies that the object was successfully saved to item. If canSerialize() returns false, this function must do nothing except return false as well.

Implements Serialize.

◆ setCopySource()

void setCopySource ( bool  b)
Parameters
bIf this is true, then the connection will supply a copy of the source's data. Changes to the destination data will not modify the source, thereby limiting the depth to which operations will have to be re-executed if the workspace is run again.

Before actually changing the state of copy source, a check is made to see if the state of copying is actually going to change (ie if b is not the same as what would have been returned from getCopySource). If the values are different, the destination is notified that the connection was rebuilt by calling its InputScalar::rebuilt() function.

See also
getCopySource for more details about copying between dissimilar data types.

◆ setEnabled()

void setEnabled ( bool  enable)

Temporarily enables or disables a connection. When a connection is disabled it doesn't pass data or propogate execution (as if the connection were not there).

Parameters
enabletrue enables the connection, false disables the connection.

◆ setUpToDate()

void setUpToDate ( bool  b)
overridevirtual
Parameters
bBoolean value specifying the connection's new up-to-date status.

If b is false, the call will also propagate forward the not up-to-date status for the connection's destination. That destination will then continue to propagate the status forward as necessary.

Implements Updatable.

◆ update()

bool update ( Updater updater = nullptr)
overridevirtual

This function first ensures that the source of the connection is up to date, then it updates this connection if required.

Returns
True if the update was successful.

Implements Updatable.