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 
20 #include "opflex/modb/ConstInfo.h"
21 #include "opflex/ofcore/OFTypes.h"
22 
23 namespace opflex {
24 namespace modb {
25 
40 class EnumInfo {
41 public:
42 
46  EnumInfo() {}
47 
51  EnumInfo(const std::string &name_,
52  const std::vector<ConstInfo>& consts_);
53 
57  ~EnumInfo();
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 
87 private:
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
const std::vector< ConstInfo > & getConsts() const
Get the vector of possible const values for the enum.
Definition: EnumInfo.h:69
Enum info defines the set of possible values for an enum as well as the properties current defined by...
Definition: EnumInfo.h:40
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:63
Interface definition file for ConstInfo.
EnumInfo()
Default constructor.
Definition: EnumInfo.h:46