- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

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
11 #include <qi/type/typeinterface.hpp>
12
13 namespace qi {
14
15 template<typename T>
16 class IntTypeInterfaceImpl: public IntTypeInterface
17 {
18 public:
19 using ImplType = detail::TypeImplMethodsBySize_t<T>;
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
41 _QI_BOUNCE_TYPE_METHODS(ImplType);
42 };
43
44 template<typename T> class TypeBoolImpl: public IntTypeInterface
45 {
46 public:
47 using ImplType = detail::TypeImplMethodsBySize_t<T>;
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
69 _QI_BOUNCE_TYPE_METHODS(ImplType);
70 };
71
72 }
73
74
75 namespace qi {
76
77
78 template<typename T>
79 class FloatTypeInterfaceImpl: public FloatTypeInterface
80 {
81 public:
82 using ImplType = detail::TypeImplMethodsBySize_t<T>;
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
99 _QI_BOUNCE_TYPE_METHODS(ImplType);
100 };
101
102 }
103
104 #endif // _QITYPE_DETAIL_TYPEINT_HXX_
qi::IntTypeInterfaceImpl
Definition: inttypeinterface.hxx:16
qi::TypeBoolImpl::ImplType
detail::TypeImplMethodsBySize_t< T > ImplType
Definition: inttypeinterface.hxx:47
qi::int64_t
int64_t int64_t
Definition: types.hpp:61
qi::FloatTypeInterfaceImpl::ImplType
detail::TypeImplMethodsBySize_t< T > ImplType
Definition: inttypeinterface.hxx:82
qi::TypeBoolImpl
Definition: inttypeinterface.hxx:44
qi::TypeBoolImpl::set
void set(void **storage, int64_t value) override
Set the value of the integer.
Definition: inttypeinterface.hxx:54
qi::IntTypeInterfaceImpl::size
unsigned int size() override
Return the size in bytes.
Definition: inttypeinterface.hxx:31
qi::TypeBoolImpl::isSigned
bool isSigned() override
Return true if the integer is signed.
Definition: inttypeinterface.hxx:64
qi::detail::TypeImplMethodsBySize_t
typename TypeImplMethodsBySize< T >::type TypeImplMethodsBySize_t
Definition: type.hxx:130
qi::TypeBoolImpl::size
unsigned int size() override
Return the size in bytes.
Definition: inttypeinterface.hxx:59
qi::IntTypeInterfaceImpl::ImplType
detail::TypeImplMethodsBySize_t< T > ImplType
Definition: inttypeinterface.hxx:19
qi::FloatTypeInterfaceImpl
Definition: inttypeinterface.hxx:79
qi::FloatTypeInterfaceImpl::size
unsigned int size() override
Return the size in bytes.
Definition: inttypeinterface.hxx:94
qi::IntTypeInterfaceImpl::isSigned
bool isSigned() override
Return true if the integer is signed.
Definition: inttypeinterface.hxx:36
qi::FloatTypeInterface
Definition: typeinterface.hpp:92
qi::IntTypeInterfaceImpl::_QI_BOUNCE_TYPE_METHODS
_QI_BOUNCE_TYPE_METHODS(ImplType)
qi::IntTypeInterfaceImpl::set
void set(void **storage, int64_t value) override
Set the value of the integer.
Definition: inttypeinterface.hxx:26
qi::IntTypeInterface
Definition: typeinterface.hpp:78
qi::FloatTypeInterfaceImpl::_QI_BOUNCE_TYPE_METHODS
_QI_BOUNCE_TYPE_METHODS(ImplType)
typeinterface.hpp
qi::FloatTypeInterfaceImpl::set
void set(void **storage, double value) override
Set the value of the float.
Definition: inttypeinterface.hxx:89
qi::TypeBoolImpl::_QI_BOUNCE_TYPE_METHODS
_QI_BOUNCE_TYPE_METHODS(ImplType)