OpFlex Framework 1.7.0
EnumInfo.h
Go to the documentation of this file.
1/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
6/*
7 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
8 *
9 * This program and the accompanying materials are made available under the
10 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
11 * and is available at http://www.eclipse.org/legal/epl-v10.html
12 */
13
14#ifndef MODB_ENUMINFO_H
15#define MODB_ENUMINFO_H
16
17#include <string>
18#include <vector>
19
21#include "opflex/ofcore/OFTypes.h"
22
23namespace opflex {
24namespace modb {
25
32
40class EnumInfo {
41public:
42
47
51 EnumInfo(const std::string &name_,
52 const std::vector<ConstInfo>& consts_);
53
58
63 const std::string& getName() const { return name; }
64
69 const std::vector<ConstInfo>& getConsts() const { return consts; }
70
77 const uint64_t getIdByName(const std::string& name) const;
78
85 const std::string& getNameById(uint64_t id) const;
86
87private:
91 std::string name;
92
96 std::vector<ConstInfo> consts;
97
98 typedef OF_UNORDERED_MAP<std::string, uint64_t> const_name_map_t;
99 typedef OF_UNORDERED_MAP<uint64_t, std::string> const_value_map_t;
100
101 const_name_map_t const_name_map;
102 const_value_map_t const_value_map;
103};
104
105/* @} metadata */
106/* @} cpp */
107
108} /* namespace modb */
109} /* namespace opflex */
110
111#endif
Interface definition file for ConstInfo.
const std::vector< ConstInfo > & getConsts() const
Get the vector of possible const values for the enum.
Definition EnumInfo.h:69
EnumInfo()
Default constructor.
Definition EnumInfo.h:46
~EnumInfo()
Destructor.
const uint64_t getIdByName(const std::string &name) const
Get the constant value by the enum name.
const std::string & getName() const
Get the name of the enum.
Definition EnumInfo.h:63
const std::string & getNameById(uint64_t id) const
Get the enum constant name by the enum value.
EnumInfo(const std::string &name_, const std::vector< ConstInfo > &consts_)
Construct an enum info with the given name and consts.