SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
ImporterGroup.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 
11 #ifndef smtk_operation_ImporterGroup_h
12 #define smtk_operation_ImporterGroup_h
13 
14 #include "smtk/CoreExports.h"
15 
16 #include "smtk/common/TypeName.h"
17 
18 #include "smtk/operation/Operation.h"
19 #include "smtk/operation/groups/ResourceIOGroup.h"
20 
21 #include <set>
22 #include <string>
23 
24 namespace smtk
25 {
26 namespace operation
27 {
28 class Manager;
29 
30 class SMTKCORE_EXPORT ImporterGroup : public ResourceIOGroup
31 {
32 public:
34 
35  static constexpr const char* const type_name = "importer";
36 
37  ImporterGroup(std::shared_ptr<smtk::operation::Manager> manager)
38  : ResourceIOGroup(type_name, manager)
39  {
40  }
41 
42  // Given a file name, return the set of operators that accept the input file.
43  std::set<Operation::Index> operationsForFileName(const std::string&) const;
44 
45  // Given a resource type and a file name, return the set of operators that
46  // accept the input file and return a resource of the given type.
47  template<typename ResourceType>
48  std::set<Operation::Index> operationsForResourceAndFileName(const std::string&) const;
49 
50  // Given a resource name and a file name, return the set of operators that
51  // accept the input file and return a resource of the given type.
52  std::set<Operation::Index> operationsForResourceAndFileName(
53  const std::string&,
54  const std::string&) const;
55 
56 private:
57  // Given a set of operation indices, remove the ones that do not accept the
58  // given file name.
59  void filterOperationsThatRejectFileName(std::set<Operation::Index>&, const std::string&) const;
60 };
61 
62 template<typename ResourceType>
63 std::set<Operation::Index> ImporterGroup::operationsForResourceAndFileName(
64  const std::string& fileName) const
65 {
66  return operationsForResourceAndFileName(smtk::common::typeName<ResourceType>(), fileName);
67 }
68 } // namespace operation
69 } // namespace smtk
70 
71 #endif // smtk_operation_ImporterGroup_h
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
TypeName.h
Named type functions.
smtk::plugin::Manager
smtk::common::Singleton< detail::Manager > Manager
The Manager is a singleton interface for registering available plugins to manager instances.
Definition: Manager.h:92
smtk::operation::ImporterGroup
Definition: ImporterGroup.h:30
smtk::operation::ResourceIOGroup
Definition: ResourceIOGroup.h:37
smtk::operation::ResourceIOGroup::registerOperation
bool registerOperation(const std::string &, const std::string &fileItemName=m_defaultFileItemName)
Register an IO operation identified by it's unique name, the type of resource it handles and the file...
Definition: ResourceIOGroup.h:128