fw4spl
StructuralCreatorDB.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWATOMSPATCH_STRUCTURALCREATORDB_HPP__
8 #define __FWATOMSPATCH_STRUCTURALCREATORDB_HPP__
9 
10 #include <string>
11 #include <map>
12 #include <utility>
13 
14 #include <fwCore/base.hpp>
15 #include <fwCore/mt/types.hpp>
16 
17 #include "fwAtomsPatch/config.hpp"
18 
19 namespace fwAtoms
20 {
21 class Object;
22 }
23 
24 namespace fwAtomsPatch
25 {
26 
27 class IStructuralCreator;
28 
33 class FWATOMSPATCH_CLASS_API StructuralCreatorDB
34 {
35 
36 public:
37  typedef SPTR (StructuralCreatorDB) sptr;
39  typedef std::pair< std::string, std::string > VersionIDType;
41  typedef std::map< VersionIDType, SPTR(::fwAtomsPatch::IStructuralCreator) > CreatorsType;
42 
48  FWATOMSPATCH_API void registerCreator(SPTR(::fwAtomsPatch::IStructuralCreator) creator);
49 
57  FWATOMSPATCH_API SPTR(::fwAtomsPatch::IStructuralCreator) getCreator(const std::string& classname,
58  const std::string& version);
59 
65  FWATOMSPATCH_API SPTR(::fwAtoms::Object) create(const std::string& classname, const std::string& version);
66 
68  FWATOMSPATCH_API size_t size() const;
69 
71  static StructuralCreatorDB::sptr getDefault()
72  {
73  return s_default;
74  }
75 
78  {
79  }
80 
83  {
84  }
85 
86 private:
87 
90  {
91  }
92 
94  mutable ::fwCore::mt::ReadWriteMutex m_mutex;
95 
97  CreatorsType m_creators;
98 
99  FWATOMSPATCH_API static StructuralCreatorDB::sptr s_default;
100 
101 };
102 
103 
104 } // fwAtomsPatch
105 
106 
107 
108 #endif /* __FWATOMSPATCH_STRUCTURALCREATORDB_HPP__ */
#define SPTR(_cls_)
fwAtoms contains basic objects to represent any other kind of object
Base class of all structural creators. Creates a new atom object with the default values correspondin...
STL namespace.
Structural creator database. All structural creators are stored in this database. ...
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
std::map< VersionIDType, std::shared_ptr< ::fwAtomsPatch::IStructuralCreator > > CreatorsType
Typedef used to store all the structural creators.
std::pair< std::string, std::string > VersionIDType
Typedef used to store the pair classname/version of a data structure.