OpendTect-6_4  6.4
ioobj.h
Go to the documentation of this file.
1 #ifndef ioobj_h
2 #define ioobj_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: 31-7-1995
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 
16 #include "generalmod.h"
17 #include "multiid.h"
18 #include "namedobj.h"
19 #include "uistring.h"
20 
21 class Conn;
22 class IOObj;
23 class CallBack;
24 class ascistream;
25 class ascostream;
26 class Translator;
27 
28 
29 /*\brief factory entry for IOObjs. Should deliver IOObj of certain type. */
30 
32 {
33 public:
34 virtual ~IOObjProducer() {}
35  virtual bool canMake(const char*) const = 0;
36  virtual IOObj* make(const char*,const MultiID&,
37  bool fill_defs) const = 0;
38 
39 };
40 
41 /*\brief object describing how to do I/O for objects
42 
43 The IOMan object manager manages IODir directories of IOObj objects. These
44 objects contain the information needed to do the I/O needed for the storage
45 that is accessed in OpendTect software.
46 
47 Every IOObj has a unique key in the form of a MultiID. This key
48 holds (a) the position of the IOObj in the IOMan/IODir tree (b) a unique
49 integer as an index in the IOObj's own IODir.
50 
51 If you know an IOObj is actually pointing to a simple file (i.e. if it's an
52 IOStream), then you can get the full filename (i.e. with path) using
53 fullUserExpr().
54 
55 */
56 
57 
58 mExpClass(General) IOObj : public NamedObject
59 {
60 public:
61  uiString uiName() const { return toUiString(name()); }
62 
63  IOObj* clone() const;
64  virtual const MultiID& key() const { return key_; }
65 
66  virtual ~IOObj();
67  virtual bool isBad() const = 0;
68  virtual void copyFrom(const IOObj*) = 0;
69  virtual bool hasConnType( const char* s ) const
70  { return connType() == s; }
71 
72  virtual const char* connType() const = 0;
73  virtual Conn* getConn(bool forread) const = 0;
74 
75  virtual const OD::String& translator() const {return transl_;}
76  virtual void setTranslator( const char* s ) {transl_ = s; }
77  virtual const OD::String& group() const {return group_;}
78  virtual void setGroup( const char* s ) {group_ = s; }
79  virtual const char* fullUserExpr(bool forread=true) const = 0;
80  virtual BufferString mainFileName() const { return fullUserExpr(); }
81 
82  virtual bool implExists(bool forread) const = 0;
83  virtual bool implReadOnly() const { return true; }
84  virtual bool implRemove() const { return false;}
85  virtual bool implManagesObjects() const { return false;}
86  virtual bool implRename(const char*,const CallBack* cb=0)
87  { return false; }
88  virtual bool implSetReadOnly(bool) const { return false;}
89 
90  virtual const char* dirName() const { return dirnm_; }
92  virtual IOPar& pars() const { return pars_;}
95  void updateCreationPars() const;
96 
97  static bool isKey(const char*);
100  static bool isSurveyDefault(const MultiID&);
102  void setSurveyDefault(const char* subsel = 0) const;
107  Translator* createTranslator() const;
110  void acquireNewKeyIn(const MultiID&);
112 
113  static int tmpID() { return 999999; }
114  inline bool isTmp() const {return key_.leafID()>=tmpID();}
115  bool isProcTmp() const;
116  bool isUserSelectable(bool forread=true) const;
117  bool isInCurrentSurvey() const;
118 
119 protected:
120 
125 
126  IOObj(const char* nm=0,const char* ky=0);
127  IOObj(const IOObj&);
128  static IOObj* get(ascistream&,const char*,const char*);
129  bool put(ascostream&) const;
130  virtual bool getFrom(ascistream&) = 0;
131  virtual bool putTo(ascostream&) const = 0;
132  int myKey() const;
133 
134 private:
135 
136  friend class IODir;
137 
138  static IOObj* produce(const char*,const char* nm=0,const char* ky=0,
139  bool initdefaults=true);
140  void copyStuffFrom(const IOObj&);
141 
143 
144 public:
145 
146  void setKey( const char* nm ) { key_ = nm; }
147  virtual void setDirName( const char* s ) { dirnm_ = s; }
148  virtual bool isSubdir() const { return false; }
149  static int addProducer(IOObjProducer*);
151 
152 };
153 
154 mGlobal(General) bool equalIOObj(const MultiID&,const MultiID&);
155 mGlobal(General) bool areEqual(const IOObj*,const IOObj*);
156 mGlobal(General) bool fullImplRemove(const IOObj&);
157 
158 #endif
#define mExpClass(module)
Definition: commondefs.h:160
BufferString dirnm_
Definition: ioobj.h:121
BufferString group_
Definition: ioobj.h:124
virtual bool isUserSelectable(bool forread=true) const
Definition: transl.h:150
virtual const char * connType() const
virtual BufferString mainFileName() const
Definition: ioobj.h:80
Definition: ioobj.h:58
Export_Basic uiString toUiString(ViewStyle)
#define mGlobal(module)
Definition: commondefs.h:163
virtual bool implExists(const IOObj *, bool forread) const
OpendTect standard ascii format file writing.
Definition: ascstream.h:32
BufferString transl_
Definition: ioobj.h:123
Definition: uistring.h:89
virtual const OD::String & group() const
Definition: ioobj.h:77
virtual void setDirName(const char *s)
Definition: ioobj.h:147
virtual IOPar & pars() const
Definition: ioobj.h:92
void setKey(const char *nm)
Definition: ioobj.h:146
virtual bool implSetReadOnly(bool) const
Definition: ioobj.h:88
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
bool equalIOObj(const MultiID &, const MultiID &)
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
TranslatorGroup * group_
Definition: transl.h:162
virtual bool implRename(const char *, const CallBack *cb=0)
Definition: ioobj.h:86
uiString uiName() const
Definition: ioobj.h:61
IOPar & pars_
Definition: ioobj.h:142
virtual ~IOObjProducer()
Definition: ioobj.h:34
OpendTect standard ascii format file reading.
Definition: ascstream.h:83
virtual bool implRemove() const
Definition: ioobj.h:84
bool fullImplRemove(const IOObj &)
I/O Interpreter class for a certain object type.
Definition: transl.h:123
virtual bool implManagesObjects() const
Definition: ioobj.h:85
Data connection.
Definition: conn.h:30
virtual void setTranslator(const char *s)
Definition: ioobj.h:76
bool isTmp() const
Definition: ioobj.h:114
virtual bool hasConnType(const char *s) const
Definition: ioobj.h:69
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
virtual bool isSubdir() const
Definition: ioobj.h:148
MultiID key_
Definition: ioobj.h:122
Definition: ioobj.h:31
Object with a name.
Definition: namedobj.h:35
virtual const char * dirName() const
The directory ame within the tree.
Definition: ioobj.h:90
Definition: iodir.h:36
virtual const MultiID & key() const
Definition: ioobj.h:64
virtual void setGroup(const char *s)
Definition: ioobj.h:78
bool areEqual(const IOObj *, const IOObj *)
CallBacks object-oriented (object + method).
Definition: callback.h:57
virtual bool implReadOnly() const
Definition: ioobj.h:83
static int tmpID()
Definition: ioobj.h:113
Compound key consisting of ints.
Definition: multiid.h:25
virtual const OD::String & translator() const
Definition: ioobj.h:75

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