Mirror reflection library 0.5.13

mirror/raw_ptr/type_info_cmp.hpp

Go to the documentation of this file.
00001 
00010 #ifndef MIRROR_RAW_PTR_TYPE_INFO_CMP_1011291729_HPP
00011 #define MIRROR_RAW_PTR_TYPE_INFO_CMP_1011291729_HPP
00012 
00013 #include <typeinfo>
00014 
00015 MIRROR_NAMESPACE_BEGIN
00016 namespace aux {
00017 
00018 // @c std::type_info - based type comparator
00019 class type_info_cmp
00020 {
00021 private:
00022     // type definition for the type-info type
00023     typedef ::std::type_info std_ti;
00024 
00025     // pointer to the type info wrapped by this class
00026     const std_ti* the_ti;
00027 
00028     // getter member function
00029     const std_ti& get(void) const
00030     {
00031         return *the_ti;
00032     }
00033 
00034     // equality comparison
00035     static bool equal(
00036         const type_info_cmp& a,
00037         const type_info_cmp& b
00038     )
00039     {
00040         return a.get() == b.get();
00041     }
00042 
00043     // less than comparison
00044     static bool less_than(
00045         const type_info_cmp& a,
00046         const type_info_cmp& b
00047     )
00048     {
00049         return a.get().before(b.get());
00050     }
00051 public:
00052     typedef type_info_cmp type;
00053 
00054     template <typename T>
00055     static const std_ti* create(void)
00056     {
00057         return &typeid(typename std::remove_cv<T>::type);
00058     }
00059 
00060     type_info_cmp(const std_ti* a_ti)
00061      : the_ti(a_ti)
00062     { }
00063 
00066 
00067     friend bool operator == (
00068         const type_info_cmp& a,
00069         const type_info_cmp& b
00070     ) { return equal(a, b); }
00071 
00073     friend bool operator != (
00074         const type_info_cmp& a,
00075         const type_info_cmp& b
00076     ) { return !equal(a, b); }
00077 
00079     friend bool operator <  (
00080         const type_info_cmp& a,
00081         const type_info_cmp& b
00082     ) { return less_than(a, b); }
00083 
00085     friend bool operator >  (
00086         const type_info_cmp& a,
00087         const type_info_cmp& b
00088     ) { return !equal(a, b) && !less_than(a, b); }
00089 
00091     friend bool operator <= (
00092         const type_info_cmp& a,
00093         const type_info_cmp& b
00094     ) { return equal(a, b) || less_than(a, b); }
00095 
00097     friend bool operator >= (
00098         const type_info_cmp& a,
00099         const type_info_cmp& b
00100     ) { return !less_than(a, b); }
00102 };
00103 
00104 } // namespace aux
00105 MIRROR_NAMESPACE_END
00106 
00107 #endif // MIRROR_RAW_PTR_TYPE_INFO_CMP_HPP

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.