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):
180 m_fd(f),m_name(
std::move(n)),m_desc(
std::move(d)),
181 m_tech(t),m_flags(fa),m_iflags(fa),m_fptr(p),
182 m_isOpen(o),m_shared(
s){};
184 Fd
fd()
const {
return m_fd; }
190 void*
fptr()
const {
return m_fptr; }
201 void fptr(
void* v) { m_fptr = v; }
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]" );
218 return ( m_fd==fa.
fd() && m_name==fa.
name() && m_desc==fa.
desc() &&
219 m_tech==fa.
tech() && m_flags==fa.
flags() && m_fptr==fa.
fptr() &&
224 if ( m_name != rhs.
name() ) {
225 return ( m_name < rhs.
name() );
227 return ( m_flags < rhs.
iflags() );
239 void* m_fptr =
nullptr;
240 bool m_isOpen =
false;
241 bool m_shared =
false;
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",
304 "INVALID_ACTION" } };
305 return t < tbl.
size() ? s<< tbl[t] :
s;
308 #define FILEMGR_CALLBACK_ARGS const Io::FileAttr*, const std::string& 342 virtual void listHandlers()
const = 0;
343 virtual void listFiles()
const = 0;
348 bool onlyOpen=
true)
const = 0;
350 bool onlyOpen=
true)
const = 0;
355 bool onlyOpen=
true)
const = 0;
358 bool onlyOpen=
true)
const = 0;
365 bool onlyOpen=
true)
const =0;
368 bool onlyOpen=
true)
const =0;
386 virtual Io::Fd fd(
void* fptr)
const = 0;
390 virtual void* fptr(
const Io::Fd&)
const = 0;
401 const bool shared=
false 408 const bool shared=
false 415 const bool shared=
false 435 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)
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
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)
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
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
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
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