fw4spl
core/fwAtomsPatch/include/fwAtomsPatch/patcher/factory/new.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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_PATCHER_FACTORY_NEW_HPP__
8 #define __FWATOMSPATCH_PATCHER_FACTORY_NEW_HPP__
9 
10 #include "fwAtomsPatch/config.hpp"
11 #include "fwAtomsPatch/patcher/registry/detail.hpp"
12 
13 #include <string>
14 
15 namespace fwAtomsPatch
16 {
17 
18 namespace patcher
19 {
20 
21 class IPatcher;
22 
23 namespace factory
24 {
25 
26 template<class CLASSNAME > SPTR( CLASSNAME ) New();
27 
32 class Key
33 {
34 template<typename CLASSNAME>
35 friend SPTR( CLASSNAME ) fwAtomsPatch::patcher::factory::New();
36 
37 Key()
38 {
39 }
40 };
41 
42 FWATOMSPATCH_API SPTR(::fwAtomsPatch::patcher::IPatcher) New(
43  const ::fwAtomsPatch::patcher::registry::KeyType & classname );
44 
45 template<class CLASSNAME > SPTR( CLASSNAME ) New()
46 {
47  SPTR(CLASSNAME) obj = std::make_shared< CLASSNAME >( Key() );
48 
49  return obj;
50 }
51 
52 } // namespace factory
53 
54 } // namespace patcher
55 
56 } // namespace fwAtomsPatch
57 
58 #endif /* __FWATOMSPATCH_PATCHER_FACTORY_NEW_HPP__ */
59 
#define SPTR(_cls_)
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
Contains fwAtomsFilter::factory utilities.
Base class of all patchers.
Definition: IPatcher.hpp:40
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.