Into

Modules

Documentation

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
(
  • void * resource1
  • void * resource2
  • const QString & role
)  = 0

Connect two resources.

virtual bool
(
  • void * resource1
  • void * resource2
  • const QString & role
)  = 0

Disconnect resources.

template<class T, class U>
bool
(
  • T * resource1
  • U * resource2
  • const QString & role
)

Connect resource1 and resource2 as specified by role.

template<class T, class U>
(
  • T * resource1
  • U * resource2
  • const QString & role
  • bool * mustDelete
)

Creates a resource connector that can bind the two resources together as role.

template<class T, class U>
bool
(
  • T * resource1
  • U * resource2
  • const QString & role
)

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

    (
    • void * resource1
    • void * resource2
    • const QString & role
    )
    [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 void pointers to the correct type.

    Returns

    true if the resources were successfully connected, false otherwise.

  • virtual bool disconnectResources

    (
    • void * resource1
    • void * resource2
    • const QString & role
    )
    [pure virtual]

    Disconnect resources.

    If the resources are not connected, this function does nothing.

    Returns

    true if the resources were successfully disconnected, false otherwise.

  • template<class T, class U>

    bool connectResources

    (
    • T * resource1
    • U * resource2
    • const QString & role
    )

    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 T must be resolvable with #resourceName().

    resource2

    a pointer to a class instance, such as QWidget. The resource name of type U must be resolvable with #resourceName().

    role

    the type of connection between the resources, such as "pii:display".

    Returns

    true if the resources were successfully connected, false otherwise. 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

    (
    • T * resource1
    • U * resource2
    • const QString & role
    • bool * mustDelete
    )

    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 be false).

  • template<class T, class U>

    bool disconnectResources

    (
    • T * resource1
    • U * resource2
    • const QString & role
    )

    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.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.