| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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/ClassID.h"
12 #include "GaudiKernel/IFileMgr.h"
13 #include "GaudiKernel/IIncidentListener.h"
14 #include "GaudiKernel/Service.h"
15 #include "GaudiKernel/StatusCode.h"
16
17 #include <list>
18 #include <map>
19 #include <string>
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, IFileMgr, IIncidentListener>
32 {
33 public:
34 using extends::extends;
35 ~FileMgr() override;
36
37 StatusCode initialize() override;
38 StatusCode finalize() override;
39
40 void handle( const Incident& ) override;
41
42 StatusCode regHandler( FileHdlr ) override;
43 StatusCode hasHandler( const IoTech& ) const override;
44
45 StatusCode deregHandler( const IoTech& ) override;
46
47 StatusCode getHandler( const IoTech&, FileHdlr& ) const override;
48 StatusCode getHandler( const std::string&, FileHdlr& ) const override;
49
50 int getFileAttr( const std::string&, std::vector<const FileAttr*>& ) const override;
51 StatusCode getFileAttr( const Fd, const FileAttr*& ) const override;
52 StatusCode getFileAttr( void*, const FileAttr*& ) const override;
53
54 void listHandlers() const override;
55 void listFiles() const override;
56 virtual void listActions() const; // does not override...
57 virtual void listSuppression() const; // does not override...
58
59 int getFiles( std::vector<std::string>&, bool onlyOpen = true ) const override;
60 int getFiles( std::vector<const Io::FileAttr*>&, bool onlyOpen = true ) const override;
61 int getFiles( const Io::IoTech&, std::vector<std::string>&, bool onlyOpen = true ) const override;
62 int getFiles( const Io::IoTech&, std::vector<const Io::FileAttr*>&, bool onlyOpen = true ) const override;
63 int getFiles( const Io::IoTech&, const Io::IoFlags&, std::vector<std::string>&, bool onlyOpen = true ) const override;
64 int getFiles( const Io::IoTech&, const Io::IoFlags&, std::vector<const Io::FileAttr*>&,
65 bool onlyOpen = true ) const override;
66
67 int getFd( std::vector<Fd>& ) const override;
68 int getFd( const Io::IoTech&, std::vector<Io::Fd>& ) const override;
69 int getFd( const Io::IoTech&, const Io::IoFlags&, std::vector<Io::Fd>& ) const override;
70
71 // get file name given Fd or ptr
72 const std::string& fname( const Io::Fd& ) const override;
73 const std::string& fname( void* ) const override;
74
75 // get Fd or ptr given file name
76 Io::Fd fd( const std::string& ) const override;
77 Io::Fd fd( void* ) const override;
78
79 void* fptr( const std::string& ) const override;
80 void* fptr( const Io::Fd& ) const override;
81
82 int getLastError( std::string& ) const override;
83
84 // Open file, get Fd and ptr
85 Io::open_t open( const Io::IoTech&, const std::string& caller, const std::string& fname, const Io::IoFlags&,
86 Io::Fd& fd, void*& ptr, const std::string& desc = "", const bool shared = false ) override;
87
88 // Open file, get Fd
89 Io::open_t open( const Io::IoTech&, const std::string& caller, const std::string& fname, const Io::IoFlags&, Io::Fd&,
90 const std::string& desc = "", const bool shared = false ) override;
91
92 // Open file, get ptr
93 Io::open_t open( const Io::IoTech&, const std::string& caller, const std::string& fname, const Io::IoFlags&, void*&,
94 const std::string& desc = "", const bool shared = false ) override;
95
96 Io::close_t close( const Fd, const std::string& caller ) override;
97 Io::close_t close( void*, const std::string& caller ) override;
98
99 Io::reopen_t reopen( const Fd, const IoFlags&, const std::string& caller ) override;
100 Io::reopen_t reopen( void*, const IoFlags&, const std::string& caller ) override;
101
102 StatusCode regAction( Io::bfcn_action_t, const Io::Action&, const std::string& desc = "" ) override;
103 StatusCode regAction( Io::bfcn_action_t, const Io::Action&, const Io::IoTech&,
104 const std::string& desc = "" ) override;
105
106 void suppressAction( const std::string& ) override;
107 void suppressAction( const std::string&, const Io::Action& ) override;
108
109 private:
110 Gaudi::Property<std::string> m_logfile{this, "LogFile"};
111 Gaudi::Property<bool> m_printSummary{this, "PrintSummary", false};
112 Gaudi::Property<bool> m_loadRootHandler{this, "LoadROOTHandler", true};
113 Gaudi::Property<bool> m_loadPosixHandler{this, "LoadPOSIXHandler", true};
114
115 Gaudi::Property<std::string> m_ssl_proxy{this, "TSSL_UserProxy", "X509"};
116 Gaudi::Property<std::string> m_ssl_cert{this, "TSSL_CertDir", "X509"};
117
118 virtual Io::open_t open( const IoTech&, const std::string& caller, const std::string& fname, const std::string& desc,
119 const IoFlags&, Fd&, void*&,
120 const bool shared ); // does not override...
121
122 typedef std::pair<Io::bfcn_action_t, std::string> bfcn_desc_t;
123 typedef std::map<Io::Action, std::list<bfcn_desc_t>> actionMap;
124 StatusCode execAction( Io::FileAttr*, const std::string&, const Io::Action& ) const;
125 StatusCode execActs( Io::FileAttr*, const std::string&, const Io::Action&, const actionMap& m ) const;
126
127 bool accessMatch( const Io::IoFlags&, const Io::IoFlags&, bool strict = false ) const;
128 bool isShareable( const std::string& filename, const Io::IoFlags& ) const;
129
130 typedef std::multimap<std::string, FileAttr*> fileMap;
131
132 fileMap m_files;
133 std::map<IoTech, FileHdlr> m_handlers;
134 std::map<Fd, FileAttr*> m_descriptors;
135 std::vector<std::unique_ptr<FileAttr>> m_attr;
136
137 std::vector<FileAttr*> m_oldFiles;
138
139 std::map<IoTech, actionMap> m_actions;
140
141 typedef std::map<std::string, int> supMap;
142 supMap m_supMap;
143
144 std::string m_lastErrS;
145 int m_lastErr;
146
147 std::unique_ptr<RootFileHandler> m_rfh;
148 std::unique_ptr<POSIXFileHandler> m_pfh;
149 };
150
151 #endif
FileMgr::m_attr
std::vector< std::unique_ptr< FileAttr > > m_attr
Definition: FileMgr.h:135
FileMgr::regHandler
StatusCode regHandler(FileHdlr) override
Definition: FileMgr.cpp:241
Io::IoTech
IoTech
Definition: IFileMgr.h:150
FileMgr::listHandlers
void listHandlers() const override
Definition: FileMgr.cpp:1315
ClassID.h
FileMgr::getFileAttr
int getFileAttr(const std::string &, std::vector< const FileAttr * > &) const override
Definition: FileMgr.cpp:937
FileMgr::listFiles
void listFiles() const override
Definition: FileMgr.cpp:1243
FileMgr::bfcn_desc_t
std::pair< Io::bfcn_action_t, std::string > bfcn_desc_t
Definition: FileMgr.h:122
FileMgr::hasHandler
StatusCode hasHandler(const IoTech &) const override
Definition: FileMgr.cpp:306
std::function
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
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:316
FileMgr::m_loadPosixHandler
Gaudi::Property< bool > m_loadPosixHandler
Definition: FileMgr.h:113
FileMgr::suppressAction
void suppressAction(const std::string &) override
Definition: FileMgr.cpp:1479
Io::IoFlag
IoFlag
Definition: IFileMgr.h:25
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:1000
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:142
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:132
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:123
FileMgr::deregHandler
StatusCode deregHandler(const IoTech &) override
Definition: FileMgr.cpp:288
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1383
graphanalysis.filename
string filename
Definition: graphanalysis.py:109
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:134
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:1462
FileMgr::m_rfh
std::unique_ptr< RootFileHandler > m_rfh
Definition: FileMgr.h:147
FileMgr::listActions
virtual void listActions() const
Definition: FileMgr.cpp:1354
std::string
STL class.
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:1198
Io::Action
Action
Definition: IFileMgr.h:290
Service.h
FileMgr
Definition: FileMgr.h:31
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:133
FileMgr::m_loadRootHandler
Gaudi::Property< bool > m_loadRootHandler
Definition: FileMgr.h:112
FileMgr::handle
void handle(const Incident &) override
Definition: FileMgr.cpp:234
FileMgr::getHandler
StatusCode getHandler(const IoTech &, FileHdlr &) const override
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:1408
Io::FileHdlr
Definition: IFileMgr.h:263
RootFileHandler
Definition: RootFileHandler.h:17
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:148
FileMgr::m_lastErrS
std::string m_lastErrS
Definition: FileMgr.h:144
FileMgr::regAction
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition: FileMgr.cpp:1328
FileMgr::fileMap
std::multimap< std::string, FileAttr * > fileMap
Definition: FileMgr.h:130
std::multimap< std::string, FileAttr * >
std::pair
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:137
std::vector
STL class.
std::unique_ptr< RootFileHandler >
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
FileMgr::listSuppression
virtual void listSuppression() const
Definition: FileMgr.cpp:1504
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
FileMgr::isShareable
bool isShareable(const std::string &filename, const Io::IoFlags &) const
FileMgr::m_ssl_proxy
Gaudi::Property< std::string > m_ssl_proxy
Definition: FileMgr.h:115
IFileMgr.h
IIncidentListener.h
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:139
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:1175
FileMgr::m_lastErr
int m_lastErr
Definition: FileMgr.h:145
StatusCode.h
FileMgr::m_printSummary
Gaudi::Property< bool > m_printSummary
Definition: FileMgr.h:111
FileMgr::m_logfile
Gaudi::Property< std::string > m_logfile
Definition: FileMgr.h:110
FileMgr::getFd
int getFd(std::vector< Fd > &) const override
FileMgr::~FileMgr
~FileMgr() override
Definition: FileMgr.cpp:78
FileMgr::finalize
StatusCode finalize() override
Definition: FileMgr.cpp:166
FileMgr::m_ssl_cert
Gaudi::Property< std::string > m_ssl_cert
Definition: FileMgr.h:116
Io::close_t
int close_t
Definition: IFileMgr.h:253
FileMgr::initialize
StatusCode initialize() override
Definition: FileMgr.cpp:87
FileMgr::getLastError
int getLastError(std::string &) const override
Definition: FileMgr.cpp:1258
Io::FileAttr
Definition: IFileMgr.h:174
FileMgr::fptr
void * fptr(const std::string &) const override
Definition: FileMgr.cpp:1221
FileMgr::supMap
std::map< std::string, int > supMap
Definition: FileMgr.h:141