7 #ifndef GAUDIKERNEL_IFILEMGR_H 8 #define GAUDIKERNEL_IFILEMGR_H 1 47 int f()
const {
return _f; }
55 operator int()
const {
return _f; }
68 return ( (
_f & 3 ) == ( fa & 3 ) );
75 const int SHIFT = 8 *
sizeof( int ) - 1;
76 const unsigned MASK = 1 << SHIFT;
78 for (
int i = 1; i <= SHIFT + 1; ++i ) {
79 s += ( f & MASK ?
'1' :
'0' );
81 if ( i % 8 == 0 ) s +=
' ';
103 for (
int i = 0; i < 32; ++i ) {
105 if ( b & f ) ff += s_names.
at( (
IoFlag )( b ) ) +
"|";
123 size_t j( 0 ), k( 0 );
125 while ( ( k = f.
find(
"|", j ) ) != std::string::npos ) {
126 fs = f.
substr( j, k - j );
127 if ( s_n.
find( fs ) == s_n.
end() ) {
133 fl = fl | s_n.
at( fs );
138 if ( s_n.
find( fs ) == s_n.
end() ) {
144 fl = fl | s_n.
at( fs );
163 return t < tbl.
size() ? s << tbl[t] :
s;
180 , m_name(
std::move( n ) )
181 , m_desc(
std::move( d ) )
189 Fd
fd()
const {
return m_fd; }
195 void*
fptr()
const {
return m_fptr; }
205 void fptr(
void* v ) { m_fptr = v; }
211 os <<
"name: \"" << fa.
name() <<
"\" tech: " << fa.
tech() <<
" desc: " << fa.
desc()
212 <<
" flags: " << IoFlagName( fa.
flags() ) <<
" i_flags: " << IoFlagName( fa.
iflags() ) <<
" Fd: " << fa.
fd()
213 <<
" ptr: " << fa.
fptr() << ( fa.
isOpen() ?
" [o]" :
" [c]" ) << ( fa.
isShared() ?
" [s]" :
" [u]" );
219 return ( m_fd == fa.
fd() && m_name == fa.
name() && m_desc == fa.
desc() && m_tech == fa.
tech() &&
225 if ( m_name != rhs.
name() ) {
226 return ( m_name < rhs.
name() );
228 return ( m_flags < rhs.
iflags() );
239 void* m_fptr =
nullptr;
240 bool m_isOpen =
false;
241 bool m_shared =
false;
272 : tech( t ), b_open_fcn( o ), b_close_fcn( c ), b_reopen_fcn( r ){};
274 : tech( t ), b_open_fcn( o ), b_closeP_fcn( c ), b_reopenP_fcn( r ){};
275 FileHdlr(
IoTech t, bfcn_open_t o, bfcn_close_t c1, bfcn_closeP_t c2, bfcn_reopen_t r1, bfcn_reopenP_t r2 )
276 : tech( t ), b_open_fcn( o ), b_close_fcn( c1 ), b_closeP_fcn( c2 ), b_reopen_fcn( r1 ), b_reopenP_fcn( r2 ){};
291 {
"OPEN",
"CLOSE",
"REOPEN",
"OPEN_ERR",
"CLOSE_ERR",
"REOPEN_ERR",
"INVALID_ACTION"}};
292 return t < tbl.
size() ? s << tbl[t] :
s;
295 #define FILEMGR_CALLBACK_ARGS const Io::FileAttr*, const std::string& 327 virtual void listHandlers()
const = 0;
328 virtual void listFiles()
const = 0;
344 bool onlyOpen =
true )
const = 0;
346 bool onlyOpen =
true )
const = 0;
358 virtual const std::string& fname(
void* )
const = 0;
362 virtual Io::Fd fd(
void* fptr )
const = 0;
365 virtual void* fptr(
const std::string& )
const = 0;
366 virtual void* fptr(
const Io::Fd& )
const = 0;
380 void*&,
const std::string& desc,
const bool shared =
false ) = 0;
396 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)