OpendTect  6.6
ioman.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: 3-8-1995
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 
15 #include "generalmod.h"
16 #include "ctxtioobj.h"
17 #include "multiid.h"
18 #include "namedobj.h"
19 #include "surveydisklocation.h"
20 
21 class CommandLineParser;
22 class CtxtIOObj;
23 class IODir;
24 class IOMManager;
25 class IOObj;
26 class IOObjContext;
27 class IOSubDir;
28 class SurveyInfo;
29 class SurveyDataTreePreparer;
30 class SurveyDiskLocation;
31 
40 extern "C" {
41 
42 mGlobal(General) const char* setDBMDataSource(const char* fullpath,
43  bool refresh=false);
46 }
47 
48 mExpClass(General) IOMan : public NamedCallBacker
50 public:
51 
52  bool isBad() const { return state_ != Good; }
53  bool isReady() const;
54  const OD::String& message() const { return msg_; }
55 
56  bool isUsable(const DBKey&) const;
57  bool isUsable(const MultiID&) const;
58  bool implExists(const MultiID&) const;
59  bool isReadOnly(const MultiID&) const;
60  bool isManagedObject(const MultiID&) const;
61  bool implRename(const MultiID&,const char* newnm,
62  const CallBack* cb=nullptr);
63  bool implReloc(const MultiID&,const char* newdir,
64  const CallBack* cb=nullptr);
65  bool implRemove(const MultiID&,
66  bool rmentry=false,uiRetVal* uirv=nullptr);
67  bool implRemove(const IOObj&) const;
68 
71  IOObj* get(const DBKey&) const;
72  IOObj* get(const MultiID&) const;
73  IOObj* getLocal(const char* objname,const char* tgname) const;
74  IOObj* getOfGroup(const char* tgname,bool first=true,
75  bool onlyifsingle=false) const;
76  IOObj* getIfOnlyOne( const char* trgroupname )
77  { return getOfGroup(trgroupname,true,true); }
78  IOObj* getFirst(const IOObjContext&,int* nrpresent=0) const;
80  IOObj* getFromPar(const IOPar&,const char* basekey,
81  const IOObjContext&,bool mknew,
82  BufferString& errmsg) const;
83  IOObj* get(const char* objname,const char* tgname) const;
84  IOObj* get(const IOObjContext&,const char* objnm) const;
85 
86  bool isPresent(const MultiID&) const;
87  bool isPresent(const char*,const char* tgname=0) const;
92  const MultiID& key() const;
93  const char* curDirName() const;
94  const char* rootDir() const { return rootdir_; }
95  bool isKey(const char* keystr) const;
96  const char* nameOf(const char* keystr) const;
98  const char* objectName(const DBKey&) const;
99 
100  MultiID createNewKey(const MultiID& dirkey);
101 
102  bool to(const MultiID&,bool force_reread=false);
103  bool toRoot(bool force_reread=false)
104  { return to(0,force_reread); }
105 
106  void getEntry(CtxtIOObj&,bool newistmp=false,
107  int translidxingroup=-1);
109  bool commitChanges(const IOObj&);
110  bool permRemove(const MultiID&);
112 
113  const char* surveyName() const;
114 
116  {
117  public:
118  CustomDirData( const char* selkey, const char* dirnm,
119  const char* desc="Custom data" )
120  : selkey_(selkey)
121  , dirname_(dirnm)
122  , desc_(desc) {}
123 
129 
131  bool operator ==( const CustomDirData& cdd ) const
132  { return selkey_ == cdd.selkey_; }
133  };
134 
135  static const MultiID& addCustomDataDir(const CustomDirData&);
138 
147 
148  static bool isValidDataRoot(const char* dirnm);
149  static bool isValidSurveyDir(const char* dirnm);
150 
151  static void setTempSurvey(const SurveyDiskLocation&);
152  static void cancelTempSurvey();
153 
154 private:
155 
156  enum State { Bad, NeedInit, Good };
157 
161  int curlvl_;
165 
166  void init();
167  void reInit(bool dotrigger);
168  IOMan(const char* rd=0);
170 
171  static IOMan* theinst_;
172  static void setupCustomDataDirs(int);
173 
174  bool setDir(const char*);
175  int levelOf(const char* dirnm) const;
176  int curLevel() const { return curlvl_; }
177  bool to(const IOSubDir*,bool);
179  const CallBack* cb=nullptr);
180  IOObj* crWriteIOObj(const CtxtIOObj&,const MultiID&,int) const;
181 
182  friend class IOMManager;
183  friend class SurveyDataTreePreparer;
184  friend mGlobal(General) IOMan& IOM();
185 
186 public:
187 
188  // Don't use these functions unless you really know what you're doing
189 
190  bool setRootDir(const char*);
191  static bool validSurveySetup(BufferString& errmsg);
193 
194  void setChangeSurveyBlocked( bool yn )
195  { survchgblocked_ = yn; }
196  bool changeSurveyBlocked() const
197  { return survchgblocked_; }
198  void applClosing() { applicationClosing.trigger(); }
199  static bool newSurvey(SurveyInfo* newsi=0);
201  static bool setSurvey(const char*);
205  static void surveyParsChanged();
208  uiRetVal setDataSource(const char* dataroot,const char* survdir,
209  bool refresh=false);
210  uiRetVal setDataSource(const char* fullpath,bool refresh=false);
211  uiRetVal setDataSource(const IOPar&,bool refresh=false);
213  bool refresh=false);
215  IODir* getDir(const char* trlgrpnm) const;
217  IODir* getDir(const MultiID&) const;
218 };
219 
220 
221 mGlobal(General) IOMan& IOM();
222 
223 
225 {
226 public:
229 
230  static bool hasChanged();
232 
233 private:
234  bool needscleanup_ = false;
235 };
IOMan::getIfOnlyOne
IOObj * getIfOnlyOne(const char *trgroupname)
Definition: ioman.h:76
IOMan::isBad
bool isBad() const
Definition: ioman.h:52
IOMan::levelOf
int levelOf(const char *dirnm) const
IOMan::mODTextTranslationClass
mODTextTranslationClass(IOMan)
SurveyChanger::changedToSurvey
static SurveyDiskLocation changedToSurvey()
IOMan::getDir
IODir * getDir(IOObjContext::StdSelType) const
IOMan::reInit
void reInit(bool dotrigger)
IOMan::setDir
bool setDir(const char *)
IOMan::state_
State state_
Definition: ioman.h:159
IOMan::surveyParsChanged
static void surveyParsChanged()
IOMan::dirptr_
IODir * dirptr_
Definition: ioman.h:160
IOMan::get
IOObj * get(const IOObjContext &, const char *objnm) const
IOMan::msg_
BufferString msg_
Definition: ioman.h:162
IOMan::surveyChanged
Notifier< IOMan > surveyChanged
To restore OD to normal state.
Definition: ioman.h:144
Notifier::trigger
void trigger()
Definition: notify.h:132
NamedCallBacker
CallBacker object with a name. Use if you want your object to be able to send and receive CallBack's,...
Definition: namedobj.h:72
Conv::to
T to(const F &fr)
Definition: convert.h:34
IOMan::setTempSurvey
static void setTempSurvey(const SurveyDiskLocation &)
IOMan::afterSurveyChange
Notifier< IOMan > afterSurveyChange
When operating in normal state.
Definition: ioman.h:145
IOMan::newIODir
Notifier< IOMan > newIODir
Definition: ioman.h:139
IOMan::setRootDir
bool setRootDir(const char *)
mGlobal
#define mGlobal(module)
Definition: commondefs.h:180
IOSubDir
Definition: iosubdir.h:19
IOMan::getFirst
IOObj * getFirst(const IOObjContext &, int *nrpresent=0) const
if interested in nrpresent pass valid address
IOMan::isValidSurveyDir
static bool isValidSurveyDir(const char *dirnm)
IOM
IOMan & IOM()
IOMan::getOfGroup
IOObj * getOfGroup(const char *tgname, bool first=true, bool onlyifsingle=false) const
IOMan::commitChanges
bool commitChanges(const IOObj &)
IOMan::setupCustomDataDirs
static void setupCustomDataDirs(int)
IOMan::changeSurveyBlocked
bool changeSurveyBlocked() const
Definition: ioman.h:196
CtxtIOObj
Holds an IOObjCtxt plus a pointer to an IOObj and/or an IOPar.
Definition: ctxtioobj.h:146
IOMan::rootdir_
BufferString rootdir_
Definition: ioman.h:158
IOMan::isValidDataRoot
static bool isValidDataRoot(const char *dirnm)
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
IOMan::getEntry
void getEntry(CtxtIOObj &, bool newistmp=false, int translidxingroup=-1)
will create a new entry if necessary
IOMan::curlvl_
int curlvl_
Definition: ioman.h:161
namedobj.h
IOMan::get
IOObj * get(const DBKey &) const
Next functions return a new (unmanaged) IOObj.
SurveyChanger::hasChanged
static bool hasChanged()
IOMan::isUsable
bool isUsable(const MultiID &) const
IOMan::permRemove
bool permRemove(const MultiID &)
Removes only entry in IODir.
uiRetVal
Definition: uistringset.h:105
IOMan::isReadOnly
bool isReadOnly(const MultiID &) const
IOMan::isManagedObject
bool isManagedObject(const MultiID &) const
CommandLineParser
Definition: commandlineparser.h:53
operator==
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:81
IODir
Definition: iodir.h:38
IOMan::setChangeSurveyBlocked
void setChangeSurveyBlocked(bool yn)
Definition: ioman.h:194
IOMan::validSurveySetup
static bool validSurveySetup(BufferString &errmsg)
IOMan::applClosing
void applClosing()
Definition: ioman.h:198
IOMan::to
bool to(const MultiID &, bool force_reread=false)
IOMan::CustomDirData::selkey_
MultiID selkey_
Definition: ioman.h:124
IOMan::setDataSource
uiRetVal setDataSource(const IOPar &, bool refresh=false)
IOMan::get
IOObj * get(const char *objname, const char *tgname) const
multiid.h
IOMan::to
bool to(const IOSubDir *, bool)
IOMan::message
const OD::String & message() const
Definition: ioman.h:54
IOMan::applicationClosing
Notifier< IOMan > applicationClosing
'Final' call ...
Definition: ioman.h:146
IOMan::isPresent
bool isPresent(const MultiID &) const
IOMan::implExists
bool implExists(const MultiID &) const
IOMan::removeUnusable
void removeUnusable(DBKeySet &)
IOMan::curLevel
int curLevel() const
Definition: ioman.h:176
IOMan::getDir
IODir * getDir(const MultiID &) const
CallBack
CallBacks object-oriented (object + method).
Definition: callback.h:62
IOMan::fullSurveyPath
BufferString fullSurveyPath() const
IOMan::isReady
bool isReady() const
IOMan::objectName
const char * objectName(const DBKey &) const
IOMan::isPresent
bool isPresent(const char *, const char *tgname=0) const
IOMan::IOM
friend IOMan & IOM()
IOMan::newSurvey
static bool newSurvey(SurveyInfo *newsi=0)
DBKey
Definition: dbkey.h:21
IOObjContext
Holds the context for selecting and/or creating IOObjs.
Definition: ctxtioobj.h:62
IOMan::setDataSource
uiRetVal setDataSource(const CommandLineParser &, bool refresh=false)
IOMan::doReloc
bool doReloc(const MultiID &, Translator *, IOStream &, IOStream &, const CallBack *cb=nullptr)
IOMan::theinst_
static IOMan * theinst_
Definition: ioman.h:171
IOMan::init
void init()
Notifier< IOMan >
IOObj
Definition: ioobj.h:58
IOMan::~IOMan
~IOMan()
IOMan::addCustomDataDir
static const MultiID & addCustomDataDir(const CustomDirData &)
IOMan::implReloc
bool implReloc(const MultiID &, const char *newdir, const CallBack *cb=nullptr)
IOMan::getIOSubDir
static IOSubDir * getIOSubDir(const CustomDirData &)
IOMan::setDataSource
uiRetVal setDataSource(const char *dataroot, const char *survdir, bool refresh=false)
IOMan::survchgblocked_
bool survchgblocked_
Definition: ioman.h:163
SurveyChanger
Definition: ioman.h:225
IOMan::implRemove
bool implRemove(const MultiID &, bool rmentry=false, uiRetVal *uirv=nullptr)
IOStream
Definition: iostrm.h:26
MultiID
Compound key consisting of ints.
Definition: multiid.h:24
IOMan::CustomDirData
Definition: ioman.h:116
IOMan::setDataSource
uiRetVal setDataSource(const char *fullpath, bool refresh=false)
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
ctxtioobj.h
IOMan::crWriteIOObj
IOObj * crWriteIOObj(const CtxtIOObj &, const MultiID &, int) const
IOMan
Definition: ioman.h:49
IOMan::entryAdded
Notifier< IOMan > entryAdded
Definition: ioman.h:141
SurveyChanger::SurveyChanger
SurveyChanger(const SurveyDiskLocation &)
IOMan::surveyToBeChanged
Notifier< IOMan > surveyToBeChanged
Before the change.
Definition: ioman.h:143
IOMan::implRemove
bool implRemove(const IOObj &) const
IOMan::State
State
Definition: ioman.h:156
IOObjContext::StdSelType
StdSelType
Definition: ctxtioobj.h:65
IOMan::IOMan
IOMan(const char *rd=0)
IOMan::entryRemoved
Notifier< IOMan > entryRemoved
CallBacker: CBCapsule<MultiID>
Definition: ioman.h:140
OD::String
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
IOMan::entryChanged
Notifier< IOMan > entryChanged
Definition: ioman.h:142
IOMan::isKey
bool isKey(const char *keystr) const
DBKeySet
Definition: dbkey.h:58
IOMan::key
const MultiID & key() const
of current IODir
IOMan::implRename
bool implRename(const MultiID &, const char *newnm, const CallBack *cb=nullptr)
Translator
I/O Interpreter class for a certain object type.
Definition: transl.h:123
IOMan::isUsable
bool isUsable(const DBKey &) const
IOMan::get
IOObj * get(const MultiID &) const
IOMan::toRoot
bool toRoot(bool force_reread=false)
Definition: ioman.h:103
IOMan::nameOf
const char * nameOf(const char *keystr) const
if keystr is not an IOObj key, will return keystr
IOMan::createNewKey
MultiID createNewKey(const MultiID &dirkey)
IOMan::CustomDirData::desc_
BufferString desc_
Definition: ioman.h:128
surveydisklocation.h
IOMan::setSurvey
static bool setSurvey(const char *)
IOMan::surveyName
const char * surveyName() const
IOMan::cancelTempSurvey
static void cancelTempSurvey()
setDBMDataSource
const char * setDBMDataSource(const char *fullpath, bool refresh=false)
manages the 'Meta-'data store for the IOObj's. This info is read from the .omf files.
IOMan::getDir
IODir * getDir(const char *trlgrpnm) const
Threads::Lock
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class.
Definition: threadlock.h:53
IOMan::CustomDirData::CustomDirData
CustomDirData(const char *selkey, const char *dirnm, const char *desc="Custom data")
Definition: ioman.h:118
IOMan::rootDir
const char * rootDir() const
Definition: ioman.h:94
SurveyDiskLocation
Survey location on disk.
Definition: surveydisklocation.h:35
IOMan::getLocal
IOObj * getLocal(const char *objname, const char *tgname) const
IOPar
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:55
SurveyChanger::~SurveyChanger
~SurveyChanger()
IOMan::curDirName
const char * curDirName() const
OS dir name.
SurveyDiskLocation::dirname_
BufferString dirname_
The survey directory name.
Definition: surveydisklocation.h:76
SurveyInfo
Holds survey general information.
Definition: survinfo.h:45
IOMan::getFromPar
IOObj * getFromPar(const IOPar &, const char *basekey, const IOObjContext &, bool mknew, BufferString &errmsg) const
IOMan::lock_
Threads::Lock lock_
Definition: ioman.h:164

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