SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
10 #ifndef smtk_task_Task_h
11 #define smtk_task_Task_h
13 #include "smtk/resource/Component.h"
14 #include "smtk/resource/Resource.h"
16 #include "smtk/CoreExports.h"
18 #include "smtk/SystemConfig.h"
19 #include "smtk/common/Deprecation.h"
20 #include "smtk/common/Managers.h"
21 #include "smtk/common/Observers.h"
25 #include "nlohmann/json.hpp"
47 std::set<smtk::task::Task*>& workflows,
48 std::set<smtk::task::Task*>& visited);
49 SMTKCORE_EXPORT std::set<smtk::task::Task*>
workflowsOfTask(
const Task& task);
85 using Dependencies = std::map<WeakPtr, typename Observers::Key, std::owner_less<WeakPtr>>;
103 const Configuration& config,
105 const std::shared_ptr<smtk::common::Managers>& managers =
nullptr);
107 const Configuration& config,
108 const PassedDependencies& dependencies,
110 const std::shared_ptr<smtk::common::Managers>& managers =
nullptr);
112 ~
Task()
override =
default;
119 std::string
name()
const override {
return m_name; }
120 virtual void setName(
const std::string& name);
122 const std::shared_ptr<resource::Resource> resource()
const override;
132 void configure(
const Configuration& config);
135 SMTK_DEPRECATED_IN_24_01(
"Use name() instead.")
136 const std::
string& title()
const {
return m_name; }
140 SMTK_DEPRECATED_IN_24_01(
"Use setName() instead.")
141 void setTitle(const std::
string& title) { this->setName(title); }
147 const std::set<smtk::string::Token>&
style()
const {
return m_style; }
153 std::shared_ptr<smtk::view::Configuration> findViewFor(
219 virtual State state()
const;
229 virtual bool editableCompletion()
const;
243 virtual bool markCompleted(
bool completed);
261 PassedDependencies dependencies()
const;
270 bool canAddDependency(
const std::shared_ptr<Task>& dependency);
276 bool addDependency(
const std::shared_ptr<Task>& dependency);
282 template<
typename Container>
283 bool addDependencies(
const Container& tasks);
289 bool removeDependency(
const std::shared_ptr<Task>& dependency);
295 template<
typename Container>
296 bool removeDependencies(
const Container& tasks);
328 friend SMTKCORE_EXPORT
void
343 virtual bool updateState(
Task& dependency,
State prev,
State next);
350 bool internalStateChanged(
State next);
357 bool m_completed =
false;
362 bool m_strictDependencies =
false;
388 template<
typename Container>
391 bool addedAll =
true;
392 for (
const auto& task : tasks)
399 template<
typename Container>
402 bool removedAll =
true;
403 for (
const auto& task : tasks)
413 #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:89
std::string name() const override
Return the task's name.
Definition: Task.h:119
Observers & observers()
Return this object's observers so other classes may insert themselves.
Definition: Task.h:314
bool removeDependency(const std::shared_ptr< Task > &dependency)
Remove a dependency.
Definition: Task.cxx:382
Observers m_observers
The set of observers of this task's state.
Definition: Task.h:369
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:360
std::set< Ptr > PassedDependencies
A task's dependencies are other tasks passed as shared pointers.
Definition: Task.h:87
A task manager is responsible for creating new tasks.
Definition: Manager.h:68
bool addDependency(const std::shared_ptr< Task > &dependency)
Add a dependency.
Definition: Task.cxx:346
Manager * manager() const
Return the tasks's manager (or null if unmanaged).
Definition: Task.h:325
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:85
#define smtkCreateMacro(...)
Add static create() methods to a class.
Definition: SharedFromThis.h:173
bool areDependenciesStrict() const
Return true if this task has been configured with strict dependency enforcement.
Definition: Task.h:256
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:322
std::function< smtk::common::Visit(Task &)> Visitor
Signature of functions invoked when visiting dependencies or children while allowing early terminatio...
Definition: Task.h:92
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:58
#define smtkTypeMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:128
std::string m_name
A task name to present to the user.
Definition: Task.h:353
std::weak_ptr< smtk::task::Manager > m_manager
If this task is being managed, this will refer to its manager.
Definition: Task.h:376
virtual bool hasChildren() const
Return whether or not the task has children.
Definition: Task.h:303
smtk::common::Singleton< detail::Manager > Manager
The Manager is a singleton interface for registering available plugins to manager instances.
Definition: Manager.h:92
#define smtkSuperclassMacro(...)
Add a typedef to the superclass of this class.
Definition: SharedFromThis.h:147
std::function< void(Task &, State, State)> Observer
A task's state changes may be observed.
Definition: Task.h:81
Task is a base class for all SMTK tasks.
Definition: Task.h:73
std::set< smtk::string::Token > m_style
The set of style classes for this task.
Definition: Task.h:355
bool addDependencies(const Container &tasks)
Add a container of task-pointers as dependencies.
Definition: Task.h:389
A string token identified by an integer.
Definition: Token.h:29
smtk::common::UUID m_id
The unique identifier for this task.
Definition: Task.h:378
Task * parent() const
Return a parent task if one exists; null otherwise.
Definition: Task.h:299
Component is the base class for records stored in an smtk::resource::Resource.
Definition: Component.h:43
Macros for dealing with shared-pointer classes.
const common::UUID & id() const override
Set/get the task's unique identifier.
Definition: Task.h:115
std::set< WeakPtr, std::owner_less< WeakPtr > > m_dependents
Tasks upon which this task depends.
Definition: Task.h:367
bool removeDependencies(const Container &tasks)
Remove a container of task-pointers as dependencies.
Definition: Task.h:400
RelatedTasks
The types of related tasks to visit.
Definition: Task.h:95
A container for caching and retrieving instances of types.
Definition: TypeContainer.h:42