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/Managers.h"
17 #include "smtk/common/Observers.h"
21 #include "nlohmann/json.hpp"
43 std::set<smtk::task::Task*>& workflows,
44 std::set<smtk::task::Task*>& visited);
45 SMTKCORE_EXPORT std::set<smtk::task::Task*>
workflowsOfTask(
const Task& task);
80 using Dependencies = std::map<WeakPtr, typename Observers::Key, std::owner_less<WeakPtr>>;
98 const Configuration& config,
99 const std::shared_ptr<smtk::common::Managers>& managers =
nullptr);
101 const Configuration& config,
102 const PassedDependencies& dependencies,
103 const std::shared_ptr<smtk::common::Managers>& managers =
nullptr);
105 virtual ~
Task() =
default;
115 void configure(
const Configuration& config);
118 const std::string&
title()
const {
return m_title; }
122 void setTitle(
const std::string& title);
128 const std::set<std::string>&
style()
const {
return m_style; }
129 bool addStyle(
const std::string& styleClass);
130 bool removeStyle(
const std::string& styleClass);
176 virtual State state()
const;
190 bool markCompleted(
bool completed);
196 PassedDependencies dependencies()
const;
202 bool addDependency(
const std::shared_ptr<Task>& dependency);
208 template<
typename Container>
209 bool addDependencies(
const Container& tasks);
215 bool removeDependency(
const std::shared_ptr<Task>& dependency);
221 template<
typename Container>
222 bool removeDependencies(
const Container& tasks);
251 friend SMTKCORE_EXPORT
void
266 virtual bool updateState(
Task& dependency,
State prev,
State next);
273 bool internalStateChanged(
State next);
280 bool m_completed =
false;
307 template<
typename Container>
310 bool addedAll =
true;
311 for (
const auto& task : tasks)
318 template<
typename Container>
321 bool removedAll =
true;
322 for (
const auto& task : tasks)
332 #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:84
Observers & observers()
Return this object's observers so other classes may insert themselves.
Definition: Task.h:240
bool removeDependency(const std::shared_ptr< Task > &dependency)
Remove a dependency.
Definition: Task.cxx:263
Observers m_observers
The set of observers of this task's state.
Definition: Task.h:290
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:283
std::set< Ptr > PassedDependencies
A task's dependencies are other tasks passed as shared pointers.
Definition: Task.h:82
std::string m_title
A task name to present to the user.
Definition: Task.h:276
const std::set< std::string > & style() const
Set/get style classes for the task.
Definition: Task.h:128
bool addDependency(const std::shared_ptr< Task > &dependency)
Add a dependency.
Definition: Task.cxx:214
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:80
#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
State internalState() const
Return the internal state of the task.
Definition: Task.h:248
std::function< smtk::common::Visit(Task &)> Visitor
Signature of functions invoked when visiting dependencies or children while allowing early terminatio...
Definition: Task.h:87
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:22
std::weak_ptr< smtk::task::Manager > m_manager
If this task is being managed, this will refer to its manager.
Definition: Task.h:297
std::set< std::string > m_style
The set of style classes for this task.
Definition: Task.h:278
virtual bool hasChildren() const
Return whether or not the task has children.
Definition: Task.h:229
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:76
const std::string & title() const
Return the title of the task (if one was provided).
Definition: Task.h:118
Task is a base class for all SMTK tasks.
Definition: Task.h:69
bool addDependencies(const Container &tasks)
Add a container of task-pointers as dependencies.
Definition: Task.h:308
Task * parent() const
Return a parent task if one exists; null otherwise.
Definition: Task.h:225
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:288
bool removeDependencies(const Container &tasks)
Remove a container of task-pointers as dependencies.
Definition: Task.h:319
RelatedTasks
The types of related tasks to visit.
Definition: Task.h:90
A container for caching and retrieving instances of types.
Definition: TypeContainer.h:37