OpendTect  6.6
ctxtioobj.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: 7-1-1996
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "generalmod.h"
15 #include "namedobj.h"
16 #include "multiid.h"
17 #include "enums.h"
18 #include "ioobj.h"
19 #include "iopar.h"
20 
21 class TranslatorGroup;
22 class IOStream;
23 
29 {
30 public:
31 
36 
39 
42 
43  bool isGood(const IOObj&,bool forread=true) const;
44  void clear();
45 
46  static bool isAllowedTranslator(const char* tnm,const char* allowd);
47 
48 };
49 
50 
62 {
63 public:
64 
65  enum StdSelType { Seis=0, Surf, Loc, Feat, WllInf, NLA, Misc, Attr, Mdl,
66  Geom, None };
68 
70  const char* prefname=0);
72 
74 
79  bool multi_;
80 
82  bool forread_;
84  bool maydooper_;
87 
88  bool validIOObj(const IOObj&) const;
89 
90  struct StdDirData
91  {
92  StdDirData(const char*,const char*,
93  const char*);
94 
95  const char* id_;
96  const char* dirnm_;
97  const char* desc_;
99 
100  mDeprecated("Use id_") const char*& id;
101  mDeprecated("Use dirnm_") const char*& dirnm;
102  mDeprecated("Use desc_") const char*& desc;
103  };
104 
105  static int totalNrStdDirs();
106  static const StdDirData* getStdDirData(StdSelType);
107  static BufferString getDataDirName(StdSelType);
108  static BufferString getDataDirName(StdSelType,bool dironly);
110 
111  const char* objectTypeName() const;
112  inline bool hasStdSelKey() const { return stdseltype_ != None; }
115  const MultiID&) const;
116  void fillTrGroup() const;
119  void fixTranslator( const char* trusrnm )
120  { deftransl_ = toselect_.allowtransls_ = trusrnm; }
121 
122  int nrMatches() const;
123  inline bool haveMatches() const { return nrMatches() > 0; }
124 
125  mDeprecated("Use stdseltype_") StdSelType& stdseltype;
126  mDeprecated("Use trgroup_") const TranslatorGroup*& trgroup;
127  mDeprecated("Use newonlevel_") int& newonlevel;
128  mDeprecated("Use multi_") bool& multi;
129  mDeprecated("Use forread_") bool& forread;
130  mDeprecated("Use selkey_") MultiID& selkey;
131  mDeprecated("Use maydooper_") bool& maydooper;
132  mDeprecated("Use deftransl_") BufferString& deftransl;
133  mDeprecated("Use toselect_") IOObjSelConstraints& toselect;
134 };
135 
136 
145 mExpClass(General) CtxtIOObj : public NamedObject
146 {
147 public:
149  CtxtIOObj( const IOObjContext& ct, IOObj* o=0 )
150  : NamedObject(ct), ctxt_(ct), ioobj_(o) , iopar_(0)
151  , ctxt(ctxt_), ioobj(ioobj_), iopar(iopar_)
152  { if ( o ) setName(o->name()); }
153  CtxtIOObj( const CtxtIOObj& ct )
154  : NamedObject(ct), ctxt_(ct.ctxt_)
155  , ioobj_(ct.ioobj_?ct.ioobj_->clone():0)
156  , iopar_(ct.iopar_?new IOPar(*ct.iopar_):0)
157  , ctxt(ctxt_), ioobj(ioobj_), iopar(iopar_)
158  {}
160  void destroyAll();
161 
162  virtual const OD::String& name() const { return ctxt_.name(); }
163  virtual void setName(const char* nm) { ctxt_.setName(nm); }
164  virtual BufferString getName() const { return ctxt_.getName(); }
165 
166  void setObj(IOObj*);
167  void setObj(const MultiID&);
168  void setPar(IOPar*);
169  int fillObj(bool mktmpifnew=false,int translidxfornew=-1);
175  void fillDefault(bool alsoifonlyone=true);
177  void fillDefaultWithKey(const char*,bool alsoifonlyone=true);
179 
183 
184  //Legacy
185  mDeprecated("Use ctxt_") IOObjContext& ctxt;
186  mDeprecated("Use ioobj_") IOObj*& ioobj;
187  mDeprecated("Use iopar_") IOPar*& iopar;
188 };
189 
190 
CtxtIOObj::ioobj_
IOObj * ioobj_
Definition: ctxtioobj.h:181
NamedObject
object with a name.
Definition: namedobj.h:42
IOObjSelConstraints
Holds constraints on IOObj selection.
Definition: ctxtioobj.h:29
IOObjContext::selkey_
MultiID selkey_
If set, overrules the 'standard'.
Definition: ctxtioobj.h:83
CtxtIOObj::setObj
void setObj(const MultiID &)
destroys previous
IOObjContext::forread_
bool forread_
this selection only
Definition: ctxtioobj.h:82
IOObjContext::haveMatches
bool haveMatches() const
Definition: ctxtioobj.h:123
IOObjContext::StdDirData::id_
const char * id_
Definition: ctxtioobj.h:95
IOObjSelConstraints::allowtransls_
BufferString allowtransls_
FileMultiString of glob expressions.
Definition: ctxtioobj.h:40
Seis
Summary for a Seismic object.
Definition: segydirectdef.h:22
CtxtIOObj::ctxt_
IOObjContext ctxt_
Definition: ctxtioobj.h:180
CtxtIOObj
Holds an IOObjCtxt plus a pointer to an IOObj and/or an IOPar.
Definition: ctxtioobj.h:146
IOObjContext::getSelKey
MultiID getSelKey() const
IOObjSelConstraints::isAllowedTranslator
static bool isAllowedTranslator(const char *tnm, const char *allowd)
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
IOObjSelConstraints::clear
void clear()
IOObjSelConstraints::allownonuserselectable_
bool allownonuserselectable_
allow 'alien' like SEG-Y
Definition: ctxtioobj.h:41
namedobj.h
CtxtIOObj::setPar
void setPar(IOPar *)
destroys previous
CtxtIOObj::destroyAll
mStopAllowDeprecatedSection void destroyAll()
IOObjSelConstraints::isGood
bool isGood(const IOObj &, bool forread=true) const
CtxtIOObj::iopar_
IOPar * iopar_
Definition: ctxtioobj.h:182
IOObjContext::StdDirData::desc_
const char * desc_
Can be converted to StdSelType.
Definition: ctxtioobj.h:97
IOObjContext::stdseltype_
StdSelType stdseltype_
intrinsics
Definition: ctxtioobj.h:76
IOObjContext::StdDirData
Definition: ctxtioobj.h:91
IOObjContext::crDefaultWriteObj
IOStream * crDefaultWriteObj(const Translator &, const MultiID &) const
IOObjSelConstraints::IOObjSelConstraints
IOObjSelConstraints()
IOObjContext::validIOObj
bool validIOObj(const IOObj &) const
mStartAllowDeprecatedSection
#define mStartAllowDeprecatedSection
Definition: plfdefs.h:232
multiid.h
IOObjContext::IOObjContext
IOObjContext(const IOObjContext &)
IOObjContext::fixTranslator
void fixTranslator(const char *trusrnm)
Definition: ctxtioobj.h:119
IOObjContext::maydooper_
bool maydooper_
Will we allow add/remove etc?
Definition: ctxtioobj.h:84
CtxtIOObj::fillDefaultWithKey
void fillDefaultWithKey(const char *, bool alsoifonlyone=true)
With alternate key.
CtxtIOObj::CtxtIOObj
CtxtIOObj(const CtxtIOObj &ct)
Definition: ctxtioobj.h:153
mDeprecated
#define mDeprecated(msg)
Definition: plfdefs.h:215
IOObjContext::deftransl_
BufferString deftransl_
Translator to use for new entry.
Definition: ctxtioobj.h:85
IOObjContext
Holds the context for selecting and/or creating IOObjs.
Definition: ctxtioobj.h:62
IOObjContext::newonlevel_
int newonlevel_
level 0 is survey dir
Definition: ctxtioobj.h:78
IOObjSelConstraints::~IOObjSelConstraints
~IOObjSelConstraints()
CtxtIOObj::setObj
void setObj(IOObj *)
destroys previous
IOObj
Definition: ioobj.h:58
CtxtIOObj::name
virtual const OD::String & name() const
Definition: ctxtioobj.h:162
TranslatorGroup
Group of Translators. Has a static factory.
Definition: transl.h:56
IOStream
Definition: iostrm.h:26
CtxtIOObj::fillIfOnlyOne
void fillIfOnlyOne()
IOObjContext::StdDirData::dirnm_
const char * dirnm_
Definition: ctxtioobj.h:96
mStopAllowDeprecatedSection
#define mStopAllowDeprecatedSection
Definition: plfdefs.h:233
MultiID
Compound key consisting of ints.
Definition: multiid.h:24
IOObjContext::fillTrGroup
void fillTrGroup() const
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
Network::None
@ None
Definition: networkcommon.h:33
CtxtIOObj::getName
virtual BufferString getName() const
Definition: ctxtioobj.h:164
CtxtIOObj::fillDefault
void fillDefault(bool alsoifonlyone=true)
gets Default.xx or does fillIfOnlyOne()
Geom
Definition: geometry.h:19
IOObjSelConstraints::dontallow_
IOPar & dontallow_
Definition: ctxtioobj.h:38
CtxtIOObj::CtxtIOObj
mStartAllowDeprecatedSection CtxtIOObj(const IOObjContext &ct, IOObj *o=0)
Definition: ctxtioobj.h:149
IOObjContext::StdSelType
StdSelType
Definition: ctxtioobj.h:65
IOObjContext::trgroup_
const TranslatorGroup * trgroup_
Mandatory, must never be 0.
Definition: ctxtioobj.h:77
IOObjContext::StdDirData::StdDirData
StdDirData(const char *, const char *, const char *)
IOObjContext::toselect_
IOObjSelConstraints toselect_
Definition: ctxtioobj.h:86
OD::String
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
NamedObject::operator=
NamedObject & operator=(const NamedObject &)
enums.h
IOObjSelConstraints::IOObjSelConstraints
IOObjSelConstraints(const IOObjSelConstraints &)
Translator
I/O Interpreter class for a certain object type.
Definition: transl.h:123
IOObjContext::mDeclareEnumUtils
mDeclareEnumUtils(StdSelType)
CtxtIOObj::mDeprecated
mDeprecated("Use ctxt_") IOObjContext &ctxt
iopar.h
IOObjContext::StdDirData::mDeprecated
mDeprecated("Use id_") const char *&id
IOObjContext::IOObjContext
IOObjContext(const TranslatorGroup *, const char *prefname=0)
IOObjContext::multi_
bool multi_
If true, multi allowed.
Definition: ctxtioobj.h:79
CtxtIOObj::fillObj
int fillObj(bool mktmpifnew=false, int translidxfornew=-1)
IOPar
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:55
IOObjContext::mDeprecated
mDeprecated("Use stdseltype_") StdSelType &stdseltype
IOObjSelConstraints::require_
IOPar & require_
Definition: ctxtioobj.h:37
IOObjContext::nrMatches
int nrMatches() const
IOObjContext::WllInf
@ WllInf
Definition: ctxtioobj.h:65
ioobj.h
CtxtIOObj::setName
virtual void setName(const char *nm)
Definition: ctxtioobj.h:163

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