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

TrivialProducerAgent outputs configured objects on output ports. More...

#include <TrivialProducerAgent.h>

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

Public Types

using State = smtk::task::State
 
using Configuration = nlohmann::json
 
- Public Types inherited from smtk::task::Agent
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

 smtkSuperclassMacro (smtk::task::Agent)
 
 smtkTypeMacro (smtk::task::TrivialProducerAgent)
 
 TrivialProducerAgent (Task *owningTask)
 
State state () const override
 Return the current state of the agent. More...
 
void configure (const Configuration &config) override
 Configure the agent based on a provided JSON configuration.
 
Configuration configuration () const override
 Produce a JSON configuration object for the current task state.
 
std::string troubleshoot () const override
 Provide feedback to users on how to make this agent completable.
 
std::shared_ptr< PortDataportData (const Port *port) const override
 Return the port data from the agent.
 
PortoutputPort () const
 Tell the agent that the data on port has been updated. More...
 
- Public Member Functions inherited from smtk::task::Agent
 smtkTypeMacroBase (smtk::task::Agent)
 
 Agent (Task *owningTask)
 
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 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.
 

Static Public Member Functions

static PortaddObjectInRole (Task *task, const std::string &agentName, smtk::string::Token role, smtk::resource::PersistentObject *object)
 A helper to add an object to a TrivialProducerAgent owned by a task. More...
 
static bool addObjectInRole (Task *task, Port *port, smtk::string::Token role, smtk::resource::PersistentObject *object)
 
static PortremoveObjectFromRole (Task *task, const std::string &agentName, smtk::string::Token role, smtk::resource::PersistentObject *object)
 A helper to remove an object from a TrivialProducerAgent owned by a task. More...
 
static bool removeObjectFromRole (Task *task, Port *port, smtk::string::Token role, smtk::resource::PersistentObject *object)
 
static PortresetData (Task *task, const std::string &agentName)
 A helper to reset a TrivialProducerAgent owned by a task. More...
 
static bool resetData (Task *task, Port *port)
 

Protected Member Functions

virtual State computeInternalState ()
 
- Protected Member Functions inherited from smtk::task::Agent
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

State m_internalState { State::Completable }
 
std::shared_ptr< ObjectsInRolesm_data
 
std::map< smtk::string::Token, std::pair< int, int > > m_requiredObjectCounts
 
Portm_outputPort { nullptr }
 
- Protected Attributes inherited from smtk::task::Agent
smtk::task::Taskm_parent
 
smtk::string::Token m_name
 A name that can be used to distinguish instances of agents.
 

Detailed Description

TrivialProducerAgent outputs configured objects on output ports.

This agent exists so that operations such as EmplaceWorklet can assign objects to a task. The downstream or child tasks of this agent's task will then be configured with the objects in the roles as configured.

Unless the task's configuration includes a minimum/maximum count of objects per role, the task will always be completable.

Member Function Documentation

◆ addObjectInRole()

Port * smtk::task::TrivialProducerAgent::addObjectInRole ( Task task,
const std::string &  agentName,
smtk::string::Token  role,
smtk::resource::PersistentObject object 
)
static

A helper to add an object to a TrivialProducerAgent owned by a task.

Note that if multiple agents match the same agentName or port, only the first occurence will have object inserted.

We notify downstream observers of the agent's output port with a call to portDataUpdated(); be careful as this call to add objects is expected to be called during an operation (which may run on a non-GUI thread).

◆ outputPort()

Port* smtk::task::TrivialProducerAgent::outputPort ( ) const
inline

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

Return the port this agent broadcasts its data to.

◆ removeObjectFromRole()

Port * smtk::task::TrivialProducerAgent::removeObjectFromRole ( Task task,
const std::string &  agentName,
smtk::string::Token  role,
smtk::resource::PersistentObject object 
)
static

A helper to remove an object from a TrivialProducerAgent owned by a task.

Note that if multiple agents match the same agentName or port, only the first occurence will have object removed.

We notify downstream observers of the agent's output port with a call to portDataUpdated(); be careful as this call to add objects is expected to be called during an operation (which may run on a non-GUI thread).

◆ resetData()

Port * smtk::task::TrivialProducerAgent::resetData ( Task task,
const std::string &  agentName 
)
static

A helper to reset a TrivialProducerAgent owned by a task.

Note that if multiple agents match the same agentName, the first of them will be reset. If multiple agents match the same port, all of them will be reset. This is done so that the variant which accepts an agentName can return the modified Port. (Operations which modify ports must add them to the operation result.)

We notify downstream observers of the agent's output port with a call to portDataUpdated(); be careful as this call to add objects is expected to be called during an operation (which may run on a non-GUI thread).

◆ state()

State smtk::task::TrivialProducerAgent::state ( ) const
overridevirtual

Return the current state of the agent.

By default, this agent will always be completable, even if no resources are assigned. However, if the agent's configuration contains minimum/maximum counts for objects by role, the state will only be completable when the number of objects in each specified role is in the allowed range.

Implements smtk::task::Agent.


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