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