SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
This object provides applications a way to change and observe the active task. More...
#include <Active.h>
Classes | |
struct | Internal |
Public Types | |
using | Observer = std::function< void(smtk::task::Task *, smtk::task::Task *)> |
The signature for observers of the active task. More... | |
using | Observers = smtk::common::Observers< smtk::task::Active::Observer > |
The container for registered observers. | |
Public Member Functions | |
smtkTypeMacroBase (smtk::task::Active) | |
Active (smtk::task::Instances *instances=nullptr) | |
Construct an active-task tracker. | |
smtk::task::Task * | task () const |
Return the active task (or nullptr if no task is active). | |
bool | switchTo (smtk::task::Task *) |
Change the active task (or abandon the currently-active task by passing nullptr). More... | |
Observers & | observers () |
Return the set of active-task observers (so you can insert yourself). | |
const Observers & | observers () const |
This object provides applications a way to change and observe the active task.
If passed an smtk::task::Manager::Instances object at construction, only managed tasks may be active. This ensures that before a task is destroyed this object can notify observers the active task is becoming inactive.
If not passed an smtk::task::Manager::Instances object at construction, any task may become active but unmanaged tasks might be deleted without any notification that the active task changed. You are strongly encouraged to pass Instances to the constructor.
using smtk::task::Active::Observer = std::function<void(smtk::task::Task*, smtk::task::Task*)> |
The signature for observers of the active task.
Observers are passed the previously-active task and the soon-to-be-active task.
Note that either task may be null (i.e., it is possible to have no active task).
bool smtk::task::Active::switchTo | ( | smtk::task::Task * | task | ) |
Change the active task (or abandon the currently-active task by passing nullptr).
This method returns true if the active task changed and false otherwise. Passing a task that is not managed by instances passed to the constructor will always return false. Passing a task that is already active or unavailable will return false.