1 #ifndef RTABMAP_FLANN_ANY_H_ 2 #define RTABMAP_FLANN_ANY_H_ 42 virtual void static_delete(
void** x) = 0;
43 virtual void copy_from_value(
void const* src,
void**
dest) = 0;
44 virtual void clone(
void*
const* src,
void** dest) = 0;
45 virtual void move(
void*
const* src,
void** dest) = 0;
46 virtual void* get_value(
void** src) = 0;
47 virtual const void* get_value(
void*
const * src) = 0;
48 virtual ::size_t get_size() = 0;
49 virtual const std::type_info& type() = 0;
50 virtual void print(std::ostream& out,
void*
const* src) = 0;
56 virtual ::size_t
get_size() {
return sizeof(T); }
57 virtual const std::type_info&
type() {
return typeid(T); }
67 new (
dest) T(* reinterpret_cast<T const*>(src));
69 virtual void clone(
void*
const* src,
void**
dest) { *dest = *src; }
70 virtual void move(
void*
const* src,
void**
dest) { *dest = *src; }
71 virtual void*
get_value(
void** src) {
return reinterpret_cast<void*
>(src); }
72 virtual const void*
get_value(
void*
const * src) {
return reinterpret_cast<const void*
>(src); }
73 virtual void print(std::ostream& out,
void*
const* src) { out << *reinterpret_cast<T const*>(src); }
81 if (* x)
delete (*
reinterpret_cast<T**
>(x)); *x =
NULL;
85 *dest =
new T(*reinterpret_cast<T const*>(src));
89 *dest =
new T(**reinterpret_cast<T* const*>(src));
91 virtual void move(
void*
const* src,
void**
dest)
93 (*
reinterpret_cast<T**
>(
dest))->~T();
94 **
reinterpret_cast<T**
>(
dest) = **reinterpret_cast<T* const*>(src);
96 virtual void*
get_value(
void** src) {
return *src; }
97 virtual const void*
get_value(
void*
const * src) {
return *src; }
98 virtual void print(std::ostream& out,
void*
const* src) { out << *reinterpret_cast<T const*>(*src); }
124 #define SMALL_POLICY(TYPE) \ 126 struct choose_policy<TYPE> { typedef small_any_policy<TYPE> type; \ 161 template <
typename T>
203 template <
typename T>
207 policy = anyimpl::get_policy<T>();
229 std::swap(policy, x.
policy);
230 std::swap(
object, x.
object);
239 T* r =
reinterpret_cast<T*
>(policy->
get_value(&
object));
248 const T* r =
reinterpret_cast<const T*
>(policy->
get_value(&
object));
262 policy = anyimpl::get_policy<anyimpl::empty_any>();
275 return policy->
type() ==
typeid(T);
278 const std::type_info&
type()
const 280 return policy->
type();
283 friend std::ostream&
operator <<(std::ostream& out,
const any& any_val);
294 #endif // FLANN_ANY_H_ virtual void * get_value(void **src)=0
virtual void static_delete(void **x)
any_t & assign(const T &x)
Assignment function.
any(const T &x)
Initializing constructor.
virtual const void * get_value(void *const *src)
SMALL_POLICY(signed char)
base_any_policy * get_policy()
This function will return a different policy for each type.
virtual void * get_value(void **src)
virtual void copy_from_value(void const *src, void **dest)=0
virtual const std::type_info & type()
virtual void copy_from_value(void const *src, void **dest)
virtual void copy_from_value(void const *src, void **dest)
ROSCONSOLE_DECL void print(FilterBase *filter, void *logger, Level level, const char *file, int line, const char *function, const char *fmt,...) ROSCONSOLE_PRINTF_ATTRIBUTE(7
virtual void print(std::ostream &out, void *const *src)
void reset()
Frees any allocated memory, and sets the value to NULL.
virtual const void * get_value(void *const *src)
virtual void print(std::ostream &out, void *const *src)=0
const std::type_info & type() const
bool has_type()
Returns if the type is compatible with the policy.
std::ostream & operator<<(std::ostream &out, const empty_any &)
virtual const std::type_info & type()=0
virtual void static_delete(void **x)=0
virtual void * get_value(void **src)
bool compatible(const any &x) const
Returns true if the two types are the same.
virtual void move(void *const *src, void **dest)
any(const char *x)
Special initializing constructor for string literals.
virtual void clone(void *const *src, void **dest)=0
any(const any &x)
Copy constructor.
anyimpl::base_any_policy * policy
const T & cast() const
Cast operator. You can only cast to the original type.
T & cast()
Cast operator. You can only cast to the original type.
virtual void clone(void *const *src, void **dest)
virtual ::size_t get_size()
any & operator=(const char *x)
any & assign(const any &x)
Assignment function from another any.
virtual void clone(void *const *src, void **dest)
virtual void move(void *const *src, void **dest)
virtual void print(std::ostream &out, void *const *src)
any_t & operator=(const T &x)
Assignment operator.
any & swap(any &x)
Utility functions.
virtual void static_delete(void **)
small_any_policy< T * > type
bool empty() const
Returns true if the any contains no value.