DABC (Data Acquisition Backbone Core)  2.9.9
FileInterface.h
Go to the documentation of this file.
1 #ifndef LTSM_FileInterface
2 #define LTSM_FileInterface
3 
4 
5 #ifndef DABC_BinaryFile
6 #include "dabc/BinaryFile.h"
7 #endif
8 
9 // JAM 12-jun-2019 use file system demon branch of ltsm library
10 #define LTSM_USE_FSD 1
11 
12 
13 
14 extern "C"
15  {
16 #include "tsmapi.h"
17  }
18 
19 #ifdef LTSM_USE_FSD
20 extern "C"
21  {
22 #include "fsdapi.h"
23  }
24 #endif
25 
26 
27 #ifndef DABC_string
28 #include "dabc/string.h"
29 #endif
30 
31 
32 
33 namespace ltsm
34  {
35 
37  {
38  protected:
39 
40  struct session_t* fSession; //< keep session open during several files
41  std::string fCurrentFile; //< remember last open file, for info output
42  std::string fServername;
43  std::string fNode;
44  std::string fPassword;
45  std::string fOwner;
46  std::string fFsname;
47  std::string fDescription;
48 
49 
50  int fMaxFilesPerSession; //< set maximum number of files before re-opening session. For correct migration job on TSM server
51 
52  int fSessionConnectRetries;//< number of attempts to connect new tsm session
53 
54 
55  bool fIsClosing; //< avoid double fclose on termination by this
56 
57 
58  int fSessionFileCount; //< count number of files in current session
59 
60  bool fUseDaysubfolders; //< append number of day in year as subfolder if true
61 
62 #ifdef LTSM_USE_FSD
63  bool fUseFileSystemDemon; //< write to file system demon server instead of TSM server
64 
65  std::string fServernameFSD; //< name of the file system demon port
66  int fPortFSD; //< port of file system demon connection
67 
68  struct fsd_session_t* fSessionFSD; //< keep fsd session open during several files
69 
70 #endif
71 
72 
74  bool OpenTSMSession(const char* options);
75 
77  bool CloseTSMSession();
78 
79 
80 
81  public:
82 
83  FileInterface();
84 
85  virtual ~FileInterface();
86 
87  virtual Handle fopen(const char* fname, const char* mode,
88  const char* opt = 0);
89 
90  virtual void fclose(Handle f);
91 
92  virtual size_t fwrite(const void* ptr, size_t sz, size_t nmemb,
93  Handle f);
94 
95  virtual size_t fread(void* ptr, size_t sz, size_t nmemb, Handle f);
96 
97  virtual bool feof(Handle f);
98 
99  virtual bool fflush(Handle f);
100 
101  virtual bool fseek(Handle f, long int offset, bool realtive = true);
102 
103  virtual dabc::Object* fmatch(const char* fmask,
104  bool select_files = true);
105 
106  virtual int GetFileIntPar(Handle h, const char* parname);
107 
108  virtual bool GetFileStrPar(Handle h, const char* parname, char* sbuf,
109  int sbuflen);
110 
111  };
112 
113  }
114 
115 #endif
Defines and implements basic POSIX file interface.
Definition: BinaryFile.h:33
void * Handle
File handle descriptor.
Definition: BinaryFile.h:37
Base class for most of the DABC classes.
Definition: Object.h:116
virtual bool fflush(Handle f)
bool CloseTSMSession()
Shut down current TSM session.
std::string fPassword
Definition: FileInterface.h:44
std::string fServernameFSD
Definition: FileInterface.h:65
virtual int GetFileIntPar(Handle h, const char *parname)
Method returns file-specific int parameter.
virtual bool GetFileStrPar(Handle h, const char *parname, char *sbuf, int sbuflen)
Method returns file-specific string parameter.
std::string fOwner
Definition: FileInterface.h:45
virtual size_t fread(void *ptr, size_t sz, size_t nmemb, Handle f)
virtual void fclose(Handle f)
struct fsd_session_t * fSessionFSD
Definition: FileInterface.h:68
virtual bool feof(Handle f)
virtual bool fseek(Handle f, long int offset, bool realtive=true)
bool OpenTSMSession(const char *options)
Re-open session with parameters specified in dabc options string.
struct session_t * fSession
Definition: FileInterface.h:40
virtual Handle fopen(const char *fname, const char *mode, const char *opt=0)
std::string fServername
Definition: FileInterface.h:42
virtual dabc::Object * fmatch(const char *fmask, bool select_files=true)
Produce list of files, object must be explicitly destroyed with ref.Destroy call One could decide if ...
std::string fCurrentFile
Definition: FileInterface.h:41
virtual size_t fwrite(const void *ptr, size_t sz, size_t nmemb, Handle f)
std::string fFsname
Definition: FileInterface.h:46
std::string fDescription
Definition: FileInterface.h:47
Definition: Factory.h:21