OpendTect-6_4  6.4
attribdesc.h
Go to the documentation of this file.
1 #ifndef attribdesc_h
2 #define attribdesc_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Kristofer Tingdahl
9  Date: 07-10-1999
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "attributeenginemod.h"
16 #include "refcount.h"
17 #include "bufstring.h"
18 #include "bufstringset.h"
19 #include "seistype.h"
20 #include "attribdescid.h"
21 #include "typeset.h"
22 
23 
24 namespace Attrib
25 {
26 
27 class Desc;
28 class Param;
29 class DescSet;
30 class ValParam;
31 
32 typedef void(*DescStatusUpdater)(Desc&);
33 typedef void(*DescDefaultsUpdater)(Desc&);
34 
39 mExpClass(AttributeEngine) DescSetup
40 {
41  public:
42  DescSetup();
43  mDefSetupClssMemb(DescSetup,bool,is2d)
44  mDefSetupClssMemb(DescSetup,bool,ps)
45  mDefSetupClssMemb(DescSetup,bool,singletraceonly)
46  mDefSetupClssMemb(DescSetup,bool,usingtrcpos)
47  mDefSetupClssMemb(DescSetup,bool,depthonly)
48  mDefSetupClssMemb(DescSetup,bool,timeonly)
49  mDefSetupClssMemb(DescSetup,bool,hidden)
50  mDefSetupClssMemb(DescSetup,bool,steering)
51  mDefSetupClssMemb(DescSetup,bool,stored)
52 };
53 
54 
59 mExpClass(AttributeEngine) InputSpec
60 {
61 public:
62  InputSpec( const char* d, bool enabled )
63  : desc_(d), enabled_(enabled)
64  , issteering_(false) {}
65 
66  const char* getDesc() const { return desc_; }
67 
70  bool enabled_;
72 
73  bool operator==(const InputSpec&) const;
74 };
75 
76 
89 mExpClass(AttributeEngine) Desc
90 { mRefCountImpl(Desc)
91 public:
92 
93  enum Locality { SingleTrace, PossiblyMultiTrace, MultiTrace };
94 
95  Desc(const Desc&);
96  Desc(const char* attrname,
97  DescStatusUpdater updater=0,
98  DescDefaultsUpdater defupdater=0);
99 
100  const OD::String& attribName() const;
101 
102  void setDescSet(DescSet*);
103  DescSet* descSet() const;
104  DescID id() const;
105  bool getParentID(DescID cid,DescID& pid,int&) const;
106  void getAncestorIDs(DescID cid,
107  TypeSet<DescID>&,TypeSet<int>&) const;
108  /*ordered from parent to oldest original*/
109 
110  bool getDefStr(BufferString&) const;
111  bool parseDefStr(const char*);
112 
113  const char* userRef() const;
114  void setUserRef(const char*);
115 
116  int nrOutputs() const;
117  void selectOutput(int);
118  int selectedOutput() const;
119 
120  Seis::DataType dataType(int output=-1) const;
123  Locality locality() const { return locality_; }
124  void setLocality( Locality l ) { locality_ = l; }
125  bool usesTracePosition() const { return usestrcpos_;}
126  void setUsesTrcPos( bool yn ) { usestrcpos_ = yn; }
127  bool isSteering() const { return issteering_;}
128  void setSteering( bool yn ) { issteering_ = yn; }
129  bool isHidden() const { return hidden_; }
131  void setHidden( bool yn ) { hidden_ = yn; }
134  bool isStored() const;
135  bool isStoredInMem() const;
136  BufferString getStoredID(bool recursive=false) const;
137  BufferString getStoredType(bool recursive=false) const;
138 
139  void setNeedProvInit( bool yn=true )
140  { needprovinit_ = yn; }
141  bool needProvInit() const
142  { return needprovinit_;}
143 
144  int nrInputs() const;
145  InputSpec& inputSpec(int);
146  const InputSpec& inputSpec(int) const;
147  bool setInput(int,const Desc*);
148  Desc* getInput(int);
149  const Desc* getInput(int) const;
150  void getInputs(TypeSet<Attrib::DescID>&) const;
151  void getDependencies(TypeSet<Attrib::DescID>&) const;
155  bool is2D() const { return is2d_; }
156  void set2D( bool yn ) { is2d_ = yn; }
157  bool isPS() const { return isps_; }
158  void setPS( bool yn ) { isps_ = yn; }
159 
160  enum SatisfyLevel { AllOk, Warning, Error };
161  SatisfyLevel isSatisfied() const;
164  const char* errMsg() const;
165  void setErrMsg( const char* str ) { errmsg_=str; }
166 
167  bool isIdenticalTo(const Desc&,
168  bool cmpoutput=true) const;
169  bool isIdentifiedBy(const char*) const;
170  DescID inputId(int idx) const;
171 
172  /* Interface to factory */
173  void addParam(Param*);
175  const Param* getParam(const char* key) const;
176  Param* getParam(const char* key);
177  const ValParam* getValParam(const char* key) const;
178  ValParam* getValParam(const char* key);
179  void setParamEnabled(const char* key,bool yn=true);
180  bool isParamEnabled(const char* key) const;
181  void setParamRequired(const char* key,bool yn=true);
182  bool isParamRequired(const char* key) const;
183 
184  void updateParams();
185  void updateDefaultParams();
186  void changeStoredID(const char*);
187 
188  void addInput(const InputSpec&);
189  bool removeInput(int idx);
190  void removeOutputs();
191  void addOutputDataType(Seis::DataType);
192  void setNrOutputs(Seis::DataType,int);
193  void addOutputDataTypeSameAs(int);
194  void changeOutputDataType(int,Seis::DataType);
195 
196  static bool getAttribName(const char* defstr,BufferString&);
197  static bool getParamString(const char* defstr,
198  const char* key,BufferString&);
199 
200  Desc* getStoredInput() const;
201  DescID getMultiOutputInputID() const;
202 
203  //Used to clone an attribute chain and apply it on multiple components
204  //of the same input cube (different offsets for instance)
205  Desc* cloneDescAndPropagateInput(const DescID&,
206  BufferString);
207  //6.0 only, next versions will see the protected member
208  //become public instead
209  static void getKeysValsPublic(const char* defstr,
210  BufferStringSet& keys,
211  BufferStringSet& vals,
212  const char* onlyneedkey=0)
213  { getKeysVals(defstr,keys, vals, onlyneedkey); }
217  // Will be removed after 6.2
218  static const char* sKeyInlDipComp();
219  static const char* sKeyCrlDipComp();
220  static const char* sKeyLineDipComp();
221 
222 protected:
223 
224  bool setInput_(int,Desc*);
225  Param* findParam(const char* key);
226 
227  static void getKeysVals(const char* defstr,
228  BufferStringSet& keys,
229  BufferStringSet& vals,
230  const char* onlyneedkey=0);
237  bool hidden_;
239  bool is2d_;
240  bool isps_;
241  Locality locality_;
243 
246 
249 
253 
257 };
258 
259 } // namespace Attrib
260 
261 #define mGetIntFromDesc( __desc, var, varstring ) \
262 {\
263  var = __desc.getValParam(varstring)->getIntValue(0); \
264  if ( mIsUdf(var) )\
265  var = __desc.getValParam(varstring)->getDefaultIntValue(0);\
266 }
267 
268 #define mGetFloatFromDesc( __desc, var, varstring ) \
269 {\
270  var = __desc.getValParam(varstring)->getFValue(0); \
271  if ( mIsUdf(var) )\
272  var = __desc.getValParam(varstring)->getDefaultfValue(0);\
273 }
274 
275 
276 #define mGetDoubleFromDesc( __desc, var, varstring ) \
277 {\
278  var = __desc.getValParam(varstring)->getDValue(0); \
279  if ( mIsUdf(var) )\
280  var = __desc.getValParam(varstring)->getDefaultdValue(0);\
281 }
282 
283 
284 #define mGetBoolFromDesc( __desc, var, varstring ) \
285 {\
286  Attrib::ValParam* valparam##var = \
287  const_cast<Attrib::ValParam*>(__desc.getValParam(varstring));\
288  mDynamicCastGet(Attrib::BoolParam*,boolparam##var,valparam##var);\
289  if ( boolparam##var ) \
290  var = boolparam##var->isSet() ? boolparam##var->getBoolValue(0)\
291  : boolparam##var->getDefaultBoolValue(0);\
292 }
293 
294 #define mGetEnumFromDesc( __desc, var, varstring ) \
295 {\
296  Attrib::ValParam* valparam##var = \
297  const_cast<Attrib::ValParam*>(__desc.getValParam(varstring));\
298  mDynamicCastGet(Attrib::EnumParam*,enumparam##var,valparam##var);\
299  if ( enumparam##var ) \
300  var = enumparam##var->isSet() ? enumparam##var->getIntValue(0)\
301  : enumparam##var->getDefaultIntValue(0);\
302 }
303 
304 #define mGetStringFromDesc( __desc, var, varstring ) \
305 {\
306  var = __desc.getValParam(varstring)->getStringValue(0); \
307  if ( FixedString(var).isEmpty() )\
308  var = __desc.getValParam(varstring)->getDefaultStringValue(0); \
309 }
310 
311 #define mGetBinIDFromDesc( __desc, var, varstring ) \
312 {\
313  var.inl() = __desc.getValParam(varstring)->getIntValue(0); \
314  var.crl() = __desc.getValParam(varstring)->getIntValue(1); \
315  if ( mIsUdf(var.inl()) || mIsUdf(var.crl()) )\
316  {\
317  Attrib::ValParam* valparam##var = \
318  const_cast<Attrib::ValParam*>(__desc.getValParam(varstring));\
319  mDynamicCastGet(Attrib::BinIDParam*,binidparam##var,valparam##var);\
320  if ( binidparam##var ) \
321  var = binidparam##var->getDefaultBinIDValue();\
322  }\
323  if ( __desc.descSet()->is2D() ) \
324  var.inl() = 0; \
325 }
326 
327 #define mGetFloatIntervalFromDesc( __desc, var, varstring ) \
328 {\
329  var.start = __desc.getValParam(varstring)->getFValue(0); \
330  var.stop = __desc.getValParam(varstring)->getFValue(1); \
331  if ( mIsUdf(var.start) || mIsUdf(var.stop) )\
332  {\
333  Attrib::ValParam* valparam##var = \
334  const_cast<Attrib::ValParam*>(__desc.getValParam(varstring));\
335  mDynamicCastGet(Attrib::ZGateParam*,gateparam##var,valparam##var);\
336  if ( gateparam##var ) \
337  var = gateparam##var->getDefaultGateValue();\
338  }\
339 }
340 
341 #define mGetFloat( var, varstring ) \
342  mGetFloatFromDesc( desc_, var, varstring )
343 #define mGetInt( var, varstring ) \
344  mGetIntFromDesc( desc_, var, varstring )
345 #define mGetBool( var, varstring ) \
346  mGetBoolFromDesc( desc_, var, varstring )
347 #define mGetEnum( var, varstring ) \
348  mGetEnumFromDesc( desc_, var, varstring )
349 #define mGetString( var, varstring ) \
350  mGetStringFromDesc( desc_, var, varstring )
351 #define mGetBinID( var, varstring ) \
352  mGetBinIDFromDesc( desc_, var, varstring )
353 #define mGetFloatInterval( var, varstring ) \
354  mGetFloatIntervalFromDesc( desc_, var, varstring )
355 #define mGetDouble( var, varstring ) \
356  mGetDoubleFromDesc( desc_, var, varstring )
357 
358 #endif
Attribute Value Parameter.
Definition: attribparambase.h:94
#define mRefCountImpl(ClassName)
Macro to setup a class with destructor for reference counting.
Definition: refcount.h:163
#define mExpClass(module)
Definition: commondefs.h:160
ObjectSet< Param > params_
Definition: attribdesc.h:248
BufferString userref_
Definition: attribdesc.h:250
DescStatusUpdater statusupdater_
Definition: attribdesc.h:254
Locality locality() const
Definition: attribdesc.h:123
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
bool issteering_
Definition: attribdesc.h:236
void(* DescDefaultsUpdater)(Desc &)
Definition: attribdesc.h:33
void setErrMsg(const char *str)
Definition: attribdesc.h:165
static void getKeysValsPublic(const char *defstr, BufferStringSet &keys, BufferStringSet &vals, const char *onlyneedkey=0)
Definition: attribdesc.h:209
#define mDefSetupClssMemb(clss, typ, memb)
Definition: commondefs.h:133
bool isps_
Definition: attribdesc.h:240
bool usestrcpos_
Definition: attribdesc.h:242
Set of attribute descriptions.
Definition: attribdescset.h:35
bool isSteering() const
Definition: attribdesc.h:127
DescDefaultsUpdater defaultsupdater_
Definition: attribdesc.h:255
bool is2d_
Definition: attribdesc.h:239
AttribDesc ID: each Desc has a unique ID in a set; the boolean isstored allows us to know whether thi...
Definition: attribdescid.h:27
TypeSet< int > outputtypelinks_
Definition: attribdesc.h:235
void setLocality(Locality l)
Definition: attribdesc.h:124
Set of BufferString objects.
Definition: bufstringset.h:28
bool needprovinit_
Definition: attribdesc.h:238
InputSpec(const char *d, bool enabled)
Definition: attribdesc.h:62
void set2D(bool yn)
Definition: attribdesc.h:156
Set of pointers to objects.
Definition: commontypes.h:32
int seloutput_
Definition: attribdesc.h:251
Specification of input data of an attribute.
Definition: attribdesc.h:59
bool hidden_
Definition: attribdesc.h:237
TypeSet< InputSpec > inputspecs_
Definition: attribdesc.h:244
FixedString Desc()
Definition: keystrs.h:62
void setNeedProvInit(bool yn=true)
Definition: attribdesc.h:139
bool is2D() const
Definition: attribdesc.h:155
bool enabled_
Definition: attribdesc.h:70
Description of an attribute in an Attrib::DescSet. Each attribute has a name (e.g. "Similarity"), a user reference (e.g. "My similarity"), and at least one output. In addition, it may have parameters and inputs. If it has multiple outputs, only one of the outputs are selected.
Definition: attribdesc.h:89
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
Setup class for Attrib::Desc.
Definition: attribdesc.h:39
A parameter that is used by an attribute.
Definition: attribparambase.h:36
void setUsesTrcPos(bool yn)
Definition: attribdesc.h:126
bool usesTracePosition() const
Definition: attribdesc.h:125
BufferString errmsg_
Definition: attribdesc.h:256
DescSet * descset_
Definition: attribdesc.h:252
bool issteering_
Definition: attribdesc.h:71
Locality locality_
Definition: attribdesc.h:241
ObjectSet< Desc > inputs_
Definition: attribdesc.h:245
TypeSet< Seis::DataType > forbiddenDts_
Definition: attribdesc.h:69
void setPS(bool yn)
Definition: attribdesc.h:158
void(* DescStatusUpdater)(Desc &)
Definition: attribdesc.h:32
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
Definition: attribdesc.h:160
BufferString errmsg_
Definition: horizontracker.h:119
bool isPS() const
Definition: attribdesc.h:157
void setHidden(bool yn)
Definition: attribdesc.h:131
bool isHidden() const
Definition: attribdesc.h:129
BufferString attribname_
Definition: attribdesc.h:247
DataType
Definition: seistype.h:54
const char * errMsg() const
Definition: horizontracker.h:61
void setSteering(bool yn)
Definition: attribdesc.h:128
bool needProvInit() const
Definition: attribdesc.h:141
SatisfyLevel
Definition: attribdesc.h:160
Semblance Attribute.
Definition: attribdataholder.h:25
TypeSet< Seis::DataType > outputtypes_
Definition: attribdesc.h:234
const char * getDesc() const
Definition: attribdesc.h:66
BufferString desc_
Definition: attribdesc.h:68

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