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

FillOutAttributes is a task that is incomplete until specified attributes are valid. More...

#include <FillOutAttributes.h>

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

Classes

struct  AttributeSet
 A predicate used to collect resources that fit a given role. More...
 
struct  ResourceAttributes
 Per-resource sets of validated attributes. More...
 

Public Types

using AttributeSetVisitor = std::function< smtk::common::Visit(AttributeSet &)>
 Signatures of functors that visit resources-by-role predicates.
 
using ConstAttributeSetVisitor = std::function< smtk::common::Visit(const AttributeSet &)>
 
- Public Types inherited from smtk::task::Task
enum  RelatedTasks { RelatedTasks::Depend, RelatedTasks::Child }
 The types of related tasks to visit. More...
 
using Observer = std::function< void(Task &, State, State)>
 A task's state changes may be observed.
 
using Observers = smtk::common::Observers< Observer >
 The collection of all observers of this task instance.
 
using Dependencies = std::map< WeakPtr, typename Observers::Key, std::owner_less< WeakPtr > >
 A task's dependencies are other tasks stored as weak pointers.
 
using PassedDependencies = std::set< Ptr >
 A task's dependencies are other tasks passed as shared pointers.
 
using Configuration = nlohmann::json
 Tasks are configured with arbitrary JSON objects, though this may change.
 
using Visitor = std::function< smtk::common::Visit(Task &)>
 Signature of functions invoked when visiting dependencies or children while allowing early termination.
 
- 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::FillOutAttributes)
 
 smtkSuperclassMacro (smtk::task::AgentlessTask)
 
 smtkCreateMacro (smtk::resource::PersistentObject)
 
 FillOutAttributes (const Configuration &config, Manager &taskManager, const smtk::common::Managers::Ptr &managers=nullptr)
 
 FillOutAttributes (const Configuration &config, const PassedDependencies &dependencies, Manager &taskManager, const smtk::common::Managers::Ptr &managers=nullptr)
 
void configure (const Configuration &config)
 Parse configuration information to initialize this instance.
 
const std::unordered_map< smtk::string::Token, Port * > & ports () const override
 Report this task's ports.
 
std::shared_ptr< PortDataportData (const Port *port) const override
 Return data for this task's output port. More...
 
void portDataUpdated (const Port *port) override
 Update the task based on new port data.
 
bool getViewData (smtk::common::TypeContainer &configuration) const override
 Provide the attribute resource(s) that the user should edit.
 
smtk::common::Visit visitAttributeSets (ConstAttributeSetVisitor visitor) const
 
smtk::common::Visit visitAttributeSets (AttributeSetVisitor visitor)
 
- Public Member Functions inherited from smtk::task::AgentlessTask
 smtkTypeMacro (smtk::task::AgentlessTask)
 
 smtkSuperclassMacro (smtk::task::Task)
 
 smtkCreateMacro (smtk::resource::PersistentObject)
 
 AgentlessTask (const Configuration &config, Manager &taskManager, const std::shared_ptr< smtk::common::Managers > &managers=nullptr)
 
 AgentlessTask (const Configuration &config, const PassedDependencies &dependencies, Manager &taskManager, const std::shared_ptr< smtk::common::Managers > &managers=nullptr)
 
bool updateAgentState (const Agent *agent, State prev, State next, bool signal) override
 Updates the state of the task based on the change of an agent. More...
 
State internalState () const
 
- Public Member Functions inherited from smtk::task::Task
 smtkTypeMacro (smtk::task::Task)
 
 smtkSuperclassMacro (smtk::resource::Component)
 
 smtkCreateMacro (smtk::resource::PersistentObject)
 
 Task (const Configuration &config, Manager &taskManager, const std::shared_ptr< smtk::common::Managers > &managers=nullptr)
 
 Task (const Configuration &config, const PassedDependencies &dependencies, Manager &taskManager, const std::shared_ptr< smtk::common::Managers > &managers=nullptr)
 
void configure (const Configuration &config)
 A method called by all constructors passed Configuration information. More...
 
const common::UUIDid () 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 void setName (const std::string &name)
 
const std::shared_ptr< resource::Resourceresource () const override
 Components are required to return their owning resource (if any). More...
 
const std::string & title () const
 Return the title of the task (if one was provided).
 
void setTitle (const std::string &title)
 Set the title of the task to be presented to users. More...
 
virtual std::string information (const InformationOptions &opts=InformationOptions()) const
 Return user-presentable information about the task in XHTML form. More...
 
void setDescription (const std::string &description)
 Set/get a description of the task provided by workflow designers. More...
 
const std::string & description () const
 
std::string & description ()
 
bool changePortName (Port *port, const std::string &newName, std::function< bool()> fp)
 Change the Name of a Port. More...
 
const std::unordered_set< smtk::string::Token > & style () const
 Set/get style classes for the task. More...
 
bool addStyle (const smtk::string::Token &styleClass)
 
bool removeStyle (const smtk::string::Token &styleClass)
 
bool clearStyle ()
 
virtual State state () const
 Get the state. More...
 
bool isCompleted () const
 Return whether or not the task has been marked completed.
 
State agentState () const
 Returns the state of a task's agents.
 
State childrenState () const
 Returns the state of a task's children.
 
State dependencyState () const
 Returns the state of a task's dependencies.
 
virtual bool editableCompletion () const
 Return whether or not users are allowed to mark a task completed. More...
 
virtual bool markCompleted (bool completed)
 This public method allows user-interface components to indicate when the user marks a task complete (or unmarks it). More...
 
bool areDependenciesStrict () const
 Return true if this task has been configured with strict dependency enforcement. More...
 
PassedDependencies dependencies () const
 Return the tasks which this task depends upon. More...
 
bool canAddDependency (const std::shared_ptr< Task > &dependency)
 Check whether inserting a dependency would induce a cycle. More...
 
bool addDependency (const std::shared_ptr< Task > &dependency)
 Add a dependency. More...
 
template<typename Container >
bool addDependencies (const Container &tasks)
 Add a container of task-pointers as dependencies. More...
 
bool removeDependency (const std::shared_ptr< Task > &dependency)
 Remove a dependency. More...
 
template<typename Container >
bool removeDependencies (const Container &tasks)
 Remove a container of task-pointers as dependencies. More...
 
Taskparent () const
 Return a parent task if one exists; null otherwise.
 
std::unordered_set< const Task * > ancestors () const
 Returns the ancestral tasks related to this one. More...
 
std::vector< Task * > lineage () const
 Returns the lineage of this task. More...
 
virtual smtk::common::Visit visit (RelatedTasks relation, Visitor visitor) const
 Visit children. More...
 
virtual bool hasChildren () const
 Return whether or not the task has children.
 
bool canAddChild (const std::shared_ptr< Task > &child) const
 Check whether adding a child task would induce a cycle.
 
bool addChild (const std::shared_ptr< Task > &child)
 Add a child task. More...
 
template<typename Container >
bool addChildren (const Container &tasks)
 Add a container of task-pointers as children. More...
 
bool removeChild (const std::shared_ptr< Task > &child)
 Remove a child task. More...
 
template<typename Container >
bool removeChildren (const Container &tasks)
 Remove a container of task-pointers as children. More...
 
const std::unordered_set< Task * > & children () const
 Return the children of the task.
 
std::unordered_set< Agent * > agents () const
 Return the agents of the task. More...
 
Observersobservers ()
 Return this object's observers so other classes may insert themselves.
 
bool acceptsChildCategories (const std::set< std::string > &cats) const
 Evaluates a set of categories that are associated with a potential child task and return true if the the categories pass the task's agent check. More...
 
Managermanager () const
 Return the tasks's manager (or null if unmanaged).
 
std::shared_ptr< smtk::common::Managersmanagers () const
 Return the application-state container. More...
 
bool hasInternalPorts () const
 Returns true if the task contains any internal ports.
 
bool canAcceptWorklets () const
 Return true if the task can accept any worklets.
 
- Public Member Functions inherited from smtk::resource::Component
 smtkTypeMacro (smtk::resource::Component)
 
 smtkSuperclassMacro (smtk::resource::PersistentObject)
 
 smtkSharedFromThisMacro (smtk::resource::PersistentObject)
 
ResourceparentResource () 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.
 
Linkslinks () override
 Return the links that connect this component to external resources/components.
 
const Linkslinks () const override
 
Propertiesproperties () override
 Return properties defined on this component.
 
const Propertiesproperties () 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.
 

Protected Member Functions

bool initializeResources ()
 Initialize with a list of resources from manager in m_managers.
 
bool updateResourceEntry (smtk::attribute::Resource &resource, const AttributeSet &predicate, ResourceAttributes &entry)
 Update a single resource in a predicate.
 
int update (const smtk::operation::Operation &op, smtk::operation::EventType event, smtk::operation::Operation::Result result)
 Respond to operations that may change task state.
 
State computeInternalState () const override
 Check m_resourcesByRole to see if all requirements are met.
 
bool hasRelevantInfomation (const smtk::resource::ManagerPtr &resourceManager, bool &foundResources) const
 
bool hasRelevantInformation (const smtk::resource::ManagerPtr &resourceManager, bool &foundResources) const
 Returns true if the task has relevant information in terms of its definitions and instances. More...
 
- Protected Member Functions inherited from smtk::task::AgentlessTask
State computeAgentState () const override
 Compute the state based on state of the task's agents.
 
bool internalStateChanged (State next)
 
- Protected Member Functions inherited from smtk::task::Task
bool changeState (State previous, State next)
 Indicate the state of this task has changed. More...
 
bool addChild (const std::shared_ptr< Task > &child, const std::unordered_set< const Task * > &taskSet)
 Adds a child to a task. More...
 
virtual bool updateDependencyState (Task &dependency, State prev, State next)
 Update our state because a dependent task has changed state or a subclass has marked the internal state as changed. More...
 
virtual bool updateChildrenState (const Task *child, State prev, State next)
 Updates the state of the task based on the change of a child task. More...
 
virtual State computeDependencyState () const
 Compute the state based on the state of the task's dependencies. More...
 
virtual State computeChildrenState () const
 Compute the state based on the state of the task's children.
 
std::shared_ptr< PortDataoutputPortData (const Port *port) const
 Produce port data for an output port of this task by querying its agents.
 
std::shared_ptr< PortDatainputPortData (const Port *port) const
 Produce port data for an input port of this task by querying its connections.
 

Static Protected Member Functions

static bool testValidity (const smtk::attribute::AttributePtr &attribute, ResourceAttributes &resourceAtts)
 Determine if an attribute needs to be tested for its validity. More...
 

Protected Attributes

smtk::common::Managers::Ptr m_managers
 
smtk::operation::Observers::Key m_observer
 
std::vector< AttributeSetm_attributeSets
 
std::unordered_map< smtk::string::Token, Port * > m_ports
 
- Protected Attributes inherited from smtk::task::Task
std::string m_name
 A task name to present to the user.
 
std::string m_description
 A description of the task provided by a workflow designer.
 
std::unordered_set< smtk::string::Tokenm_style
 The set of style classes for this task.
 
bool m_completed = false
 Whether the user has marked the task completed or not.
 
std::map< WeakPtr, Observers::Key, std::owner_less< WeakPtr > > m_dependencies
 A set of dependent tasks and the keys used to observe their state so that this task can update its state in response.
 
bool m_strictDependencies = false
 Should dependencies be strictly enforced?
 
std::set< WeakPtr, std::owner_less< WeakPtr > > m_dependents
 Tasks upon which this task depends. More...
 
Observers m_observers
 The set of observers of this task's state.
 
Taskm_parent = nullptr
 If this task is the child of another task, this pointer references its parent. More...
 
std::weak_ptr< smtk::task::Managerm_manager
 If this task is being managed, this will refer to its manager.
 
smtk::common::UUID m_id
 The unique identifier for this task.
 
std::unordered_set< Task * > m_children
 The children of the task.
 
std::unordered_set< std::unique_ptr< Agent > > m_agents
 The agents of the task.
 
std::unordered_map< smtk::string::Token, Port * > m_ports
 The ports of the Task.
 
State m_agentState = State::Completable
 
State m_dependencyState = State::Irrelevant
 
State m_childrenState = State::Irrelevant
 

Friends

class adaptor::ResourceAndRole
 

Detailed Description

FillOutAttributes is a task that is incomplete until specified attributes are valid.

This task accepts an input attribute resource (configured by a predecessor task or specified via a role) and observe an operation manager for operations. After each operation, attributes with a definition are validated. If all attributes identify are valid, the task becomes completable. Otherwise, the task will remain (or become) incomplete.

FillOutAttributes has a single input and output port, both of which pass PortData of type ObjectsInRoles. The task itself is configured with AttributeSet instances that specify a role and the port-data is searched for these roles in order to configure attributes to be filled out. The output port contains only the attribute(s) configured by this task and does not include upstream port information so that when the output port is marked as modified it is possible for downstream tasks to be certain that it is the attributes in question that have been updated.

Member Function Documentation

◆ hasRelevantInformation()

bool smtk::task::FillOutAttributes::hasRelevantInformation ( const smtk::resource::ManagerPtr resourceManager,
bool &  foundResources 
) const
protected

Returns true if the task has relevant information in terms of its definitions and instances.

The task has relevant information if any of its definitions' or instances' isRelevant() methods return true. It will also indicate if it found any of its required resources via the foundResources parameter.

◆ portData()

std::shared_ptr< PortData > smtk::task::FillOutAttributes::portData ( const Port port) const
overridevirtual

Return data for this task's output port.

This task only has one port. Resources for each attribute-set's roles are reported. No upstream port data is transmitted to the downstream port.

Reimplemented from smtk::task::Task.

◆ testValidity()

bool smtk::task::FillOutAttributes::testValidity ( const smtk::attribute::AttributePtr attribute,
ResourceAttributes resourceAtts 
)
staticprotected

Determine if an attribute needs to be tested for its validity.

Returns true if the attribute was not already contained in resourceAtts


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