GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
GeoTessEnumType.h
Go to the documentation of this file.
1 //- ****************************************************************************
2 //-
3 //- Copyright 2009 Sandia Corporation. Under the terms of Contract
4 //- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
5 //- retains certain rights in this software.
6 //-
7 //- BSD Open Source License.
8 //- All rights reserved.
9 //-
10 //- Redistribution and use in source and binary forms, with or without
11 //- modification, are permitted provided that the following conditions are met:
12 //-
13 //- * Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //- * Redistributions in binary form must reproduce the above copyright
16 //- notice, this list of conditions and the following disclaimer in the
17 //- documentation and/or other materials provided with the distribution.
18 //- * Neither the name of Sandia National Laboratories nor the names of its
19 //- contributors may be used to endorse or promote products derived from
20 //- this software without specific prior written permission.
21 //-
22 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 //- POSSIBILITY OF SUCH DAMAGE.
33 //-
34 //- ****************************************************************************
35 
36 #ifndef ENUMTYPE_OBJECT_H
37 #define ENUMTYPE_OBJECT_H
38 
39 // **** _SYSTEM INCLUDES_ ******************************************************
40 
41 #include <iostream>
42 #include <string>
43 
44 // use standard library objects
45 using namespace std;
46 
47 // **** _LOCAL INCLUDES_ *******************************************************
48 
49 #include "CPPUtils.h"
50 
51 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
52 
53 namespace geotess
54 {
55 
56 // **** _FORWARD REFERENCES_ ***************************************************
57 
58 // **** _CLASS DEFINITION_ *****************************************************
59 
68 {
69 protected:
70 
75  : aName(""), aOrdinal(-1)
76  {
77  }
78 
83  : aName(et.aName), aOrdinal(et.aOrdinal)
84  {
85  }
86 
91  {
92  return *this;
93  }
94 
98  const string aName;
99 
103  const int aOrdinal;
104 
109  GeoTessEnumType(const string& name, int ordinal)
110  : aName(name), aOrdinal(ordinal)
111  {
112  }
113 
125  static const GeoTessEnumType* valueOf(const string& s,
126  GeoTessEnumType const* const * const array, int n);
127 
128 public:
129 
133  virtual ~GeoTessEnumType() { }
134 
138  string toString() const { return aName; }
139 
143  string name() const { return aName; }
144 
148  int ordinal() const { return aOrdinal; }
149 
153  friend bool operator==(const GeoTessEnumType& x, const GeoTessEnumType& y) { return &(x) == &(y); }
154 
158  friend bool operator!=(const GeoTessEnumType& x, const GeoTessEnumType &y) { return !(x == y); }
159 
160 };
161 // end class EnumType
162 
166 inline std::ostream& operator<<(std::ostream& o, GeoTessEnumType& s)
167 { return o << s.toString(); }
168 
169 } // end namespace geotess
170 
171 #endif // ENUMTYPE_OBJECT_H
GeoTessEnumType & operator=(const GeoTessEnumType &et)
Private assignment operator.
Definition: GeoTessEnumType.h:90
string name() const
Returns this Enums name.
Definition: GeoTessEnumType.h:143
Definition: ArrayReuse.h:55
std::ostream & operator<<(std::ostream &o, GeoTessEnumType &s)
Stream operator that will print the input EnumTypes name to the stream.
Definition: GeoTessEnumType.h:166
const string aName
The string name of this enum.
Definition: GeoTessEnumType.h:98
string toString() const
Returns this Enums name.
Definition: GeoTessEnumType.h:138
friend bool operator==(const GeoTessEnumType &x, const GeoTessEnumType &y)
Equals operator.
Definition: GeoTessEnumType.h:153
virtual ~GeoTessEnumType()
Standard destructor.
Definition: GeoTessEnumType.h:133
friend bool operator!=(const GeoTessEnumType &x, const GeoTessEnumType &y)
Not equals operator.
Definition: GeoTessEnumType.h:158
The base class for all "enum" types.
Definition: GeoTessEnumType.h:67
GeoTessEnumType()
Private default constructor.
Definition: GeoTessEnumType.h:74
int ordinal() const
Returns this Enums ordinal.
Definition: GeoTessEnumType.h:148
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
GeoTessEnumType(const GeoTessEnumType &et)
Private copy constructor.
Definition: GeoTessEnumType.h:82
const int aOrdinal
The ordinal of this enum.
Definition: GeoTessEnumType.h:103
GeoTessEnumType(const string &name, int ordinal)
Standard constuctor.
Definition: GeoTessEnumType.h:109