The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
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
23using namespace std;
24using namespace Io;
25
26/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28namespace {
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
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(
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
127 verbose() << "FileMgr::finalize()" << endmsg;
128
129 if ( m_printSummary || msgLevel( MSG::DEBUG ) ) {
130 listHandlers();
131 listFiles();
132 listActions();
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 {
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
175 if ( status.isSuccess() ) debug() << "Service finalised successfully" << endmsg;
176
177 return status;
178}
179
180/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
181
182void 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
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
235
236 auto itr = m_handlers.find( tech );
237 return ( itr != m_handlers.end() ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
238}
239
240/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
241
242open_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/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
249open_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/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
257open_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
266open_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
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
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
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
402close_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
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
441 verbose() << " ref count: " << i << endmsg;
442
443 if ( i > 1 && fa->isShared() ) {
444 // file open multiple times. don't do the actual close
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() ) ) {
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
501close_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
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
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
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() ) ) {
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
600reopen_t FileMgr::reopen( Fd fd, const IoFlags& flags, const std::string& caller ) {
601
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
665reopen_t FileMgr::reopen( void* vp, const IoFlags& flags, const std::string& caller ) {
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
723int FileMgr::getFileAttr( const std::string& fname, vector<const FileAttr*>& fa ) const {
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
738StatusCode 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
759StatusCode 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
780int 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
796int 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
806int 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
830int 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
847int 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
870int 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
893int 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
904int 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
919int 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
931const 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
940const 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
949Io::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
958Io::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
967void* 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
976void* 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
985void 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
997int FileMgr::getLastError( std::string& err ) const {
998
999 err = m_lastErrS;
1000 return m_lastErr;
1001}
1002
1003/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1004
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
1018StatusCode FileMgr::getHandler( const std::string& fname, Io::FileHdlr& hdlr ) const {
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
1053StatusCode FileMgr::regAction( bfcn_action_t bf, const Io::Action& a, const std::string& d ) {
1054
1055 return regAction( bf, a, Io::UNKNOWN, d );
1056}
1057
1058/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1059
1060StatusCode FileMgr::regAction( bfcn_action_t bf, const Io::Action& a, const Io::IoTech& t, const std::string& d ) {
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
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
1097StatusCode 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
1115StatusCode FileMgr::execActs( Io::FileAttr* fa, const std::string& caller, const Io::Action& a,
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
1147}
1148
1149/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1150
1151bool FileMgr::accessMatch( const Io::IoFlags& fold, const Io::IoFlags& fnew, bool /*strict*/ ) const {
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
1162void FileMgr::suppressAction( const std::string& f ) { return suppressAction( f, Io::INVALID_ACTION ); }
1163
1164/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1165
1166void 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}
#define ON_VERBOSE
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define ON_DEBUG
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::vector< std::unique_ptr< FileAttr > > m_attr
Definition FileMgr.h:147
Io::reopen_t reopen(const Fd, const IoFlags &, const std::string &caller) override
Definition FileMgr.cpp:600
Gaudi::Property< std::string > m_logfile
Definition FileMgr.h:122
void suppressAction(const std::string &) override
Definition FileMgr.cpp:1162
Gaudi::Property< bool > m_printSummary
Definition FileMgr.h:123
StatusCode initialize() override
Definition FileMgr.cpp:71
StatusCode deregHandler(const IoTech &) override
Definition FileMgr.cpp:220
std::vector< FileAttr * > m_oldFiles
Definition FileMgr.h:149
StatusCode execAction(Io::FileAttr *, const std::string &, const Io::Action &) const
Definition FileMgr.cpp:1097
fileMap m_files
Definition FileMgr.h:144
Gaudi::Property< std::string > m_ssl_cert
Definition FileMgr.h:128
virtual void listActions() const
Definition FileMgr.cpp:1072
std::optional< RootFileHandler > m_rfh
Definition FileMgr.h:158
StatusCode regHandler(FileHdlr) override
Definition FileMgr.cpp:186
StatusCode execActs(Io::FileAttr *, const std::string &, const Io::Action &, const actionMap &m) const
Definition FileMgr.cpp:1115
std::map< IoTech, actionMap > m_actions
Definition FileMgr.h:151
Gaudi::Property< bool > m_loadPosixHandler
Definition FileMgr.h:125
void listHandlers() const override
Definition FileMgr.cpp:1043
~FileMgr() override
Definition FileMgr.cpp:63
virtual void listSuppression() const
Definition FileMgr.cpp:1170
StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &desc="") override
Definition FileMgr.cpp:1053
std::map< Io::Action, std::list< bfcn_desc_t > > actionMap
Definition FileMgr.h:135
std::string m_lastErrS
Definition FileMgr.h:155
std::map< Fd, FileAttr * > m_descriptors
Definition FileMgr.h:146
bool accessMatch(const Io::IoFlags &, const Io::IoFlags &, bool strict=false) const
Definition FileMgr.cpp:1151
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
Gaudi::Property< std::string > m_ssl_proxy
Definition FileMgr.h:127
Gaudi::Property< bool > m_loadRootHandler
Definition FileMgr.h:124
Io::Fd fd(const std::string &) const override
Definition FileMgr.cpp:949
int getFd(std::vector< Fd > &) const override
Definition FileMgr.cpp:893
Io::close_t close(const Fd, const std::string &caller) override
Definition FileMgr.cpp:402
const std::string & fname(const Io::Fd &) const override
Definition FileMgr.cpp:931
void handle(const Incident &) override
Definition FileMgr.cpp:182
std::map< IoTech, FileHdlr > m_handlers
Definition FileMgr.h:145
int m_lastErr
Definition FileMgr.h:156
StatusCode hasHandler(const IoTech &) const override
Definition FileMgr.cpp:234
std::optional< POSIXFileHandler > m_pfh
Definition FileMgr.h:159
void * fptr(const std::string &) const override
Definition FileMgr.cpp:967
void listFiles() const override
Definition FileMgr.cpp:985
std::map< std::string, Io::Action_bitmap > m_supMap
Definition FileMgr.h:153
int getFileAttr(const std::string &, std::vector< const FileAttr * > &) const override
Definition FileMgr.cpp:723
int getFiles(std::vector< std::string > &, bool onlyOpen=true) const override
Definition FileMgr.cpp:780
int getLastError(std::string &) const override
Definition FileMgr.cpp:997
StatusCode finalize() override
Definition FileMgr.cpp:125
StatusCode getHandler(const IoTech &, FileHdlr &) const override
Definition FileMgr.cpp:1005
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.
Base class for all Incidents (computing events).
Definition Incident.h:24
IoTech tech() const
Definition IFileMgr.h:177
void * fptr() const
Definition IFileMgr.h:180
bool isOpen() const
Definition IFileMgr.h:181
IoFlags flags() const
Definition IFileMgr.h:178
Fd fd() const
Definition IFileMgr.h:174
bool isShared() const
Definition IFileMgr.h:182
const std::string & name() const
Definition IFileMgr.h:175
bool match(const IoFlags &fa, bool strict=true) const
Definition IFileMgr.h:63
StatusCode finalize() override
Definition Service.cpp:223
Gaudi::Property< int > m_outputLevel
flag indicating whether ToolHandle tools have been added to m_tools
Definition Service.h:184
StatusCode initialize() override
Definition Service.cpp:118
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isFailure() const
Definition StatusCode.h:129
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
Definition IFileMgr.h:23
Action
Definition IFileMgr.h:263
@ OPEN
Definition IFileMgr.h:263
@ CLOSE
Definition IFileMgr.h:263
@ REOPEN
Definition IFileMgr.h:263
@ OPEN_ERR
Definition IFileMgr.h:263
@ CLOSE_ERR
Definition IFileMgr.h:263
@ INVALID_ACTION
Definition IFileMgr.h:263
@ REOPEN_ERR
Definition IFileMgr.h:263
std::function< StatusCode(FILEMGR_CALLBACK_ARGS)> bfcn_action_t
Definition IFileMgr.h:273
int reopen_t
Definition IFileMgr.h:232
IoTech
Definition IFileMgr.h:147
@ ROOT
Definition IFileMgr.h:147
@ UNKNOWN
Definition IFileMgr.h:147
@ POSIX
Definition IFileMgr.h:147
@ READ
Definition IFileMgr.h:30
@ INVALID
Definition IFileMgr.h:40
@ RDWR
Definition IFileMgr.h:32
@ WRITE
Definition IFileMgr.h:31
int Fd
Definition IFileMgr.h:158
int close_t
Definition IFileMgr.h:231
int open_t
Definition IFileMgr.h:230
@ DEBUG
Definition IMessageSvc.h:22
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260
STL namespace.
bfcn_reopen_t b_reopen_fcn
Definition IFileMgr.h:247
bfcn_closeP_t b_closeP_fcn
Definition IFileMgr.h:246
bfcn_close_t b_close_fcn
Definition IFileMgr.h:245
bfcn_open_t b_open_fcn
Definition IFileMgr.h:244
bfcn_reopenP_t b_reopenP_fcn
Definition IFileMgr.h:248
IoTech tech
Definition IFileMgr.h:242