00001 // comparable_v.hpp, created on 30.06.2009 by Sebastian Mies 00002 00003 #ifndef COMPARABLE_V_HPP_ 00004 #define COMPARABLE_V_HPP_ 00005 00006 #include "vfacade.hpp" 00007 00013 class comparable_v { 00014 public: 00015 //--- comparable_v -------------------------------------------------------- 00016 00018 virtual int compare_to(const comparable_v& rhs) const = 0; 00019 00021 inline int compare_to(const comparable_v* rhs) const { 00022 return compare_to(*rhs); 00023 } 00024 00026 inline bool operator==(const comparable_v& rhs) const { 00027 return compare_to(rhs) == 0; 00028 } 00029 00031 inline bool operator!=(const comparable_v& rhs) const { 00032 return compare_to(rhs) != 0; 00033 } 00034 00036 inline bool operator<(const comparable_v& rhs) const { 00037 return compare_to(rhs) < 0; 00038 } 00039 00041 inline bool operator<=(const comparable_v& rhs) const { 00042 return compare_to(rhs) <= 0; 00043 } 00044 00046 inline bool operator>(const comparable_v& rhs) const { 00047 return compare_to(rhs) > 0; 00048 } 00049 00051 inline bool operator>=(const comparable_v& rhs) const { 00052 return compare_to(rhs) >= 0; 00053 } 00054 }; 00055 00056 typedef vfacade<comparable_v> comparable_vf; 00057 00058 template<class NonVirtual, class AdaptorType> 00059 class vobject_hull<NonVirtual, comparable_v, AdaptorType> : public comparable_v { 00060 private: 00061 typename AdaptorType::template adaptor_type<NonVirtual> obj; 00062 00063 public: 00064 template<typename T> 00065 explicit vobject_hull(T& obj) : 00066 obj(obj) { 00067 } 00068 00069 explicit vobject_hull() : 00070 obj() { 00071 } 00072 00073 //--- comparable_v -------------------------------------------------------- 00074 00076 virtual int compare_to(const comparable_v& rhs) const { 00077 return obj->compare_to(rhs); 00078 } 00079 }; 00080 00081 00082 00083 #endif /* COMPARABLE_V_HPP_ */