|
SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Ports are components that pass information between tasks of a workflow. More...
#include <Port.h>
Public Types | |
| enum | Direction { In, Out } |
| Whether the task fetches data from a port or provides data for a port. More... | |
| enum | Access { Internal, External } |
| Whether the task fetches data from a port or provides data for a port. More... | |
| using | Configuration = nlohmann::json |
| Ports may be configured with arbitrary JSON objects. | |
Public Types inherited from smtk::resource::Component | |
| typedef std::function< void(const ComponentPtr &)> | Visitor |
| typedef detail::ComponentLinks | Links |
| typedef detail::ComponentProperties | Properties |
Public Member Functions | |
| smtkTypeMacro (smtk::task::Port) | |
| smtkSuperclassMacro (smtk::resource::Component) | |
| smtkCreateMacro (smtk::resource::PersistentObject) | |
| Port (const Configuration &config, Task *parentTask, const std::shared_ptr< smtk::common::Managers > &managers=nullptr) | |
| Port (const Configuration &config, Manager &taskManager, const std::shared_ptr< smtk::common::Managers > &managers=nullptr) | |
| virtual void | configure (const Configuration &config) |
| A method called by all constructors passed Configuration information. More... | |
| virtual void | configureConnections (const Configuration &connConfig) |
| Add port connections from configuration data. More... | |
| const common::UUID & | id () const override |
| Set/get the task's unique identifier. | |
| bool | setId (const common::UUID &newId) override |
| Assign an ID to this object (used by readers; not for arbitrary reuse). More... | |
| std::string | name () const override |
| Return the task's name. | |
| virtual bool | setName (const std::string &name) |
| Direction | direction () const |
| Return the port's direction. More... | |
| Access | access () const |
| Return the port's access. More... | |
| std::unordered_set< smtk::string::Token > & | dataTypes () |
| Return the types of data this port is allowed to pass. | |
| const std::unordered_set< smtk::string::Token > & | dataTypes () const |
| const std::unordered_set< PersistentObject * > & | connections () const |
| Return the set of port connections. More... | |
| std::unordered_set< PersistentObject * > & | connections () |
| virtual std::shared_ptr< PortData > | portData (smtk::resource::PersistentObject *object) const |
| Return PortData for a given object in connections(). More... | |
| const std::shared_ptr< resource::Resource > | resource () const override |
| Components are required to return their owning resource (if any). More... | |
| smtk::string::Token | unassignedRole () const |
| Return a role to be assigned to connections that are not ports. More... | |
| const std::unordered_set< smtk::string::Token > & | style () const |
| Set/get style classes for the port. More... | |
| bool | addStyle (const smtk::string::Token &styleClass) |
| bool | removeStyle (const smtk::string::Token &styleClass) |
| bool | clearStyle () |
| virtual bool | getViewData (smtk::common::TypeContainer &configuration) const |
| Populate a type-container with view-related data for configuration. More... | |
| Task * | parent () const |
| Return a parent task if one exists; null otherwise. | |
| bool | setParent (Task *parent) |
| Set the parent task of a port. More... | |
| std::string | describe () const |
| Return an XHTML description of the port and its data. | |
Public Member Functions inherited from smtk::resource::Component | |
| smtkTypeMacro (smtk::resource::Component) | |
| smtkSuperclassMacro (smtk::resource::PersistentObject) | |
| smtkSharedFromThisMacro (smtk::resource::PersistentObject) | |
| Resource * | parentResource () const override |
| Return a raw (not shared) pointer to the resource that owns this component. More... | |
| template<typename ResourceType > | |
| ResourceType * | parentResourceAs () const |
| This variant of parentResource casts the result to the given ResourceType. | |
| Links & | links () override |
| Return the links that connect this component to external resources/components. | |
| const Links & | links () const override |
| Properties & | properties () override |
| Return properties defined on this component. | |
| const Properties & | properties () const override |
Public Member Functions inherited from smtk::resource::PersistentObject | |
| smtkTypeMacroBase (smtk::resource::PersistentObject) | |
| template<typename T > | |
| T::Ptr | as () |
| Attempt to cast this object to a subclass. | |
| template<typename T > | |
| T::ConstPtr | as () const |
| Attempt to cast this object to a subclass. | |
Static Public Member Functions | |
| static Direction | DirectionFromLabel (const std::string &label) |
| Convert Direction enumerants to/from labels. | |
| static smtk::string::Token | LabelFromDirection (Direction dir) |
| static Access | AccessFromLabel (const std::string &label) |
| Convert Access enumerants to/from labels. | |
| static smtk::string::Token | LabelFromAccess (Access ac) |
Protected Attributes | |
| smtk::common::UUID | m_id |
| The unique identifier for this task. | |
| std::string | m_name |
| A task name to present to the user. | |
| Task * | m_parent = nullptr |
| The task which owns this port. | |
| std::weak_ptr< smtk::task::Manager > | m_manager |
| If this task is being managed, this will refer to its manager. | |
| Direction | m_direction { Direction::In } |
| The direction of this port. | |
| Access | m_access { Access::External } |
| The access of this port with respect to its task. | |
| std::unordered_set< PersistentObject * > | m_connections |
| The port's upstream/downstream connections. | |
| std::unordered_set< smtk::string::Token > | m_dataTypes |
| The subclasses of PortData this port is allowed to pass. | |
| smtk::string::Token | m_unassignedRole |
| The role which "bare" objects in m_connections should be assigned. More... | |
| std::unordered_set< smtk::string::Token > | m_style |
| The set of style classes for this task. | |
Ports are components that pass information between tasks of a workflow.
Tasks are objects in a workflow that require users to perform work, make a decision, or provide information. Ports provide a way to model the flow of user-provided information between tasks.
Each port provides types of information that will be passed to or from its parent task.
A task may own 0 or more ports. Workflow designers and/or users may connect ports owned by different tasks via an adaptor; as long as the ports model information of matching types, data can be fetched as needed by the downstream task. When requesting data from a task, its ports are used as keys.
|
inline |
Return the port's access.
A port's access may not change; it should be set by configure(), which is called at construction.
|
virtual |
A method called by all constructors passed Configuration information.
In general, this method should set member variables directly instead of calling set/get methods since those may invoke observers with an uninitialized object.
|
virtual |
Add port connections from configuration data.
This method is called by configure() but may also be called elsewhere. Specifically, the task::Manager's from_json() function calls it after all of a project's persistent objects have been constructed to ensure the connections are able to be assigned.
Note that connConfig is not the same as the config parameter passed to Port::configure(). Instead, it is a subitem of config that holds only connections.
|
inline |
Return the set of port connections.
If the Port::Direction is In, these connections are objects upstream of the port. If the Port::Direction is Out, the connected objects are downstream of the port.
|
inline |
Return the port's direction.
A port's direction may not change; it should be set by configure(), which is called at construction.
|
virtual |
Populate a type-container with view-related data for configuration.
Subclasses should override this method. Generally, views will want access to a resource and potentially components in the resource that are the subject of the view. Other view configuration will come from view style() (see above) or smtk::common::Managers.
This method will return true when the configuration was modified and false otherwise.
|
virtual |
Return PortData for a given object in connections().
If object is not a port, the base Port class will either (a) construct an ObjectsInRoles instance holding the object in the unassignedRole(); or (b) return a null pointer, depending on whethern ObjectsInRoles is listed in the set returned by dataTypes().
If object is a port, the task will be asked to produce a PortData instance.
|
overridevirtual |
Components are required to return their owning resource (if any).
Components may not have an owning resource at some points in their lifecycle, so be sure to verify the returned value is non-null.
Implements smtk::resource::Component.
|
overridevirtual |
Assign an ID to this object (used by readers; not for arbitrary reuse).
TODO: care must be taken to modify the recorded ID in all links that connect to this object (see Resource::setId and its treatment of manager registration for reference).
Implements smtk::resource::PersistentObject.
| bool smtk::task::Port::setParent | ( | Task * | parent | ) |
Set the parent task of a port.
Tasks should call this when they take ownership of a port.
|
inline |
Set/get style classes for the port.
A style class specifies how applications should present the port (e.g., what type of view to provide the user, what rendering mode to use, what objects to list or exclude).
|
inline |
Return a role to be assigned to connections that are not ports.
Since persistent objects that are not ports cannot produce smtk::task::PortData themselves (that includes roles for objects), this helps ports produce ObjectsInRoles data (where a role is required).
|
protected |
The role which "bare" objects in m_connections should be assigned.
This defaults to "unassigned".
1.8.17