Go to the documentation of this file.
48 unsigned f()
const {
return _f; }
51 bool operator==(
const unsigned& fa )
const {
return (
_f == fa ); }
56 operator unsigned()
const {
return _f; }
64 if ( strict ) {
return (
_f == fa ); }
66 return ( (
_f & 3 ) == ( fa & 3 ) );
72 const unsigned SHIFT = 8 *
sizeof( unsigned ) - 1;
73 const unsigned MASK = 1u << SHIFT;
75 for (
unsigned i = 1; i <= SHIFT + 1; ++i ) {
76 s += (
f & MASK ?
'1' :
'0' );
78 if ( i % 8 == 0 )
s +=
' ';
87 static std::string IoFlagName(
IoFlags f ) {
88 static const std::map<IoFlag, std::string> s_names = { { {
READ,
"READ" },
99 for (
unsigned i = 0; i < 32; ++i ) {
100 auto b = ( 1u << i );
101 if ( b & f ) ff += s_names.at( (
IoFlag)( b ) ) +
"|";
103 ff.erase( ff.length() - 1 );
108 static const std::map<std::string, IoFlag> s_n = { { {
"READ",
Io::READ },
118 size_t j( 0 ), k( 0 );
120 while ( ( k = f.find(
"|",
j ) ) != std::string::npos ) {
121 fs = f.substr(
j, k -
j );
122 if ( s_n.find( fs ) == s_n.end() ) {
return Io::INVALID; }
126 fl = fl | s_n.at( fs );
131 if ( s_n.find( fs ) == s_n.end() ) {
return Io::INVALID; }
135 fl = fl | s_n.at( fs );
150 static const std::array<const char*, SQLITE + 1> tbl = { {
"UNKNOWN",
"POSIX",
"ROOT",
"BS",
"HDF5",
"SQLITE" } };
151 return t < tbl.size() ?
s << tbl[
t] :
s;
195 os <<
"name: \"" << fa.
name() <<
"\" tech: " << fa.
tech() <<
" desc: " << fa.
desc()
196 <<
" flags: " << IoFlagName( fa.
flags() ) <<
" i_flags: " << IoFlagName( fa.
iflags() ) <<
" Fd: " << fa.
fd()
197 <<
" ptr: " << fa.
fptr() << ( fa.
isOpen() ?
" [o]" :
" [c]" ) << ( fa.
isShared() ?
" [s]" :
" [u]" );
267 static const std::array<const char*, INVALID_ACTION + 1> tbl = {
268 {
"OPEN",
"CLOSE",
"REOPEN",
"OPEN_ERR",
"CLOSE_ERR",
"REOPEN_ERR",
"INVALID_ACTION" } };
269 return t < tbl.size() ?
s << tbl[
t] :
s;
272 #define FILEMGR_CALLBACK_ARGS const Io::FileAttr*, const std::string&
294 virtual int getFileAttr(
const std::string&, std::vector<const Io::FileAttr*>& )
const = 0;
305 virtual int getFiles( std::vector<std::string>& FILES,
bool onlyOpen =
true )
const = 0;
306 virtual int getFiles( std::vector<const Io::FileAttr*>& FILES,
bool onlyOpen =
true )
const = 0;
310 virtual int getFiles(
const Io::IoTech&, std::vector<std::string>& FILES,
bool onlyOpen =
true )
const = 0;
311 virtual int getFiles(
const Io::IoTech&, std::vector<const Io::FileAttr*>& FILES,
bool onlyOpen =
true )
const = 0;
317 bool onlyOpen =
true )
const = 0;
319 bool onlyOpen =
true )
const = 0;
322 virtual int getFd( std::vector<Io::Fd>& )
const = 0;
331 virtual const std::string&
fname(
void* )
const = 0;
338 virtual void*
fptr(
const std::string& )
const = 0;
345 Io::Fd&,
void*&,
const std::string& desc,
const bool shared =
false ) = 0;
349 Io::Fd&,
const std::string& desc,
const bool shared =
false ) = 0;
353 void*&,
const std::string& desc,
const bool shared =
false ) = 0;
366 const std::string& d =
"" ) = 0;
bfcn_closeP_t b_closeP_fcn
virtual int getFiles(std::vector< std::string > &FILES, bool onlyOpen=true) const =0
DeclareInterfaceID(IFileMgr, 1, 0)
virtual void listHandlers() const =0
virtual void listFiles() const =0
bool match(const IoFlags &fa, bool strict=true) const
virtual StatusCode deregHandler(const Io::IoTech &)=0
bool operator==(const unsigned &fa) const
FileHdlr(IoTech t, bfcn_open_t o, bfcn_closeP_t c, bfcn_reopenP_t r)
virtual const std::string & fname(void *) const =0
std::function< Io::open_t(const std::string &, Io::IoFlags, const std::string &, Io::Fd &, void *&)> bfcn_open_t
bool operator==(const IoFlags &fa) const
bool operator==(const FileAttr &fa) const
virtual StatusCode getFileAttr(const Io::Fd, const Io::FileAttr *&) const =0
std::bitset< INVALID_ACTION+1 > Action_bitmap
virtual Io::reopen_t reopen(void *, const Io::IoFlags &, const std::string &)=0
virtual int getFd(const Io::IoTech &, const Io::IoFlags &, std::vector< Io::Fd > &) const =0
friend std::ostream & operator<<(std::ostream &os, const FileAttr &fa)
void iflags(const IoFlags &f)
virtual int getFiles(const Io::IoTech &, const Io::IoFlags &, std::vector< std::string > &FILES, bool onlyOpen=true) const =0
std::ostream & operator<<(std::ostream &s, const IoFlag &f)
virtual int getFiles(const Io::IoTech &, std::vector< std::string > &FILES, bool onlyOpen=true) const =0
virtual void suppressAction(const std::string &)=0
std::function< Io::reopen_t(void *, Io::IoFlags)> bfcn_reopenP_t
virtual Io::reopen_t reopen(const Io::Fd, const Io::IoFlags &, const std::string &)=0
const std::string & name() const
void name(const std::string &n)
virtual StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &d="")=0
virtual StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const Io::IoTech &, const std::string &d="")=0
FileHdlr(IoTech t, bfcn_open_t o, bfcn_close_t c, bfcn_reopen_t r)
virtual StatusCode getHandler(const std::string &, Io::FileHdlr &) const =0
IoFlags operator|(const IoFlags &fa) const
FileAttr(Fd f, std::string n, std::string d, IoTech t, IoFlags fa, void *p, bool o, bool s=false)
bfcn_reopen_t b_reopen_fcn
virtual int getFiles(const Io::IoTech &, std::vector< const Io::FileAttr * > &FILES, bool onlyOpen=true) const =0
virtual StatusCode getFileAttr(void *, const Io::FileAttr *&) const =0
virtual int getFiles(std::vector< const Io::FileAttr * > &FILES, bool onlyOpen=true) const =0
IoFlags IoFlagFromName(const std::string &f)
std::function< Io::close_t(void *)> bfcn_closeP_t
virtual const std::string & fname(const Io::Fd &) const =0
virtual StatusCode regHandler(Io::FileHdlr)=0
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, const std::string &desc, const bool shared=false)=0
virtual Io::Fd fd(const std::string &) const =0
void desc(const std::string &d)
bfcn_reopenP_t b_reopenP_fcn
virtual int getFiles(const Io::IoTech &, const Io::IoFlags &, std::vector< const Io::FileAttr * > &FILES, bool onlyOpen=true) const =0
virtual int getFileAttr(const std::string &, std::vector< const Io::FileAttr * > &) const =0
virtual int getLastError(std::string &) const =0
virtual int getFd(const Io::IoTech &, std::vector< Io::Fd > &) const =0
#define FILEMGR_CALLBACK_ARGS
virtual void suppressAction(const std::string &, const Io::Action &)=0
virtual StatusCode getHandler(const Io::IoTech &, Io::FileHdlr &) const =0
const std::string & desc() const
void flags(const IoFlags &f)
void tech(const IoTech &t)
virtual Io::Fd fd(void *fptr) const =0
std::function< StatusCode(FILEMGR_CALLBACK_ARGS)> bfcn_action_t
virtual int getFd(std::vector< Io::Fd > &) const =0
virtual Io::close_t close(void *, const std::string &caller)=0
virtual Io::close_t close(const Io::Fd, const std::string &caller)=0
virtual StatusCode hasHandler(const Io::IoTech &) const =0
bool operator<(const FileAttr &rhs) const
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, void *&, const std::string &desc, const bool shared=false)=0
FileHdlr(IoTech t, bfcn_open_t o, bfcn_close_t c1, bfcn_closeP_t c2, bfcn_reopen_t r1, bfcn_reopenP_t r2)
virtual void * fptr(const Io::Fd &) const =0
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, void *&, const std::string &desc, const bool shared=false)=0
std::function< Io::close_t(Io::Fd)> bfcn_close_t
std::function< Io::reopen_t(Io::Fd, Io::IoFlags)> bfcn_reopen_t
IoFlags operator|(const unsigned &fa) const
virtual void * fptr(const std::string &) const =0