OpendTect-6_4  6.4
ioman.h
Go to the documentation of this file.
1 #ifndef ioman_h
2 #define ioman_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: 3-8-1995
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 
16 #include "generalmod.h"
17 #include "namedobj.h"
18 #include "multiid.h"
19 
20 class CtxtIOObj;
21 class IODir;
22 class IOObj;
23 class IOObjContext;
24 class IOSubDir;
25 class SurveyInfo;
26 class SurveyDataTreePreparer;
27 
36 mExpClass(General) IOMan : public NamedObject
37 {
38 public:
39 
40  bool isBad() const { return state_ != Good; }
41  bool isReady() const;
42  const OD::String& message() const { return msg_; }
43 
45  IOObj* get(const MultiID&) const;
46  IOObj* getLocal(const char* objname,const char* tgname) const;
47  IOObj* getOfGroup(const char* tgname,bool first=true,
48  bool onlyifsingle=false) const;
49  IOObj* getIfOnlyOne( const char* trgroupname )
50  { return getOfGroup(trgroupname,true,true); }
51  IOObj* getFirst(const IOObjContext&,int* nrpresent=0) const;
53  IOObj* getFromPar(const IOPar&,const char* basekey,
54  const IOObjContext&,bool mknew,
55  BufferString& errmsg) const;
56  IOObj* get(const char* objname,const char* tgname) const;
57 
58  bool isPresent(const char*,const char* tgname=0) const;
63  const MultiID& key() const;
64  const char* curDirName() const;
65  const char* rootDir() const { return rootdir_; }
66  bool isKey(const char* keystr) const;
67  const char* nameOf(const char* keystr) const;
69 
70  MultiID createNewKey(const MultiID& dirkey);
71 
72  bool to(const MultiID&,bool force_reread=false);
73  bool toRoot(bool force_reread=false)
74  { return to(0,force_reread); }
75 
76  void getEntry(CtxtIOObj&,bool newistmp=false,
77  int translidxingroup=-1);
79  bool commitChanges(const IOObj&);
80  bool permRemove(const MultiID&);
82 
83  const char* surveyName() const;
84 
86  {
87  public:
88  CustomDirData( const char* selkey, const char* dirnm,
89  const char* desc="Custom data" )
90  : selkey_(selkey)
91  , dirname_(dirnm)
92  , desc_(desc) {}
93 
95  BufferString dirname_;
99 
101  bool operator ==( const CustomDirData& cdd ) const
102  { return selkey_ == cdd.selkey_; }
103  };
104 
105  static const MultiID& addCustomDataDir(const CustomDirData&);
108 
116 
117  static bool isValidDataRoot(const char* dirnm);
118  static bool isValidSurveyDir(const char* dirnm);
119 
120 private:
121 
122  enum State { Bad, NeedInit, Good };
123 
127  int curlvl_;
131 
132  void init();
133  void reInit(bool dotrigger);
134  IOMan(const char* rd=0);
135  ~IOMan();
136 
137  static IOMan* theinst_;
138  static void setupCustomDataDirs(int);
139 
140  bool setDir(const char*);
141  int levelOf(const char* dirnm) const;
142  int curLevel() const { return curlvl_; }
143  bool to(const IOSubDir*,bool);
144  IOObj* crWriteIOObj(const CtxtIOObj&,const MultiID&,int) const;
145 
146  friend class SurveyDataTreePreparer;
147  friend mGlobal(General) IOMan& IOM();
148 
149 public:
150 
151  // Don't use these functions unless you really know what you're doing
152 
153  bool setRootDir(const char*);
154  static bool validSurveySetup(BufferString& errmsg);
155  static IOSubDir* getIOSubDir(const CustomDirData&);
156 
157  void setChangeSurveyBlocked( bool yn )
158  { survchgblocked_ = yn; }
159  bool changeSurveyBlocked() const
160  { return survchgblocked_; }
161  void applClosing() { applicationClosing.trigger(); }
162  static bool newSurvey(SurveyInfo* newsi=0);
164  static bool setSurvey(const char*);
168  static void surveyParsChanged();
171 };
172 
173 
174 mGlobal(General) IOMan& IOM();
175 
176 
177 #endif
#define mExpClass(module)
Definition: commondefs.h:160
IODir * dirptr_
Definition: ioman.h:126
BufferString msg_
Definition: ioman.h:128
const OD::String & message() const
Definition: ioman.h:42
Definition: ioman.h:85
IOObj * getIfOnlyOne(const char *trgroupname)
Definition: ioman.h:49
Definition: ioobj.h:58
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class...
Definition: threadlock.h:53
T to(const F &fr)
Definition: convert.h:33
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
State state_
Definition: ioman.h:125
Notifier< IOMan > surveyChanged
To restore OD to normal state.
Definition: ioman.h:113
MultiID selkey_
Definition: ioman.h:94
#define mGlobal(module)
Definition: commondefs.h:163
Notifier< IOMan > afterSurveyChange
When operating in normal state.
Definition: ioman.h:114
bool init()
manages the &#39;Meta-&#39;data store for the IOObj&#39;s. This info is read from the .omf files.
Definition: ioman.h:36
bool isBad() const
Definition: ioman.h:40
BufferString desc_
Definition: ioman.h:98
IOMan & IOM()
int curlvl_
Definition: ioman.h:127
Holds survey general information.
Definition: survinfo.h:45
Holds an IOObjCtxt plus a pointer to an IOObj and/or an IOPar.
Definition: ctxtioobj.h:142
BufferString rootdir_
Definition: ioman.h:124
const char * rootDir() const
Definition: ioman.h:65
void applClosing()
Definition: ioman.h:161
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
bool changeSurveyBlocked() const
Definition: ioman.h:159
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
static IOMan * theinst_
Definition: ioman.h:137
void trigger(T &t)
Definition: callback.h:258
State
Definition: ioman.h:122
bool survchgblocked_
Definition: ioman.h:129
CustomDirData(const char *selkey, const char *dirnm, const char *desc="Custom data")
Definition: ioman.h:88
Notifier< IOMan > applicationClosing
&#39;Final&#39; call ...
Definition: ioman.h:115
Definition: iosubdir.h:18
Notifier< IOMan > surveyToBeChanged
Before the change.
Definition: ioman.h:112
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
Object with a name.
Definition: namedobj.h:35
Notifier< IOMan > entryRemoved
CallBacker: CBCapsule<MultiID>
Definition: ioman.h:110
bool toRoot(bool force_reread=false)
Definition: ioman.h:73
Definition: iodir.h:36
Threads::Lock lock_
Definition: ioman.h:130
Notifier< IOMan > entryAdded
Definition: ioman.h:111
const char * nameOf(ButtonState)
Notifier< IOMan > newIODir
Definition: ioman.h:109
int curLevel() const
Definition: ioman.h:142
bool getFromPar(const IOPar &, GeomType &)
Compound key consisting of ints.
Definition: multiid.h:25
Holds the context for selecting and/or creating IOObjs.
Definition: ctxtioobj.h:62

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