11 #ifndef smtk_project_OperationFactory_h
12 #define smtk_project_OperationFactory_h
14 #include "smtk/CoreExports.h"
19 #include "smtk/operation/Operation.h"
38 bool registerOperation(
const std::string&);
39 bool registerOperation(
const smtk::operation::Operation::Index&);
40 template<
typename OperationType>
41 bool registerOperation();
44 bool registerOperations(
const std::set<std::string>&);
48 bool unregisterOperation(
const std::string&);
49 bool unregisterOperation(
const smtk::operation::Operation::Index&);
50 template<
typename OperationType>
51 bool unregisterOperation();
54 std::shared_ptr<smtk::operation::Operation> create(
const std::string&);
55 std::shared_ptr<smtk::operation::Operation> create(
const smtk::operation::Operation::Index&);
56 template<
typename OperationType>
57 smtk::shared_ptr<OperationType> create();
62 const std::set<std::string>&
types()
const {
return m_types; }
63 std::set<std::string>& types() {
return m_types; }
67 std::set<smtk::operation::Operation::Index> availableOperations(
70 std::shared_ptr<smtk::operation::Manager> manager()
const {
return m_manager.lock(); }
72 void setManager(
const std::weak_ptr<smtk::operation::Manager>& manager) { m_manager = manager; }
75 std::set<std::string> m_types;
76 std::weak_ptr<smtk::operation::Manager> m_manager;
79 template<
typename OperationType>
80 bool OperationFactory::registerOperation()
82 return this->registerOperation(smtk::common::typeName<OperationType>());
85 template<
typename OperationType>
86 bool OperationFactory::unregisterOperation()
88 return this->unregisterOperation(smtk::common::typeName<OperationType>());
91 template<
typename OperationType>
92 smtk::shared_ptr<OperationType> OperationFactory::create()
94 return smtk::static_pointer_cast<OperationType>(
95 this->create(std::type_index(
typeid(OperationType)).hash_code()));