OpendTect-6_4  6.4
tabledef.h
Go to the documentation of this file.
1 #ifndef tabledef_h
2 #define tabledef_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: Oct 2006
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "generalmod.h"
16 #include "coordsystem.h"
17 #include "sets.h"
18 #include "rowcol.h"
19 #include "namedobj.h"
20 #include "datainpspec.h"
21 #include "propertyref.h"
22 
23 class UnitOfMeasure;
24 
25 namespace Table
26 {
27 
28  enum ReqSpec { Optional=0, Required=1, Hidden=2 };
29 
42 mExpClass(General) TargetInfo : public NamedObject
43 {
44 public:
45 
62  struct Form : NamedObject
63  {
64  Form( const char* nm, DataInpSpec* spec )
65  : NamedObject(nm)
66  { add( spec ); }
67  Form( const char* nm, const DataInpSpec& spec )
68  : NamedObject(nm)
69  { add( spec.clone() ); }
70 
71  ~Form() { deepErase(specs_); }
72 
73  Form& add( const DataInpSpec& spec )
74  { specs_ += spec.clone(); return *this; }
75  Form& add( DataInpSpec* spec )
76  { specs_ += spec ? spec : new StringInpSpec;
77  return *this; }
78 
79  Form* duplicate( const char* nm ) const
80  {
81  Form* ret = new Form( nm, *specs_[0] );
82  for ( int idx=1; idx<specs_.size(); idx++ )
83  ret->specs_ += specs_[idx]->clone();
84  return ret;
85  }
86 
88  };
89 
90 
91  TargetInfo( const char* nm, ReqSpec rs=Optional )
93  : NamedObject(nm), req_(rs)
94  , proptype_(PropertyRef::Other)
95  { add( nm ); }
96  TargetInfo( const char* nm, DataInpSpec* spec,
97  ReqSpec rs=Optional,
99  : NamedObject(nm), req_(rs), proptype_(p)
100  { add( nm, spec ); }
101  TargetInfo( const char* nm, const DataInpSpec& spec,
102  ReqSpec rs=Optional,
104  : NamedObject(nm), req_(rs), proptype_(p)
105  { add( nm, spec ); }
106 
107  ~TargetInfo() { deepErase( forms_ ); }
108 
109  TargetInfo& add( const char* nm, DataInpSpec* spec=0 )
110  { forms_ += new Form( nm, spec ); return *this; }
111  TargetInfo& add( const char* nm, const DataInpSpec& spec )
112  { forms_ += new Form( nm, spec ); return *this; }
113  TargetInfo& add( Form* frm )
114  { forms_ += frm; return *this; }
115 
116  bool isOptional() const { return req_ != Required; }
117  bool isHidden() const { return req_ == Hidden; }
118  PropertyRef::StdType propertyType() const { return proptype_; }
120  { proptype_ = p; }
121  int nrForms() const { return forms_.size(); }
122  Form& form( int idx ) { return *forms_[idx]; }
123  const Form& form( int idx ) const { return *forms_[idx]; }
124  int formNr( const char* formnm ) const
125  {
126  for ( int idx=0; idx<forms_.size(); idx++ )
127  if ( forms_[idx]->name() == formnm )
128  return idx;
129  return -1;
130  }
131 
137  struct Selection
138  {
140  struct Elem
141  {
143  : pos_(0,-1) {}
144  Elem( const RowCol& rc, const char* kw=0 )
145  : pos_(rc), keyword_(kw) {}
146  Elem( const char* s )
147  : pos_(0,-1), val_(s) {}
148 
149  bool isInFile() const
150  { return pos_.col() >= 0; }
151  bool isKeyworded() const
152  { return isInFile() && !keyword_.isEmpty();}
153  bool isSpecified() const
154  { return !val_.isEmpty(); }
155  bool isEmpty() const
156  { return !isInFile() && !isSpecified();}
157  bool operator ==( const Elem& v ) const
158  { return pos_ == v.pos_ && val_ == v.val_
159  && keyword_ == v.keyword_; }
160 
164  };
165 
166  int form_;
170 
172  : form_(0), unit_(0), coordsys_(0) {}
173 
174  bool havePos( int ielem ) const
175  { return ielem < elems_.size()
176  && elems_[ielem].isInFile(); }
177  bool isKeyworded( int ielem ) const
178  { return ielem < elems_.size()
179  && elems_[ielem].isKeyworded(); }
180  bool isInFile( int ielem=0 ) const
181  { return ielem < elems_.size()
182  && elems_[ielem].isInFile(); }
183  const char* getVal( int ielem ) const
184  { return ielem >= elems_.size() ? 0
185  : elems_[ielem].val_.buf(); }
186  bool isFilled() const
187  { return elems_.size() > 0 && !elems_[0].isEmpty(); }
188  };
189 
191 
192  void fillPar(IOPar&) const;
193  void usePar(const IOPar&);
194 
195  static TargetInfo* mkHorPosition(bool isreq,bool wic=true,bool wll=false,
196  bool wcrs=true);
198  static TargetInfo* mkZPosition( bool isreq, bool withunits=true )
199  { return mkZPos(isreq,withunits); }
200  static TargetInfo* mkDepthPosition( bool isreq, bool withunits=true )
201  { return mkZPos(isreq,withunits,1); }
202  static TargetInfo* mkTimePosition( bool isreq, bool withunits=true )
203  { return mkZPos(isreq,withunits,-1); }
204  bool needsConversion() const;
205  Coord convert(const Coord&) const;
206 
207 protected:
208 
212 
213  static TargetInfo* mkZPos(bool,bool wu=false,int zopt=0);
214 
215 };
216 
217 
221 {
222 public:
223  FormatDesc( const char* nm )
224  : NamedObject(nm)
225  , nrhdrlines_(0)
226  , eohtokencol_(-1) {}
228  { deepErase( headerinfos_ ); deepErase( bodyinfos_ ); }
229 
232 
237 
238  bool needEOHToken() const
239  { return nrhdrlines_ < 0 && !eohtoken_.isEmpty(); }
240  int nrHdrLines() const
241  { return needEOHToken() ? mUdf(int)
242  : nrhdrlines_ > 0 ? nrhdrlines_ : 0; }
243  bool haveEOBToken() const
244  { return !eobtoken_.isEmpty(); }
245 
246  bool isGood() const;
247  bool bodyUsesCol(int) const;
248 
249  void fillPar(IOPar&) const;
250  void usePar(const IOPar&);
251 
252  void clear()
253  {
254  nrhdrlines_ = eohtokencol_ = 0;
255  eohtoken_.setEmpty(); eobtoken_.setEmpty();
256  }
257 };
258 
259 }; // namespace Table
260 
261 
262 #endif
ReqSpec
Definition: tabledef.h:28
#define mExpClass(module)
Definition: commondefs.h:160
bool isHidden() const
Definition: tabledef.h:117
Form * duplicate(const char *nm) const
Definition: tabledef.h:79
ObjectSet< Form > forms_
Definition: tabledef.h:211
const Form & form(int idx) const
Definition: tabledef.h:123
bool havePos(int ielem) const
Definition: tabledef.h:174
TargetInfo(const char *nm, const DataInpSpec &spec, ReqSpec rs=Optional, PropertyRef::StdType p=PropertyRef::Other)
Definition: tabledef.h:101
Form(const char *nm, DataInpSpec *spec)
Definition: tabledef.h:64
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
TypeSet< Elem > elems_
Definition: tabledef.h:167
virtual DataInpSpec * clone() const =0
static TargetInfo * mkTimePosition(bool isreq, bool withunits=true)
Definition: tabledef.h:202
void clear()
Definition: tabledef.h:252
BufferString eohtoken_
end-of-header token
Definition: tabledef.h:234
static TargetInfo * mkZPosition(bool isreq, bool withunits=true)
Definition: tabledef.h:198
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
RowCol pos_
Definition: tabledef.h:161
Selected element/positioning This selects the specific form and where/how it can be found in the file...
Definition: tabledef.h:137
Ref Data for a (usually petrophysical) property.
Definition: propertyref.h:42
BufferString & setEmpty()
description of input our output data content
Definition: tabledef.h:220
Definition: odinst.h:42
PropertyRef::StdType proptype_
Definition: tabledef.h:210
BufferString eobtoken_
end-of-body: no more data
Definition: tabledef.h:236
bool isEmpty() const
Definition: odset.h:45
A cartesian coordinate in 2D space.
Definition: coord.h:25
Selection selection_
Definition: tabledef.h:190
bool isSpecified() const
Definition: tabledef.h:153
TargetInfo & add(const char *nm, const DataInpSpec &spec)
Definition: tabledef.h:111
int form_
Definition: tabledef.h:166
Specifications for character string inputs.
Definition: datainpspec.h:577
Definition: tabledef.h:28
ReqSpec req_
Definition: tabledef.h:209
bool haveEOBToken() const
Definition: tabledef.h:243
Definition: propertyref.h:49
Set of (small) copyable elements.
Definition: commontypes.h:30
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
Specification of input characteristics.
Definition: datainpspec.h:89
Definition: geom2dascio.h:21
void setPropertyType(PropertyRef::StdType p)
Definition: tabledef.h:119
int nrhdrlines_
if < 0 eohtoken will be used
Definition: tabledef.h:233
Specific form in which a piece of information can be found.
Definition: tabledef.h:62
static TargetInfo * mkDepthPosition(bool isreq, bool withunits=true)
Definition: tabledef.h:200
int eohtokencol_
if < 0 eohtoken can be in any col
Definition: tabledef.h:235
Form & add(const DataInpSpec &spec)
Definition: tabledef.h:73
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
const UnitOfMeasure * unit_
Definition: tabledef.h:168
bool isFilled() const
Definition: tabledef.h:186
Definition: tabledef.h:28
TargetInfo(const char *nm, ReqSpec rs=Optional)
Definition: tabledef.h:91
Form(const char *nm, const DataInpSpec &spec)
Definition: tabledef.h:67
TargetInfo(const char *nm, DataInpSpec *spec, ReqSpec rs=Optional, PropertyRef::StdType p=PropertyRef::Other)
Definition: tabledef.h:96
ObjectSet< TargetInfo > bodyinfos_
Definition: tabledef.h:231
Selection()
Definition: tabledef.h:171
int formNr(const char *formnm) const
Definition: tabledef.h:124
BufferString keyword_
Definition: tabledef.h:162
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
Definition: tabledef.h:28
~TargetInfo()
Definition: tabledef.h:107
BufferString val_
Definition: tabledef.h:163
IdxPair used for its row() and col().
Definition: rowcol.h:25
Elem(const char *s)
Definition: tabledef.h:146
bool isOptional() const
Definition: tabledef.h:116
int nrHdrLines() const
Definition: tabledef.h:240
TargetInfo & add(const char *nm, DataInpSpec *spec=0)
Definition: tabledef.h:109
size_type size() const
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
T convert(Type inptyp, T val, Type outtyp)
Definition: angles.h:76
const char * getVal(int ielem) const
Definition: tabledef.h:183
bool isEmpty() const
Definition: odstring.h:51
bool needEOHToken() const
Definition: tabledef.h:238
bool isKeyworded(int ielem) const
Definition: tabledef.h:177
PropertyRef::StdType propertyType() const
Definition: tabledef.h:118
Form & form(int idx)
Definition: tabledef.h:122
Object with a name.
Definition: namedobj.h:35
Elem(const RowCol &rc, const char *kw=0)
Definition: tabledef.h:144
bool isInFile() const
Definition: tabledef.h:149
bool isInFile(int ielem=0) const
Definition: tabledef.h:180
int nrForms() const
Definition: tabledef.h:121
ConstRefMan< Coords::CoordSystem > coordsys_
Definition: tabledef.h:169
Elem()
Definition: tabledef.h:142
FormatDesc(const char *nm)
Definition: tabledef.h:223
TargetInfo & add(Form *frm)
Definition: tabledef.h:113
StdType
Definition: propertyref.h:46
ObjectSet< DataInpSpec > specs_
Definition: tabledef.h:87
Description of a Logical piece of information.
Definition: tabledef.h:42
holds the &#39;value&#39; of a certain selection
Definition: tabledef.h:140
Form & add(DataInpSpec *spec)
Definition: tabledef.h:75
ObjectSet< TargetInfo > headerinfos_
Definition: tabledef.h:230
~Form()
Definition: tabledef.h:71
Unit of Measure.
Definition: unitofmeasure.h:35
bool isEmpty() const
Definition: tabledef.h:155
bool isKeyworded() const
Definition: tabledef.h:151
~FormatDesc()
Definition: tabledef.h:227
void deepErase(ObjectSet< T > &os)
empty the ObjectSet deleting all objects pointed to.
Definition: objectset.h:118

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