fw4spl
core/fwDataIO/include/fwDataIO/writer/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_WRITER_FACTORY_NEW_HPP__
8 #define __FWDATAIO_WRITER_FACTORY_NEW_HPP__
9 
10 #include "fwDataIO/config.hpp"
11 #include "fwDataIO/writer/registry/detail.hpp"
12 
13 #include <string>
14 
15 namespace fwDataIO
16 {
17 namespace writer
18 {
19 
20 class IObjectWriter;
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::writer::factory::New();
35 
36 Key()
37 {
38 }
39 };
40 
41 FWDATAIO_API SPTR( ::fwDataIO::writer::IObjectWriter ) New( const ::fwDataIO::writer::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 writer
53 
54 } // namespace fwDataIO
55 
56 #endif /* __FWDATAIO_WRITER_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.
Base class for all object writers.