The Gaudi Framework  v30r3 (a5ef0a68)
FileMgr.cpp
Go to the documentation of this file.
1 #include "FileMgr.h"
2 
3 #include <fstream>
4 
7 
8 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
9 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
10 
11 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 using namespace std;
15 using namespace Io;
16 
17 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
18 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
19 namespace
20 {
21  static const std::string s_empty = "";
22 
23  constexpr struct to_name_t {
24  std::string operator()( const FileAttr* f ) const { return f->name(); }
25  std::string operator()( const std::pair<std::string, FileAttr*>& f ) const { return f.first; }
26  } to_name{};
27 
28  const auto select1st = []( auto&& x ) -> decltype( auto ) { return std::get<0>( std::forward<decltype( x )>( x ) ); };
29 
30  const auto select2nd = []( auto&& x ) -> decltype( auto ) { return std::get<1>( std::forward<decltype( x )>( x ) ); };
31 
32  template <typename InputIterator, typename OutputIterator, typename UnaryOperation, typename UnaryPredicate>
33  OutputIterator transform_if( InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op,
34  UnaryPredicate pred )
35  {
36  while ( first != last ) {
37  if ( pred( *first ) ) *result++ = op( *first );
38  ++first;
39  }
40  return result;
41  }
42 
43  template <typename InputIterator, typename OutputIterator, typename UnaryOperation, typename UnaryPredicate>
44  OutputIterator transform_copy_if( InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op,
45  UnaryPredicate pred )
46  {
47  while ( first != last ) {
48  auto t = op( *first );
49  if ( pred( t ) ) *result++ = std::move( t );
50  ++first;
51  }
52  return result;
53  }
54 }
55 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
56 
58 {
59  // Where do the new-ed FileAttr get deleted?
60  // they get pushed into m_descriptors, but m_attr is presumably
61  // where they _also_ should be pushed in order to track ownership...
62 }
63 
64 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
65 
67 {
69 
70  if ( status.isFailure() ) {
71 
72  ON_DEBUG
73  debug() << "Failed to initialize the base class (Service)" << endmsg;
74  return status;
75  }
76 
78  verbose() << "Initializing FileMgr" << endmsg;
79 
80  if ( m_loadRootHandler.value() ) {
81 
82  // setup file handler for ROOT
83 
84  msgSvc()->setOutputLevel( "RootFileHandler", m_outputLevel.value() );
85  m_rfh.emplace( msgSvc(), m_ssl_proxy, m_ssl_cert );
86 
87  auto& rfh = m_rfh.value(); // used in the lambdas to avoid capturing 'this'
88  Io::FileHdlr hdlr(
89  Io::ROOT, [&rfh]( const std::string& n, const Io::IoFlags& f, const std::string& desc, Io::Fd& fd,
90  void*& ptr ) -> Io::open_t { return rfh.openRootFile( n, f, desc, fd, ptr ); },
91  [&rfh]( void* ptr ) -> Io::close_t { return rfh.closeRootFile( ptr ); },
92  [&rfh]( void* ptr, const Io::IoFlags& f ) -> Io::reopen_t { return rfh.reopenRootFile( ptr, f ); } );
93 
94  if ( regHandler( hdlr ).isFailure() ) {
95  error() << "unable to register ROOT file handler with FileMgr" << endmsg;
96  }
97  }
98 
99  if ( m_loadPosixHandler.value() ) {
100 
101  // setup file handler for POSIX
102 
103  msgSvc()->setOutputLevel( "POSIXFileHandler", m_outputLevel.value() );
104  m_pfh.emplace( msgSvc() );
105 
106  auto& pfh = m_pfh.value(); // used in the lambdas to avoid capturing 'this'
107  Io::FileHdlr hdlp(
108  Io::POSIX, [&pfh]( const std::string& n, const Io::IoFlags& f, const std::string& desc, Io::Fd& fd,
109  void*& ptr ) -> Io::open_t { return pfh.openPOSIXFile( n, f, desc, fd, ptr ); },
110  [&pfh]( Io::Fd fd ) -> Io::close_t { return pfh.closePOSIXFile( fd ); },
111  [&pfh]( Io::Fd fd, const Io::IoFlags& f ) -> Io::reopen_t { return pfh.reopenPOSIXFile( fd, f ); } );
112 
113  if ( regHandler( hdlp ).isFailure() ) {
114  error() << "unable to register ROOT file handler with FileMgr" << endmsg;
115  }
116  }
117 
118  return StatusCode::SUCCESS;
119 }
120 
121 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
122 
124 {
125  ON_VERBOSE
126  verbose() << "FileMgr::finalize()" << endmsg;
127 
128  if ( m_printSummary || msgLevel( MSG::DEBUG ) ) {
129  listHandlers();
130  listFiles();
131  listActions();
132  listSuppression();
133  }
134 
135  if ( !m_files.empty() ) {
136  auto& log = warning();
137  log << "At finalize, the following files remained open:\n";
138  for ( const auto& itr : m_files ) log << *( itr.second ) << '\n';
139  log << endmsg;
140  }
141 
142  if ( m_logfile.value() != "" ) {
143  std::ofstream ofs;
144  ofs.open( m_logfile.value().c_str() );
145  if ( !ofs ) {
146  error() << "Unable to open output file \"" << m_logfile.value() << "\" for writing" << endmsg;
147  } else {
148  ON_DEBUG
149  debug() << "Saving log to \"" << m_logfile.value() << "\"" << endmsg;
150  for ( const auto& itr : m_files ) {
151  ofs << itr.second->name() << " " << itr.second->tech() << " " << itr.second->desc() << " "
152  << itr.second->iflags() << '\n';
153  }
154 
155  set<FileAttr> fs;
156  for ( const auto& it2 : m_oldFiles ) fs.insert( *it2 );
157  for ( const auto& it3 : fs ) {
158  ofs << it3.name() << " " << it3.tech() << " " << it3.desc() << " " << it3.iflags()
159  << ( it3.isShared() ? " SHARED" : "" ) << '\n';
160  }
161  ofs.close();
162  }
163  }
164 
165  // cleanup FileAttrs
166  m_attr.clear();
167 
168  m_rfh.reset();
169  m_pfh.reset();
170 
171  StatusCode status = Service::finalize();
172 
173  ON_DEBUG
174  if ( status.isSuccess() ) debug() << "Service finalised successfully" << endmsg;
175 
176  return status;
177 }
178 
179 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
180 
181 void FileMgr::handle( const Incident& /*inc*/ ) {}
182 
183 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
184 
186 {
187 
188  IoTech tech = fh.tech;
189 
190  if ( m_handlers.find( tech ) != m_handlers.end() ) {
191  warning() << "Handler for IoTech " << tech << " already registered. Ignoring." << endmsg;
192  return StatusCode::SUCCESS;
193  }
194 
195  if ( !fh.b_open_fcn ) {
196  error() << "open handler for tech " << tech << " is NULL" << endmsg;
197  return StatusCode::FAILURE;
198  }
199 
200  if ( !fh.b_close_fcn && !fh.b_closeP_fcn ) {
201  error() << "no close handler for tech " << tech << " registered" << endmsg;
202  return StatusCode::FAILURE;
203  }
204 
205  if ( !fh.b_reopen_fcn && !fh.b_reopenP_fcn ) {
206  error() << "no reopen handler for tech " << tech << " registered" << endmsg;
207  return StatusCode::FAILURE;
208  }
209 
210  ON_DEBUG
211  debug() << "Successfully registered handler for tech \"" << tech << "\"" << endmsg;
212 
213  m_handlers[tech] = fh;
214 
215  return StatusCode::SUCCESS;
216 }
217 
218 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
219 
221 {
222  FileHdlr hdlr;
223 
224  auto itr = m_handlers.find( tech );
225  if ( itr == m_handlers.end() ) {
226  error() << "Can't de-register tech " << tech << " as it hasn't been registered!" << endmsg;
227  return StatusCode::FAILURE;
228  }
229 
230  m_handlers.erase( itr );
231  return StatusCode::SUCCESS;
232 }
233 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
234 
236 {
237 
238  auto itr = m_handlers.find( tech );
239  return ( itr != m_handlers.end() ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
240 }
241 
242 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
243 
244 open_t FileMgr::open( const IoTech& tech, const std::string& caller, const std::string& fname, const IoFlags& flags,
245  Fd& fd, void*& ptr, const std::string& desc, bool sh )
246 {
247 
248  return open( tech, caller, fname, desc, flags, fd, ptr, sh );
249 }
250 
251 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
252 open_t FileMgr::open( const IoTech& tech, const std::string& caller, const std::string& fname, const IoFlags& flags,
253  Fd& fd, const std::string& desc, bool sh )
254 {
255 
256  void* dummy( 0 );
257  return open( tech, caller, fname, desc, flags, fd, dummy, sh );
258 }
259 
260 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
261 open_t FileMgr::open( const IoTech& tech, const std::string& caller, const std::string& fname, const IoFlags& flags,
262  void*& ptr, const std::string& desc, bool sh )
263 {
264 
265  Fd dummy( -1 );
266  return open( tech, caller, fname, desc, flags, dummy, ptr, sh );
267 }
268 
269 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
270 
271 open_t FileMgr::open( const IoTech& tech, const std::string& caller, const std::string& fname, const std::string& desc,
272  const IoFlags& flags, Fd& fd, void*& ptr, bool shared )
273 {
274 
275  // return codes: ok == 0, warning > 0, error < 0
276  // 0: ok
277  //
278  // WARNING:
279  // 1: file already open with existing FileAttributes
280  // 2: file already open with different FileAttributes
281  // 3: file opened, but fd and ptr are both invalid
282  //
283  // ERRORS:
284  // -1: no handler for TECH
285  // -2: file already open with different tech
286  // -3: file asked to be opened in shared mode, but other open file
287  // exist that are marked unshared
288  // -4: error calling tech specific open function
289 
290  ON_VERBOSE
291  verbose() << "open(" << tech << "," << caller << ",\"" << fname << "\",\"" << desc << "\"," << flags
292  << ( shared ? ",shared" : ",unshared" ) << ")" << endmsg;
293 
294  open_t r = -1;
295  FileHdlr fh;
296  if ( getHandler( tech, fh ).isFailure() ) return r;
297 
298  auto fitr = m_files.equal_range( fname );
299 
300  // make sure all files with same name have same tech
301 
302  auto itr =
303  std::find_if( fitr.first, fitr.second, [&]( fileMap::const_reference i ) { return i.second->tech() != tech; } );
304  if ( itr != fitr.second ) {
305  error() << "when calling open on " << fname << " with tech " << tech << ", file already opened with different tech "
306  << itr->second->tech() << endmsg;
307  r = -1;
308  return r;
309  }
310 
311  // check for sharing
312 
313  if ( shared ) {
314 
315  bool shareable( true );
316 
317  for ( auto itr = fitr.first; itr != fitr.second; ++itr ) {
318  FileAttr* fa = itr->second;
319 
320  if ( !fa->isShared() ) shareable = false;
321 
322  // if ( shareable && accessMatch(fa->flags(),flags) )
323  if ( shareable && fa->flags().match( flags, false ) ) {
324 
325  ON_DEBUG
326  debug() << " found shared file: " << *fa << endmsg;
327 
328  fd = fa->fd();
329  ptr = fa->fptr();
330  r = 0;
331  }
332  }
333 
334  if ( !shareable ) {
335  // at least one of the other files was not marked shared.
336  fd = -1;
337  ptr = 0;
338  r = -1;
339  }
340  }
341 
342  if ( r != 0 ) {
343 
344  try {
345  r = fh.b_open_fcn( fname, flags, desc, fd, ptr );
346  } catch ( const std::bad_function_call& err ) {
347  error() << "when calling open handler for " << tech << " on file " << fname << " caught " << err.what() << endmsg;
348  return -4;
349  } catch ( ... ) {
350  error() << "when calling open handler for " << tech << " on file " << fname << " caught an unknown exception."
351  << endmsg;
352  return -4;
353  }
354 
355  if ( r != 0 ) {
356  warning() << "open of file \"" << fname << "\", tech: \"" << tech << "\", flags: \"" << flags
357  << "\" requested by " << caller << " failed. return code: " << r << endmsg;
358 
359  FileAttr xfa( -1, fname, desc, tech, flags, 0, false );
360  execAction( &xfa, caller, Io::OPEN_ERR ).ignore();
361 
362  return r;
363  }
364  }
365 
366  //@TODO/@FIXME: should this not be pushed into m_attr???
367  // eg. m_attr.emplace_back( new FileAttr(fd,fname,desc,tech,flags,ptr,true,shared) );
368  // FileAttr* fa = m_attr.back().get();
369  FileAttr* fa = new FileAttr( fd, fname, desc, tech, flags, ptr, true, shared );
370 
371  ON_DEBUG
372  debug() << "opened file " << *fa << endmsg;
373 
374  if ( fd == -1 && ptr == 0 ) {
375  warning() << "when opening " << *fa << " both File Descriptor"
376  << " and File Ptr are invalid" << endmsg;
377  r = 3;
378  }
379 
380  for ( auto itr = fitr.first; itr != fitr.second; ++itr ) {
381  if ( fa->flags() == Io::READ || shared ) {
382  // ok
383  } else if ( *fa == *( itr->second ) ) {
384  warning() << "open call for file \"" << fname << "\" returned a pre-existing file with identical"
385  << " FileAttributes: " << *fa << endmsg;
386  r = 1;
387  } else {
388  warning() << "open call for file \"" << fname << "\" returned a pre-existing file with different"
389  << " FileAttributes -\n"
390  << "old: " << *( itr->second ) << '\n'
391  << "new: " << *fa << endmsg;
392  r = 2;
393  }
394  }
395 
396  m_files.emplace( fname, fa );
397 
398  // execute all our open callbacks
399  if ( execAction( fa, caller, Io::OPEN ).isFailure() ) {
400  warning() << "at least one open callback action failed" << endmsg;
401  }
402 
403  return r;
404 }
405 
406 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
407 
408 close_t FileMgr::close( Fd fd, const std::string& caller )
409 {
410 
411  // return codes:
412  // < 0 : error condition
413  // 0 : actual close of one file
414  // > 0 : shared file, removed from list, no actual close, returns
415  // number of shared files still open.
416 
417  ON_VERBOSE
418  verbose() << "close(" << fd << ")" << endmsg;
419 
420  close_t r = -1;
421 
422  auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
423  [&]( fileMap::const_reference i ) { return i.second->fd() == fd; } );
424 
425  if ( itr == std::end( m_files ) ) {
426  error() << "unknown file descriptor \"" << fd << "\" when calling close()" << endmsg;
427  return r;
428  }
429 
430  IoTech tech = itr->second->tech();
431 
432  FileHdlr fh;
433 
434  if ( getHandler( tech, fh ).isFailure() ) {
435  return r;
436  }
437 
438  if ( !fh.b_close_fcn ) {
439  error() << "no close(" << tech << ",Fd) function registered" << endmsg;
440  return -1;
441  }
442 
443  FileAttr* fa = itr->second;
444 
445  // find how many times this file is open
446  auto fitr = m_files.equal_range( fa->name() );
447  int i = std::count_if( fitr.first, fitr.second, [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
448 
449  ON_VERBOSE
450  verbose() << " ref count: " << i << endmsg;
451 
452  if ( i > 1 && fa->isShared() ) {
453  // file open multiple times. don't do the actual close
454  ON_DEBUG
455  debug() << "closing file " << fa->name() << " opened " << i << " times with Fd " << fd << endmsg;
456  m_files.erase( itr );
457 
458  r = i - 1;
459 
460  } else if ( i == 1 || ( i > 1 && !fa->isShared() ) ) {
461  ON_DEBUG
462  debug() << "closing " << *fa << endmsg;
463 
464  try {
465  r = fh.b_close_fcn( fd );
466  } catch ( const std::bad_function_call& err ) {
467  error() << "when calling close handler for " << tech << " on file descriptor " << fd << " caught " << err.what()
468  << endmsg;
469  execAction( fa, caller, Io::CLOSE_ERR ).ignore();
470  return -1;
471  } catch ( ... ) {
472  error() << "when calling close handler for " << tech << " on file descriptor " << fd
473  << " caught an unknown exception." << endmsg;
474  execAction( fa, caller, Io::CLOSE_ERR ).ignore();
475  return -1;
476  }
477 
478  if ( r < 0 ) {
479  warning() << "close of file with FD \"" << fd << "\", name: \"" << fa->name() << "\", tech: \"" << tech
480  << "\" failed" << endmsg;
481 
482  execAction( fa, caller, Io::CLOSE_ERR ).ignore();
483 
484  return r;
485  }
486 
487  m_files.erase( itr );
488 
489  } else if ( i <= 0 ) {
490  // this should never happen!
491  error() << "ref count < 0 when closing " << fa << ". This should never happen" << endmsg;
492  return -1;
493  }
494 
495  fa->fd( -1 );
496  fa->flags( INVALID );
497  fa->isOpen( false );
498  fa->fptr( 0 );
499  m_oldFiles.push_back( fa );
500 
501  // exec all callbacks
502  if ( execAction( fa, caller, Io::CLOSE ).isFailure() ) {
503  warning() << "at least one close callback action failed" << endmsg;
504  }
505 
506  return r;
507 }
508 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
509 
510 close_t FileMgr::close( void* vp, const std::string& caller )
511 {
512 
513  // return codes:
514  // < 0 : error condition
515  // 0 : actual close of one file
516  // > 0 : shared file, removed from list, no actual close, returns
517  // number of shared files still open.
518 
519  ON_VERBOSE
520  verbose() << "close(" << vp << ")" << endmsg;
521 
522  close_t r = -1;
523 
524  auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
525  [&]( fileMap::const_reference i ) { return i.second->fptr() == vp; } );
526 
527  if ( itr == m_files.end() ) {
528  error() << "unknown file ptr \"" << vp << "\" when calling close()" << endmsg;
529  return r;
530  }
531 
532  IoTech tech = itr->second->tech();
533 
534  FileHdlr fh;
535 
536  if ( getHandler( tech, fh ).isFailure() ) {
537  return r;
538  }
539  if ( !fh.b_closeP_fcn ) {
540  error() << "no close(" << tech << ",void*) function registered" << endmsg;
541  return -1;
542  }
543 
544  FileAttr* fa = itr->second;
545 
546  // find how many times this file is open
547  pair<fileMap::const_iterator, fileMap::const_iterator> fitr = m_files.equal_range( fa->name() );
548 
549  int i =
550  std::count_if( fitr.first, fitr.second, [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
551 
552  ON_VERBOSE
553  verbose() << " ref count: " << i << endmsg;
554 
555  if ( i > 1 && fa->isShared() ) {
556  // file open multiple times in shared access. don't do the actual close
557  ON_DEBUG
558  debug() << "closing file " << fa->name() << " opened " << i << " times with fptr " << vp << endmsg;
559  m_files.erase( itr );
560 
561  r = i - 1;
562 
563  } else if ( i == 1 || ( i > 1 && !fa->isShared() ) ) {
564  ON_DEBUG
565  debug() << "closing: " << *fa << endmsg;
566 
567  try {
568  r = fh.b_closeP_fcn( vp );
569  } catch ( const std::bad_function_call& err ) {
570  error() << "when calling close handler for " << tech << " on file " << fa->name() << " caught " << err.what()
571  << endmsg;
572  execAction( fa, caller, CLOSE_ERR ).ignore();
573  return -1;
574  } catch ( ... ) {
575  error() << "when calling close handler for " << tech << " on file " << fa->name()
576  << " caught an unknown exception." << endmsg;
577  execAction( fa, caller, CLOSE_ERR ).ignore();
578  return -1;
579  }
580 
581  if ( r < 0 ) {
582  warning() << "close of file with ptr \"" << vp << "\", name: \"" << fa->name() << "\", tech: \"" << tech
583  << "\" failed" << endmsg;
584 
585  return r;
586  }
587 
588  m_files.erase( itr );
589 
590  } else {
591  // this should never happen!
592  error() << "ref count: " << i << " < 0 when closing " << fa << ". This should never happen" << endmsg;
593  return -1;
594  }
595 
596  fa->fd( -1 );
597  fa->flags( INVALID );
598  fa->isOpen( false );
599  fa->fptr( 0 );
600  m_oldFiles.push_back( fa );
601 
602  // exec all callbacks
603  if ( execAction( fa, caller, CLOSE ).isFailure() ) {
604  warning() << "at least one close callback action failed" << endmsg;
605  }
606 
607  return r;
608 }
609 
610 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
611 
612 reopen_t FileMgr::reopen( Fd fd, const IoFlags& flags, const std::string& caller )
613 {
614 
615  ON_VERBOSE
616  verbose() << "reopen(" << fd << "," << flags << "," << caller << ")" << endmsg;
617 
618  reopen_t r = -1;
619 
620  auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
621  [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
622 
623  if ( itr == m_files.end() ) {
624  error() << "unregistered FD \"" << fd << "\" when calling reopen()" << endmsg;
625  return r;
626  }
627 
628  FileAttr* fa = itr->second;
629  IoTech tech = fa->tech();
630 
631  FileHdlr fh;
632 
633  if ( getHandler( tech, fh ).isFailure() ) {
634  return r;
635  }
636 
637  fa->flags( flags );
638 
639  if ( !fh.b_reopen_fcn ) {
640  error() << "no reopen(" << tech << ",Fd) function registered" << endmsg;
641  return -1;
642  }
643 
644  // FIXME: what does it mean to call reopen on a shared file?
645 
646  try {
647  r = fh.b_reopen_fcn( fd, flags );
648  } catch ( const std::bad_function_call& err ) {
649  error() << "when calling reopen handler for " << tech << " on file descriptor " << fd << " with flags " << flags
650  << " caught " << err.what() << endmsg;
651  return -1;
652  } catch ( ... ) {
653  error() << "when calling reopen handler for " << tech << " on file descriptor " << fd << " with flags " << flags
654  << " caught an unknown exception." << endmsg;
655  return -1;
656  }
657 
658  if ( r < 0 ) {
659  warning() << "reopen of file with FD \"" << fd << "\", name: \"" << fa->name() << "\", tech: \"" << tech
660  << "\", flags: \"" << flags << "\" failed" << endmsg;
661 
662  execAction( fa, caller, Io::REOPEN_ERR ).ignore();
663 
664  return r;
665  }
666 
667  fa->isOpen( true );
668  fa->flags( flags );
669 
670  // exec all callbacks
671  if ( execAction( fa, caller, Io::REOPEN ).isFailure() ) {
672  warning() << "at least one reopen callback action failed" << endmsg;
673  }
674 
675  return r;
676 }
677 
678 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
679 
680 reopen_t FileMgr::reopen( void* vp, const IoFlags& flags, const std::string& caller )
681 {
682  ON_VERBOSE
683  verbose() << "reopen(" << vp << "," << flags << "," << caller << ")" << endmsg;
684 
685  reopen_t r = -1;
686 
687  auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
688  [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
689  if ( itr == m_files.end() ) {
690  error() << "unregistered file ptr \"" << vp << "\" when calling reopen()" << endmsg;
691  return r;
692  }
693 
694  FileAttr* fa = itr->second;
695  FileHdlr fh;
696  IoTech tech = fa->tech();
697 
698  if ( getHandler( tech, fh ).isFailure() ) {
699  return r;
700  }
701 
702  if ( !fh.b_reopenP_fcn ) {
703  error() << "no reopen(" << tech << ",void*) function registered" << endmsg;
704  return -1;
705  }
706 
707  try {
708  r = fh.b_reopenP_fcn( vp, flags );
709  } catch ( const std::bad_function_call& err ) {
710  error() << "when calling reopen handler for " << tech << " on file " << fa->name() << " with flags " << flags
711  << " caught " << err.what() << endmsg;
712  return -1;
713  } catch ( ... ) {
714  error() << "when calling reopen handler for " << tech << " on file " << fa->name() << " with flags " << flags
715  << " caught an unknown exception." << endmsg;
716  return -1;
717  }
718 
719  if ( r < 0 ) {
720  warning() << "reopen of file with ptr \"" << vp << "\", name: \"" << fa->name() << "\", tech: \"" << tech
721  << "\", flags: \"" << flags << "\" failed" << endmsg;
722 
723  execAction( fa, caller, Io::REOPEN_ERR ).ignore();
724 
725  return r;
726  }
727 
728  fa->isOpen( true );
729  fa->flags( flags );
730 
731  // exec all callbacks
732  if ( execAction( fa, caller, Io::REOPEN ).isFailure() ) {
733  warning() << "at least one reopen callback action failed" << endmsg;
734  }
735 
736  return r;
737 }
738 
739 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
740 
742 {
743 
744  fa.clear();
745 
746  auto fitr = m_files.equal_range( fname );
747  std::transform( fitr.first, fitr.second, std::back_inserter( fa ), select2nd );
748 
749  std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( fa ),
750  [&]( const FileAttr* f ) { return f->name() == fname; } );
751 
752  return fa.size();
753 }
754 
755 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
756 
757 StatusCode FileMgr::getFileAttr( const Fd fd, const FileAttr*& fa ) const
758 {
759 
760  auto i = std::find_if( std::begin( m_files ), std::end( m_files ),
761  [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
762  if ( i != std::end( m_files ) ) {
763  fa = i->second;
764  return StatusCode::SUCCESS;
765  }
766 
767  auto j = std::find_if( std::begin( m_oldFiles ), std::end( m_oldFiles ),
768  [&]( const FileAttr* f ) { return f->fd() == fd; } );
769  if ( j != std::end( m_oldFiles ) ) {
770  fa = *j;
771  return StatusCode::SUCCESS;
772  }
773 
774  return StatusCode::FAILURE;
775 }
776 
777 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
778 
779 StatusCode FileMgr::getFileAttr( void* vp, const FileAttr*& fa ) const
780 {
781 
782  auto i = std::find_if( std::begin( m_files ), std::end( m_files ),
783  [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
784  if ( i != std::end( m_files ) ) {
785  fa = i->second;
786  return StatusCode::SUCCESS;
787  }
788 
789  auto j = std::find_if( std::begin( m_oldFiles ), std::end( m_oldFiles ),
790  [&]( const FileAttr* f ) { return f->fptr() == vp; } );
791  if ( j != std::end( m_oldFiles ) ) {
792  fa = *j;
793  return StatusCode::SUCCESS;
794  }
795 
796  return StatusCode::FAILURE;
797 }
798 
799 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
800 
801 int FileMgr::getFiles( std::vector<std::string>& files, bool op ) const
802 {
803 
804  files.clear();
805  auto not_in_files = [&]( const std::string& i ) {
806  return std::none_of( std::begin( files ), std::end( files ), [&]( const std::string& j ) { return j == i; } );
807  };
808  transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name, not_in_files );
809  if ( !op ) {
810  transform_copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
811  not_in_files );
812  }
813  return files.size();
814 }
815 
816 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
817 
818 int FileMgr::getFiles( vector<const Io::FileAttr*>& files, bool op ) const
819 {
820 
821  files.clear();
822  std::transform( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd );
823  if ( !op ) {
824  std::copy( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ) );
825  }
826  return files.size();
827 }
828 
829 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
830 
831 int FileMgr::getFiles( const IoTech& tech, vector<string>& files, bool op ) const
832 {
833 
834  if ( tech == UNKNOWN ) return getFiles( files, op );
835 
836  files.clear();
837  transform_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name,
838  [&]( fileMap::const_reference f ) {
839  return f.second->tech() == tech &&
840  std::none_of( std::begin( files ), std::end( files ),
841  [&]( const std::string& j ) { return j == f.first; } );
842  } );
843 
844  if ( !op ) {
845  transform_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
846  [&]( const FileAttr* f ) {
847  return f->tech() == tech && std::none_of( std::begin( files ), std::end( files ),
848  [&]( const std::string& j ) { return j == f->name(); } );
849  } );
850  }
851  return files.size();
852 }
853 
854 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
855 
856 int FileMgr::getFiles( const IoTech& tech, vector<const Io::FileAttr*>& files, bool op ) const
857 {
858 
859  if ( tech == UNKNOWN ) return getFiles( files, op );
860 
861  auto matches_tech = [&]( const FileAttr* f ) { return f->tech() == tech; };
862 
863  files.clear();
864  transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd, matches_tech );
865  if ( !op ) {
866  std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), matches_tech );
867  }
868 
869  return files.size();
870 }
871 
872 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
873 
874 int FileMgr::getFiles( const IoTech& tech, const IoFlags& flags, vector<string>& files, bool op ) const
875 {
876 
877  files.clear();
878 
879  auto not_in_files = [&]( const std::string& n ) {
880  return std::none_of( std::begin( files ), std::end( files ), [&]( const std::string& f ) { return f == n; } );
881  };
882  auto matches_tech_and_flags = [&]( const FileAttr* f ) {
883  return ( f->tech() == tech || tech == UNKNOWN ) && f->flags() == flags;
884  };
885 
886  transform_if(
887  std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), to_name,
888  [&]( fileMap::const_reference f ) { return matches_tech_and_flags( f.second ) && not_in_files( f.first ); } );
889  if ( !op ) {
890  transform_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ), to_name,
891  [&]( const FileAttr* f ) { return matches_tech_and_flags( f ) && not_in_files( f->name() ); } );
892  }
893 
894  return files.size();
895 }
896 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
897 
898 int FileMgr::getFiles( const IoTech& tech, const IoFlags& flags, vector<const Io::FileAttr*>& files, bool op ) const
899 {
900 
901  files.clear();
902 
903  auto matches_tech_and_flags = [&]( const FileAttr* f ) {
904  return ( f->tech() == tech || tech == UNKNOWN ) && f->flags() == flags;
905  };
906 
907  transform_copy_if( std::begin( m_files ), std::end( m_files ), std::back_inserter( files ), select2nd,
908  matches_tech_and_flags );
909  if ( !op ) {
910  std::copy_if( std::begin( m_oldFiles ), std::end( m_oldFiles ), std::back_inserter( files ),
911  matches_tech_and_flags );
912  }
913 
914  return files.size();
915 }
916 
917 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
918 
919 // get all descriptors known
920 // return number found
921 
922 int FileMgr::getFd( vector<Fd>& fd ) const
923 {
924 
925  std::transform( std::begin( m_descriptors ), std::end( m_descriptors ), std::back_inserter( fd ), select1st );
926  return m_descriptors.size();
927 }
928 
929 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
930 
931 // get all descriptors given tech
932 // return number found
933 
934 int FileMgr::getFd( const IoTech& tech, vector<Fd>& fd ) const
935 {
936 
937  if ( tech == UNKNOWN ) return getFd( fd );
938 
939  fd.clear();
940  transform_if( std::begin( m_descriptors ), std::end( m_descriptors ), std::back_inserter( fd ), select1st,
941  [&]( const std::pair<Fd, FileAttr*>& d ) { return d.second->tech() == tech; } );
942 
943  return fd.size();
944 }
945 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
946 
947 // get all descriptors of given tech and flags
948 // return number found
949 
950 int FileMgr::getFd( const IoTech& tech, const IoFlags& flags, vector<Fd>& fd ) const
951 {
952 
953  fd.clear();
954  transform_if( m_descriptors.begin(), m_descriptors.end(), std::back_inserter( fd ), select1st,
955  [&]( const std::pair<Fd, FileAttr*>& d ) {
956  return ( d.second->tech() == tech || tech == UNKNOWN ) && ( d.second->flags() == flags );
957  } );
958  return fd.size();
959 }
960 
961 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
962 
963 const std::string& FileMgr::fname( const Io::Fd& fd ) const
964 {
965 
966  auto itr = std::find_if( std::begin( m_files ), std::end( m_files ),
967  [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
968  return ( itr != std::end( m_files ) ) ? itr->second->name() : s_empty;
969 }
970 
971 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
972 
973 const std::string& FileMgr::fname( void* vp ) const
974 {
975 
976  auto itr = std::find_if( m_files.begin(), m_files.end(),
977  [&]( fileMap::const_reference f ) { return f.second->fptr() == vp; } );
978  return itr != m_files.end() ? itr->second->name() : s_empty;
979 }
980 
981 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
982 
983 Io::Fd FileMgr::fd( const std::string& fname ) const
984 {
985 
986  auto fitr = m_files.equal_range( fname );
987  auto itr = std::find_if( fitr.first, fitr.second, []( fileMap::const_reference f ) { return f.second->fd() != -1; } );
988  return itr != fitr.second ? itr->second->fd() : -1;
989 }
990 
991 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
992 
993 Io::Fd FileMgr::fd( void* fptr ) const
994 {
995 
996  auto itr = std::find_if( m_files.begin(), m_files.end(),
997  [&]( fileMap::const_reference f ) { return f.second->fptr() == fptr; } );
998  return itr != m_files.end() ? itr->second->fd() : -1;
999 }
1000 
1001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1002 
1003 void* FileMgr::fptr( const std::string& fname ) const
1004 {
1005  auto fitr = m_files.equal_range( fname );
1006  auto itr =
1007  std::find_if( fitr.first, fitr.second, []( fileMap::const_reference f ) -> bool { return f.second->fptr(); } );
1008  return itr != fitr.second ? itr->second->fptr() : nullptr;
1009 }
1010 
1011 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1012 
1013 void* FileMgr::fptr( const Io::Fd& fd ) const
1014 {
1015 
1016  auto itr = std::find_if( m_files.begin(), m_files.end(),
1017  [&]( fileMap::const_reference f ) { return f.second->fd() == fd; } );
1018  return itr != m_files.end() ? itr->second->fptr() : nullptr;
1019 }
1020 
1021 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1022 
1024 {
1025 
1026  info() << "listing registered files [" << ( m_files.size() + m_oldFiles.size() ) << "]:\n";
1027 
1028  for ( auto& itr : m_files ) info() << itr.second << '\n';
1029  for ( auto& it2 : m_oldFiles ) info() << *it2 << '\n';
1030 
1031  info() << endmsg;
1032 }
1033 
1034 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1035 
1037 {
1038 
1039  err = m_lastErrS;
1040  return m_lastErr;
1041 }
1042 
1043 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1044 
1045 StatusCode FileMgr::getHandler( const Io::IoTech& tech, Io::FileHdlr& hdlr ) const
1046 {
1047 
1048  auto itr = m_handlers.find( tech );
1049  if ( itr == m_handlers.end() ) {
1050  error() << "no handler for tech " << tech << " registered" << endmsg;
1051  return StatusCode::FAILURE;
1052  }
1053  hdlr = itr->second;
1054  return StatusCode::SUCCESS;
1055 }
1056 
1057 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1058 
1060 {
1061 
1062  auto fitr = m_files.equal_range( fname );
1063  if ( fitr.first == fitr.second ) {
1064  error() << "no file \"" << fname << "\" registered. Cannot determine tech" << endmsg;
1065  return StatusCode::FAILURE;
1066  }
1067 
1068  auto itr = fitr.first;
1069  IoTech tech = itr->second->tech();
1070 
1071  ++itr;
1072  while ( itr != fitr.second ) {
1073  if ( itr->second->tech() != tech ) {
1074  error() << "multiple technologies registered for file \"" << fname << "\". Cannot determine handler" << endmsg;
1075  return StatusCode::FAILURE;
1076  }
1077  ++itr;
1078  }
1079 
1080  return getHandler( tech, hdlr );
1081 }
1082 
1083 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1084 
1086 {
1087 
1088  info() << "Listing registered handlers:\n";
1089 
1090  for ( const auto& itr : m_handlers ) info() << " " << itr.first << '\n';
1091  info() << endmsg;
1092 }
1093 
1094 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1095 
1097 {
1098 
1099  return regAction( bf, a, Io::UNKNOWN, d );
1100 }
1101 
1102 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1103 
1105 {
1106 
1107  ON_DEBUG
1108  debug() << "registering " << a << " action " << System::typeinfoName( bf.target_type() ) << " for tech " << t
1109  << endmsg;
1110 
1111  m_actions[t][a].emplace_back( bf, ( !d.empty() ) ? d : System::typeinfoName( bf.target_type() ) );
1112  return StatusCode::SUCCESS;
1113 }
1114 
1115 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1116 
1118 {
1119 
1120  info() << "listing registered actions\n";
1121 
1122  for ( const auto& iit : m_actions ) {
1123  Io::IoTech t = iit.first;
1124  const actionMap& m = iit.second;
1125 
1126  if ( !m.empty() ) {
1127  info() << " --- Tech: ";
1128  if ( t == Io::UNKNOWN ) {
1129  info() << "ALL ---\n";
1130  } else {
1131  info() << t << " ---\n";
1132  }
1133  for ( const auto& iia : m ) {
1134  for ( const auto& it2 : iia.second ) {
1135  info() << " " << iia.first << " " << it2.second << '\n';
1136  }
1137  }
1138  }
1139  }
1140  info() << endmsg;
1141 }
1142 
1143 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1144 
1146 {
1147 
1148  Io::IoTech tech = fa->tech();
1149 
1150  StatusCode s1, s2;
1151 
1152  auto itr = m_actions.find( Io::UNKNOWN );
1153 
1154  if ( itr != m_actions.end() && !itr->second.empty() ) {
1155  s1 = execActs( fa, caller, a, itr->second );
1156  }
1157 
1158  itr = m_actions.find( tech );
1159  if ( itr != m_actions.end() && !itr->second.empty() ) {
1160  s2 = execActs( fa, caller, a, itr->second );
1161  }
1162 
1163  return ( s1.isFailure() || s2.isFailure() ) ? StatusCode::FAILURE : StatusCode::SUCCESS;
1164 }
1165 
1166 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1167 
1169  const actionMap& m ) const
1170 {
1171 
1172  auto mitr = m.find( a );
1173  if ( mitr == m.end() || mitr->second.empty() ) return StatusCode::SUCCESS;
1174 
1175  ON_DEBUG
1176  debug() << "executing " << mitr->second.size() << " " << a << " actions on " << *fa << " from " << caller << endmsg;
1177 
1178  bool fail( false );
1179 
1180  auto it2 = m_supMap.find( fa->name() );
1181  if ( it2 != m_supMap.end() ) {
1182  if ( it2->second[a] || it2->second[Io::INVALID_ACTION] ) {
1183  ON_DEBUG
1184  debug() << " --> suppressing callback action for " << a << endmsg;
1185  return StatusCode::SUCCESS;
1186  }
1187  }
1188 
1189  for ( const auto& itr : mitr->second ) {
1190 
1191  ON_DEBUG
1192  debug() << "executing " << itr.second << endmsg;
1193 
1194  if ( ( ( ( itr.first ) )( fa, caller ) ).isFailure() ) {
1195  warning() << "execution of " << itr.second << " on " << *fa << " failed during " << a << " action" << endmsg;
1196  fail = true;
1197  }
1198  }
1199 
1200  return fail ? StatusCode::FAILURE : StatusCode::SUCCESS;
1201 }
1202 
1203 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1204 
1205 bool FileMgr::accessMatch( const Io::IoFlags& fold, const Io::IoFlags& fnew, bool /*strict*/ ) const
1206 {
1207  ON_VERBOSE
1208  verbose() << "accessMatch old: " << fold << " new: " << fnew << endmsg;
1209 
1210  return ( ( ( fold == Io::READ ) && ( fnew == Io::READ ) ) ||
1211  ( ( fold & Io::WRITE ) != 0 && ( fnew & Io::WRITE ) != 0 ) ||
1212  ( ( fold & Io::RDWR ) != 0 && ( fnew & Io::RDWR ) != 0 ) );
1213 }
1214 
1215 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1216 
1217 void FileMgr::suppressAction( const std::string& f ) { return suppressAction( f, Io::INVALID_ACTION ); }
1218 
1219 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1220 
1221 void FileMgr::suppressAction( const std::string& f, const Io::Action& a ) { m_supMap[f].set( a ); }
1222 
1223 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1224 
1226 {
1227  if ( m_supMap.empty() ) return;
1228 
1229  info() << "listing suppressed file actions\n";
1230 
1231  for ( const auto& sup : m_supMap ) {
1232  info() << " " << sup.first;
1233  if ( sup.second[Io::INVALID_ACTION] ) {
1234  info() << " ALL\n";
1235  } else {
1236  for ( unsigned i = 0; i != sup.second.size(); ++i ) {
1237  if ( sup.second[i] ) info() << " " << (Io::Action)i;
1238  }
1239  info() << '\n';
1240  }
1241  }
1242  info() << endmsg;
1243 }
StatusCode regHandler(FileHdlr) override
Definition: FileMgr.cpp:185
IoTech
Definition: IFileMgr.h:158
constexpr static const auto FAILURE
Definition: StatusCode.h:88
void listHandlers() const override
Definition: FileMgr.cpp:1085
StatusCode initialize() override
Definition: Service.cpp:63
int getFileAttr(const std::string &, std::vector< const FileAttr * > &) const override
Definition: FileMgr.cpp:741
void listFiles() const override
Definition: FileMgr.cpp:1023
T empty(T...args)
Definition: IFileMgr.h:20
T copy_if(T...args)
T open(T...args)
StatusCode finalize() override
Definition: Service.cpp:173
StatusCode hasHandler(const IoTech &) const override
Definition: FileMgr.cpp:235
int reopen_t
Definition: IFileMgr.h:252
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:332
int Fd
Definition: IFileMgr.h:172
Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &fd, void *&ptr, const std::string &desc="", const bool shared=false) override
Definition: FileMgr.cpp:244
bfcn_reopen_t b_reopen_fcn
Definition: IFileMgr.h:267
void suppressAction(const std::string &) override
Definition: FileMgr.cpp:1217
bool isSuccess() const
Definition: StatusCode.h:287
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition: FileMgr.cpp:801
void * fptr() const
Definition: IFileMgr.h:195
int open_t
Definition: IFileMgr.h:250
STL namespace.
bool isOpen() const
Definition: IFileMgr.h:196
StatusCode deregHandler(const IoTech &) override
Definition: FileMgr.cpp:220
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition: FileMgr.cpp:1145
T end(T...args)
Fd fd() const
Definition: IFileMgr.h:189
STL class.
bool isFailure() const
Definition: StatusCode.h:139
bool accessMatch(const Io::IoFlags &, const Io::IoFlags &, bool strict=false) const
Definition: FileMgr.cpp:1205
virtual void listActions() const
Definition: FileMgr.cpp:1117
STL class.
Io::Fd fd(const std::string &) const override
Definition: FileMgr.cpp:983
#define DECLARE_COMPONENT(type)
Action
Definition: IFileMgr.h:285
const std::string & name() const
Definition: IFileMgr.h:190
STL class.
bool isShared() const
Definition: IFileMgr.h:197
void handle(const Incident &) override
Definition: FileMgr.cpp:181
StatusCode getHandler(const IoTech &, FileHdlr &) const override
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr double m
Definition: SystemOfUnits.h:94
bfcn_close_t b_close_fcn
Definition: IFileMgr.h:265
T close(T...args)
Io::reopen_t reopen(const Fd, const IoFlags &, const std::string &caller) override
StatusCode execActs(Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
Definition: FileMgr.cpp:1168
bfcn_closeP_t b_closeP_fcn
Definition: IFileMgr.h:266
Io::close_t close(const Fd, const std::string &caller) override
bfcn_reopenP_t b_reopenP_fcn
Definition: IFileMgr.h:268
T clear(T...args)
T move(T...args)
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition: FileMgr.cpp:1096
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
T count_if(T...args)
T target_type(T...args)
T insert(T...args)
T find_if(T...args)
T size(T...args)
bfcn_open_t b_open_fcn
Definition: IFileMgr.h:264
STL class.
STL class.
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
virtual void listSuppression() const
Definition: FileMgr.cpp:1225
IoTech tech() const
Definition: IFileMgr.h:192
T begin(T...args)
bool match(const IoFlags &fa, bool strict=true) const
Definition: IFileMgr.h:62
T back_inserter(T...args)
T none_of(T...args)
Base class for all Incidents (computing events).
Definition: Incident.h:17
const std::string & fname(const Io::Fd &) const override
Definition: FileMgr.cpp:963
T transform(T...args)
#define ON_DEBUG
Definition: FileMgr.cpp:8
int getFd(std::vector< Fd > &) const override
~FileMgr() override
Definition: FileMgr.cpp:57
IoFlags flags() const
Definition: IFileMgr.h:193
StatusCode finalize() override
Definition: FileMgr.cpp:123
#define ON_VERBOSE
Definition: FileMgr.cpp:9
IoTech tech
Definition: IFileMgr.h:262
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
int close_t
Definition: IFileMgr.h:251
StatusCode initialize() override
Definition: FileMgr.cpp:66
int getLastError(std::string &) const override
Definition: FileMgr.cpp:1036
void * fptr(const std::string &) const override
Definition: FileMgr.cpp:1003