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

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