libqi-api  2.4.3.28
 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_DETAILS_TYPEINT_HXX_
8 #define _QITYPE_DETAILS_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  virtual int64_t get(void* value)
22  {
23  return *(T*)ImplType::Access::ptrFromStorage(&value);
24  }
25 
26  virtual void set(void** storage, int64_t value)
27  {
28  *(T*)ImplType::Access::ptrFromStorage(storage) = (T)value;
29  }
30 
31  virtual unsigned int size()
32  {
33  return sizeof(T);
34  }
35 
36  virtual bool isSigned()
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  virtual int64_t get(void* value)
50  {
51  return *(T*)ImplType::Access::ptrFromStorage(&value);
52  }
53 
54  virtual void set(void** storage, int64_t value)
55  {
56  *(T*)ImplType::Access::ptrFromStorage(storage) = (T)(value != 0);
57  }
58 
59  virtual unsigned int size()
60  {
61  return 0;
62  }
63 
64  virtual bool isSigned()
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  virtual double get(void* value)
85  {
86  return *(T*)ImplType::Access::ptrFromStorage(&value);
87  }
88 
89  virtual void set(void** storage, double value)
90  {
91  *(T*)ImplType::Access::ptrFromStorage(storage) = (T)value;
92  }
93 
94  virtual unsigned int size()
95  {
96  return sizeof(T);
97  }
98 
100  };
101 
102 }
103 
104 
105 
106 #endif // _QITYPE_DETAILS_TYPEINT_HXX_
virtual unsigned int size()
Return the size in bytes.
detail::TypeImplMethodsBySize< T >::type ImplType
detail::TypeImplMethodsBySize< T >::type ImplType
detail::TypeImplMethodsBySize< T >::type ImplType
virtual void set(void **storage, int64_t value)
Set the value of the integer.
virtual unsigned int size()
Return the size in bytes.
virtual unsigned int size()
Return the size in bytes.
virtual bool isSigned()
Return true if the integer is signed.
_QI_BOUNCE_TYPE_METHODS(ImplType)
virtual void set(void **storage, int64_t value)
Set the value of the integer.
virtual bool isSigned()
Return true if the integer is signed.
virtual void set(void **storage, double value)
Set the value of the float.
int64_t int64_t
Cross-platform signed integer of length 64 bits (8 bytes).
Definition: types.hpp:76
_QI_BOUNCE_TYPE_METHODS(ImplType)