OpendTect  6.6
iodir.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: 31-7-1995
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 
15 #include "generalmod.h"
16 #include "multiid.h"
17 #include "objectset.h"
18 #include "namedobj.h"
19 #include "od_iosfwd.h"
20 
21 class DBKey;
22 class IOObj;
23 
24 
25 /*\brief 'Directory' of IOObj objects.
26 
27 The IODir class is responsible for finding all IOObj's in the system. An IODir
28 instance will actually load all IOObj's, provides access to keys and allows
29 searching. It has a key of its own.
30 
31 Few operation are done through the IODir directly: usually, IOMan will be
32 the service access point.
33 
34 */
35 
36 
37 mExpClass(General) IODir : public NamedCallBacker
38 {
39 public:
40  IODir(const char*);
41  IODir(const MultiID&);
42  ~IODir();
43 
44  void reRead();
45  bool isBad() const { return !isok_; }
46  const MultiID& key() const { return key_; }
47 
48  const IOObj* main() const;
49  const char* dirName() const { return dirname_; }
50 
51  int size() const { return objs_.size(); }
52  int isEmpty() const { return objs_.isEmpty(); }
53  const IOObj* get( int idx ) const { return objs_[idx]; }
54  const ObjectSet<IOObj>& getObjs() const { return objs_; }
55 
56  bool isPresent(const MultiID&) const;
57  int indexOf(const MultiID&) const;
58  const IOObj* get(const MultiID&) const;
59  const IOObj* get(const char* nm,const char* trgrpnm=0) const;
60  // Without trgrpnm, just returns first
61 
62  bool addObj(IOObj*,bool immediate_store=true);
64  bool commitChanges(const IOObj*);
66  bool permRemove(const MultiID&);
68 
69  static IOObj* getObj(const DBKey&);
70  static IOObj* getObj(const MultiID&);
71  static IOObj* getMain(const char*);
72 
73  // Use this if you know there's no contingency
74  // Therefore, only in special-purpose programs
75  bool doWrite() const;
76 
77  bool hasObjectsWithGroup(const char* trgrpnm) const;
78  MultiID getNewKey() const;
79 
80 private:
81 
85  bool isok_;
86  mutable int curid_;
87 
88  IODir();
89  static bool create(const char* dirnm,const MultiID&,IOObj* mainobj);
90  static IOObj* doRead(const char*,IODir*,int id=-1);
91  static void setDirName(IOObj&,const char*);
92  static IOObj* readOmf(od_istream&,const char*,IODir*,int);
93  static IOObj* getIOObj(const char* dirnm,const MultiID&);
94 
95  bool build();
96  bool wrOmf(od_ostream&) const;
97  IOObj* get( int idx ) { return objs_[idx]; }
98  IOObj* get(const MultiID&);
99 
100  MultiID newKey() const;
101 
102  friend class IOMan;
103  friend class IOObj;
104 
105 };
106 
107 
IODir::hasObjectsWithGroup
bool hasObjectsWithGroup(const char *trgrpnm) const
IODir::doRead
static IOObj * doRead(const char *, IODir *, int id=-1)
IODir::isBad
bool isBad() const
Definition: iodir.h:45
IODir::key_
MultiID key_
Definition: iodir.h:84
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
IODir::size
int size() const
Definition: iodir.h:51
IOObj::IODir
friend class IODir
Definition: ioobj.h:141
ObjectSet< IOObj >
IODir::addObj
bool addObj(IOObj *, bool immediate_store=true)
after call, IOObj is mine
IODir::get
const IOObj * get(const char *nm, const char *trgrpnm=0) const
IODir::isok_
bool isok_
Definition: iodir.h:85
IODir::isEmpty
int isEmpty() const
Definition: iodir.h:52
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
od_istream
OD class for stream read common access to the std::cin.
Definition: od_istream.h:24
namedobj.h
IODir::IODir
IODir()
IODir::indexOf
int indexOf(const MultiID &) const
IODir::commitChanges
bool commitChanges(const IOObj *)
after call, assume pointer will be invalid
IODir
Definition: iodir.h:38
IODir::isPresent
bool isPresent(const MultiID &) const
IODir::get
const IOObj * get(int idx) const
Definition: iodir.h:53
IODir::main
const IOObj * main() const
IODir::get
const IOObj * get(const MultiID &) const
multiid.h
IODir::IODir
IODir(const MultiID &)
IODir::wrOmf
bool wrOmf(od_ostream &) const
IODir::build
bool build()
IODir::objs_
ObjectSet< IOObj > objs_
Definition: iodir.h:82
IODir::getIOObj
static IOObj * getIOObj(const char *dirnm, const MultiID &)
IODir::permRemove
bool permRemove(const MultiID &)
IODir::IODir
IODir(const char *)
DBKey
Definition: dbkey.h:21
IODir::setDirName
static void setDirName(IOObj &, const char *)
IODir::ensureUniqueName
bool ensureUniqueName(IOObj &)
IODir::getObj
static IOObj * getObj(const MultiID &)
IODir::dirName
const char * dirName() const
Definition: iodir.h:49
IOObj
Definition: ioobj.h:58
IODir::getNewKey
MultiID getNewKey() const
IODir::key
const MultiID & key() const
Definition: iodir.h:46
MultiID
Compound key consisting of ints.
Definition: multiid.h:24
IODir::getMain
static IOObj * getMain(const char *)
IODir::doWrite
bool doWrite() const
IODir::dirname_
BufferString dirname_
Definition: iodir.h:83
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
IOMan
Definition: ioman.h:49
IODir::get
IOObj * get(const MultiID &)
IOObj::key_
MultiID key_
Definition: ioobj.h:127
od_iosfwd.h
IODir::readOmf
static IOObj * readOmf(od_istream &, const char *, IODir *, int)
IODir::getObjs
const ObjectSet< IOObj > & getObjs() const
Definition: iodir.h:54
IODir::curid_
int curid_
Definition: iodir.h:86
IODir::getObj
static IOObj * getObj(const DBKey &)
IODir::create
static bool create(const char *dirnm, const MultiID &, IOObj *mainobj)
IODir::~IODir
~IODir()
IODir::reRead
void reRead()
od_ostream
OD class for stream write common access to the user log file, or std::cout in other than od_main.
Definition: od_ostream.h:26
objectset.h
IODir::get
IOObj * get(int idx)
Definition: iodir.h:97
IODir::newKey
MultiID newKey() const

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