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

Group is a task that owns children and draws its state from them. More...

#include <Group.h>

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

Public Member Functions

 smtkTypeMacro (smtk::task::Group)
 
 smtkSuperclassMacro (smtk::task::Task)
 
 smtkCreateMacro (smtk::task::Task)
 
 Group (const Configuration &config, const smtk::common::Managers::Ptr &managers=nullptr)
 
 Group (const Configuration &config, const PassedDependencies &dependencies, const smtk::common::Managers::Ptr &managers=nullptr)
 
void configure (const Configuration &config)
 
std::vector< Task::Ptr > children () const
 
bool hasChildren () const override
 Return whether or not the task has children. More...
 
smtk::common::Visit visit (RelatedTasks relation, Visitor visitor) const override
 Visit children. More...
 
const std::vector< std::weak_ptr< smtk::task::Adaptor > > & adaptors () const
 
void setAdaptorData (const std::string &tagName, Task::Configuration &config)
 Set/get adaptor configuration data passed to/from child tasks.
 
const Task::ConfigurationadaptorData () const
 
Task::ConfigurationadaptorData ()
 
Task::Configuration adaptorData (const std::string &key) const
 
smtk::common::Managers::Ptr managers () const
 Return the managers used to configure this Group.
 
- Public Member Functions inherited from smtk::task::Task
 smtkTypeMacroBase (smtk::task::Task)
 
 smtkCreateMacro (smtk::task::Task)
 
 Task (const Configuration &config, const std::shared_ptr< smtk::common::Managers > &managers=nullptr)
 
 Task (const Configuration &config, const PassedDependencies &dependencies, 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 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...
 
const std::set< std::string > & style () const
 Set/get style classes for the task. More...
 
bool addStyle (const std::string &styleClass)
 
bool removeStyle (const std::string &styleClass)
 
bool clearStyle ()
 
virtual bool getViewData (smtk::common::TypeContainer &configuration) const
 Populate a type-container with view-related data for configuration. More...
 
virtual State state () const
 Get the state. More...
 
bool markCompleted (bool completed)
 This public method allows user-interface components to indicate when the user marks a task complete (or unmarks it). More...
 
PassedDependencies dependencies () const
 Return the tasks which this task depends upon. 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.
 
Observersobservers ()
 Return this object's observers so other classes may insert themselves.
 
State internalState () const
 Return the internal state of the task. More...
 

Protected Member Functions

State computeInternalState () const
 Check m_resourcesByRole to see if all requirements are met.
 
void childStateChanged (Task &child, State prev, State next)
 
- Protected Member Functions inherited from smtk::task::Task
bool changeState (State previous, State next)
 Indicate the state has changed. More...
 
virtual bool updateState (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...
 
bool internalStateChanged (State next)
 Update the internal state, possibly transitioning the task's final state. More...
 

Protected Attributes

smtk::common::Managers::Ptr m_managers
 
std::map< Task::Ptr, Task::Observers::Key > m_children
 
std::vector< std::weak_ptr< smtk::task::Adaptor > > m_adaptors
 
Task::Configuration m_adaptorData
 
- Protected Attributes inherited from smtk::task::Task
std::string m_title
 A task name to present to the user.
 
std::set< std::string > m_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.
 
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.
 

Additional Inherited Members

- 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.
 

Detailed Description

Group is a task that owns children and draws its state from them.

A task group exists to organize a set of tasks.

The Group instance is responsible for configuring its children, including creating dependencies among them. The Group's state and output are dependent on its children.

The group has a "mode," which describes how children are related to one another: when the mode is parallel, children have no dependency on one another and the group itself is dependent on all of its children. When the mode is serial, children must be completed in the order specified (i.e., each successive task is dependent on its predecessor) and the group itself is dependent on the final child task.

Member Function Documentation

◆ hasChildren()

bool smtk::task::Group::hasChildren ( ) const
inlineoverridevirtual

Return whether or not the task has children.

By default, tasks do not support children.

Reimplemented from smtk::task::Task.

◆ visit()

smtk::common::Visit smtk::task::Group::visit ( RelatedTasks  relation,
Visitor  visitor 
) const
overridevirtual

Visit children.

If hasChildren returns false, this will return immediately.

For the signature taking a Visitor, this method returns smtk::common::Visit::Halt if iteration was terminated.

Subclasses that override hasChildren should override these methods.

Reimplemented from smtk::task::Task.


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