OpFlex Framework  1.3.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 
20 #include <boost/unordered_map.hpp>
21 
22 #include "opflex/modb/ConstInfo.h"
23 
24 namespace opflex {
25 namespace modb {
26 
41 class EnumInfo {
42 public:
43 
47  EnumInfo() {}
48 
52  EnumInfo(const std::string &name_,
53  const std::vector<ConstInfo>& consts_);
54 
58  ~EnumInfo();
59 
64  const std::string& getName() const { return name; }
65 
70  const std::vector<ConstInfo>& getConsts() const { return consts; }
71 
78  const uint64_t getIdByName(const std::string& name) const;
79 
86  const std::string& getNameById(uint64_t id) const;
87 
88 private:
92  std::string name;
93 
97  std::vector<ConstInfo> consts;
98 
99  typedef boost::unordered_map<std::string, uint64_t> const_name_map_t;
100  typedef boost::unordered_map<uint64_t, std::string> const_value_map_t;
101 
102  const_name_map_t const_name_map;
103  const_value_map_t const_value_map;
104 };
105 
106 /* @} metadata */
107 /* @} cpp */
108 
109 } /* namespace modb */
110 } /* namespace opflex */
111 
112 #endif
const std::vector< ConstInfo > & getConsts() const
Get the vector of possible const values for the enum.
Definition: EnumInfo.h:70
Enum info defines the set of possible values for an enum as well as the properties current defined by...
Definition: EnumInfo.h:41
const uint64_t getIdByName(const std::string &name) const
Get the constant value by the enum name.
~EnumInfo()
Destructor.
const std::string & getNameById(uint64_t id) const
Get the enum constant name by the enum value.
const std::string & getName() const
Get the name of the enum.
Definition: EnumInfo.h:64
Interface definition file for ConstInfo.
EnumInfo()
Default constructor.
Definition: EnumInfo.h:47