fw4spl
core/fwGui/include/fwGui/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 __FWGUI_FACTORY_NEW_HPP__
8 #define __FWGUI_FACTORY_NEW_HPP__
9 
10 #include "fwGui/config.hpp"
11 #include "fwGui/registry/detail.hpp"
12 
13 #include <string>
14 
15 namespace fwGui
16 {
17 
18 class GuiBaseObject;
19 
20 namespace factory
21 {
22 
23 template<class CLASSNAME > SPTR( CLASSNAME ) New();
24 
29 class Key
30 {
31 template<typename CLASSNAME>
32 friend SPTR( CLASSNAME ) fwGui::factory::New();
33 
34 Key()
35 {
36 }
37 };
38 
39 FWGUI_API SPTR( ::fwGui::GuiBaseObject ) New( const ::fwGui::registry::KeyType & classname );
40 
41 template<class CLASSNAME > SPTR( CLASSNAME ) New()
42 {
43  SPTR(CLASSNAME) guiObj = std::make_shared< CLASSNAME >( Key() );
44  return guiObj;
45 }
46 
47 } // namespace factory
48 
49 } // namespace fwGui
50 
51 #endif /* __FWGUI_FACTORY_NEW_HPP__ */
52 
#define SPTR(_cls_)
The namespace fwGui contains the base interface for IHM services.
Definition: SJobBar.hpp:23
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Contains fwAtomsFilter::factory utilities.
Base class for all fwGui&#39;s classes.