/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/include/BDSTypeSafeEnum.hh

00001 #ifndef BDSTypeSafeEnum_h
00002 #define BDSTypeSafeEnum_h 
00003 
00004 #include <ostream>
00005 
00023 template<typename def, typename inner = typename def::type>
00024 class BDSTypeSafeEnum : public def
00025 {
00026   typedef inner type;
00027   inner val;
00028  
00029 public:
00030  
00031   BDSTypeSafeEnum() : val() {}
00032   BDSTypeSafeEnum(type v) : val(v) {}
00034   type underlying() const { return val; }
00035 
00037   friend bool operator == (const BDSTypeSafeEnum & lhs, const BDSTypeSafeEnum & rhs) { return lhs.val == rhs.val; }
00038   friend bool operator != (const BDSTypeSafeEnum & lhs, const BDSTypeSafeEnum & rhs) { return lhs.val != rhs.val; }
00039   friend bool operator <  (const BDSTypeSafeEnum & lhs, const BDSTypeSafeEnum & rhs) { return lhs.val <  rhs.val; }
00040   friend bool operator <= (const BDSTypeSafeEnum & lhs, const BDSTypeSafeEnum & rhs) { return lhs.val <= rhs.val; }
00041   friend bool operator >  (const BDSTypeSafeEnum & lhs, const BDSTypeSafeEnum & rhs) { return lhs.val >  rhs.val; }
00042   friend bool operator >= (const BDSTypeSafeEnum & lhs, const BDSTypeSafeEnum & rhs) { return lhs.val >= rhs.val; }
00043   friend std::ostream& operator<< (std::ostream &out, const BDSTypeSafeEnum& a) {out << a.underlying(); return out;}
00045 };
00046 
00047 #endif

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7