fw4spl
fwMemory/include/fwMemory/camp/mapper.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 __FWMEMORY_CAMP_MAPPER_HPP__
8 #define __FWMEMORY_CAMP_MAPPER_HPP__
9 
10 #include <camp/valuemapper.hpp>
11 
12 #include <fwTools/Type.hpp>
13 
14 namespace camp_ext
15 {
16 
17 
18 template <>
19 struct ValueMapper< ::fwTools::Type >
20 {
21  typedef ::fwTools::Type ReturnType;
22  static const int type = camp::stringType;
23  static const std::string to(const ReturnType& source)
24  {
25  return source.string();
26  }
27 
28  static ReturnType from(bool source)
29  {
30  CAMP_ERROR(camp::BadType(camp::boolType, camp::mapType<ReturnType>()));
31  }
32  static ReturnType from(long source)
33  {
34  CAMP_ERROR(camp::BadType(camp::intType, camp::mapType<ReturnType>()));
35  }
36  static ReturnType from(double source)
37  {
38  CAMP_ERROR(camp::BadType(camp::realType, camp::mapType<ReturnType>()));
39  }
40  static ReturnType from(const std::string& source)
41  {
42  return ::fwTools::Type::create(source);
43  }
44  static ReturnType from(const camp::EnumObject& source)
45  {
46  CAMP_ERROR(camp::BadType(camp::enumType, camp::mapType<ReturnType>()));
47  }
48  static ReturnType from(const camp::UserObject& source)
49  {
50  CAMP_ERROR(camp::BadType(camp::userType, camp::mapType<ReturnType>()));
51  }
52 };
53 
54 
55 } // namespace camp_ext
56 
57 #endif //__FWMEMORY_CAMP_MAPPER_HPP__
Class describing an elementary C++ type aka unsigned char, signed char, .... int, float...
Definition: Type.hpp:32
FWTOOLS_API const std::string & string() const
Return a human readable string.
Definition: Type.cpp:175