GeoTessCPP  2.1
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 
116  static GeoTessData* getData(const GeoTessDataType& dataType, int nAttributes);
117 
127  static GeoTessData* getData(double values[], const int& size);
128  static GeoTessData* getData(const vector<double>& values);
129 
139  static GeoTessData* getData(float values[], const int& size);
140  static GeoTessData* getData(const vector<float>& values);
141 
151  static GeoTessData* getData(LONG_INT values[], const int& size);
152  static GeoTessData* getData(const vector<LONG_INT>& values);
153 
163  static GeoTessData* getData(int values[], const int& size);
164  static GeoTessData* getData(const vector<int>& values);
165 
175  static GeoTessData* getData(short values[], const int& size);
176  static GeoTessData* getData(const vector<short>& values);
177 
187  static GeoTessData* getData(byte values[], const int& size);
188  static GeoTessData* getData(const vector<byte>& values);
189 
195  virtual const GeoTessDataType& getDataType() const = ABSTRACT;
196 
201  virtual int size() const = ABSTRACT;
202 
208  virtual double getDouble(int attributeIndex) const = ABSTRACT;
209 
215  virtual float getFloat(int attributeIndex) const = ABSTRACT;
216 
222  virtual LONG_INT getLong(int attributeIndex) const = ABSTRACT;
223 
229  virtual int getInt(int attributeIndex) const = ABSTRACT;
230 
236  virtual short getShort(int attributeIndex) const = ABSTRACT;
237 
243  virtual byte getByte(int attributeIndex) const = ABSTRACT;
244 
248  virtual void getValue(int attributeIndex, double& val) const = ABSTRACT;
249 
253  virtual void getValue(int attributeIndex, float& val) const = ABSTRACT;
254 
258  virtual void getValue(int attributeIndex, LONG_INT& val) const = ABSTRACT;
259 
263  virtual void getValue(int attributeIndex, int& val) const = ABSTRACT;
264 
268  virtual void getValue(int attributeIndex, short& val) const = ABSTRACT;
269 
273  virtual void getValue(int attributeIndex, byte& val) const = ABSTRACT;
274 
280  virtual void getValues(double values[], const int& n) = ABSTRACT;
281 
287  virtual void getValues(float values[], const int& n) = ABSTRACT;
288 
294  virtual void getValues(LONG_INT values[], const int& n) = ABSTRACT;
295 
301  virtual void getValues(int values[], const int& n) = ABSTRACT;
302 
308  virtual void getValues(short values[], const int& n) = ABSTRACT;
309 
315  virtual void getValues(byte values[], const int& n) = ABSTRACT;
316 
317 
325  virtual GeoTessData& setValue(int attributeIndex, double v) = ABSTRACT;
326 
334  virtual GeoTessData& setValue(int attributeIndex, float v) = ABSTRACT;
335 
343  virtual GeoTessData& setValue(int attributeIndex, LONG_INT v) = ABSTRACT;
344 
352  virtual GeoTessData& setValue(int attributeIndex, int v) = ABSTRACT;
353 
361  virtual GeoTessData& setValue(int attributeIndex, short v) = ABSTRACT;
362 
370  virtual GeoTessData& setValue(int attributeIndex, byte v) = ABSTRACT;
371 
372 
379  template <typename T>
380  void fill(T fillValue) { for (int i=0; i<size(); ++i) setValue(i,fillValue);}
381 
393  virtual bool isNaN(int attributeIndex) const = ABSTRACT;
394 
395 
397 
401  GeoTessData() { ++aClassCount; };
402 
406  virtual ~GeoTessData();
407 
412  virtual GeoTessData* copy() = ABSTRACT;
413 
419  static GeoTessData* getData(IFStreamBinary& ifs, GeoTessMetaData& gtmd);
420 
426  static GeoTessData* getData(IFStreamAscii& input, GeoTessMetaData& gtmd);
427 
432  virtual void write(IFStreamBinary& ofs) = ABSTRACT;
433 
438  virtual void write(IFStreamAscii& ofs) = ABSTRACT;
439 
441 
442 }; // end class Data
443 
444 } // end namespace geotess
445 
446 #endif // DATA_OBJECT_H
virtual int class_size() const
Definition: GeoTessData.h:94
void fill(T fillValue)
Definition: GeoTessData.h:380
static string class_name()
Definition: GeoTessData.h:89
Enumeration of supported DataType including DOUBLE, FLOAT, LONG, INT, SHORT and BYTE.
Definition: GeoTessDataType.h:67
static int class_count()
Definition: GeoTessData.h:99
Manages a single data value attached to a grid node.
Definition: GeoTessData.h:63
virtual const GeoTessDataType & getDataType() const
#define byte
signed-byte typedef
Definition: CPPGlobals.h:94
#define ABSTRACT
Global constant used to make pure virtual functions readable.
Definition: CPPGlobals.h:78
#define LONG_INT
Definition: CPPGlobals.h:111
Manages a 1D array of data values attached to a single grid node.
Definition: GeoTessData.h:62
Abstract base class that manages the data values attached to a single grid point. ...
Definition: GeoTessData.h:75
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71