12 #include "RMF/config.h"
15 #include "internal/small_set_map.h"
21 struct RMFEXPORT FrameTypeTag {
24 static RMF_SMALL_UNORDERED_MAP<std::string, int>& get_from();
25 static RMF_SMALL_UNORDERED_MAP<int, std::string>& get_to();
28 struct RMFEXPORT NodeTypeTag {
30 static RMF_SMALL_UNORDERED_MAP<std::string, int>& get_from();
31 static RMF_SMALL_UNORDERED_MAP<int, std::string>& get_to();
35 struct RMFEXPORT RepresentationTypeTag {
37 static RMF_SMALL_UNORDERED_MAP<std::string, int>& get_from();
38 static RMF_SMALL_UNORDERED_MAP<int, std::string>& get_to();
56 std::string get_string()
const {
return TagT::get_to().find(i_)->second; }
61 explicit Enum(
int i) : i_(i) {
62 RMF_USAGE_CHECK(TagT::get_to().find(i) != TagT::get_to().end(),
63 "Enum value not defined");
65 Enum(
bool,
int i) : i_(i) {
69 if (TagT::get_to().find(i) == TagT::get_to().end()) {
73 Enum(std::string name) {
74 RMF_USAGE_CHECK(TagT::get_from().find(name) != TagT::get_from().end(),
75 "Enum name not defined");
76 i_ = TagT::get_from().find(name)->second;
78 Enum(
int i, std::string name) : i_(i) {
79 TagT::get_to()[i] = name;
80 TagT::get_from()[name] = i;
84 RMF_SHOWABLE(
Enum, get_string());
85 #if !defined(RMF_DOXYGEN) && !defined(SWIG)
86 operator int()
const {
return i_; }
96 #if !defined(SWIG) && !defined(RMF_DOXYGEN)
97 template <
class Traits>
98 inline std::ostream& operator<<(std::ostream& out, Enum<Traits> v) {
102 template <
class Traits>
103 inline std::istream& operator>>(std::istream& in, Enum<Traits>& v) {
106 v = Enum<Traits>(val);
130 typedef std::vector<FrameType> FrameTypes;
131 typedef std::vector<NodeType> NodeTypes;
132 typedef std::vector<RepresentationType> RepresentationTypes;
Enum< RepresentationTypeTag > RepresentationType
Enum< FrameTypeTag > FrameType
std::size_t hash_value(const BufferConstHandle &t)
Produce hash values for boost hash tables.
Declarations of the various exception types.
#define RMF_COMPARISONS(Name)
Implement comparison in a class using field as the variable to compare.
A strong enum with an associated string name for each value.
#define RMF_HASHABLE(name, hashret)
Implement a hash function for the class.
Various general useful macros for IMP.
Enum< NodeTypeTag > NodeType