DDS-PSM-C++  1.0
ISO C++ API for OpenSplice DDS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
SafeEnumeration.hpp
Go to the documentation of this file.
1 #ifndef OMG_DDS_CORE_SAFEENUMERATION_HPP_
2 #define OMG_DDS_CORE_SAFEENUMERATION_HPP_
3 
4 namespace dds {
5  namespace core {
6  template<typename def, typename inner = typename def::type>
7  class safe_enum : public def
8  {
9  typedef typename def::type type;
10  inner val;
11 
12  public:
13 
14  safe_enum(type v) : val(v) {}
15  inner underlying() const { return val; }
16 
17  bool operator == (const safe_enum & s) const { return this->val == s.val; }
18  bool operator != (const safe_enum & s) const { return this->val != s.val; }
19  bool operator < (const safe_enum & s) const { return this->val < s.val; }
20  bool operator <= (const safe_enum & s) const { return this->val <= s.val; }
21  bool operator > (const safe_enum & s) const { return this->val > s.val; }
22  bool operator >= (const safe_enum & s) const { return this->val >= s.val; }
23  };
24 
25 
26  }
27 }
28 
29 
30 
31 #endif /* OMG_DDS_CORE_SAFEENUMERATION_HPP_ */