OpendTect-6_4  6.4
datainterp.h
Go to the documentation of this file.
1 #ifndef datainterp_h
2 #define datainterp_h
3 
4 /*
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H.Bril
9  Date: Nov 2000
10  Contents: Binary data interpretation
11  RCS: $Id$
12 ________________________________________________________________________
13 
14 */
15 
16 #include "datachar.h"
17 #include "gendefs.h"
18 class od_istream;
19 
20 
21 #if defined(__msvc__) && (defined(GENERAL_EXPORTS) || defined(General_EXPORTS) )
22 # define mGenClass class dll_export
23 #else
24 # define mGenClass class
25 #endif
26 
36 template<class T>
38 {
39 public:
40  static DataInterpreter<T> create();
42  bool alsoifequal);
47  static DataInterpreter<T>* create(const char*,bool alsoifequal);
52  static DataInterpreter<T>* create(const IOPar& par,const char* key,
53  bool alsoifequal);
60  bool ignoreendianness=false);
62  void set(const DataCharacteristics&,
63  bool ignoreendianness=false);
66  inline DataInterpreter<T>& operator=( const DataCharacteristics& dc )
67  { set( dc, false ); return *this; }
68 
69  bool needSwap() const;
70  void swap( void* buf, od_int64 bufsz_in_elements ) const
71  { (this->*swpfn)( buf, bufsz_in_elements );
72  const_cast<DataInterpreter<T>*>(this)->swpSwap(); }
73 
74  T get(od_istream&) const;
75  static T get(const DataInterpreter<T>*,od_istream&);
76  static bool get(const DataInterpreter<T>*,od_istream&,T&);
77  inline T get( const void* buf, od_int64 nr ) const
78  { return (this->*getfn)( buf, nr ); }
79  inline void put( void* buf, od_int64 nr, T t ) const
80  { (this->*putfn)( buf, nr, t ); }
81 
82  inline bool operator ==( const DataInterpreter& di ) const
83  { return di.getfn == getfn; }
84  inline bool operator !=( const DataInterpreter& di ) const
85  { return di.getfn != getfn; }
86  inline bool isSUCompat() const
87  { return getfn == &DataInterpreter::getF; }
88  int nrBytes() const;
89  DataCharacteristics dataChar() const;
90 
91 protected:
92 
93  void swap2(void*,od_int64) const;
94  void swap4(void*,od_int64) const;
95  void swap8(void*,od_int64) const;
96 
97  T getS1(const void*,od_int64) const;
98  T getS2(const void*,od_int64) const;
99  T getS4(const void*,od_int64) const;
100  T getS8(const void*,od_int64) const;
101  T getU1(const void*,od_int64) const;
102  T getU2(const void*,od_int64) const;
103  T getU4(const void*,od_int64) const;
104  T getF(const void*,od_int64) const;
105  T getD(const void*,od_int64) const;
106 
107  T getS2Ibm(const void*,od_int64) const;
108  T getS4Ibm(const void*,od_int64) const;
109  T getFIbm(const void*,od_int64) const;
110 
111  T getS2swp(const void*,od_int64) const;
112  T getS4swp(const void*,od_int64) const;
113  T getS8swp(const void*,od_int64) const;
114  T getU2swp(const void*,od_int64) const;
115  T getU4swp(const void*,od_int64) const;
116  T getFswp(const void*,od_int64) const;
117  T getDswp(const void*,od_int64) const;
118 
119  T getS2Ibmswp(const void*,od_int64) const;
120  T getS4Ibmswp(const void*,od_int64) const;
121  T getFIbmswp(const void*,od_int64) const;
122 
123  void putS1(void*,od_int64,T) const;
124  void putS2(void*,od_int64,T) const;
125  void putS4(void*,od_int64,T) const;
126  void putS8(void*,od_int64,T) const;
127  void putU1(void*,od_int64,T) const;
128  void putU2(void*,od_int64,T) const;
129  void putU4(void*,od_int64,T) const;
130  void putF(void*,od_int64,T) const;
131  void putD(void*,od_int64,T) const;
132 
133  void putS2Ibm(void*,od_int64,T) const;
134  void putS4Ibm(void*,od_int64,T) const;
135  void putFIbm(void*,od_int64,T) const;
136 
137  void putS2swp(void*,od_int64,T) const;
138  void putS4swp(void*,od_int64,T) const;
139  void putS8swp(void*,od_int64,T) const;
140  void putU2swp(void*,od_int64,T) const;
141  void putU4swp(void*,od_int64,T) const;
142  void putFswp(void*,od_int64,T) const;
143  void putDswp(void*,od_int64,T) const;
144 
145  void putS2Ibmswp(void*,od_int64,T) const;
146  void putS4Ibmswp(void*,od_int64,T) const;
147  void putFIbmswp(void*,od_int64,T) const;
148 
149  typedef T (DataInterpreter<T>::*GetFn)(const void*,od_int64) const;
150  typedef void (DataInterpreter<T>::*PutFn)(void*,od_int64,T) const;
151  typedef void (DataInterpreter<T>::*SwapFn)(void*,od_int64) const;
152  GetFn getfn;
153  PutFn putfn;
154  SwapFn swpfn;
155 
156  void swap0(void*,od_int64) const {}
157  T get0(const void*,od_int64) const { return 0; }
158  void put0(void*,od_int64,T) const {}
159  void swpSwap();
160 
161 };
162 
163 
164 #endif
void swap(void *buf, od_int64 bufsz_in_elements) const
Definition: datainterp.h:70
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
SwapFn swpfn
Definition: datainterp.h:154
T get0(const void *, od_int64) const
Definition: datainterp.h:157
#define mGenClass
Definition: datainterp.h:24
#define od_int64
Definition: plftypes.h:36
GetFn getfn
Definition: datainterp.h:152
bool isSUCompat() const
Definition: datainterp.h:86
OD class for stream read.
Definition: od_istream.h:24
Byte-level data interpreter.
Definition: cbvswriter.h:22
void put0(void *, od_int64, T) const
Definition: datainterp.h:158
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
PutFn putfn
Definition: datainterp.h:153
byte-level data characteristics of stored data.
Definition: datachar.h:37
void swap0(void *, od_int64) const
Definition: datainterp.h:156
T getF(const void *, od_int64) const
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:62
void put(void *buf, od_int64 nr, T t) const
Definition: datainterp.h:79
static uiHor3DInterpol * create(uiParent *)
DataInterpreter< T > & operator=(const DataCharacteristics &dc)
Definition: datainterp.h:66
od_istream & operator=(const od_istream &s)
Definition: od_istream.h:39

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019