Graphite Version 3
An experimental 3D geometry processing program
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
meta_enum.h
Go to the documentation of this file.
1/*
2 * GXML/Graphite: Geometry and Graphics Programming Library + Utilities
3 * Copyright (C) 2000 Bruno Levy
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 * If you modify this software, you should include a notice giving the
20 * name of the person performing the modification, the date of modification,
21 * and the reason for such modification.
22 *
23 * Contact: Bruno Levy
24 *
25 * levy@loria.fr
26 *
27 * ISA Project
28 * LORIA, INRIA Lorraine,
29 * Campus Scientifique, BP 239
30 * 54506 VANDOEUVRE LES NANCY CEDEX
31 * FRANCE
32 *
33 * Note that the GNU General Public License does not permit incorporating
34 * the Software into proprietary programs.
35 */
36
37#ifndef H_OGF_META_TYPES_META_ENUM_H
38#define H_OGF_META_TYPES_META_ENUM_H
39
42#include <vector>
43
49namespace OGF {
50
56 gom_class GOM_API MetaEnum : public MetaType {
57 public:
58
63 MetaEnum(const std::string& name) ;
64
68 ~MetaEnum() override ;
69
70 gom_slots:
75 size_t nb_values() const {
76 return values_.size();
77 }
78
79
85 int ith_value(index_t i) const {
86 ogf_assert(i < values_.size()) ;
87 return values_[i].value ;
88 }
89
95 const std::string& ith_name(index_t i) const {
96 ogf_assert(i < values_.size()) ;
97 return values_[i].name ;
98 }
99
106 bool has_value(int value) const ;
107
114 bool has_value(const std::string& name) const ;
115
122 int get_value_by_name(const std::string& name) const ;
123
130 const std::string& get_name_by_value(int value) const ;
131
137 void add_value(const std::string& name, int value) ;
138
139
144 void add_values(const ArgList& values);
145
146 private:
147 struct Value {
148 std::string name ;
149 int value ;
150 } ;
151 std::vector<Value> values_ ;
152 } ;
153
158}
159
160#endif
A smart pointer with reference-counted copy semantics.
Represents a list of name-value pairs.
Definition arg_list.h:65
MetaType for enums.
Definition meta_enum.h:56
int get_value_by_name(const std::string &name) const
Gets a value by symbolic name.
int ith_value(index_t i) const
Gets a value by index.
Definition meta_enum.h:85
void add_value(const std::string &name, int value)
Adds a new value to this MetaEnum.
const std::string & ith_name(index_t i) const
Gets a symbolic name by index.
Definition meta_enum.h:95
MetaEnum(const std::string &name)
MetaEnum constructor.
const std::string & get_name_by_value(int value) const
Gets a symbolic name by value.
bool has_value(int value) const
Tests whether a MetaEnum has a value.
bool has_value(const std::string &name) const
Tests whether a MetaEnum has a symbolic name.
~MetaEnum() override
MetaEnum destructor.
void add_values(const ArgList &values)
Adds values to this MegaEnum.
The representation of a type in the Meta repository.
Definition meta_type.h:222
Base class for meta informations.
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:329
Global Graphite namespace.
Definition common.h:76
SmartPointer< MetaEnum > MetaEnum_var
Automatic reference-counted pointer to a MetaEnum.
Definition meta_enum.h:157
Definitions common to all include files in the gom library.