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

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