SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
10 #ifndef smtk_operation_Operation_h
11 #define smtk_operation_Operation_h
13 #include "smtk/resource/Lock.h"
39 class ImportPythonOperation;
43 using Handler = std::function<void(Operation&,
const std::shared_ptr<smtk::attribute::Attribute>&)>;
47 std::weak_ptr<smtk::resource::Resource>,
48 smtk::resource::LockType,
49 std::owner_less<std::weak_ptr<smtk::resource::Resource>>>;
69 typedef std::size_t Index;
72 typedef std::shared_ptr<smtk::attribute::Attribute> Parameters;
75 typedef std::shared_ptr<smtk::attribute::Attribute> Result;
79 typedef std::shared_ptr<smtk::attribute::Resource> Specification;
81 typedef std::shared_ptr<smtk::attribute::Definition> Definition;
102 virtual Index index()
const {
return std::type_index(
typeid(*
this)).hash_code(); }
126 virtual bool configure(
133 virtual bool ableToOperate();
153 Outcome safeOperate();
154 Outcome safeOperate(Handler handler);
164 virtual bool releaseResult(Result& result);
175 Specification specification();
180 Parameters parameters();
181 Parameters parameters()
const;
185 Result createResult(Outcome);
191 bool restoreTrace(
const std::string& trace);
194 void setManagers(
const std::shared_ptr<smtk::common::Managers>& m) { m_managers = m; }
195 std::shared_ptr<smtk::common::Managers> managers()
const {
return m_managers; }
213 virtual Result operateInternal() = 0;
218 virtual void postProcessResult(Result&) {}
223 virtual void markModifiedResources(Result&);
226 virtual bool unmanageResources(Result&);
230 virtual void generateSummary(Result&);
234 Specification createBaseSpecification()
const;
236 int m_debugLevel{ 0 };
237 std::weak_ptr<Manager> m_manager;
238 std::shared_ptr<smtk::common::Managers> m_managers;
249 explicit Key() =
default;
250 Key(std::initializer_list<int>) {}
254 Result operate(
Key) {
return operateInternal(); }
261 virtual Specification createSpecification() = 0;
263 Specification m_specification;
264 Parameters m_parameters;
265 Definition m_resultDefinition;
266 std::vector<std::weak_ptr<smtk::attribute::Attribute>> m_results;
279 #endif // smtk_operation_Operation_h
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
An operation Manager is responsible for creating new operations and filtering operations based on inp...
Definition: Manager.h:42
Outcome
Definition: Operation.h:84
A class for adding python operations to the current session.
Definition: ImportPythonOperation.h:27
Operation::Outcome outcome(const Operation::Result &result)
Return the outcome of an operation given its result object.
Definition: Operation.cxx:626
Log messages for later presentation to a user or a file.
Definition: Logger.h:94
#define smtkEnableSharedPtr(...)
An abbreviation for enabling shared pointers.
Definition: SharedFromThis.h:214
smtk::shared_ptr< smtk::operation::Manager > ManagerPtr
Definition: PublicPointerDefs.h:355
std::map< std::weak_ptr< smtk::resource::Resource >, smtk::resource::LockType, std::owner_less< std::weak_ptr< smtk::resource::Resource > >> ResourceAccessMap
Hold a set of resources to be locked for an operation along with the type of lock to acquire.
Definition: Operation.h:49
Operation is a base class for all SMTK operations.
Definition: Operation.h:61
smtk::shared_ptr< smtk::attribute::Attribute > AttributePtr
Definition: PublicPointerDefs.h:463
A helper for dealing with serialization/deserialization done within an operation.
Definition: Helper.h:25
Definition: Operation.h:247
smtk::common::Singleton< detail::Manager > Manager
The Manager is a singleton interface for registering available plugins to manager instances.
Definition: Manager.h:92
void setManagers(const std::shared_ptr< smtk::common::Managers > &m)
Operations may be passed application state in the form of a Managers type-container.
Definition: Operation.h:194
ManagerPtr manager() const
Operations that are managed have a non-null pointer to their manager.
Definition: Operation.h:188
smtk::shared_ptr< smtk::attribute::Item > ItemPtr
Definition: PublicPointerDefs.h:474
Macros for dealing with shared-pointer classes.
#define smtkTypeMacroBase(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:131
smtk::shared_ptr< smtk::resource::Manager > ManagerPtr
Definition: PublicPointerDefs.h:288
virtual bool threadSafe() const
Is this type of operation safe to launch in a thread?
Definition: Operation.h:198