7 #ifndef GAUDIKERNEL_IFILEMGR_H 8 #define GAUDIKERNEL_IFILEMGR_H 1 46 int f()
const {
return _f; }
54 operator int()
const {
return _f; }
67 return ( (
_f & 3 ) == ( fa & 3 ) );
74 const int SHIFT = 8 *
sizeof( int ) - 1;
75 const unsigned MASK = 1 << SHIFT;
77 for (
int i = 1; i <= SHIFT + 1; ++i ) {
78 s += ( f & MASK ?
'1' :
'0' );
80 if ( i % 8 == 0 ) s +=
' ';
102 for (
int i = 0; i < 32; ++i ) {
104 if ( b & f ) ff += s_names.
at( (
IoFlag )( b ) ) +
"|";
122 size_t j( 0 ), k( 0 );
124 while ( ( k = f.
find(
"|", j ) ) != std::string::npos ) {
125 fs = f.
substr( j, k - j );
126 if ( s_n.
find( fs ) == s_n.
end() ) {
132 fl = fl | s_n.
at( fs );
137 if ( s_n.
find( fs ) == s_n.
end() ) {
143 fl = fl | s_n.
at( fs );
162 return t < tbl.
size() ? s << tbl[t] :
s;
179 , m_name(
std::move( n ) )
180 , m_desc(
std::move( d ) )
188 Fd
fd()
const {
return m_fd; }
194 void*
fptr()
const {
return m_fptr; }
204 void fptr(
void* v ) { m_fptr = v; }
210 os <<
"name: \"" << fa.
name() <<
"\" tech: " << fa.
tech() <<
" desc: " << fa.
desc()
211 <<
" flags: " << IoFlagName( fa.
flags() ) <<
" i_flags: " << IoFlagName( fa.
iflags() ) <<
" Fd: " << fa.
fd()
212 <<
" ptr: " << fa.
fptr() << ( fa.
isOpen() ?
" [o]" :
" [c]" ) << ( fa.
isShared() ?
" [s]" :
" [u]" );
218 return ( m_fd == fa.
fd() && m_name == fa.
name() && m_desc == fa.
desc() && m_tech == fa.
tech() &&
224 if ( m_name != rhs.
name() ) {
225 return ( m_name < rhs.
name() );
227 return ( m_flags < rhs.
iflags() );
238 void* m_fptr =
nullptr;
239 bool m_isOpen =
false;
240 bool m_shared =
false;
271 : tech( t ), b_open_fcn( o ), b_close_fcn( c ), b_reopen_fcn( r ){};
273 : tech( t ), b_open_fcn( o ), b_closeP_fcn( c ), b_reopenP_fcn( r ){};
274 FileHdlr(
IoTech t, bfcn_open_t o, bfcn_close_t
c1, bfcn_closeP_t
c2, bfcn_reopen_t r1, bfcn_reopenP_t r2 )
275 : tech( t ), b_open_fcn( o ), b_close_fcn( c1 ), b_closeP_fcn( c2 ), b_reopen_fcn( r1 ), b_reopenP_fcn( r2 ){};
289 {
"OPEN",
"CLOSE",
"REOPEN",
"OPEN_ERR",
"CLOSE_ERR",
"REOPEN_ERR",
"INVALID_ACTION"}};
290 return t < tbl.
size() ? s << tbl[t] :
s;
293 #define FILEMGR_CALLBACK_ARGS const Io::FileAttr*, const std::string& 325 virtual void listHandlers()
const = 0;
326 virtual void listFiles()
const = 0;
342 bool onlyOpen =
true )
const = 0;
344 bool onlyOpen =
true )
const = 0;
356 virtual const std::string& fname(
void* )
const = 0;
360 virtual Io::Fd fd(
void* fptr )
const = 0;
363 virtual void* fptr(
const std::string& )
const = 0;
364 virtual void* fptr(
const Io::Fd& )
const = 0;
378 void*&,
const std::string& desc,
const bool shared =
false ) = 0;
394 virtual void suppressAction(
const std::string& ) = 0;
std::function< Io::reopen_t(void *, Io::IoFlags)> bfcn_reopenP_t
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)
std::function< Io::close_t(Io::Fd)> bfcn_close_t
std::function< Io::reopen_t(Io::Fd, Io::IoFlags)> bfcn_reopen_t
std::function< Io::open_t(const std::string &, Io::IoFlags, const std::string &, Io::Fd &, void *&)> bfcn_open_t
bool operator==(const FileAttr &fa) const
FileHdlr(IoTech t, bfcn_open_t o, bfcn_close_t c, bfcn_reopen_t r)
std::function< Io::close_t(void *)> bfcn_closeP_t
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)
bool operator==(const int &fa) const
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.
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
bool operator==(const IoFlags &fa) const
std::ostream & operator<<(std::ostream &s, const IoFlag &f)
bfcn_closeP_t b_closeP_fcn
FileHdlr(IoTech t, bfcn_open_t o, bfcn_closeP_t c, bfcn_reopenP_t r)
bfcn_reopenP_t b_reopenP_fcn
std::function< StatusCode(FILEMGR_CALLBACK_ARGS)> bfcn_action_t
void tech(const IoTech &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
IoFlags operator|(const int &fa) const
void desc(const std::string &d)
IoFlags operator|(const IoFlags &fa) const
friend std::ostream & operator<<(std::ostream &os, const FileAttr &fa)