classPiiResourceConnector
#include <PiiResourceConnector.h>
An interface for classes that connect resource instances together.
Description
A "resource" can be an operation, a widget, or a distance measure, to name a few examples. To establish a connection between two resources one needs to first instantiate them and the connector. Then, pointers to the two resources are passed to the connector to bind the instances together.
Constructors and destructor
|
virtual
|
Public member functions
|
virtual bool
|
Connect two resources. |
|
virtual bool
|
Disconnect resources. |
|
template<class T, class U>
bool
|
Connect resource1 and resource2 as specified by role. |
|
template<class T, class U>
|
Creates a resource connector that can bind the two resources together as role. |
|
template<class T, class U>
bool
|
Disconnect two resources. |
|
PII_YDIN_EXPORT QString
|
Returns the name of a PiiResourceConnector resource that can bind the two named resources together as role. |
Function details
-
virtual ~PiiResourceConnector
()[virtual] -
virtual bool connectResources
[pure virtual]Connect two resources.
There are different flavors of "connection" including, for example, Qt's signal-slot connections and socket connections between PiiOperations. Each connector is specific to a pair of resources. Thus, it knows how to cast the provided
voidpointers to the correct type.Returns
trueif the resources were successfully connected,falseotherwise. -
virtual bool disconnectResources
[pure virtual]Disconnect resources.
If the resources are not connected, this function does nothing.
Returns
trueif the resources were successfully disconnected,falseotherwise. -
template<class T, class U>
bool connectResources
Connect resource1 and resource2 as specified by role.
PiiOperation* pOperation = PiiYdin::createResource<PiiOperation>("PiiVisualTrainer"); QWidget* pDisplay = PiiYdin::createResource<QWidget>("PiiVisualTrainerWidget"); PiiYdin::connectResources(pOperation, pDisplay, "pii:configurator");
Parameters
- resource1
-
a pointer to a class instance, such as PiiOperation. The resource name of type
Tmust be resolvable with #resourceName(). - resource2
-
a pointer to a class instance, such as QWidget. The resource name of type
Umust be resolvable with #resourceName(). - role
-
the type of connection between the resources, such as "pii:display".
Returns
trueif the resources were successfully connected,falseotherwise. The connection will fail if the name of one of the resources cannot be determined or if there is no connector (see PiiYdin::resourceDatabase()) associated with the two resources in the specified role. -
template<class T, class U>
PiiResourceConnector * createResourceConnector
Creates a resource connector that can bind the two resources together as role.
If the resources have not been assigned a connection named role or the connection has no associated connector, 0 will be returned. The function may return either a newly allocated connector object (in which case mustDelete flag will be set to
true) or either of the two resources (mustDelete will befalse). -
template<class T, class U>
bool disconnectResources
Disconnect two resources.
The behavior is similar to connectResources(), except that an existing connection (if any) between the two resources will be broken.
-
PII_YDIN_EXPORT QString resourceConnectorName
Returns the name of a PiiResourceConnector resource that can bind the two named resources together as role.
If no such connector exists, returns an empty string.
Add a note
Not a single note added yet. Be the first, add yours.