libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
inttypeinterface.hxx
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QITYPE_DETAIL_TYPEINT_HXX_
8 #define _QITYPE_DETAIL_TYPEINT_HXX_
9 #include <boost/type_traits/is_signed.hpp>
10 
12 
13 namespace qi {
14 
15  template<typename T>
17  {
18  public:
20 
21  int64_t get(void* value) override
22  {
23  return *(T*)ImplType::Access::ptrFromStorage(&value);
24  }
25 
26  void set(void** storage, int64_t value) override
27  {
28  *(T*)ImplType::Access::ptrFromStorage(storage) = (T)value;
29  }
30 
31  unsigned int size() override
32  {
33  return sizeof(T);
34  }
35 
36  bool isSigned() override
37  {
38  return boost::is_signed<T>::value;
39  }
40 
42  };
43 
44  template<typename T> class TypeBoolImpl: public IntTypeInterface
45  {
46  public:
48 
49  int64_t get(void* value) override
50  {
51  return *(T*)ImplType::Access::ptrFromStorage(&value);
52  }
53 
54  void set(void** storage, int64_t value) override
55  {
56  *(T*)ImplType::Access::ptrFromStorage(storage) = (T)(value != 0);
57  }
58 
59  unsigned int size() override
60  {
61  return 0;
62  }
63 
64  bool isSigned() override
65  {
66  return 0;
67  }
68 
70  };
71 
72 }
73 
74 
75 namespace qi {
76 
77 
78  template<typename T>
80  {
81  public:
83 
84  double get(void* value) override
85  {
86  return *(T*)ImplType::Access::ptrFromStorage(&value);
87  }
88 
89  void set(void** storage, double value) override
90  {
91  *(T*)ImplType::Access::ptrFromStorage(storage) = (T)value;
92  }
93 
94  unsigned int size() override
95  {
96  return sizeof(T);
97  }
98 
100  };
101 
102 }
103 
104 #endif // _QITYPE_DETAIL_TYPEINT_HXX_
detail::TypeImplMethodsBySize_t< T > ImplType
int64_t int64_t
Definition: types.hpp:61
detail::TypeImplMethodsBySize_t< T > ImplType
void set(void **storage, int64_t value) override
Set the value of the integer.
unsigned int size() override
Return the size in bytes.
bool isSigned() override
Return true if the integer is signed.
typename TypeImplMethodsBySize< T >::type TypeImplMethodsBySize_t
Definition: type.hxx:130
unsigned int size() override
Return the size in bytes.
detail::TypeImplMethodsBySize_t< T > ImplType
unsigned int size() override
Return the size in bytes.
bool isSigned() override
Return true if the integer is signed.
_QI_BOUNCE_TYPE_METHODS(ImplType)
void set(void **storage, int64_t value) override
Set the value of the integer.
void set(void **storage, double value) override
Set the value of the float.
_QI_BOUNCE_TYPE_METHODS(ImplType)