| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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