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;
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); }
82 delete (*
reinterpret_cast<T**
>(x));
87 *dest =
new T(*reinterpret_cast<T const*>(src));
91 *dest =
new T(**reinterpret_cast<T* const*>(src));
93 virtual void move(
void*
const* src,
void**
dest)
95 (*
reinterpret_cast<T**
>(
dest))->~T();
96 **
reinterpret_cast<T**
>(
dest) = **reinterpret_cast<T* const*>(src);
98 virtual void*
get_value(
void** src) {
return *src; }
99 virtual const void*
get_value(
void*
const * src) {
return *src; }
100 virtual void print(std::ostream& out,
void*
const* src) { out << *reinterpret_cast<T const*>(*src); }
126 #define SMALL_POLICY(TYPE) \ 128 struct choose_policy<TYPE> { typedef small_any_policy<TYPE> type; \ 163 template <
typename T>
205 template <
typename T>
209 policy = anyimpl::get_policy<T>();
241 T* r =
reinterpret_cast<T*
>(policy->
get_value(&
object));
250 const T* r =
reinterpret_cast<const T*
>(policy->
get_value(&
object));
264 policy = anyimpl::get_policy<anyimpl::empty_any>();
277 return policy->
type() ==
typeid(
T);
280 const std::type_info&
type()
const 282 return policy->
type();
285 friend std::ostream&
operator <<(std::ostream& out,
const any& any_val);
296 #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)
void swap(linb::any &lhs, linb::any &rhs) noexcept
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)
bool compatible(const any &x) const
Returns true if the two types are the same.
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
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)
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
bool empty() const
Returns true if the any contains no value.
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.
const T & cast() const
Cast operator. You can only cast to the original type.
const std::type_info & type() const
any & swap(any &x)
Utility functions.
virtual void static_delete(void **)
small_any_policy< T * > type