GeoTessCPP  2.2.3
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 National Technology & Engineering Solutions of Sandia, LLC
4 //- (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
5 //- Government 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 //- 1. Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //-
16 //- 2. Redistributions in binary form must reproduce the above copyright
17 //- notice, this list of conditions and the following disclaimer in the
18 //- documentation and/or other materials provided with the distribution.
19 //-
20 //- 3. Neither the name of the copyright holder nor the names of its
21 //- contributors may be used to endorse or promote products derived from
22 //- this software without specific prior written permission.
23 //-
24 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 //- POSSIBILITY OF SUCH DAMAGE.
35 //-
36 //- ****************************************************************************
37 
38 #ifndef DATATYPE_OBJECT_H
39 #define DATATYPE_OBJECT_H
40 
41 // **** _SYSTEM INCLUDES_ ******************************************************
42 
43 #include <iostream>
44 #include <string>
45 
46 // use standard library objects
47 using namespace std;
48 
49 // **** _LOCAL INCLUDES_ *******************************************************
50 
51 #include "GeoTessEnumType.h"
52 
53 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
54 
55 namespace geotess
56 {
57 
58 // **** _FORWARD REFERENCES_ ***************************************************
59 
60 // **** _CLASS DEFINITION_ *****************************************************
61 
70 {
71 private:
72 
77  {
78  }
79 
84  {
85  }
86 
90  GeoTessDataType& operator=(const GeoTessDataType& dt)
91  {
92  return *this;
93  }
94 
98  static const int aSize;
99 
104  static inline int nextOrdinal()
105  {
106  static int firstOrdinal = 0;
107  return firstOrdinal++;
108  }
109 
115  GeoTessDataType(const string& name)
116  : GeoTessEnumType(name, nextOrdinal())
117  {
118  }
119 
120 public:
121 
125  static const GeoTessDataType DOUBLE;
126  static const GeoTessDataType FLOAT;
127  static const GeoTessDataType LONG;
128  static const GeoTessDataType INT;
129  static const GeoTessDataType SHORT;
130  static const GeoTessDataType BYTE;
131  static const GeoTessDataType NONE;
132 
136  static const GeoTessDataType* aArray[];
137 
142  {
143  }
144 
145 // /**
146 // * Assignment Operator.
147 // */
148 // DataType& DataType::operator=(const DataType& dt)
149 // {
150 // EnumType::operator=(dt);
151 //
152 // return *this;
153 // }
154 
162  static const GeoTessDataType* valueOf(const string& s)
163  {
164  return (const GeoTessDataType*) GeoTessEnumType::valueOf(s,
165  (GeoTessEnumType const* const * const ) aArray, aSize);
166  }
167 
171  static GeoTessDataType const* const * const values()
172  {
173  return aArray;
174  }
175 
179  static int size()
180  {
181  return aSize;
182  }
183 
184  /*
185  * Return DataType.
186  */
187  template<typename T>
188  static const GeoTessDataType& getDataType(T typ)
189  {
190  return GeoTessDataType::NONE;
191  }
192 
193 };
194 // end class DataType
195 
199 template<>
200 inline const GeoTessDataType& GeoTessDataType::getDataType<double>(double typ)
201 {
202  return GeoTessDataType::DOUBLE;
203 }
204 
208 template<>
209 inline const GeoTessDataType& GeoTessDataType::getDataType<float>(float typ)
210 {
211  return GeoTessDataType::FLOAT;
212 }
213 
217 template<>
218 inline const GeoTessDataType& GeoTessDataType::getDataType<LONG_INT>(LONG_INT typ)
219 {
220  return GeoTessDataType::LONG;
221 }
222 
226 template<>
227 inline const GeoTessDataType& GeoTessDataType::getDataType<int>(int typ)
228 {
229  return GeoTessDataType::INT;
230 }
231 
235 template<>
236 inline const GeoTessDataType& GeoTessDataType::getDataType<short>(short typ)
237 {
238  return GeoTessDataType::SHORT;
239 }
240 
244 template<>
245 inline const GeoTessDataType& GeoTessDataType::getDataType<byte>(byte typ)
246 {
247  return GeoTessDataType::BYTE;
248 }
249 
250 } // end namespace geotess
251 
252 #endif // DATATYPE_OBJECT_H
geotess::GeoTessDataType::NONE
static const GeoTessDataType NONE
Definition: GeoTessDataType.h:131
geotess::GeoTessDataType::~GeoTessDataType
virtual ~GeoTessDataType()
Definition: GeoTessDataType.h:141
geotess
Definition: ArrayReuse.h:57
geotess::GeoTessDataType::DOUBLE
static const GeoTessDataType DOUBLE
Definition: GeoTessDataType.h:125
GeoTessEnumType.h
geotess::GeoTessEnumType
The base class for all "enum" types.
Definition: GeoTessEnumType.h:70
geotess::GeoTessDataType::LONG
static const GeoTessDataType LONG
Definition: GeoTessDataType.h:127
geotess::GeoTessDataType::INT
static const GeoTessDataType INT
Definition: GeoTessDataType.h:128
geotess::GeoTessDataType::getDataType
static const GeoTessDataType & getDataType(T typ)
Definition: GeoTessDataType.h:188
geotess::GeoTessDataType::SHORT
static const GeoTessDataType SHORT
Definition: GeoTessDataType.h:129
geotess::GeoTessDataType::BYTE
static const GeoTessDataType BYTE
Definition: GeoTessDataType.h:130
geotess::GeoTessDataType::size
static int size()
Definition: GeoTessDataType.h:179
geotess::GeoTessDataType::valueOf
static const GeoTessDataType * valueOf(const string &s)
Definition: GeoTessDataType.h:162
geotess::GeoTessDataType
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
Definition: GeoTessDataType.h:70
LONG_INT
#define LONG_INT
Definition: CPPGlobals.h:113
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:73
geotess::GeoTessDataType::values
static GeoTessDataType const *const *const values()
Definition: GeoTessDataType.h:171
geotess::GeoTessDataType::FLOAT
static const GeoTessDataType FLOAT
Definition: GeoTessDataType.h:126