• Main Page
  • Namespaces
  • Classes
  • Files
  • File List

ioobj.h

00001 #ifndef ioobj_h
00002 #define ioobj_h
00003 
00004 /*+
00005 ________________________________________________________________________
00006 
00007  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
00008  Author:        A.H. Bril
00009  Date:          31-7-1995
00010  RCS:           $Id: ioobj.h,v 1.31 2010-04-23 05:41:41 cvsnanne Exp $
00011 ________________________________________________________________________
00012 
00013 -*/
00014  
00015  
00016 #include "conn.h"
00017 #include "multiid.h"
00018 #include "namedobj.h"
00019 class IOPar;
00020 class CallBack;
00021 class ascistream;
00022 class ascostream;
00023 class Translator;
00024 class IOLink;
00025 
00026 
00027 /*\brief factory entry for IOObjs. Should deliver IOObj of certain type. */
00028 
00029 mClass IOObjProducer
00030 {
00031 public:
00032 
00033     virtual bool        canMake(const char*) const      = 0;
00034     virtual IOObj*      make(const char*,const MultiID&,
00035                              bool fill_defs) const      = 0;
00036 
00037 };
00038 
00039 /*\brief object describing how to do I/O for objects
00040 
00041 The IOMan object manager manages IODir directories of IOObj objects. These
00042 objects contain the information needed to do the I/O needed for the storage
00043 that is accessed in OpendTect software. IOObj objects not in the root IODir will
00044 have a parent object, which may or may not be useful in relation to the IOObj.
00045 
00046 In any case, every IOObj has a unique key in the form of a MultiID. This key
00047 holds (a) the position of the IOObj in the IOMan/IODir tree (b) a unique
00048 integer as an index in the IOObj's own IODir.
00049 
00050 A special type of IOObj is the IOLink, which is the object that links to the
00051 'main object' of a sub-IODir. It will usually return info as if it's the main
00052 object itself, but will also allow changing the IOMan's dir with it.
00053 If a link is removed, the entire tree below it is removed.
00054 
00055 */
00056 
00057 
00058 mClass IOObj : public NamedObject
00059 {
00060 public:
00061 
00062     IOObj*              clone() const;
00063     IOObj*              getParent() const;
00065     virtual const MultiID& key() const                  { return key_; }
00066 
00067     virtual             ~IOObj();
00068     virtual bool        bad() const                     = 0;
00069     virtual bool        isLink() const                  { return false; }
00070     virtual void        copyFrom(const IOObj*)          = 0;
00071     virtual bool        hasConnType( const char* s ) const
00072                         { return s && !strcmp(s,connType()); }
00073 
00074     virtual const char* connType() const                = 0;
00075     virtual Conn*       getConn(Conn::State) const      = 0;
00076     virtual bool        slowOpen() const                { return false; }
00077 
00078     virtual const MultiID& parentKey() const    = 0;
00079     virtual void        setParentKey(const char*)       = 0;
00080     virtual const char* translator() const              = 0;
00081     virtual void        setTranslator(const char*)      = 0;
00082     virtual const char* group() const                   = 0;
00083     virtual void        setGroup(const char*)           = 0;
00084     virtual const char* fullUserExpr(bool forread) const= 0;
00085 
00086     virtual bool        implExists(bool forread) const  = 0;
00087     virtual bool        implReadOnly() const            { return true; }
00088     virtual bool        implRemove() const              { return false; }
00089     virtual bool        implShouldRemove() const        { return true; }
00090     virtual bool        implRename(const char*,const CallBack* cb=0)
00091                                                         { return false; }
00092     virtual bool        implSetReadOnly(bool) const     { return false; }
00093     virtual bool        removeQuery() const             { return false; }
00094     virtual void        genDefaultImpl()                {}
00095 
00096     virtual const char* dirName() const;
00099     bool                isStandAlone() const { return dirname_ ? true : false; }
00101     void                setStandAlone(const char* dirnm);
00103     virtual IOPar&      pars() const                    { return pars_; }
00105 
00106     static bool         isKey(const char*);
00108     static bool         isSurveyDefault(const MultiID&);
00110 
00111     Translator*         getTranslator() const;
00114     virtual void        acquireNewKey();
00116 
00117     static const int    tmpID()         { return  999999; }
00118     inline bool         isTmp() const   { return key_.leafID() == tmpID(); }
00119     bool                isReadDefault() const;
00120 
00121     static int          addProducer(IOObjProducer*);
00123 
00124 protected:
00125 
00126     FileNameString*     dirname_;
00127     IOLink*             mylink_;
00128     MultiID             key_;
00129 
00130                         IOObj(const char* nm=0,const char* ky=0);
00131                         IOObj(IOObj*,const char* ky=0);
00132     static IOObj*       get(ascistream&,const char*,const char*);
00133     bool                put(ascostream&) const;
00134     virtual bool        getFrom(ascistream&)            = 0;
00135     virtual bool        putTo(ascostream&) const        = 0;
00136     void                setKey( const char* nm )        { key_ = nm; }
00137 
00138 private:
00139 
00140     friend class        IODir;
00141     friend class        IOLink;
00142 
00143     IOPar&              pars_;
00144     int                 myKey() const;
00145 
00146     static IOObj*       produce(const char*,const char* nm=0,const char* ky=0,
00147                                 bool initdefaults=true);
00148 
00149 };
00150 
00151 mGlobal bool equalIOObj(const MultiID&,const MultiID&);
00152 mGlobal bool areEqual(const IOObj*,const IOObj*);
00153 mGlobal bool fullImplRemove(const IOObj&);
00154 
00155 #endif

Generated on Tue Nov 30 2010 for General by  doxygen 1.7.1