12#include "RMF/config.h"
15#include "internal/small_set_map.h"
21struct RMFEXPORT FrameTypeTag {
24 static RMF_SMALL_UNORDERED_MAP<std::string, int>& get_from();
25 static RMF_SMALL_UNORDERED_MAP<int, std::string>& get_to();
28struct RMFEXPORT NodeTypeTag {
30 static RMF_SMALL_UNORDERED_MAP<std::string, int>& get_from();
31 static RMF_SMALL_UNORDERED_MAP<int, std::string>& get_to();
35struct RMFEXPORT RepresentationTypeTag {
37 static RMF_SMALL_UNORDERED_MAP<std::string, int>& get_from();
38 static RMF_SMALL_UNORDERED_MAP<int, std::string>& get_to();
48 int compare(
const Enum<TagT>& o)
const {
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)
97template <
class Traits>
98inline std::ostream& operator<<(std::ostream& out, Enum<Traits> v) {
102template <
class Traits>
103inline std::istream& operator>>(std::istream& in,
Enum<Traits>& v) {
130typedef std::vector<FrameType> FrameTypes;
131typedef std::vector<NodeType> NodeTypes;
132typedef std::vector<RepresentationType> RepresentationTypes;
A strong enum with an associated string name for each value.
Declarations of the various exception types.
Various general useful macros for IMP.
#define RMF_HASHABLE(name, hashret)
Implement a hash function for the class.
#define RMF_COMPARISONS(Name)
Implement comparison in a class using field as the variable to compare.
The namespace for all functionality in the library.
Enum< NodeTypeTag > NodeType
Enum< RepresentationTypeTag > RepresentationType
std::size_t hash_value(const BufferConstHandle &t)
Produce hash values for boost hash tables.
Enum< FrameTypeTag > FrameType