GeoTessCPP: include/Data.h Source File

GeoTessCPP 2.0.0 Software to facilitate storage and retrieval of 3D information about the Earth.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Data.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 DATA_OBJECT_H
37 #define DATA_OBJECT_H
38
39 // **** _SYSTEM INCLUDES_ ******************************************************
40
41 #include <iostream>
42 #include <string>
43 #include <fstream>
44
45 // use standard library objects
46 using namespace std;
47
48 // **** _LOCAL INCLUDES_ *******************************************************
49
50 #include "CPPGlobals.h"
51 #include "DataType.h"
52
53 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
54
55 namespace geotess {
56
57 // **** _FORWARD REFERENCES_ ***************************************************
58
59 class GeoTessMetaData;
60 class IFStreamAscii;
61 class IFStreamBinary;
62 template<typename T> class DataArray;
63 template<typename T> class DataValue;
64
65 // **** _CLASS DEFINITION_ *****************************************************
66
75 class GEOTESS_EXP_IMP Data
76 {
77 private:
78
82 static int aClassCount;
83
84 public:
85
89 static string class_name() { return "Data"; };
90
94 virtual int class_size() const { return (int) sizeof(Data); };
95
99 static int class_count() { return aClassCount; };
100
105 virtual bool operator == (const Data& d) const
106 { return (getDataType() == d.getDataType()); }
107
117 static Data* getData(double values[], const int& size);
118 static Data* getData(const vector<double>& values);
119
129 static Data* getData(float values[], const int& size);
130 static Data* getData(const vector<float>& values);
131
141 static Data* getData(LONG_INT values[], const int& size);
142 static Data* getData(const vector<LONG_INT>& values);
143
153 static Data* getData(int values[], const int& size);
154 static Data* getData(const vector<int>& values);
155
165 static Data* getData(short values[], const int& size);
166 static Data* getData(const vector<short>& values);
167
177 static Data* getData(byte values[], const int& size);
178 static Data* getData(const vector<byte>& values);
179
185 virtual const DataType& getDataType() const = ABSTRACT;
186
191 virtual int size() const = ABSTRACT;
192
198 virtual double getDouble(int attributeIndex) const = ABSTRACT;
199
205 virtual float getFloat(int attributeIndex) const = ABSTRACT;
206
212 virtual LONG_INT getLong(int attributeIndex) const = ABSTRACT;
213
219 virtual int getInt(int attributeIndex) const = ABSTRACT;
220
226 virtual short getShort(int attributeIndex) const = ABSTRACT;
227
233 virtual byte getByte(int attributeIndex) const = ABSTRACT;
234
238 virtual void getValue(int attributeIndex, double& val) const = ABSTRACT;
239
243 virtual void getValue(int attributeIndex, float& val) const = ABSTRACT;
244
248 virtual void getValue(int attributeIndex, LONG_INT& val) const = ABSTRACT;
249
253 virtual void getValue(int attributeIndex, int& val) const = ABSTRACT;
254
258 virtual void getValue(int attributeIndex, short& val) const = ABSTRACT;
259
263 virtual void getValue(int attributeIndex, byte& val) const = ABSTRACT;
264
270 virtual void getValues(double values[], const int& n) = ABSTRACT;
271
277 virtual void getValues(float values[], const int& n) = ABSTRACT;
278
284 virtual void getValues(LONG_INT values[], const int& n) = ABSTRACT;
285
291 virtual void getValues(int values[], const int& n) = ABSTRACT;
292
298 virtual void getValues(short values[], const int& n) = ABSTRACT;
299
305 virtual void getValues(byte values[], const int& n) = ABSTRACT;
306
307
315 virtual Data& setValue(int attributeIndex, double v) = ABSTRACT;
316
324 virtual Data& setValue(int attributeIndex, float v) = ABSTRACT;
325
333 virtual Data& setValue(int attributeIndex, LONG_INT v) = ABSTRACT;
334
342 virtual Data& setValue(int attributeIndex, int v) = ABSTRACT;
343
351 virtual Data& setValue(int attributeIndex, short v) = ABSTRACT;
352
360 virtual Data& setValue(int attributeIndex, byte v) = ABSTRACT;
361
362
369 template <typename T>
370 void fill(T fillValue) { for (int i=0; i<size(); ++i) setValue(i,fillValue);}
371
383 virtual bool isNaN(int attributeIndex) const = ABSTRACT;
384
385
387
391 Data() { ++aClassCount; };
392
396 virtual ~Data();
397
402 virtual Data* copy() = ABSTRACT;
403
409 static Data* getData(IFStreamBinary& ifs, GeoTessMetaData& gtmd);
410
416 static Data* getData(IFStreamAscii& input, GeoTessMetaData& gtmd);
417
422 virtual void write(IFStreamBinary& ofs) = ABSTRACT;
423
428 virtual void write(IFStreamAscii& ofs) = ABSTRACT;
429
431
432 }; // end class Data
433
434 } // end namespace geotess
435
436 #endif // DATA_OBJECT_H