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

iostrm.h

00001 #ifndef iostrm_H
00002 #define iostrm_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:          2-8-1995
00010  RCS:           $Id: iostrm.h,v 1.26 2009-07-22 16:01:15 cvsbert Exp $
00011 ________________________________________________________________________
00012 
00013 
00014 -*/
00015  
00016 #include "ioobject.h"
00017 #include "streamconn.h"
00018 #include "ranges.h"
00019 class StreamProvider;
00020 
00021 /*\brief An IOStream is a file (default), device or command entry in the omf. */
00022 
00023 
00024 mClass IOStream : public IOObject
00025 {
00026 public:
00027                         IOStream(const char* nm=0,const char* id=0,
00028                                  bool =false);
00029     virtual             ~IOStream();
00030     bool                bad() const;
00031     StreamConn::Type    type() const                    { return type_; }
00032     void                setType( StreamConn::Type t )   { type_ = t; }
00033 
00034     void                copyFrom(const IOObj*);
00035     const char*         fullUserExpr(bool) const;
00036     const char*         getExpandedName(bool forread,
00037                                         bool fillwildcard=true) const;
00038     void                genDefaultImpl()                { genFileName(); }
00039 
00040     const char*         connType() const;
00041     bool                slowOpen() const
00042                         { return type_ == StreamConn::Device; }
00043     Conn*               getConn(Conn::State) const;
00044 
00045     bool                implExists(bool forread) const;
00046     bool                implReadOnly() const;
00047     bool                implRemove() const;
00048     bool                implShouldRemove() const;
00049     bool                implSetReadOnly(bool) const;
00050     bool                implRename(const char*,const CallBack* cb=0);
00051 
00052     bool                multiConn() const
00053                         { return isMulti() && curfnr <= fnrs.stop; }
00054     int                 connNr() const
00055                         { return curfnr; }
00056     bool                toNextConnNr()
00057                         { curfnr += fnrs.step; return validNr(); }
00058     int                 lastConnNr() const
00059                         { return fnrs.stop; }
00060     int                 nextConnNr() const
00061                         { return curfnr+fnrs.step; }
00062     void                resetConnNr()
00063                         { curfnr = fnrs.start; }
00064     void                setConnNr( int nr )
00065                         { curfnr = nr; }
00066 
00067     const char*         hostName() const                { return hostname; }
00068     void                setHostName( const char* hn )   { hostname = hn; }
00069     const char*         fileName() const                { return fname; }
00070     void                setFileName(const char*);
00071     void                setExt( const char* ext )       { extension = ext; }
00072     void                genFileName();
00073 
00074     const char*         reader() const                  { return fname; }
00075     const char*         writer() const
00076                         { return writecmd ? (const char*)(*writecmd) : 0; }
00077     void                setReader(const char*);
00078     void                setWriter(const char*);
00079 
00080     const char*         devName() const;
00081     void                setDevName(const char*);
00082     int                 blockSize() const               { return blocksize; }
00083     void                setBlockSize( int bs )          { blocksize = bs; }
00084     int                 skipFiles() const               { return skipfiles; }
00085     void                setSkipFiles( int sf )          { skipfiles = sf; }
00086     void                setRewind( bool yn_ )           { rew = yn_; }
00087     bool                rewindTape() const              { return rew; }
00088 
00089     int                 zeroPadding() const             { return padzeros; }
00090     void                setZeroPadding( int zp )        { padzeros = zp; }
00091     StepInterval<int>&  fileNumbers()                   { return fnrs; }
00092     const StepInterval<int>& fileNumbers() const        { return fnrs; }
00093 
00094     StreamProvider*     streamProvider(bool,bool fillwc=true) const;
00095     bool                isMulti() const
00096                         { return fnrs.start != fnrs.stop; }
00097 
00098 protected:
00099 
00100     bool                getFrom(ascistream&);
00101     bool                putTo(ascostream&) const;
00102 
00103     BufferString        hostname;
00104     int                 nrfiles;
00105     FileNameString      fname;
00106 
00107     BufferString        extension;
00108     FileNameString*     readcmd;
00109     FileNameString*     writecmd;
00110     int                 blocksize;
00111     int                 skipfiles;
00112     bool                rew;
00113     int                 padzeros;
00114     StepInterval<int>   fnrs;
00115     int                 curfnr;
00116     int                 nrretries;
00117     int                 retrydelay;
00118 
00119     StreamConn::Type    type_;
00120 
00121     void                getDev(ascistream&);
00122     bool                validNr() const
00123                         { return curfnr*fnrs.step <= fnrs.stop*fnrs.step; }
00124     bool                implDo(bool,bool) const;
00125 
00126     static int          prodid; 
00127 };
00128 
00129 
00130 #endif

Generated on Tue Nov 30 2010 for General by  doxygen 1.7.1