SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
smtk::task::Agent Class Referenceabstract

Agent is a base class for all SMTK agents. More...

#include <Agent.h>

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

Public Types

enum  CategoryEvaluation { CategoryEvaluation::Pass, CategoryEvaluation::Reject, CategoryEvaluation::Neutral }
 The set of values that an agent's acceptChildCategories method can return. More...
 
using State = smtk::task::State
 
using Configuration = nlohmann::json
 

Public Member Functions

 smtkTypeMacroBase (smtk::task::Agent)
 
 Agent (Task *owningTask)
 
virtual State state () const =0
 Return the current state of the agent.
 
virtual void configure (const Configuration &config)
 Configure the agent based on a provided JSON configuration. More...
 
virtual Configuration configuration () const
 Return the agent's configuration.
 
virtual std::shared_ptr< PortDataportData (const Port *port) const
 Return the port data from the agent. More...
 
virtual void portDataUpdated (const Port *port)
 Tell the agent that the data on port has been updated. More...
 
Taskparent () const
 Return the agent's parent task.
 
virtual std::string troubleshoot () const
 Return a description of actions users must take to make the agent's state completable. More...
 
virtual bool getViewData (smtk::common::TypeContainer &configuration) const
 Insert view-related objects into configuration. More...
 
smtk::string::Token name () const
 Agents may have a name that can be used to distinguish them. More...
 
virtual CategoryEvaluation acceptsChildCategories (const std::set< std::string > &cats) const
 Evaluates a set of categories that are associated with potential children tasks.
 

Protected Member Functions

virtual void taskStateChanged (State prev, State &next)
 Receive notification the parent Task's state has changed.
 
virtual void taskStateChanged (Task *task, State prev, State next)
 Receive notification that a Task's state has changed. More...
 

Protected Attributes

smtk::task::Taskm_parent
 
smtk::string::Token m_name
 A name that can be used to distinguish instances of agents.
 

Friends

class Task
 

Detailed Description

Agent is a base class for all SMTK agents.

SMTK agents work within a Task and are used to both configure a task and validate task's state. Agents can be assigned to the ports of a task and control how the task responds to new data that is available on its input ports as well as the data produced on its output ports.

Subclasses of Agent are responsible for providing custom behavior that is required by the task in order for it to perform properly.

Member Enumeration Documentation

◆ CategoryEvaluation

The set of values that an agent's acceptChildCategories method can return.

Enumerator
Pass 

The agent would allow tasks with those categories to be children of the agent's task.

Reject 

The agent would disallow tasks with those categories to be children of the agent's task.

Neutral 

The agent would neither allow or disallow.

Member Function Documentation

◆ configure()

void smtk::task::Agent::configure ( const Configuration &  config)
virtual

Configure the agent based on a provided JSON configuration.

The base implementation will set m_name if provided.

Reimplemented in smtk::task::SubmitOperationAgent, smtk::task::PortForwardingAgent, smtk::task::FillOutAttributesAgent, smtk::task::TrivialProducerAgent, smtk::task::GatherObjectsAgent, and smtk::task::ChildCategoriesAgent.

◆ getViewData()

bool smtk::task::Agent::getViewData ( smtk::common::TypeContainer configuration) const
virtual

Insert view-related objects into configuration.

Subclasses should override this; the default implementation does nothing. This method should return true when configuration is modified and false otherwise.

Reimplemented in smtk::task::FillOutAttributesAgent.

◆ name()

smtk::string::Token smtk::task::Agent::name ( ) const
inline

Agents may have a name that can be used to distinguish them.

You are allowed to create multiple instances of an Agent subclass assigned to the same task. In order to distinguish them, you may assign them names. You are not required to name agents. Names must be specified by data passed to Agent::configure().

◆ portData()

std::shared_ptr< PortData > smtk::task::Agent::portData ( const Port port) const
virtual

Return the port data from the agent.

If the agent is not assigned to port, the method returns nullptr.

Reimplemented in smtk::task::SubmitOperationAgent, smtk::task::PortForwardingAgent, smtk::task::FillOutAttributesAgent, smtk::task::TrivialProducerAgent, and smtk::task::GatherObjectsAgent.

◆ portDataUpdated()

void smtk::task::Agent::portDataUpdated ( const Port port)
virtual

Tell the agent that the data on port has been updated.

This will be called when an input port connection is modified upstream of this agent, so port should always be an input port of this agent's parent task.

Reimplemented in smtk::task::SubmitOperationAgent, smtk::task::PortForwardingAgent, and smtk::task::FillOutAttributesAgent.

◆ taskStateChanged()

void smtk::task::Agent::taskStateChanged ( Task task,
State  prev,
State  next 
)
protectedvirtual

Receive notification that a Task's state has changed.

This method would allow a Task to delegate children state calculation to an Agent instead

Reimplemented in smtk::task::SubmitOperationAgent, and smtk::task::FillOutAttributesAgent.

◆ troubleshoot()

virtual std::string smtk::task::Agent::troubleshoot ( ) const
inlinevirtual

Return a description of actions users must take to make the agent's state completable.

Subclasses should override this method.

This should be XHTML text that can be inserted into an unordered HTML list (

) along with the text from other agent instances.

This should be an empty string when the agent's state is either completable or completed.

Reimplemented in smtk::task::SubmitOperationAgent, and smtk::task::TrivialProducerAgent.


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