fw4spl
core/fwCamp/include/fwCamp/factory/new.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 __FWCAMP_FACTORY_NEW_HPP__
8 #define __FWCAMP_FACTORY_NEW_HPP__
9 
10 #include <string>
11 
12 
13 #include <fwCore/macros.hpp>
14 
15 #include "fwCamp/config.hpp"
16 #include "fwCamp/registry/detail.hpp"
17 
18 namespace fwCamp
19 {
20 namespace factory
21 {
22 
23 FWCAMP_API SPTR( ::camp::UserObject ) New( const ::fwCamp::registry::KeyType & classname, ::fwTools::Object *object);
24 
25 template<class CLASSNAME > SPTR( ::camp::UserObject ) New(::fwTools::Object *object)
26 {
27  SPTR(::camp::UserObject) obj = std::make_shared< ::camp::UserObject >(*(dynamic_cast<CLASSNAME*>( object )));
28  return obj;
29 }
30 
31 } // namespace factory
32 } // namespace fwCamp
33 
34 #endif /* __FWCAMP_FACTORY_NEW_HPP__ */
35 
36 
#define SPTR(_cls_)
Define Base class for FW4SPL objects and services.
This file defines fwCore base macros.
Contains fwAtomsFilter::factory utilities.
All necessary for camp binding with simple types.