OpendTect  6.3
propertyref.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: Bert Bril
8  Date: Sep 2010
9 ________________________________________________________________________
10 
11 
12 -*/
13 
14 #include "generalmod.h"
15 #include "generalmod.h"
16 #include "ranges.h"
17 #include "namedobj.h"
18 #include "enums.h"
19 #include "bufstringset.h"
20 #include "color.h"
21 #include "repos.h"
22 
23 
24 class ascistream;
25 class ascostream;
26 class Property;
27 class MathProperty;
28 struct PropRef_ThickRef_Man;
29 
30 
41 {
42 public:
43 
44  enum StdType {
45  Anis, Area, Class, Comp, Den, Dist, ElaRa, ElPot,
46  GR, Imp, Perm, Pres, PresWt, Res, Son, Temp, Time,
48  };
50  static StdType surveyZType();
51 
52  PropertyRef( const char* nm, StdType t=Other )
53  : NamedObject(nm)
54  , stdtype_(t), mathdef_(0) {}
55  PropertyRef( const PropertyRef& pr )
56  : NamedObject(pr.name())
57  , mathdef_(0) { *this = pr; }
58  virtual ~PropertyRef();
59  PropertyRef& operator =(const PropertyRef&);
60  inline bool operator ==( const PropertyRef& pr ) const
61  { return name() == pr.name(); }
62  inline bool operator !=( const PropertyRef& pr ) const
63  { return name() != pr.name(); }
64  bool isKnownAs(const char*) const;
65  bool hasFixedDef() const { return mathdef_; }
66 
67  inline StdType stdType() const { return stdtype_; }
68  inline bool hasType( StdType t ) const
69  { return stdtype_ == t; }
70  inline bool isCompatibleWith( const PropertyRef& pr ) const
71  { return hasType(pr.stdType()); }
72  inline void setStdType( StdType t ) { stdtype_ = t; }
73  void setFixedDef(const MathProperty*);
75 
76  inline BufferStringSet& aliases() { return aliases_; }
77  inline const BufferStringSet& aliases() const { return aliases_; }
78  const MathProperty& fixedDef() const { return *mathdef_; }
80 
81  static const PropertyRef& undef();
82 
83  // Defaults for display
84  mStruct(General) DispDefs
85  {
86  DispDefs()
87  : color_(Color::Black())
88  , defval_(0)
89  , range_(mUdf(float),mUdf(float)) {}
90  ~DispDefs();
91 
92  Color color_;
93  Property* defval_;
94  Interval<float> range_;
95  BufferString unit_;
96 
97  float commonValue() const;
98  };
99 
100  DispDefs disp_;
101 
102  static const PropertyRef& thickness();
104  inline bool isThickness() const { return this == &thickness(); }
105  static const char* standardSVelStr() { return "Swave velocity";}
106  static const char* standardSVelAliasStr() { return "SVel";}
107  static const char* standardPVelStr() { return "Pwave velocity";}
108  static const char* standardPVelAliasStr() { return "PVel";}
109 
110 protected:
111 
115 
116  friend class PropertyRefSet;
117  void usePar(const IOPar&);
118  void fillPar(IOPar&) const;
119 public:
120  static void setThickness(const PropertyRef*);
121 
122 };
123 
124 
126 {
127 public:
128 
129  PropertyRefSet();
131  : ObjectSet<PropertyRef>() { *this = prs; }
132  ~PropertyRefSet();
134 
135  inline bool isPresent( const char* nm ) const
136  { return indexOf(nm) >= 0; }
137  int indexOf(const char*) const;
138  int indexOf(PropertyRef::StdType,int occ=0) const;
139  inline PropertyRef* find( const char* nm ) { return fnd(nm); }
140  inline const PropertyRef* find( const char* nm ) const { return fnd(nm); }
141 
142  int add(PropertyRef*);
145  int ensurePresent(PropertyRef::StdType,const char* nm1,
146  const char* nm2=0,const char* nm3=0);
147 
148  bool save(Repos::Source) const;
149 
150  inline bool isPresent( const PropertyRef* pr ) const
151  { return ObjectSet<PropertyRef>::isPresent(pr); }
152  int indexOf( const PropertyRef* pr ) const
153  { return ObjectSet<PropertyRef>::indexOf(pr); }
156 
157 protected:
158 
159  PropertyRef* fnd(const char*) const;
160  virtual PropertyRefSet& doAdd( PropertyRef* pr )
161  { add(pr); return *this; }
162 
163 public:
164 
165  void readFrom(ascistream&);
166  bool writeTo(ascostream&) const;
167 
168 };
169 
170 mGlobal(General) const PropertyRefSet& PROPS();
171 inline PropertyRefSet& ePROPS() { return const_cast<PropertyRefSet&>(PROPS()); }
172 
173 
175 {
176 public:
177 
179  bool operator ==(const PropertyRefSelection&) const;
180 
181  int indexOf(const char*) const;
182  int find(const char*) const; // also uses 'isKnownAs'
183 
184  inline bool isPresent( const char* prnm ) const
185  { return indexOf( prnm ) >= 0; }
186  inline int indexOf( const PropertyRef* pr ) const
188  inline bool isPresent( const PropertyRef* pr ) const
190 
191  inline const PropertyRef* getByName( const char* nm ) const
192  { const int idx = indexOf(nm);
193  return idx < 0 ? 0 : (*this)[idx]; }
194 
196 
197  static PropertyRefSelection getAll(bool with_thickness=true,
198  const PropertyRef* exclude=0);
200 
201 };
#define mExpClass(module)
Definition: commondefs.h:157
Velocity.
Definition: velocityfunction.h:30
BufferStringSet aliases_
Definition: propertyref.h:113
Calculated property.
Definition: mathproperty.h:30
MathProperty * mathdef_
Definition: propertyref.h:114
const PropertyRefSet & PROPS()
Definition: propertyref.h:174
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
StdType stdtype_
Definition: propertyref.h:112
int add(PropertyRef *)
bool isThickness() const
Definition: propertyref.h:104
#define mStruct(module)
Definition: commondefs.h:162
#define mGlobal(module)
Definition: commondefs.h:160
DispDefs disp_
Definition: propertyref.h:98
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:200
OpendTect standard ascii format file writing.
Definition: ascstream.h:30
Ref Data for a (usually petrophysical) property.
Definition: propertyref.h:40
const BufferStringSet & aliases() const
Definition: propertyref.h:77
PropertyRef * find(const char *nm)
Definition: propertyref.h:139
void readFrom(ascistream &)
virtual bool isPresent(const T *) const
Definition: objectset.h:348
Definition: odinst.h:40
const MathProperty & fixedDef() const
be sure hasFixedDef() returns true!
Definition: propertyref.h:78
Set of BufferString objects.
Definition: bufstringset.h:25
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:173
const PropertyRef * find(const char *nm) const
Definition: propertyref.h:140
PropertyRefSet & operator=(const PropertyRefSet &)
#define mDeclareEnumUtils(enm)
Some utilities surrounding the often needed enum <-> string table.
Definition: enums.h:188
Set of pointers to objects.
Definition: commontypes.h:28
bool isCompatibleWith(const PropertyRef &pr) const
Definition: propertyref.h:70
bool isPresent(const PropertyRef *pr) const
Definition: propertyref.h:188
static const char * standardPVelStr()
Definition: propertyref.h:107
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
const PropertyRef * getByName(const char *nm) const
Definition: propertyref.h:191
Definition: propertyref.h:125
int ensurePresent(PropertyRef::StdType, const char *nm1, const char *nm2=0, const char *nm3=0)
virtual PropertyRefSet & doAdd(PropertyRef *pr)
Definition: propertyref.h:160
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
Source
Definition: repos.h:23
static const char * standardSVelStr()
Definition: propertyref.h:105
Definition: repos.h:23
bool isPresent(const PropertyRef *pr) const
Definition: propertyref.h:150
void setStdType(StdType t)
Definition: propertyref.h:72
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
PropertyRef(const PropertyRef &pr)
Definition: propertyref.h:55
static const char * standardSVelAliasStr()
Definition: propertyref.h:106
bool hasType(StdType t) const
Definition: propertyref.h:68
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:187
const T * find(const ObjectSet< T > &os, const S &val)
Get const object in set.
Definition: objectset.h:187
OpendTect standard ascii format file reading.
Definition: ascstream.h:81
bool isPresent(const char *prnm) const
Definition: propertyref.h:184
Definition: propertyref.h:47
bool isPresent(const char *nm) const
Definition: propertyref.h:135
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
StdType stdType() const
Definition: propertyref.h:67
Definition: propertyref.h:46
object with a name.
Definition: namedobj.h:20
bool writeTo(ascostream &) const
A (usually petrophysical) property of some object.
Definition: property.h:29
Definition: seistype.h:31
bool save(Repos::Source) const
static const char * standardPVelAliasStr()
Definition: propertyref.h:108
int indexOf(const PropertyRef *pr) const
Definition: propertyref.h:152
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:24
StdType
Definition: propertyref.h:44
Definition: propertyref.h:45
BufferStringSet & aliases()
Definition: propertyref.h:76
PropertyRef * fnd(const char *) const
int indexOf(const PropertyRef *pr) const
Definition: propertyref.h:186
PropertyRefSet(const PropertyRefSet &prs)
Definition: propertyref.h:130
virtual const OD::String & name() const
Definition: namedobj.h:33
bool hasFixedDef() const
Definition: propertyref.h:65
virtual size_type indexOf(const T *) const
Definition: objectset.h:341
bool subselect(PropertyRef::StdType, ObjectSet< const PropertyRef > &) const
PropertyRefSet & ePROPS()
Definition: propertyref.h:171
static Color Black()
Definition: color.h:76

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