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

strmprov.h

00001 #ifndef strmprov_h
00002 #define strmprov_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:          17-5-1995
00010  Contents:      Generalized stream opener.
00011  RCS:           $Id: strmprov.h,v 1.35 2009-07-22 16:01:14 cvsbert Exp $
00012 ________________________________________________________________________
00013 
00014 -*/
00015  
00016 #include "streamconn.h"
00017 class CallBack;
00018 class TaskRunner;
00019 class BufferStringSet;
00020 
00021 
00041 mClass StreamProvider
00042 {
00043 public:
00044                 StreamProvider(const char* nm=0);
00045                 StreamProvider(const char*,const char*,StreamConn::Type);
00046     void        set(const char*);
00047     bool        rename(const char*,const CallBack* cb=0);
00049 
00050     bool        skipFiles(int) const;
00052     bool        rewind() const;
00054     bool        offline() const;
00056     bool        bad() const                             { return isbad_; }
00057 
00058     bool        exists(int forread) const;
00059     bool        remove(bool recursive=true) const;
00060     bool        setReadOnly(bool yn) const;
00061     bool        isReadOnly() const;
00062 
00063     StreamData  makeOStream(bool binary=true) const;
00066     StreamData  makeIStream(bool binary=true,bool allowpreloaded=true) const;
00068     bool        executeCommand(bool inbg=false,bool inconsole=false) const;
00071     void        mkBatchCmd(BufferString& comm) const;
00072 
00073     const char* fullName() const;
00074     const char* hostName() const                { return hostname_.buf(); }
00075     const char* fileName() const                { return fname_.buf(); }
00076     const char* command() const                 { return fname_.buf(); }
00077     long        blockSize() const               { return blocksize_; }
00078 
00079     void        setHostName( const char* hname ) { hostname_ = hname; }
00080     void        setFileName( const char* fn )   { fname_ = fn; }
00081     void        setCommand( const char* fn )    { fname_ = fn; }
00082     void        setBlockSize( long bs )         { blocksize_ = bs; }
00083     void        addPathIfNecessary(const char*);
00085     void        setRemExec( const char* s )             { rshcomm_ = s; }
00086 
00087     StreamConn::Type    type()                          { return type_; }
00088     bool                isNormalFile() const;
00089 
00090     static const char*  sStdIO();
00091     static const char*  sStdErr();
00092 
00093     static bool         isPreLoaded(const char*,bool isid);
00095     static bool         preLoad(const char*,TaskRunner&,const char* id);
00097     static bool         preLoad(const BufferStringSet&,TaskRunner&,
00098                                 const char* id);
00100     static void         getPreLoadedIDs(BufferStringSet&);
00101     static void         getPreLoadedFileNames(const char* id,BufferStringSet&);
00103     static int          getPreLoadedDataPackID(const char*);
00104     static void         unLoad(const char*,bool isid=false);
00106     static void         unLoadAll();
00107 
00108 protected:
00109 
00110     BufferString        fname_;
00111     BufferString        hostname_;
00112     BufferString        rshcomm_;
00113 
00114     long                blocksize_;
00115     bool                isbad_;
00116     StreamConn::Type    type_;
00117 
00118     void                mkOSCmd(bool) const;
00119     static StreamData   makePLIStream(int);
00120 
00121     static void sendCBMsg(const CallBack*,const char*);
00123 
00124 };
00125 
00127 mGlobal bool ExecOSCmd(const char*,bool inbg=false);
00128 
00130 mGlobal const char* GetExecCommand(const char* prognm,const char* filenm);
00131 
00133 mGlobal bool ExecuteScriptCommand(const char* prognm,const char* filenm);
00134 
00135 #endif

Generated on Tue Nov 30 2010 for Basic by  doxygen 1.7.1