SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Track smtk::task::Task objects with smtk::common::Instances. More...
#include <Instances.h>
Public Types | |
using | WorkflowObserver = std::function< void(const std::set< Task * > &, WorkflowEvent, Task *)> |
The signature for observing workflow construction/destruction/modification. More... | |
using | WorkflowObservers = smtk::common::Observers< WorkflowObserver > |
Observers that are invoked when the workflow structure changes. | |
![]() | |
using | Superclass = smtk::common::Factory< BaseType, InputTypes... > |
An alias for the inherited parent class. | |
using | Observer = std::function< void(InstanceEvent, const std::shared_ptr< BaseType > &)> |
The signature of observers watching managed instance lifecycle events. | |
using | Observers = smtk::common::Observers< Observer > |
Access to the set of observers of instances. | |
using | Visitor = std::function< smtk::common::Visit(const std::shared_ptr< BaseType > &)> |
The signature used to visit managed instances of objects. | |
Public Member Functions | |
smtkTypeMacroBase (smtk::task::Instances) | |
smtkSuperclassMacro (smtk::task::TaskInstancesBase) | |
Instances (Manager &taskManager) | |
Instances (const Instances &)=delete | |
void | operator= (const Instances &)=delete |
const WorkflowObservers & | workflowObservers () const |
Return the set of workflow-event observers (so you can add yourself to it). | |
WorkflowObservers & | workflowObservers () |
bool | pauseWorkflowNotifications (bool doPause) |
Pause or resume workflow-event notifications. More... | |
bool | workflowEvent (const std::set< Task * > &workflows, WorkflowEvent event, Task *subject) |
Notify observers of a change. More... | |
std::set< smtk::task::Task::Ptr > | findByTitle (const std::string &title) const |
Returns the tasks with the given title. | |
smtk::task::Task::Ptr | findById (smtk::string::Token taskId) const |
Returns the task with the given (presumably unique) ID. | |
Task::Ptr | createFromName (const std::string &taskType) |
Task::Ptr | createFromName (const std::string &taskType, Task::Configuration &configuration, std::shared_ptr< smtk::common::Managers > managers) |
Task::Ptr | createFromName (const std::string &taskType, smtk::task::Task::Configuration &configuration, smtk::task::Task::PassedDependencies &dependencies, std::shared_ptr< smtk::common::Managers > managers) |
![]() | |
Instances () | |
Construct a manager of object instances. | |
Instances (const Instances &)=delete | |
Delete copy constructor and assignment operator. | |
void | operator= (const Instances &)=delete |
template<typename Type , typename... Args> | |
std::shared_ptr< Type > | create (Args &&... args) |
Create an instance of the given Type and manage it. | |
template<typename... Args> | |
std::shared_ptr< BaseType > | createFromName (const std::string &typeName, Args &&... args) |
Create and manage an instance of Type using its type-name. | |
template<typename... Args> | |
std::shared_ptr< BaseType > | createFromIndex (const std::size_t &typeIndex, Args &&... args) |
Create and manage an instance of a Type using its type-index. | |
bool | manage (const std::shared_ptr< BaseType > &instance) |
Manage an already-created instance of a class. More... | |
bool | unmanage (const std::shared_ptr< BaseType > &instance) |
Unmanage (drop the reference to) an instance. More... | |
bool | contains (const std::shared_ptr< BaseType > &instance) |
Determine whether instance is managed or not. | |
void | clear () |
Unmanage all instances. | |
Observers & | observers () |
Return the set of observers of instances (so that you can insert an observer). | |
smtk::common::Visit | visit (Visitor visitor) const |
Iterate over the collection of instances, invoking a visitor on each. More... | |
std::size_t | size () const |
Return the number of instances being managed. | |
![]() | |
bool | registerType () |
Register a Type to the factory. | |
bool | registerType (Metadata &&metadata) |
Register a Typeusing the Type's Metadata. | |
bool | registerTypes () |
Register a tuple of Types. | |
bool | unregisterType () |
Unregister a Type. | |
bool | unregisterType (const std::string &typeName) |
Unregister a Type using its type name. | |
bool | unregisterType (const std::size_t &typeIndex) |
Unregister a Type using its type index. | |
bool | unregisterTypes () |
Unregister a tuple of Types. | |
bool | contains () const |
Determine whether or not a Type is available. | |
bool | contains (const std::string &typeName) const |
Determine whether or not a Type is available using its type name. | |
bool | contains (const std::size_t typeIndex) const |
Determine whether or not a Type is available using its type index. | |
std::unique_ptr< Type > | create (Args &&... args) const |
Create an instance of a Type. | |
std::unique_ptr< BaseType > | createFromName (const std::string &typeName, Args &&... args) const |
Create an instance of a Type using its type name. | |
std::unique_ptr< BaseType > | createFromIndex (const std::size_t &typeIndex, Args &&... args) const |
Create an instance of a Type using its type name. | |
std::shared_ptr< Type > | make (Args &&... args) const |
Make a shared instance of a Type. | |
std::shared_ptr< BaseType > | makeFromName (const std::string &typeName, Args &&... args) const |
Make a shared instance of a Type using its type name. | |
std::shared_ptr< BaseType > | makeFromIndex (const std::size_t &typeIndex, Args &&... args) const |
Create an instance of a Type using its type name. | |
Interface< TagType, true > | get () const |
Access a convenience Interface for creating objects that singles out one of the three modes of creation: by type, by type name and by type index. | |
Protected Attributes | |
Manager & | m_taskManager |
WorkflowObservers | m_workflowObservers |
bool | m_workflowNotificationsPaused = false |
bool | m_needNotification = false |
Track smtk::task::Task objects with smtk::common::Instances.
This class adds an API for observing vectors of tasks that form workflows as instances are managed/unmanaged and dependencies are added/removed.
using smtk::task::Instances::WorkflowObserver = std::function<void(const std::set<Task*>&, WorkflowEvent, Task*)> |
The signature for observing workflow construction/destruction/modification.
The first parameter is the head task of the workflow (i.e., the one on which all others depend). The second parameter is the type of event and the third parameter is a task that is non-null only for WorkflowEvent::TaskAdded and WorkflowEvent::TaskRemoved events:
Task::Ptr smtk::task::Instances::createFromName | ( | const std::string & | taskType | ) |
Create a task given its class name and optionally more configuration data.
These override the base factory methods by supplying the task manager.
Task::Ptr smtk::task::Instances::createFromName | ( | const std::string & | taskType, |
smtk::task::Task::Configuration & | configuration, | ||
smtk::task::Task::PassedDependencies & | dependencies, | ||
std::shared_ptr< smtk::common::Managers > | managers | ||
) |
Create a task given its class name and optionally more configuration data.
These override the base factory methods by supplying the task manager.
Task::Ptr smtk::task::Instances::createFromName | ( | const std::string & | taskType, |
Task::Configuration & | configuration, | ||
std::shared_ptr< smtk::common::Managers > | managers | ||
) |
Create a task given its class name and optionally more configuration data.
These override the base factory methods by supplying the task manager.
bool smtk::task::Instances::pauseWorkflowNotifications | ( | bool | doPause | ) |
Pause or resume workflow-event notifications.
This exists so that deserialization does not generate many redundant events (e.g., creating a new head for each task then destroying each as dependencies are added).
bool smtk::task::Instances::workflowEvent | ( | const std::set< Task * > & | workflows, |
WorkflowEvent | event, | ||
Task * | subject | ||
) |
Notify observers of a change.
Use this method to invoke observers since it can be "paused" (i.e., no observers will be invoked if m_workflowNotificationsPaused is true).