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