| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FileMgr.h
Go to the documentation of this file.
1
2 // FileMgr.h
3 // Manages all file open/reopen/close
4 // implementation of IFileMgr
5 // Author: C.Leggett
7
8 #ifndef GAUDISVC_FILEMGR_H
9 #define GAUDISVC_FILEMGR_H 1
10
11 #include "GaudiKernel/IFileMgr.h"
12 #include "GaudiKernel/Service.h"
13 #include "GaudiKernel/IIncidentListener.h"
14 #include "GaudiKernel/ClassID.h"
15 #include "GaudiKernel/MsgStream.h"
16 #include "GaudiKernel/StatusCode.h"
17
18 #include <string>
19 #include <map>
20 #include <list>
21
22 using Io::IoTech;
23 using Io::IoFlag;
24 using Io::IoFlags;
25 using Io::FileAttr;
26 using Io::FileHdlr;
27 using Io::Fd;
28
29 class RootFileHandler;
30 class POSIXFileHandler;
31
32 class FileMgr: public extends2<Service, IFileMgr, IIncidentListener> {
33 public:
34 FileMgr(const std::string& name, ISvcLocator* svc);
35 virtual ~FileMgr();
36
37 public:
38 virtual StatusCode initialize();
39 virtual StatusCode finalize();
40
41 public:
42 virtual void handle(const Incident&);
43
44 public:
45 virtual StatusCode regHandler(FileHdlr);
46 virtual StatusCode hasHandler(const IoTech&) const;
47
48 virtual StatusCode deregHandler(const IoTech&);
49
50 virtual StatusCode getHandler(const IoTech&, FileHdlr&) const;
51 virtual StatusCode getHandler(const std::string&, FileHdlr&) const;
52
53 virtual int getFileAttr(const std::string&, std::vector<const FileAttr*>&) const;
54 virtual StatusCode getFileAttr(const Fd, const FileAttr*&) const;
55 virtual StatusCode getFileAttr(void*, const FileAttr*&) const;
56
57 virtual void listHandlers() const;
58 virtual void listFiles() const;
59 virtual void listActions() const;
60 virtual void listSuppression() const;
61
62 virtual int getFiles(std::vector<std::string>&, bool onlyOpen=true) const;
63 virtual int getFiles(std::vector<const Io::FileAttr*>&,
64 bool onlyOpen=true) const;
65 virtual int getFiles(const Io::IoTech&, std::vector<std::string>&,
66 bool onlyOpen=true) const;
67 virtual int getFiles(const Io::IoTech&, std::vector<const Io::FileAttr*>&,
68 bool onlyOpen=true) const;
69 virtual int getFiles(const Io::IoTech&, const Io::IoFlags&,
70 std::vector<std::string>&, bool onlyOpen=true) const;
71 virtual int getFiles(const Io::IoTech&, const Io::IoFlags&,
72 std::vector<const Io::FileAttr*>&,
73 bool onlyOpen=true) const;
74
75 virtual int getFd(std::vector<Fd>&) const;
76 virtual int getFd(const Io::IoTech&, std::vector<Io::Fd>&) const;
77 virtual int getFd(const Io::IoTech&, const Io::IoFlags&,
78 std::vector<Io::Fd> &) const;
79
80 // get file name given Fd or ptr
81 virtual const std::string& fname(const Io::Fd&) const;
82 virtual const std::string& fname(void*) const;
83
84 // get Fd or ptr given file name
85 virtual Io::Fd fd(const std::string&) const;
86 virtual Io::Fd fd(void*) const;
87
88 virtual void* fptr(const std::string&) const;
89 virtual void* fptr(const Io::Fd&) const;
90
91 virtual int getLastError(std::string&) const;
92
93
94 // Open file, get Fd and ptr
95 virtual Io::open_t open(const Io::IoTech&, const std::string& caller,
96 const std::string& fname,
97 const Io::IoFlags&, Io::Fd& fd, void*& ptr,
98 const std::string& desc="",
99 const bool shared=false);
100
101 // Open file, get Fd
102 virtual Io::open_t open(const Io::IoTech&, const std::string& caller,
103 const std::string& fname,
104 const Io::IoFlags&, Io::Fd&,
105 const std::string& desc="",
106 const bool shared=false);
107
108 // Open file, get ptr
109 virtual Io::open_t open(const Io::IoTech&, const std::string& caller,
110 const std::string& fname,
111 const Io::IoFlags&, void*&,
112 const std::string& desc="",
113 const bool shared=false);
114
115
116 virtual Io::close_t close(const Fd, const std::string& caller);
117 virtual Io::close_t close(void*, const std::string& caller);
118
119 virtual Io::reopen_t reopen(const Fd, const IoFlags&,
120 const std::string& caller);
121 virtual Io::reopen_t reopen(void*, const IoFlags&,
122 const std::string& caller);
123
124
125 virtual StatusCode regAction(Io::bfcn_action_t, const Io::Action&,
126 const std::string& desc="");
127 virtual StatusCode regAction(Io::bfcn_action_t, const Io::Action&,
128 const Io::IoTech&, const std::string& desc="");
129
130 virtual void suppressAction(const std::string&);
131 virtual void suppressAction(const std::string&, const Io::Action&);
132
133 private:
134
135 StringProperty m_logfile;
136 BooleanProperty m_printSummary, m_loadRootHandler, m_loadPosixHandler;
137 StringProperty m_ssl_proxy, m_ssl_cert;
138
139 virtual Io::open_t open(const IoTech&, const std::string& caller,
140 const std::string& fname, const std::string& desc,
141 const IoFlags&, Fd&, void*&,
142 const bool shared);
143
144 typedef std::pair<Io::bfcn_action_t,std::string> bfcn_desc_t;
145 typedef std::map<Io::Action, std::list<bfcn_desc_t> > actionMap;
146 StatusCode execAction(Io::FileAttr*, const std::string&, const Io::Action&);
147 StatusCode execActs(Io::FileAttr*, const std::string&, const Io::Action&,
148 actionMap& m);
149
150 bool accessMatch(const Io::IoFlags&, const Io::IoFlags&,
151 bool strict=false) const;
152 bool isShareable(const std::string& filename, const Io::IoFlags&) const;
153
154
155 typedef std::multimap<std::string, FileAttr*> fileMap;
156
157 fileMap m_files;
158 std::map<IoTech, FileHdlr> m_handlers;
159 std::map<Fd, FileAttr*> m_descriptors;
160 std::map<void*, FileAttr*> m_fptr;
161 std::vector<FileAttr*> m_attr;
162
163 typedef std::list<FileAttr*> fileList;
164 fileList m_oldFiles;
165
166 std::map< IoTech, actionMap > m_actions;
167
168 typedef std::map<std::string, int> supMap;
169 supMap m_supMap;
170
171 std::string m_lastErrS;
172 int m_lastErr;
173
174 RootFileHandler* m_rfh;
175 POSIXFileHandler* m_pfh;
176 mutable MsgStream m_log;
177
178 };
179
180 #endif
181