| The Gaudi Framework v27r1

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

- File List
- File Members

FileMgr.h
Go to the documentation of this file.
1 // 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/StatusCode.h"
16
17 #include <string>
18 #include <map>
19 #include <list>
20
21 using Io::IoTech;
22 using Io::IoFlag;
23 using Io::IoFlags;
24 using Io::FileAttr;
25 using Io::FileHdlr;
26 using Io::Fd;
27
28 class RootFileHandler;
29 class POSIXFileHandler;
30
31 class FileMgr: public extends<Service,
32 IFileMgr,
33 IIncidentListener> {
34 public:
35 FileMgr(const std::string& name, ISvcLocator* svc);
36 ~FileMgr() override;
37
38 StatusCode initialize() override;
39 StatusCode finalize() override;
40
41 void handle(const Incident&) override;
42
43 StatusCode regHandler(FileHdlr) override;
44 StatusCode hasHandler(const IoTech&) const override;
45
46 StatusCode deregHandler(const IoTech&) override;
47
48 StatusCode getHandler(const IoTech&, FileHdlr&) const override;
49 StatusCode getHandler(const std::string&, FileHdlr&) const override;
50
51 int getFileAttr(const std::string&, std::vector<const FileAttr*>&) const override;
52 StatusCode getFileAttr(const Fd, const FileAttr*&) const override;
53 StatusCode getFileAttr(void*, const FileAttr*&) const override;
54
55 void listHandlers() const override;
56 void listFiles() const override;
57 virtual void listActions() const ; // does not override...
58 virtual void listSuppression() const ; // does not override...
59
60 int getFiles(std::vector<std::string>&, bool onlyOpen=true) const override;
61 int getFiles(std::vector<const Io::FileAttr*>&,
62 bool onlyOpen=true) const override;
63 int getFiles(const Io::IoTech&, std::vector<std::string>&,
64 bool onlyOpen=true) const override;
65 int getFiles(const Io::IoTech&, std::vector<const Io::FileAttr*>&,
66 bool onlyOpen=true) const override;
67 int getFiles(const Io::IoTech&, const Io::IoFlags&,
68 std::vector<std::string>&, bool onlyOpen=true) const override;
69 int getFiles(const Io::IoTech&, const Io::IoFlags&,
70 std::vector<const Io::FileAttr*>&,
71 bool onlyOpen=true) const override;
72
73 int getFd(std::vector<Fd>&) const override;
74 int getFd(const Io::IoTech&, std::vector<Io::Fd>&) const override;
75 int getFd(const Io::IoTech&, const Io::IoFlags&,
76 std::vector<Io::Fd> &) const override;
77
78 // get file name given Fd or ptr
79 const std::string& fname(const Io::Fd&) const override;
80 const std::string& fname(void*) const override;
81
82 // get Fd or ptr given file name
83 Io::Fd fd(const std::string&) const override;
84 Io::Fd fd(void*) const override;
85
86 void* fptr(const std::string&) const override;
87 void* fptr(const Io::Fd&) const override;
88
89 int getLastError(std::string&) const override;
90
91
92 // Open file, get Fd and ptr
93 Io::open_t open(const Io::IoTech&, const std::string& caller,
94 const std::string& fname,
95 const Io::IoFlags&, Io::Fd& fd, void*& ptr,
96 const std::string& desc="",
97 const bool shared=false) override;
98
99 // Open file, get Fd
100 Io::open_t open(const Io::IoTech&, const std::string& caller,
101 const std::string& fname,
102 const Io::IoFlags&, Io::Fd&,
103 const std::string& desc="",
104 const bool shared=false) override;
105
106 // Open file, get ptr
107 Io::open_t open(const Io::IoTech&, const std::string& caller,
108 const std::string& fname,
109 const Io::IoFlags&, void*&,
110 const std::string& desc="",
111 const bool shared=false) override;
112
113
114 Io::close_t close(const Fd, const std::string& caller) override;
115 Io::close_t close(void*, const std::string& caller) override;
116
117 Io::reopen_t reopen(const Fd, const IoFlags&,
118 const std::string& caller) override;
119 Io::reopen_t reopen(void*, const IoFlags&,
120 const std::string& caller) override;
121
122
123 StatusCode regAction(Io::bfcn_action_t, const Io::Action&,
124 const std::string& desc="") override;
125 StatusCode regAction(Io::bfcn_action_t, const Io::Action&,
126 const Io::IoTech&, const std::string& desc="") override;
127
128 void suppressAction(const std::string&) override;
129 void suppressAction(const std::string&, const Io::Action&) override;
130
131 private:
132
133 StringProperty m_logfile;
134 BooleanProperty m_printSummary, m_loadRootHandler, m_loadPosixHandler;
135 StringProperty m_ssl_proxy, m_ssl_cert;
136
137 virtual Io::open_t open(const IoTech&, const std::string& caller,
138 const std::string& fname, const std::string& desc,
139 const IoFlags&, Fd&, void*&,
140 const bool shared) ; // does not override...
141
142 typedef std::pair<Io::bfcn_action_t,std::string> bfcn_desc_t;
143 typedef std::map<Io::Action, std::list<bfcn_desc_t> > actionMap;
144 StatusCode execAction(Io::FileAttr*, const std::string&, const Io::Action&) const;
145 StatusCode execActs(Io::FileAttr*, const std::string&, const Io::Action&,
146 const actionMap& m) const;
147
148 bool accessMatch(const Io::IoFlags&, const Io::IoFlags&,
149 bool strict=false) const;
150 bool isShareable(const std::string& filename, const Io::IoFlags&) const;
151
152
153 typedef std::multimap<std::string, FileAttr*> fileMap;
154
155 fileMap m_files;
156 std::map<IoTech, FileHdlr> m_handlers;
157 std::map<Fd, FileAttr*> m_descriptors;
158 std::vector<std::unique_ptr<FileAttr>> m_attr;
159
160 std::vector<FileAttr*> m_oldFiles;
161
162 std::map< IoTech, actionMap > m_actions;
163
164 typedef std::map<std::string, int> supMap;
165 supMap m_supMap;
166
167 std::string m_lastErrS;
168 int m_lastErr;
169
170 std::unique_ptr<RootFileHandler> m_rfh;
171 std::unique_ptr<POSIXFileHandler> m_pfh;
172
173 };
174
175 #endif
176
FileMgr::m_attr
std::vector< std::unique_ptr< FileAttr > > m_attr
Definition: FileMgr.h:158
FileMgr::regHandler
StatusCode regHandler(FileHdlr) override
Definition: FileMgr.cpp:274
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Io::IoTech
IoTech
Definition: IFileMgr.h:150
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1231
FileMgr::m_logfile
StringProperty m_logfile
Definition: FileMgr.h:133
ClassID.h
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
std::function
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:254
Io::Fd
int Fd
Definition: IFileMgr.h:172
FileMgr::open
Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &fd, void *&ptr, const std::string &desc="", const bool shared=false) override
Definition: FileMgr.cpp:349
FileMgr::suppressAction
void suppressAction(const std::string &) override
Definition: FileMgr.cpp:1512
Io::IoFlag
IoFlag
Definition: IFileMgr.h:25
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:165
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:155
Io::open_t
int open_t
Definition: IFileMgr.h:252
FileMgr::actionMap
std::map< Io::Action, std::list< bfcn_desc_t > > actionMap
Definition: FileMgr.h:143
FileMgr::getLastError
int getLastError(std::string &) const override
Definition: FileMgr.cpp:1291
FileMgr::deregHandler
StatusCode deregHandler(const IoTech &) override
Definition: FileMgr.cpp:321
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1416
graphanalysis.filename
string filename
Definition: graphanalysis.py:109
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:157
FileMgr::hasHandler
StatusCode hasHandler(const IoTech &) const override
Definition: FileMgr.cpp:339
std::map
STL class.
POSIXFileHandler
Definition: POSIXFileHandler.h:17
FileMgr::accessMatch
bool accessMatch(const Io::IoFlags &, const Io::IoFlags &, bool strict=false) const
Definition: FileMgr.cpp:1495
FileMgr::m_rfh
std::unique_ptr< RootFileHandler > m_rfh
Definition: FileMgr.h:170
FileMgr::listActions
virtual void listActions() const
Definition: FileMgr.cpp:1387
std::string
STL class.
Io::Action
Action
Definition: IFileMgr.h:290
SimpleProperty< std::string >
Service.h
FileMgr
Definition: FileMgr.h:31
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:156
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
FileMgr::handle
void handle(const Incident &) override
Definition: FileMgr.cpp:267
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
Io::IoFlags
Definition: IFileMgr.h:39
FileMgr::reopen
Io::reopen_t reopen(const Fd, const IoFlags &, const std::string &caller) override
FileMgr::execActs
StatusCode execActs(Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
Definition: FileMgr.cpp:1441
Io::FileHdlr
Definition: IFileMgr.h:263
RootFileHandler
Definition: RootFileHandler.h:17
FileMgr::m_printSummary
BooleanProperty m_printSummary
Definition: FileMgr.h:134
FileMgr::bfcn_desc_t
std::pair< Io::bfcn_action_t, std::string > bfcn_desc_t
Definition: FileMgr.h:142
FileMgr::close
Io::close_t close(const Fd, const std::string &caller) override
FileMgr::m_pfh
std::unique_ptr< POSIXFileHandler > m_pfh
Definition: FileMgr.h:171
FileMgr::getFileAttr
int getFileAttr(const std::string &, std::vector< const FileAttr * > &) const override
Definition: FileMgr.cpp:970
FileMgr::m_lastErrS
std::string m_lastErrS
Definition: FileMgr.h:167
FileMgr::regAction
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition: FileMgr.cpp:1361
FileMgr::FileMgr
FileMgr(const std::string &name, ISvcLocator *svc)
Definition: FileMgr.cpp:78
FileMgr::fileMap
std::multimap< std::string, FileAttr * > fileMap
Definition: FileMgr.h:153
std::multimap< std::string, FileAttr * >
std::pair
FileMgr::m_loadRootHandler
BooleanProperty m_loadRootHandler
Definition: FileMgr.h:134
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:160
std::vector
STL class.
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:1208
std::unique_ptr< RootFileHandler >
FileMgr::m_loadPosixHandler
BooleanProperty m_loadPosixHandler
Definition: FileMgr.h:134
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
FileMgr::listSuppression
virtual void listSuppression() const
Definition: FileMgr.cpp:1537
FileMgr::fptr
void * fptr(const std::string &) const override
Definition: FileMgr.cpp:1254
FileMgr::m_ssl_cert
StringProperty m_ssl_cert
Definition: FileMgr.h:135
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
FileMgr::isShareable
bool isShareable(const std::string &filename, const Io::IoFlags &) const
IFileMgr.h
IIncidentListener.h
FileMgr::m_lastErr
int m_lastErr
Definition: FileMgr.h:168
StatusCode.h
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:1033
FileMgr::listFiles
void listFiles() const override
Definition: FileMgr.cpp:1276
FileMgr::m_ssl_proxy
StringProperty m_ssl_proxy
Definition: FileMgr.h:135
FileMgr::listHandlers
void listHandlers() const override
Definition: FileMgr.cpp:1348
FileMgr::~FileMgr
~FileMgr() override
Definition: FileMgr.cpp:96
FileMgr::getFd
int getFd(std::vector< Fd > &) const override
FileMgr::finalize
StatusCode finalize() override
Definition: FileMgr.cpp:199
Io::close_t
int close_t
Definition: IFileMgr.h:253
FileMgr::initialize
StatusCode initialize() override
Definition: FileMgr.cpp:105
Io::FileAttr
Definition: IFileMgr.h:174
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:162
FileMgr::supMap
std::map< std::string, int > supMap
Definition: FileMgr.h:164