OpendTect-6_4  6.4
strmprov.h
Go to the documentation of this file.
1 #ifndef strmprov_h
2 #define strmprov_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: 17-5-1995
10  Contents: Generalized stream opener.
11  RCS: $Id$
12 ________________________________________________________________________
13 
14 -*/
15 
16 #include "basicmod.h"
17 #include "strmdata.h"
18 #include "bufstring.h"
19 #include "oscommand.h"
20 class CallBack;
21 class TaskRunner;
22 class BufferStringSet;
23 
24 
47 {
48 public:
49  StreamProvider(const char* nm=0);
50  void set(const char*);
51 
52  inline bool isBad() const { return fname_.isEmpty(); }
53 
54  bool exists(bool forread) const;
55  bool remove(bool recursive=true) const;
56  bool setReadOnly(bool yn) const;
57  bool isReadOnly() const;
58  bool rename(const char*,const CallBack* cb=0);
61 
62  StreamData makeOStream(bool binary=true,bool editmode=false) const;
67  StreamData makeIStream(bool binary=true,bool allowpreloaded=true) const;
69 
70  const char* fullName() const;
71  const char* fileName() const { return fname_.buf(); }
72  const char* command() const { return fileName(); }
73  const char* hostName() const { return hostname_.buf(); }
74 
75  void setFileName( const char* fn );
76  void setCommand(const char* cmd, const char* hostnm=0);
77  void addPathIfNecessary(const char*);
79 
80  bool isFile() const { return !iscomm_; }
81  bool isCommand() const { return iscomm_; }
82 
83  static const char* sStdIO();
84  static const char* sStdErr();
85 
86  // Pre-load interface
87  static bool isPreLoaded(const char*,bool isid);
89  static bool preLoad(const char*,TaskRunner&,const char* id);
91  static bool preLoad(const BufferStringSet&,TaskRunner&,
92  const char* id);
94  static void getPreLoadedIDs(BufferStringSet&);
95  static void getPreLoadedFileNames(const char* id,BufferStringSet&);
97  static int getPreLoadedDataPackID(const char*);
98  static void unLoad(const char*,bool isid=false);
100  static void unLoadAll();
101 
102 protected:
103 
105  bool iscomm_;
107 
108  static StreamData makePLIStream(int);
109  void mkOSCmd(BufferString&) const;
110 
111  static void sendCBMsg(const CallBack*,const char*);
112 
113 };
114 
115 
116 
117 #endif
bool rename(const char *oldname, const char *newname)
#define mExpClass(module)
Definition: commondefs.h:160
Provides I/O stream for file or system command.
Definition: strmprov.h:46
bool iscomm_
Definition: strmprov.h:105
BufferString fname_
Definition: strmprov.h:104
const char * fileName() const
Definition: strmprov.h:71
bool isBad() const
Definition: strmprov.h:52
Set of BufferString objects.
Definition: bufstringset.h:28
BufferString hostname_
Definition: strmprov.h:106
Class that can execute a task.
Definition: task.h:169
Holds data to use and close an iostream.
Definition: strmdata.h:28
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
bool isFile() const
Definition: strmprov.h:80
const char * hostName() const
Definition: strmprov.h:73
const char * command() const
Definition: strmprov.h:72
CallBacks object-oriented (object + method).
Definition: callback.h:57
bool exists(const char *)
bool isCommand() const
Definition: strmprov.h:81

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