| The Gaudi Framework v30r0 (c919700c)

- 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 "POSIXFileHandler.h"
18 #include "RootFileHandler.h"
19
20 #include "boost/optional.hpp"
21
22 #include <list>
23 #include <map>
24 #include <string>
25
26 using Io::IoTech;
27 using Io::IoFlag;
28 using Io::IoFlags;
29 using Io::FileAttr;
30 using Io::FileHdlr;
31 using Io::Fd;
32
33 class RootFileHandler;
34 class POSIXFileHandler;
35
36 class FileMgr : public extends<Service, IFileMgr, IIncidentListener>
37 {
38 public:
39 using extends::extends;
40 ~FileMgr() override;
41
42 StatusCode initialize() override;
43 StatusCode finalize() override;
44
45 void handle( const Incident& ) override;
46
47 StatusCode regHandler( FileHdlr ) override;
48 StatusCode hasHandler( const IoTech& ) const override;
49
50 StatusCode deregHandler( const IoTech& ) override;
51
52 StatusCode getHandler( const IoTech&, FileHdlr& ) const override;
53 StatusCode getHandler( const std::string&, FileHdlr& ) const override;
54
55 int getFileAttr( const std::string&, std::vector<const FileAttr*>& ) const override;
56 StatusCode getFileAttr( const Fd, const FileAttr*& ) const override;
57 StatusCode getFileAttr( void*, const FileAttr*& ) const override;
58
59 void listHandlers() const override;
60 void listFiles() const override;
61 virtual void listActions() const; // does not override...
62 virtual void listSuppression() const; // does not override...
63
64 int getFiles( std::vector<std::string>&, bool onlyOpen = true ) const override;
65 int getFiles( std::vector<const Io::FileAttr*>&, bool onlyOpen = true ) const override;
66 int getFiles( const Io::IoTech&, std::vector<std::string>&, bool onlyOpen = true ) const override;
67 int getFiles( const Io::IoTech&, std::vector<const Io::FileAttr*>&, bool onlyOpen = true ) const override;
68 int getFiles( const Io::IoTech&, const Io::IoFlags&, std::vector<std::string>&, bool onlyOpen = true ) const override;
69 int getFiles( const Io::IoTech&, const Io::IoFlags&, std::vector<const Io::FileAttr*>&,
70 bool onlyOpen = true ) const override;
71
72 int getFd( std::vector<Fd>& ) const override;
73 int getFd( const Io::IoTech&, std::vector<Io::Fd>& ) const override;
74 int getFd( const Io::IoTech&, const Io::IoFlags&, std::vector<Io::Fd>& ) const override;
75
76 // get file name given Fd or ptr
77 const std::string& fname( const Io::Fd& ) const override;
78 const std::string& fname( void* ) const override;
79
80 // get Fd or ptr given file name
81 Io::Fd fd( const std::string& ) const override;
82 Io::Fd fd( void* ) const override;
83
84 void* fptr( const std::string& ) const override;
85 void* fptr( const Io::Fd& ) const override;
86
87 int getLastError( std::string& ) const override;
88
89 // Open file, get Fd and ptr
90 Io::open_t open( const Io::IoTech&, const std::string& caller, const std::string& fname, const Io::IoFlags&,
91 Io::Fd& fd, void*& ptr, const std::string& desc = "", const bool shared = false ) override;
92
93 // Open file, get Fd
94 Io::open_t open( const Io::IoTech&, const std::string& caller, const std::string& fname, const Io::IoFlags&, Io::Fd&,
95 const std::string& desc = "", const bool shared = false ) override;
96
97 // Open file, get ptr
98 Io::open_t open( const Io::IoTech&, const std::string& caller, const std::string& fname, const Io::IoFlags&, void*&,
99 const std::string& desc = "", const bool shared = false ) override;
100
101 Io::close_t close( const Fd, const std::string& caller ) override;
102 Io::close_t close( void*, const std::string& caller ) override;
103
104 Io::reopen_t reopen( const Fd, const IoFlags&, const std::string& caller ) override;
105 Io::reopen_t reopen( void*, const IoFlags&, const std::string& caller ) override;
106
107 StatusCode regAction( Io::bfcn_action_t, const Io::Action&, const std::string& desc = "" ) override;
108 StatusCode regAction( Io::bfcn_action_t, const Io::Action&, const Io::IoTech&,
109 const std::string& desc = "" ) override;
110
111 void suppressAction( const std::string& ) override;
112 void suppressAction( const std::string&, const Io::Action& ) override;
113
114 private:
115 Gaudi::Property<std::string> m_logfile{this, "LogFile"};
116 Gaudi::Property<bool> m_printSummary{this, "PrintSummary", false};
117 Gaudi::Property<bool> m_loadRootHandler{this, "LoadROOTHandler", true};
118 Gaudi::Property<bool> m_loadPosixHandler{this, "LoadPOSIXHandler", true};
119
120 Gaudi::Property<std::string> m_ssl_proxy{this, "TSSL_UserProxy", "X509"};
121 Gaudi::Property<std::string> m_ssl_cert{this, "TSSL_CertDir", "X509"};
122
123 virtual Io::open_t open( const IoTech&, const std::string& caller, const std::string& fname, const std::string& desc,
124 const IoFlags&, Fd&, void*&,
125 const bool shared ); // does not override...
126
127 typedef std::pair<Io::bfcn_action_t, std::string> bfcn_desc_t;
128 typedef std::map<Io::Action, std::list<bfcn_desc_t>> actionMap;
129 StatusCode execAction( Io::FileAttr*, const std::string&, const Io::Action& ) const;
130 StatusCode execActs( Io::FileAttr*, const std::string&, const Io::Action&, const actionMap& m ) const;
131
132 bool accessMatch( const Io::IoFlags&, const Io::IoFlags&, bool strict = false ) const;
133 bool isShareable( const std::string& filename, const Io::IoFlags& ) const;
134
135 typedef std::multimap<std::string, FileAttr*> fileMap;
136
137 fileMap m_files;
138 std::map<IoTech, FileHdlr> m_handlers;
139 std::map<Fd, FileAttr*> m_descriptors;
140 std::vector<std::unique_ptr<FileAttr>> m_attr;
141
142 std::vector<FileAttr*> m_oldFiles;
143
144 std::map<IoTech, actionMap> m_actions;
145
146 typedef std::map<std::string, int> supMap;
147 supMap m_supMap;
148
149 std::string m_lastErrS;
150 int m_lastErr;
151
152 boost::optional<RootFileHandler> m_rfh;
153 boost::optional<POSIXFileHandler> m_pfh;
154 };
155
156 #endif
FileMgr::m_attr
std::vector< std::unique_ptr< FileAttr > > m_attr
Definition: FileMgr.h:140
FileMgr::regHandler
StatusCode regHandler(FileHdlr) override
Definition: FileMgr.cpp:188
Io::IoTech
IoTech
Definition: IFileMgr.h:157
FileMgr::listHandlers
void listHandlers() const override
Definition: FileMgr.cpp:1088
ClassID.h
FileMgr::getFileAttr
int getFileAttr(const std::string &, std::vector< const FileAttr * > &) const override
Definition: FileMgr.cpp:744
FileMgr::listFiles
void listFiles() const override
Definition: FileMgr.cpp:1026
FileMgr::bfcn_desc_t
std::pair< Io::bfcn_action_t, std::string > bfcn_desc_t
Definition: FileMgr.h:127
FileMgr::hasHandler
StatusCode hasHandler(const IoTech &) const override
Definition: FileMgr.cpp:238
std::function
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
Io::reopen_t
int reopen_t
Definition: IFileMgr.h:251
Io::Fd
int Fd
Definition: IFileMgr.h:171
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:247
FileMgr::m_loadPosixHandler
Gaudi::Property< bool > m_loadPosixHandler
Definition: FileMgr.h:118
POSIXFileHandler.h
FileMgr::suppressAction
void suppressAction(const std::string &) override
Definition: FileMgr.cpp:1224
Io::IoFlag
IoFlag
Definition: IFileMgr.h:26
FileMgr::getFiles
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:804
FileMgr::m_supMap
supMap m_supMap
Definition: FileMgr.h:147
FileMgr::m_files
fileMap m_files
Definition: FileMgr.h:137
Io::open_t
int open_t
Definition: IFileMgr.h:249
FileMgr::actionMap
std::map< Io::Action, std::list< bfcn_desc_t > > actionMap
Definition: FileMgr.h:128
FileMgr::deregHandler
StatusCode deregHandler(const IoTech &) override
Definition: FileMgr.cpp:223
FileMgr::execAction
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1148
graphanalysis.filename
string filename
Definition: graphanalysis.py:117
FileMgr::m_descriptors
std::map< Fd, FileAttr * > m_descriptors
Definition: FileMgr.h:139
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:1211
FileMgr::listActions
virtual void listActions() const
Definition: FileMgr.cpp:1120
std::string
STL class.
FileMgr::fd
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:986
Io::Action
Action
Definition: IFileMgr.h:284
Service.h
FileMgr
Definition: FileMgr.h:36
FileMgr::m_handlers
std::map< IoTech, FileHdlr > m_handlers
Definition: FileMgr.h:138
FileMgr::m_loadRootHandler
Gaudi::Property< bool > m_loadRootHandler
Definition: FileMgr.h:117
FileMgr::handle
void handle(const Incident &) override
Definition: FileMgr.cpp:184
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:94
Io::IoFlags
Definition: IFileMgr.h:40
FileMgr::m_rfh
boost::optional< RootFileHandler > m_rfh
Definition: FileMgr.h:152
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:1171
Io::FileHdlr
Definition: IFileMgr.h:260
RootFileHandler
Definition: RootFileHandler.h:17
FileMgr::close
Io::close_t close(const Fd, const std::string &caller) override
FileMgr::m_lastErrS
std::string m_lastErrS
Definition: FileMgr.h:149
FileMgr::regAction
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition: FileMgr.cpp:1099
FileMgr::fileMap
std::multimap< std::string, FileAttr * > fileMap
Definition: FileMgr.h:135
std::multimap< std::string, FileAttr * >
std::pair
FileMgr::m_oldFiles
std::vector< FileAttr * > m_oldFiles
Definition: FileMgr.h:142
std::vector
STL class.
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
FileMgr::listSuppression
virtual void listSuppression() const
Definition: FileMgr.cpp:1242
FileMgr::m_pfh
boost::optional< POSIXFileHandler > m_pfh
Definition: FileMgr.h:153
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:120
IFileMgr.h
IIncidentListener.h
FileMgr::m_actions
std::map< IoTech, actionMap > m_actions
Definition: FileMgr.h:144
FileMgr::fname
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:966
FileMgr::m_lastErr
int m_lastErr
Definition: FileMgr.h:150
StatusCode.h
FileMgr::m_printSummary
Gaudi::Property< bool > m_printSummary
Definition: FileMgr.h:116
FileMgr::m_logfile
Gaudi::Property< std::string > m_logfile
Definition: FileMgr.h:115
FileMgr::getFd
int getFd(std::vector< Fd > &) const override
FileMgr::~FileMgr
~FileMgr() override
Definition: FileMgr.cpp:60
FileMgr::finalize
StatusCode finalize() override
Definition: FileMgr.cpp:126
FileMgr::m_ssl_cert
Gaudi::Property< std::string > m_ssl_cert
Definition: FileMgr.h:121
Io::close_t
int close_t
Definition: IFileMgr.h:250
RootFileHandler.h
FileMgr::initialize
StatusCode initialize() override
Definition: FileMgr.cpp:69
FileMgr::getLastError
int getLastError(std::string &) const override
Definition: FileMgr.cpp:1039
Io::FileAttr
Definition: IFileMgr.h:173
FileMgr::fptr
void * fptr(const std::string &) const override
Definition: FileMgr.cpp:1006
FileMgr::supMap
std::map< std::string, int > supMap
Definition: FileMgr.h:146