7 #ifndef GAUDIKERNEL_IFILEMGR_H
8 #define GAUDIKERNEL_IFILEMGR_H 1
44 int f()
const {
return _f; }
52 operator int()
const {
return _f; }
64 return ( (
_f&3) == (fa&3) );
70 const int SHIFT = 8 *
sizeof( int ) - 1;
71 const unsigned MASK = 1 << SHIFT;
73 for (
int i = 1;
i <= SHIFT + 1; ++
i ) {
74 s += ( f & MASK ?
'1' :
'0' );
76 if (
i % 8 == 0 ) s +=
' ';
93 for (
int i=0;
i<32; ++
i) {
95 if ( b & f ) ff += s_names.
at((
IoFlag)(b)) +
"|";
111 while ( (k=f.
find(
"|",j)) != std::string::npos) {
113 if (s_n.
find(fs) == s_n.
end()) {
119 fl = fl | s_n.
at(fs);
124 if (s_n.
find(fs) == s_n.
end()) {
130 fl = fl | s_n.
at(fs);
137 return s << IoFlagName(f);
140 return s << IoFlagName(f);
161 "UNKNOWN",
"POSIX",
"ROOT",
162 "BS",
"HDF5",
"SQLITE" };
163 return t < tbl.
size() ? s << tbl[t] :
s;
179 IoFlags fa,
void* p,
bool o,
bool s=
false):
207 os <<
"name: \"" << fa.
name() <<
"\" tech: " << fa.
tech()
208 <<
" desc: " << fa.
desc()
209 <<
" flags: " << IoFlagName(fa.
flags())
210 <<
" i_flags: " << IoFlagName(fa.
iflags())
211 <<
" Fd: " << fa.
fd() <<
" ptr: " << fa.
fptr()
212 << (fa.
isOpen() ?
" [o]" :
" [c]" )
213 << (fa.
isShared() ?
" [s]" :
" [u]" );
274 : tech(t), b_open_fcn(o), b_close_fcn(c), b_reopen_fcn(r){};
276 : tech(t), b_open_fcn(o), b_closeP_fcn(c), b_reopenP_fcn(r){};
278 bfcn_reopen_t r1,bfcn_reopenP_t r2)
279 : tech(t), b_open_fcn(o), b_close_fcn(c1), b_closeP_fcn(c2),
280 b_reopen_fcn(r1), b_reopenP_fcn(r2){};
302 "OPEN",
"CLOSE",
"REOPEN",
303 "OPEN_ERR",
"CLOSE_ERR",
"REOPEN_ERR",
305 return t < tbl.
size() ? s<< tbl[t] :
s;
308 #define FILEMGR_CALLBACK_ARGS const Io::FileAttr*, const std::string&
346 virtual void listHandlers()
const = 0;
347 virtual void listFiles()
const = 0;
352 bool onlyOpen=
true)
const = 0;
354 bool onlyOpen=
true)
const = 0;
359 bool onlyOpen=
true)
const = 0;
362 bool onlyOpen=
true)
const = 0;
369 bool onlyOpen=
true)
const =0;
372 bool onlyOpen=
true)
const =0;
390 virtual Io::Fd fd(
void* fptr)
const = 0;
394 virtual void* fptr(
const Io::Fd&)
const = 0;
405 const bool shared=
false
412 const bool shared=
false
419 const bool shared=
false
439 virtual void suppressAction(
const std::string&) = 0;
void flags(const IoFlags &f)
GAUDI_API unsigned long getLastError()
Get last system known error.
bfcn_reopen_t b_reopen_fcn
void name(const std::string &n)
bool operator==(const FileAttr &fa) const
FileHdlr(IoTech t, bfcn_open_t o, bfcn_close_t c, bfcn_reopen_t r)
FileAttr(Fd f, std::string n, std::string d, IoTech t, IoFlags fa, void *p, bool o, bool s=false)
const std::string & name() const
void iflags(const IoFlags &f)
IoFlags IoFlagFromName(const std::string &f)
bool operator<(const FileAttr &rhs) const
const std::string & desc() const
General service interface definition.
This class is used for returning status codes from appropriate routines.
bool operator==(const IoFlags &fa) const
std::ostream & operator<<(std::ostream &s, const IoFlag &f)
bfcn_closeP_t b_closeP_fcn
std::function< Io::open_t(const std::string &, Io::IoFlags, const std::string &, Io::Fd &, void *&)> bfcn_open_t
FileHdlr(IoTech t, bfcn_open_t o, bfcn_closeP_t c, bfcn_reopenP_t r)
bfcn_reopenP_t b_reopenP_fcn
std::function< Io::close_t(void *)> bfcn_closeP_t
std::function< Io::close_t(Io::Fd)> bfcn_close_t
void tech(const IoTech &t)
std::function< StatusCode(FILEMGR_CALLBACK_ARGS) > bfcn_action_t
FileHdlr(IoTech t, bfcn_open_t o, bfcn_close_t c1, bfcn_closeP_t c2, bfcn_reopen_t r1, bfcn_reopenP_t r2)
bool match(const IoFlags &fa, bool strict=true) const
DeclareInterfaceID(IService, 4, 0)
InterfaceID.
void desc(const std::string &d)
IoFlags operator|(const IoFlags &fa) const
std::function< Io::reopen_t(void *, Io::IoFlags)> bfcn_reopenP_t
std::function< Io::reopen_t(Io::Fd, Io::IoFlags)> bfcn_reopen_t
friend std::ostream & operator<<(std::ostream &os, const FileAttr &fa)