SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
10 #ifndef smtk_task_Task_h
11 #define smtk_task_Task_h
13 #include "smtk/CoreExports.h"
15 #include "smtk/SystemConfig.h"
16 #include "smtk/common/Deprecation.h"
17 #include "smtk/common/Managers.h"
18 #include "smtk/common/Observers.h"
22 #include "nlohmann/json.hpp"
44 std::set<smtk::task::Task*>& workflows,
45 std::set<smtk::task::Task*>& visited);
46 SMTKCORE_EXPORT std::set<smtk::task::Task*>
workflowsOfTask(
const Task& task);
81 using Dependencies = std::map<WeakPtr, typename Observers::Key, std::owner_less<WeakPtr>>;
98 SMTK_DEPRECATED_IN_23_02(
"Use variants that accept a task::Manager&.")
100 const Configuration& config,
101 const std::shared_ptr<
smtk::common::Managers>& managers =
nullptr);
103 const Configuration& config,
105 const std::shared_ptr<
smtk::common::Managers>& managers =
nullptr);
106 SMTK_DEPRECATED_IN_23_02("Use variants that accept a task::
Manager&.")
108 const Configuration& config,
109 const PassedDependencies& dependencies,
110 const std::shared_ptr<
smtk::common::Managers>& managers =
nullptr);
112 const Configuration& config,
113 const PassedDependencies& dependencies,
115 const std::shared_ptr<
smtk::common::Managers>& managers =
nullptr);
117 virtual ~
Task() = default;
124 smtk::
string::Token
id()
const {
return m_id; }
134 void configure(
const Configuration& config);
137 const std::string&
title()
const {
return m_title; }
141 void setTitle(
const std::string& title);
147 const std::set<smtk::string::Token>&
style()
const {
return m_style; }
195 virtual State state()
const;
209 bool markCompleted(
bool completed);
215 PassedDependencies dependencies()
const;
221 bool addDependency(
const std::shared_ptr<Task>& dependency);
227 template<
typename Container>
228 bool addDependencies(
const Container& tasks);
234 bool removeDependency(
const std::shared_ptr<Task>& dependency);
240 template<
typename Container>
241 bool removeDependencies(
const Container& tasks);
273 friend SMTKCORE_EXPORT
void
288 virtual bool updateState(
Task& dependency,
State prev,
State next);
295 bool internalStateChanged(
State next);
302 bool m_completed =
false;
334 template<
typename Container>
337 bool addedAll =
true;
338 for (
const auto& task : tasks)
345 template<
typename Container>
348 bool removedAll =
true;
349 for (
const auto& task : tasks)
359 #endif // smtk_task_Task_h
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
@ Completable
The task is available and accomplished but has not been marked complete.
nlohmann::json Configuration
Tasks are configured with arbitrary JSON objects, though this may change.
Definition: Task.h:85
Observers & observers()
Return this object's observers so other classes may insert themselves.
Definition: Task.h:259
bool removeDependency(const std::shared_ptr< Task > &dependency)
Remove a dependency.
Definition: Task.cxx:325
Observers m_observers
The set of observers of this task's state.
Definition: Task.h:312
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 st...
Definition: Task.h:305
std::set< Ptr > PassedDependencies
A task's dependencies are other tasks passed as shared pointers.
Definition: Task.h:83
std::string m_title
A task name to present to the user.
Definition: Task.h:298
A task manager is responsible for creating new tasks.
Definition: Manager.h:46
bool addDependency(const std::shared_ptr< Task > &dependency)
Add a dependency.
Definition: Task.cxx:276
Manager * manager() const
Return the tasks's manager (or null if unmanaged).
Definition: Task.h:270
State
The set of states that a task may take on.
Definition: State.h:29
std::map< WeakPtr, typename Observers::Key, std::owner_less< WeakPtr > > Dependencies
A task's dependencies are other tasks stored as weak pointers.
Definition: Task.h:81
#define smtkCreateMacro(...)
Add static create() methods to a class.
Definition: SharedFromThis.h:113
#define smtkEnableSharedPtr(...)
An abbreviation for enabling shared pointers.
Definition: SharedFromThis.h:154
Visit
Return values common to most visitor methods.
Definition: Visit.h:23
const std::set< smtk::string::Token > & style() const
Set/get style classes for the task.
Definition: Task.h:147
State internalState() const
Return the internal state of the task.
Definition: Task.h:267
std::function< smtk::common::Visit(Task &)> Visitor
Signature of functions invoked when visiting dependencies or children while allowing early terminatio...
Definition: Task.h:88
smtk::string::Token m_id
The unique identifier for this task.
Definition: Task.h:321
void workflowsOfTask(Task *task, std::set< smtk::task::Task * > &workflows, std::set< smtk::task::Task * > &visited)
Free functions that populate a set of workflow "head" tasks for an input task (this is the set of tas...
Definition: Task.cxx:25
std::weak_ptr< smtk::task::Manager > m_manager
If this task is being managed, this will refer to its manager.
Definition: Task.h:319
virtual bool hasChildren() const
Return whether or not the task has children.
Definition: Task.h:248
smtk::common::Singleton< detail::Manager > Manager
The Manager is a singleton interface for registering available plugins to manager instances.
Definition: Manager.h:92
std::function< void(Task &, State, State)> Observer
A task's state changes may be observed.
Definition: Task.h:77
const std::string & title() const
Return the title of the task (if one was provided).
Definition: Task.h:137
Task is a base class for all SMTK tasks.
Definition: Task.h:70
std::set< smtk::string::Token > m_style
The set of style classes for this task.
Definition: Task.h:300
bool addDependencies(const Container &tasks)
Add a container of task-pointers as dependencies.
Definition: Task.h:335
A string token identified by an integer.
Definition: Token.h:30
Task * parent() const
Return a parent task if one exists; null otherwise.
Definition: Task.h:244
Macros for dealing with shared-pointer classes.
#define smtkTypeMacroBase(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:55
std::set< WeakPtr, std::owner_less< WeakPtr > > m_dependents
Tasks upon which this task depends.
Definition: Task.h:310
bool removeDependencies(const Container &tasks)
Remove a container of task-pointers as dependencies.
Definition: Task.h:346
RelatedTasks
The types of related tasks to visit.
Definition: Task.h:91
A container for caching and retrieving instances of types.
Definition: TypeContainer.h:37