GeoTessCPP  2.0.0
Software to facilitate storage and retrieval of 3D information about the Earth.
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
GeoTessData.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 GEO_DATA_OBJECT_H
37 #define GEO_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 "GeoTessDataType.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 GeoTessDataArray;
63 template<typename T> class GeoTessDataValue;
64 
65 // **** _CLASS DEFINITION_ *****************************************************
66 
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(GeoTessData); };
95 
99  static int class_count() { return aClassCount; };
100 
105  virtual bool operator == (const GeoTessData& d) const
106  { return (getDataType() == d.getDataType()); }
107 
117  static GeoTessData* getData(double values[], const int& size);
118  static GeoTessData* getData(const vector<double>& values);
119 
129  static GeoTessData* getData(float values[], const int& size);
130  static GeoTessData* getData(const vector<float>& values);
131 
141  static GeoTessData* getData(LONG_INT values[], const int& size);
142  static GeoTessData* getData(const vector<LONG_INT>& values);
143 
153  static GeoTessData* getData(int values[], const int& size);
154  static GeoTessData* getData(const vector<int>& values);
155 
165  static GeoTessData* getData(short values[], const int& size);
166  static GeoTessData* getData(const vector<short>& values);
167 
177  static GeoTessData* getData(byte values[], const int& size);
178  static GeoTessData* getData(const vector<byte>& values);
179 
185  virtual const GeoTessDataType& 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 GeoTessData& setValue(int attributeIndex, double v) = ABSTRACT;
316 
324  virtual GeoTessData& setValue(int attributeIndex, float v) = ABSTRACT;
325 
333  virtual GeoTessData& setValue(int attributeIndex, LONG_INT v) = ABSTRACT;
334 
342  virtual GeoTessData& setValue(int attributeIndex, int v) = ABSTRACT;
343 
351  virtual GeoTessData& setValue(int attributeIndex, short v) = ABSTRACT;
352 
360  virtual GeoTessData& 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  GeoTessData() { ++aClassCount; };
392 
396  virtual ~GeoTessData();
397 
402  virtual GeoTessData* copy() = ABSTRACT;
403 
409  static GeoTessData* getData(IFStreamBinary& ifs, GeoTessMetaData& gtmd);
410 
416  static GeoTessData* 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