SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
smtk::task::ObjectsInRoles Class Reference

ObjectsInRoles holds references to objects as its payload. More...

#include <ObjectsInRoles.h>

Inheritance diagram for smtk::task::ObjectsInRoles:
[legend]
Collaboration diagram for smtk::task::ObjectsInRoles:
[legend]

Public Types

using ObjectSet = std::unordered_set< smtk::resource::PersistentObject * >
 
using RoleMap = std::unordered_map< smtk::string::Token, ObjectSet >
 

Public Member Functions

 smtkTypeMacro (smtk::task::ObjectsInRoles)
 
 smtkSuperclassMacro (smtk::task::PortData)
 
 smtkCreateMacro (smtk::task::PortData)
 
const RoleMap & data () const
 Return the objects for this port.
 
bool addObject (smtk::resource::PersistentObject *object, smtk::string::Token role)
 Add an object to this data in the specified role. More...
 
bool removeObject (smtk::resource::PersistentObject *object, smtk::string::Token role=smtk::string::Token::Invalid)
 Remove an object from this data. More...
 
bool clear ()
 Reset all the data in the role map.
 
bool merge (const PortData *other) override
 If other is also an instance of ObjectsInRoles, unite its data with this instance.
 
smtk::resource::PersistentObjectfirstObjectInRoleOfType (smtk::string::Token role, smtk::string::Token objectType)
 Find the first object of the given type in the given role.
 
template<typename T >
T * firstObjectInRoleAs (smtk::string::Token role, smtk::string::Token objectType)
 
- Public Member Functions inherited from smtk::task::PortData
 smtkTypeMacroBase (smtk::task::PortData)
 
 smtkCreateMacro (smtk::task::PortData)
 
virtual ~PortData ()=default
 This default virtual destructor forces PortData to be polymorphic.
 

Static Public Member Functions

static smtk::resource::PersistentObjectfindTaskPortObjectInRoleOfType (smtk::task::Task *task, smtk::string::Token portName, smtk::string::Token role, smtk::string::Token objectType)
 This is a convenience for consumers of port data. More...
 
template<typename T >
static T * findTaskPortObjectInRoleAs (smtk::task::Task *task, smtk::string::Token portName, smtk::string::Token role, smtk::string::Token objectType)
 

Protected Attributes

RoleMap m_data
 

Detailed Description

ObjectsInRoles holds references to objects as its payload.

Member Function Documentation

◆ addObject()

bool smtk::task::ObjectsInRoles::addObject ( smtk::resource::PersistentObject object,
smtk::string::Token  role 
)

Add an object to this data in the specified role.

Multiple objects may be added to any role. You may not add an object with an invalid role (i.e., !role.valid()); if you intend to add objects with no role assigned, use a token such as "unassigned".

◆ findTaskPortObjectInRoleOfType()

smtk::resource::PersistentObject * smtk::task::ObjectsInRoles::findTaskPortObjectInRoleOfType ( smtk::task::Task task,
smtk::string::Token  portName,
smtk::string::Token  role,
smtk::string::Token  objectType 
)
static

This is a convenience for consumers of port data.

It identifies a port on the task, fetches its port data, and then – assuming the port data is an ObjectsInRoles instance – searches for an object in the given role of the given type using firstObjectInRoleOfType().

◆ removeObject()

bool smtk::task::ObjectsInRoles::removeObject ( smtk::resource::PersistentObject object,
smtk::string::Token  role = smtk::string::Token::Invalid 
)

Remove an object from this data.

If a role is provided, the object will only be removed from that role. If no role is provided, all occurrences of the object will be removed.


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