SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
smtk::resource::Links Class Referenceabstract

Links is a virtual class describing the API for connecting one resource/component to another resource/component. More...

#include <Links.h>

Inheritance diagram for smtk::resource::Links:
[legend]

Public Types

typedef std::pair< smtk::common::UUID, smtk::common::UUIDKey
 A Key is a pair of UUIDs. More...
 
typedef int RoleType
 

Public Member Functions

virtual ~Links ()=default
 Force this class to be polymorphic.
 
bool isLinkedTo (const ResourcePtr &, const RoleType &) const
 Given a resource or component and a role, check if a link of this role type exists between us and the input object.
 
bool isLinkedTo (const ComponentPtr &, const RoleType &) const
 
Key addLinkTo (const ResourcePtr &, const RoleType &)
 Given a resource or component and a role type, construct a link from us to the input object and assign the link a random UUID. More...
 
Key addLinkTo (const ComponentPtr &, const RoleType &)
 
PersistentObjectSet linkedTo (const RoleType &) const
 Given a role, return a set of objects to which this object links.
 
PersistentObjectSet linkedFrom (const ResourcePtr &, const RoleType &) const
 Given a role and a resource corresponding to the rhs of a link, return a set of objects from the rhs that link to this object using this role type.
 
PersistentObjectSet linkedFrom (const RoleType &) const
 Given a role, return a set of objects that link to this object using this role type. More...
 
bool removeLink (const Key &)
 Given a Link key, remove the associated link. Return true if successful.
 
bool removeLinksTo (const ResourcePtr &, const RoleType &)
 Given a resource or component and a role, remove all links from this object and the input object of this role type. More...
 
bool removeLinksTo (const ComponentPtr &, const RoleType &)
 
std::pair< PersistentObjectPtr, RoleType > linkedObjectAndRole (const Key &) const
 Given a Link key, return the object and role to which this object is linked, or return nullptr if no link exists with this link id.
 
PersistentObjectPtr linkedObject (const Key &key) const
 
std::pair< smtk::common::UUID, RoleType > linkedObjectIdAndRole (const Key &) const
 Given a Link key, return the id and role to which this object is linked, or return a null id if no link exists with this link id. More...
 
smtk::common::UUID linkedObjectId (const Key &key) const
 
LinkInformation linkedObjectInformation (const Key &key) const
 

Static Public Member Functions

static constexpr RoleType topLevelRole ()
 
static constexpr RoleType invalidRole ()
 

Static Public Attributes

static constexpr RoleType TopLevelRole = std::numeric_limits<Links::RoleType>::lowest()
 A special role used to link pairs of resources together. More...
 
static constexpr RoleType InvalidRole = std::numeric_limits<Links::RoleType>::lowest() + 1
 A special Role indicating that a link is invalid.
 

Protected Member Functions

virtual ResourceleftHandSideResource ()=0
 
virtual const ResourceleftHandSideResource () const =0
 
virtual const smtk::common::UUIDleftHandSideComponentId () const
 
Key addLinkTo (Resource *lhs1, const smtk::common::UUID &lhs2, const ResourcePtr &rhs1, const smtk::common::UUID &rhs2, const RoleType &role)
 This is protected so that ResourceLinks::copyLinks() can call it. More...
 

Detailed Description

Links is a virtual class describing the API for connecting one resource/component to another resource/component.

Member Typedef Documentation

◆ Key

A Key is a pair of UUIDs.

the First UUID is the id of the resource link, and the second one is the id of the component link.

Member Function Documentation

◆ addLinkTo() [1/2]

Links::Key smtk::resource::Links::addLinkTo ( const ResourcePtr rhs1,
const RoleType &  role 
)

Given a resource or component and a role type, construct a link from us to the input object and assign the link a random UUID.

Return a key that uniquely identifies the link if successful, or return a key comprised of a pair of null UUIDs if the link construction failed.

◆ addLinkTo() [2/2]

Links::Key smtk::resource::Links::addLinkTo ( Resource lhs1,
const smtk::common::UUID lhs2,
const ResourcePtr rhs1,
const smtk::common::UUID rhs2,
const RoleType &  role 
)
protected

This is protected so that ResourceLinks::copyLinks() can call it.

In general, you should not call this method directly; instead, call addLinkTo(Component, RoleType) or addLinkTo(Resource, RoleType).

◆ linkedFrom()

PersistentObjectSet smtk::resource::Links::linkedFrom ( const RoleType &  role) const

Given a role, return a set of objects that link to this object using this role type.

Because links are unidirectional, this method queries every resource managed by the accessible manager (the one managing lhs1) and queries their links for links to this object. If the resource associated with this link object is not managed, this method returns an empty set.

◆ linkedObjectIdAndRole()

std::pair< smtk::common::UUID, Links::RoleType > smtk::resource::Links::linkedObjectIdAndRole ( const Key key) const

Given a Link key, return the id and role to which this object is linked, or return a null id if no link exists with this link id.

This method is similar to linkedObjectAndRole() but does not require the link to successfully resolve to return a non-null value.

◆ removeLinksTo()

bool smtk::resource::Links::removeLinksTo ( const ResourcePtr rhs1,
const RoleType &  role 
)

Given a resource or component and a role, remove all links from this object and the input object of this role type.

Return true if successful.

Member Data Documentation

◆ TopLevelRole

constexpr RoleType smtk::resource::Links::TopLevelRole = std::numeric_limits<Links::RoleType>::lowest()
staticconstexpr

A special role used to link pairs of resources together.

All top-level links between resources use this role; if you intend to link two resources in a specific role, this is stored by a second Link in the bottom-level Links container between null UUIDs.


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