fw4spl
core/fwDataIO/include/fwDataIO/reader/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 __FWDATAIO_READER_FACTORY_NEW_HPP__
8 #define __FWDATAIO_READER_FACTORY_NEW_HPP__
9 
10 #include "fwDataIO/config.hpp"
11 #include "fwDataIO/reader/registry/detail.hpp"
12 
13 #include <string>
14 
15 namespace fwDataIO
16 {
17 namespace reader
18 {
19 
20 class IObjectReader;
21 
22 namespace factory
23 {
24 
25 template<class CLASSNAME > SPTR( CLASSNAME ) New();
26 
31 class Key
32 {
33 template<typename CLASSNAME>
34 friend SPTR( CLASSNAME ) fwDataIO::reader::factory::New();
35 
36 Key()
37 {
38 }
39 };
40 
41 FWDATAIO_API SPTR( ::fwDataIO::reader::IObjectReader ) New( const ::fwDataIO::reader::registry::KeyType & classname );
42 
43 template<class CLASSNAME > SPTR( CLASSNAME ) New()
44 {
45  SPTR(CLASSNAME) obj = std::make_shared< CLASSNAME >( Key() );
46 
47  return obj;
48 }
49 
50 } // namespace factory
51 
52 } // namespace reader
53 
54 } // namespace fwDataIO
55 
56 #endif /* __FWDATAIO_READER_FACTORY_NEW_HPP__ */
57 
#define SPTR(_cls_)
This namespace fwDataIO contains reader and writer for several framework&#39;s data.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Contains fwAtomsFilter::factory utilities.