SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
10 #ifndef smtk_operation_Operation_h
11 #define smtk_operation_Operation_h
13 #include "smtk/CoreExports.h"
35 class ImportPythonOperation;
39 using Handler = std::function<void(Operation&,
const std::shared_ptr<smtk::attribute::Attribute>&)>;
57 typedef std::size_t Index;
60 typedef std::shared_ptr<smtk::attribute::Attribute> Parameters;
63 typedef std::shared_ptr<smtk::attribute::Attribute> Result;
67 typedef std::shared_ptr<smtk::attribute::Resource> Specification;
69 typedef std::shared_ptr<smtk::attribute::Definition> Definition;
90 virtual Index index()
const {
return std::type_index(
typeid(*
this)).hash_code(); }
114 virtual bool configure(
121 virtual bool ableToOperate();
141 Outcome safeOperate();
142 Outcome safeOperate(Handler handler);
152 virtual bool releaseResult(Result& result);
163 Specification specification();
168 Parameters parameters();
169 Parameters parameters()
const;
173 Result createResult(Outcome);
179 bool restoreTrace(
const std::string& trace);
182 void setManagers(
const std::shared_ptr<smtk::common::Managers>& m) { m_managers = m; }
183 std::shared_ptr<smtk::common::Managers> managers()
const {
return m_managers; }
195 virtual Result operateInternal() = 0;
200 virtual void postProcessResult(Result&) {}
205 virtual void markModifiedResources(Result&);
208 virtual bool unmanageResources(Result&);
212 virtual void generateSummary(Result&);
216 Specification createBaseSpecification()
const;
218 int m_debugLevel{ 0 };
219 std::weak_ptr<Manager> m_manager;
220 std::shared_ptr<smtk::common::Managers> m_managers;
231 explicit Key() =
default;
232 Key(std::initializer_list<int>) {}
236 Result operate(
Key) {
return operateInternal(); }
243 virtual Specification createSpecification() = 0;
245 Specification m_specification;
246 Parameters m_parameters;
247 Definition m_resultDefinition;
248 std::vector<std::weak_ptr<smtk::attribute::Attribute>> m_results;
253 #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:72
A class for adding python operations to the current session.
Definition: ImportPythonOperation.h:27
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:154
smtk::shared_ptr< smtk::operation::Manager > ManagerPtr
Definition: PublicPointerDefs.h:348
Operation is a base class for all SMTK operations.
Definition: Operation.h:51
smtk::shared_ptr< smtk::attribute::Attribute > AttributePtr
Definition: PublicPointerDefs.h:456
Definition: Operation.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
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:182
ManagerPtr manager() const
Operations that are managed have a non-null pointer to their manager.
Definition: Operation.h:176
smtk::shared_ptr< smtk::attribute::Item > ItemPtr
Definition: PublicPointerDefs.h:467
Macros for dealing with shared-pointer classes.
#define smtkTypeMacroBase(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:55
smtk::shared_ptr< smtk::resource::Manager > ManagerPtr
Definition: PublicPointerDefs.h:281
virtual bool threadSafe() const
Is this type of operation safe to launch in a thread?
Definition: Operation.h:186