The Gaudi Framework  master (37c0b60a)
IoComponentMgr.h
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 \***********************************************************************************/
12 // IoComponentMgr.h
13 // Header file for class IoComponentMgr
14 // Author: S.Binet<binet@cern.ch>
16 #ifndef GAUDIMP_IOCOMPONENTMGR_H
17 #define GAUDIMP_IOCOMPONENTMGR_H 1
18 
19 // Python includes
20 #include <Python.h>
21 
22 // STL includes
23 #include <list>
24 #include <map>
25 #include <string>
26 #include <vector>
27 
28 // FrameWork includes
29 #include <GaudiKernel/Service.h>
30 
31 // GaudiKernel
35 
36 // Forward declaration
37 class ISvcLocator;
38 
39 class IoComponentMgr : public extends<Service, IIoComponentMgr, IIncidentListener> {
41  // Public methods:
43 public:
45  using extends::extends;
46 
48 
49  StatusCode initialize() override;
50  StatusCode finalize() override;
52 
53  void handle( const Incident& ) override;
54 
56  // Const methods:
58 
61  bool io_hasitem( IIoComponent* iocomponent ) const override;
62 
66  bool io_contains( IIoComponent* iocomponent, const std::string& fname ) const override;
67 
69  // Non-const methods:
71 
78  StatusCode io_register( IIoComponent* iocomponent ) override;
79 
87  const std::string& pfn ) override;
88 
92  StatusCode io_update( IIoComponent* iocomponent, const std::string& old_fname,
93  const std::string& new_fname ) override;
94 
98  StatusCode io_update( IIoComponent* iocomponent, const std::string& work_dir ) override;
99 
102  StatusCode io_update_all( const std::string& work_dir ) override;
103 
106  std::vector<std::string> io_retrieve( IIoComponent* iocomponent ) override;
107 
111  StatusCode io_retrieve( IIoComponent* iocomponent, std::string& fname ) override;
112 
117  StatusCode io_reinitialize() override;
118 
123  StatusCode io_finalize() override;
124 
126  // Private data:
128 private:
134 
136  : m_oldfname( "" ), m_oldabspath( "" ), m_newfname( "" ), m_iomode( IIoComponentMgr::IoMode::INVALID ) {}
138  : m_oldfname( f ), m_oldabspath( p ), m_newfname( "" ), m_iomode( t ) {}
140  : m_oldfname( rhs.m_oldfname )
141  , m_oldabspath( rhs.m_oldabspath )
142  , m_newfname( rhs.m_newfname )
143  , m_iomode( rhs.m_iomode ) {}
144  bool operator<( IoComponentEntry const& rhs ) const {
145  if ( m_oldfname == rhs.m_oldfname ) {
146  return ( m_iomode < rhs.m_iomode );
147  } else {
148  return ( m_oldfname < rhs.m_oldfname );
149  }
150  }
151 
153  os << "old: \"" << c.m_oldfname << "\" absolute path: \"" << c.m_oldabspath << "\" new: \"" << c.m_newfname
154  << "\" m: " << ( ( c.m_iomode == IIoComponentMgr::IoMode::READ ) ? "R" : "W" );
155  return os;
156  }
157  };
158 
160  IoComponentMgr() = delete;
161 
165 
169 
170  // This is the registry
172  typedef IoDict_t::const_iterator iodITR;
173 
175 
178 
181  "DirectIOPatterns",
182  {
183  "://",
184  },
185  "Search patterns for direct I/O input names" };
186 
187  bool findComp( IIoComponent*, const std::string&, iodITR& ) const;
189  bool findComp( const std::string&, std::pair<iodITR, iodITR>& ) const;
190 
191  std::string list() const;
192 };
193 
194 #endif //> !GAUDIMP_IOCOMPONENTMGR_H
IIoComponentMgr::IoMode::READ
@ READ
Definition: IIoComponentMgr.h:41
IoComponentMgr::findComp
bool findComp(IIoComponent *, const std::string &, iodITR &) const
Definition: IoComponentMgr.cpp:402
IIoComponent.h
std::string
STL class.
IoComponentMgr::io_retrieve
std::vector< std::string > io_retrieve(IIoComponent *iocomponent) override
: retrieve all registered filenames for a given IIoComponent
Definition: IoComponentMgr.cpp:219
Io::INVALID
@ INVALID
Definition: IFileMgr.h:47
IoComponentMgr::iodITR
IoDict_t::const_iterator iodITR
Definition: IoComponentMgr.h:172
IIoComponent
Definition: IIoComponent.h:26
std::list< IIoComponent * >
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:174
std::pair
IoComponentMgr::finalize
StatusCode finalize() override
Definition: IoComponentMgr.cpp:86
std::vector< std::string >
ISvcLocator
Definition: ISvcLocator.h:46
IoComponentMgr::handle
void handle(const Incident &) override
Definition: IoComponentMgr.cpp:445
IoComponentMgr::IoComponentEntry::operator<
bool operator<(IoComponentEntry const &rhs) const
Definition: IoComponentMgr.h:144
IoComponentMgr::IoComponentMgr
IoComponentMgr()=delete
Default constructor:
IoComponentMgr::io_hasitem
bool io_hasitem(IIoComponent *iocomponent) const override
: check if the registry contains a given IIoComponent
Definition: IoComponentMgr.cpp:98
gaudirun.c
c
Definition: gaudirun.py:525
IIoComponentMgr::IoMode::Type
Type
Definition: IIoComponentMgr.h:41
IoComponentMgr::initialize
StatusCode initialize() override
Gaudi Service Implementation.
Definition: IoComponentMgr.cpp:63
bug_34121.t
t
Definition: bug_34121.py:31
IoComponentMgr::IoRegistry_t
std::map< std::string, IIoComponent * > IoRegistry_t
Definition: IoComponentMgr.h:162
IoComponentMgr::io_register
StatusCode io_register(IIoComponent *iocomponent) override
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
Definition: IoComponentMgr.cpp:146
IoComponentMgr::m_ioregistry
IoRegistry_t m_ioregistry
Registry of IIoComponents.
Definition: IoComponentMgr.h:164
StatusCode
Definition: StatusCode.h:65
std::ostream
STL class.
IoComponentMgr::IoStack_t
std::list< IIoComponent * > IoStack_t
Definition: IoComponentMgr.h:166
IoComponentMgr::IoDict_t
std::multimap< IIoComponent *, IoComponentEntry > IoDict_t
Definition: IoComponentMgr.h:171
IoComponentMgr::IoComponentEntry::IoComponentEntry
IoComponentEntry(const IoComponentEntry &rhs)
Definition: IoComponentMgr.h:139
IoComponentMgr::io_update
StatusCode io_update(IIoComponent *iocomponent, const std::string &old_fname, const std::string &new_fname) override
: allow a IIoComponent to update the contents of the registry with a new file name
Definition: IoComponentMgr.cpp:295
IoComponentMgr
Definition: IoComponentMgr.h:39
IoComponentMgr::IoComponentEntry::IoComponentEntry
IoComponentEntry(const std::string &f, const std::string &p, const IIoComponentMgr::IoMode::Type &t)
Definition: IoComponentMgr.h:137
IoComponentMgr::IoComponentEntry::m_newfname
std::string m_newfname
Definition: IoComponentMgr.h:132
std::map< std::string, IIoComponent * >
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
IoComponentMgr::list
std::string list() const
Definition: IoComponentMgr.cpp:433
IIoComponentMgr.h
IoComponentMgr::IoComponentEntry::m_iomode
IIoComponentMgr::IoMode::Type m_iomode
Definition: IoComponentMgr.h:133
Service.h
IoComponentMgr::IoComponentEntry::m_oldabspath
std::string m_oldabspath
Definition: IoComponentMgr.h:131
IoComponentMgr::io_update_all
StatusCode io_update_all(const std::string &work_dir) override
: Update all IIoComponents with a new work directory
Definition: IoComponentMgr.cpp:361
IoComponentMgr::m_iostack
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
Definition: IoComponentMgr.h:168
IoComponentMgr::IoComponentEntry::IoComponentEntry
IoComponentEntry()
Definition: IoComponentMgr.h:135
IIncidentListener.h
IoComponentMgr::m_dict_location
std::string m_dict_location
location of the python dictionary
Definition: IoComponentMgr.h:177
IoComponentMgr::IoComponentEntry::m_oldfname
std::string m_oldfname
Definition: IoComponentMgr.h:130
IoComponentMgr::io_finalize
StatusCode io_finalize() override
: finalize the I/O subsystem.
Definition: IoComponentMgr.cpp:379
std::multimap< IIoComponent *, IoComponentEntry >
IIoComponentMgr
Definition: IIoComponentMgr.h:32
IoComponentMgr::IoComponentEntry
Definition: IoComponentMgr.h:129
IoComponentMgr::IoComponentEntry::operator<<
friend std::ostream & operator<<(std::ostream &os, const IoComponentEntry &c)
Definition: IoComponentMgr.h:152
Incident
Definition: Incident.h:27
IoComponentMgr::io_contains
bool io_contains(IIoComponent *iocomponent, const std::string &fname) const override
: check if the registry contains a given IIoComponent and that component had
Definition: IoComponentMgr.cpp:111
IoComponentMgr::m_directio_patterns
Gaudi::Property< std::vector< std::string > > m_directio_patterns
search patterns for special file names (direct I/O protocols)
Definition: IoComponentMgr.h:180
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:37
IoComponentMgr::io_reinitialize
StatusCode io_reinitialize() override
: reinitialize the I/O subsystem.
Definition: IoComponentMgr.cpp:273