GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
GeoTessDataType.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 DATATYPE_OBJECT_H
37 #define DATATYPE_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 "GeoTessEnumType.h"
50 
51 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
52 
53 namespace geotess
54 {
55 
56 // **** _FORWARD REFERENCES_ ***************************************************
57 
58 // **** _CLASS DEFINITION_ *****************************************************
59 
68 {
69 private:
70 
75  {
76  }
77 
82  {
83  }
84 
88  GeoTessDataType& operator=(const GeoTessDataType& dt)
89  {
90  return *this;
91  }
92 
96  static const int aSize;
97 
102  static inline int nextOrdinal()
103  {
104  static int firstOrdinal = 0;
105  return firstOrdinal++;
106  }
107 
113  GeoTessDataType(const string& name)
114  : GeoTessEnumType(name, nextOrdinal())
115  {
116  }
117 
118 public:
119 
123  static const GeoTessDataType DOUBLE;
124  static const GeoTessDataType FLOAT;
125  static const GeoTessDataType LONG;
126  static const GeoTessDataType INT;
127  static const GeoTessDataType SHORT;
128  static const GeoTessDataType BYTE;
129  static const GeoTessDataType NONE;
130 
134  static const GeoTessDataType* aArray[];
135 
140  {
141  }
142 
143 // /**
144 // * Assignment Operator.
145 // */
146 // DataType& DataType::operator=(const DataType& dt)
147 // {
148 // EnumType::operator=(dt);
149 //
150 // return *this;
151 // }
152 
160  static const GeoTessDataType* valueOf(const string& s)
161  {
162  return (const GeoTessDataType*) GeoTessEnumType::valueOf(s,
163  (GeoTessEnumType const* const * const ) aArray, aSize);
164  }
165 
169  static GeoTessDataType const* const * const values()
170  {
171  return aArray;
172  }
173 
177  static int size()
178  {
179  return aSize;
180  }
181 
182  /*
183  * Return DataType.
184  */
185  template<typename T>
186  static const GeoTessDataType& getDataType(T typ)
187  {
188  return GeoTessDataType::NONE;
189  }
190 
191 };
192 // end class DataType
193 
197 template<>
198 inline const GeoTessDataType& GeoTessDataType::getDataType<double>(double typ)
199 {
200  return GeoTessDataType::DOUBLE;
201 }
202 
206 template<>
207 inline const GeoTessDataType& GeoTessDataType::getDataType<float>(float typ)
208 {
209  return GeoTessDataType::FLOAT;
210 }
211 
215 template<>
216 inline const GeoTessDataType& GeoTessDataType::getDataType<LONG_INT>(LONG_INT typ)
217 {
218  return GeoTessDataType::LONG;
219 }
220 
224 template<>
225 inline const GeoTessDataType& GeoTessDataType::getDataType<int>(int typ)
226 {
227  return GeoTessDataType::INT;
228 }
229 
233 template<>
234 inline const GeoTessDataType& GeoTessDataType::getDataType<short>(short typ)
235 {
236  return GeoTessDataType::SHORT;
237 }
238 
242 template<>
243 inline const GeoTessDataType& GeoTessDataType::getDataType<byte>(byte typ)
244 {
245  return GeoTessDataType::BYTE;
246 }
247 
248 } // end namespace geotess
249 
250 #endif // DATATYPE_OBJECT_H
static const GeoTessDataType FLOAT
Definition: GeoTessDataType.h:124
static const GeoTessDataType DOUBLE
The actual enums for this type.
Definition: GeoTessDataType.h:123
static const GeoTessDataType INT
Definition: GeoTessDataType.h:126
Definition: ArrayReuse.h:55
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
Definition: GeoTessDataType.h:67
static const GeoTessDataType BYTE
Definition: GeoTessDataType.h:128
static int size()
Returns the total number of enums of this type.
Definition: GeoTessDataType.h:177
static const GeoTessDataType * valueOf(const string &s)
Assignment Operator.
Definition: GeoTessDataType.h:160
virtual ~GeoTessDataType()
Standard Destructor.
Definition: GeoTessDataType.h:139
#define byte
signed-byte typedef
Definition: CPPGlobals.h:94
The base class for all "enum" types.
Definition: GeoTessEnumType.h:67
static const GeoTessDataType NONE
Definition: GeoTessDataType.h:129
#define LONG_INT
Definition: CPPGlobals.h:111
static const GeoTessDataType & getDataType(T typ)
Definition: GeoTessDataType.h:186
static const GeoTessDataType SHORT
Definition: GeoTessDataType.h:127
static GeoTessDataType const *const *const values()
Returns the array of all enums for this type.
Definition: GeoTessDataType.h:169
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
static const GeoTessDataType LONG
Definition: GeoTessDataType.h:125