The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IoComponentMgr.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
17 
18 // Python includes
19 #include <Python.h>
20 
21 // STL includes
22 #include <list>
23 #include <map>
24 #include <string>
25 #include <vector>
26 
27 // FrameWork includes
28 #include <GaudiKernel/Service.h>
29 
30 // GaudiKernel
34 
35 // Forward declaration
36 class ISvcLocator;
37 
38 class IoComponentMgr : public extends<Service, IIoComponentMgr, IIncidentListener> {
40  // Public methods:
42 public:
44  using extends::extends;
45 
47 
48  StatusCode initialize() override;
49  StatusCode finalize() override;
51 
52  void handle( const Incident& ) override;
53 
55  // Const methods:
57 
60  bool io_hasitem( IIoComponent* iocomponent ) const override;
61 
65  bool io_contains( IIoComponent* iocomponent, const std::string& fname ) const override;
66 
68  // Non-const methods:
70 
77  StatusCode io_register( IIoComponent* iocomponent ) override;
78 
85  StatusCode io_register( IIoComponent* iocomponent, IIoComponentMgr::IoMode::Type iomode, const std::string& fname,
86  const std::string& pfn ) override;
87 
91  StatusCode io_update( IIoComponent* iocomponent, const std::string& old_fname,
92  const std::string& new_fname ) override;
93 
97  StatusCode io_update( IIoComponent* iocomponent, const std::string& work_dir ) override;
98 
101  StatusCode io_update_all( const std::string& work_dir ) override;
102 
105  std::vector<std::string> io_retrieve( IIoComponent* iocomponent ) override;
106 
110  StatusCode io_retrieve( IIoComponent* iocomponent, std::string& fname ) override;
111 
116  StatusCode io_reinitialize() override;
117 
122  StatusCode io_finalize() override;
123 
125  // Private data:
127 private:
128  struct IoComponentEntry final {
129  std::string m_oldfname;
130  std::string m_oldabspath;
131  std::string m_newfname;
133 
134  IoComponentEntry() = default;
135  IoComponentEntry( const std::string& f, const std::string& p, const IIoComponentMgr::IoMode::Type& t )
136  : m_oldfname( f ), m_oldabspath( p ), m_iomode( t ) {}
137 
138  friend bool operator<( const IoComponentEntry& lhs, const IoComponentEntry& rhs ) {
139  return std::tie( lhs.m_oldfname, lhs.m_iomode ) < std::tie( rhs.m_oldfname, rhs.m_iomode );
140  }
141 
142  friend std::ostream& operator<<( std::ostream& os, const IoComponentEntry& c ) {
143  return os << "old: \"" << c.m_oldfname << "\" absolute path: \"" << c.m_oldabspath << "\" new: \""
144  << c.m_newfname << "\" m: " << ( ( c.m_iomode == IIoComponentMgr::IoMode::READ ) ? "R" : "W" );
145  }
146  };
147 
149  IoComponentMgr() = delete;
150 
151  typedef std::map<std::string, IIoComponent*> IoRegistry_t;
154 
155  typedef std::list<IIoComponent*> IoStack_t;
158 
159  // This is the registry
160  typedef std::multimap<IIoComponent*, IoComponentEntry> IoDict_t;
161  typedef IoDict_t::const_iterator iodITR;
162 
164 
166  std::string m_dict_location;
167 
170  "DirectIOPatterns",
171  {
172  "://",
173  },
174  "Search patterns for direct I/O input names" };
175 
176  bool findComp( IIoComponent*, const std::string&, iodITR& ) const;
177  bool findComp( IIoComponent*, std::pair<iodITR, iodITR>& ) const;
178  bool findComp( const std::string&, std::pair<iodITR, iodITR>& ) const;
179 
180  std::string list() const;
181 };
IIoComponentMgr::IoMode::READ
@ READ
Definition: IIoComponentMgr.h:29
IoComponentMgr::findComp
bool findComp(IIoComponent *, const std::string &, iodITR &) const
Definition: IoComponentMgr.cpp:402
IIoComponent.h
IoComponentMgr::io_retrieve
std::vector< std::string > io_retrieve(IIoComponent *iocomponent) override
: retrieve all registered filenames for a given IIoComponent
Definition: IoComponentMgr.cpp:219
IoComponentMgr::iodITR
IoDict_t::const_iterator iodITR
Definition: IoComponentMgr.h:161
IIoComponent
Definition: IIoComponent.h:15
IoComponentMgr::m_cdict
IoDict_t m_cdict
Definition: IoComponentMgr.h:163
IoComponentMgr::finalize
StatusCode finalize() override
Definition: IoComponentMgr.cpp:86
ISvcLocator
Definition: ISvcLocator.h:42
IoComponentMgr::handle
void handle(const Incident &) override
Definition: IoComponentMgr.cpp:445
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:29
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:151
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:153
IIoComponentMgr::IoMode::INVALID
@ INVALID
Definition: IIoComponentMgr.h:29
StatusCode
Definition: StatusCode.h:64
IoComponentMgr::IoStack_t
std::list< IIoComponent * > IoStack_t
Definition: IoComponentMgr.h:155
IoComponentMgr::IoDict_t
std::multimap< IIoComponent *, IoComponentEntry > IoDict_t
Definition: IoComponentMgr.h:160
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:38
IoComponentMgr::IoComponentEntry::IoComponentEntry
IoComponentEntry(const std::string &f, const std::string &p, const IIoComponentMgr::IoMode::Type &t)
Definition: IoComponentMgr.h:135
IoComponentMgr::IoComponentEntry::m_newfname
std::string m_newfname
Definition: IoComponentMgr.h:131
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:19
IoComponentMgr::list
std::string list() const
Definition: IoComponentMgr.cpp:433
IIoComponentMgr.h
IoComponentMgr::IoComponentEntry::m_iomode
IIoComponentMgr::IoMode::Type m_iomode
Definition: IoComponentMgr.h:132
Service.h
IoComponentMgr::IoComponentEntry::m_oldabspath
std::string m_oldabspath
Definition: IoComponentMgr.h:130
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::IoComponentEntry::IoComponentEntry
IoComponentEntry()=default
IoComponentMgr::m_iostack
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
Definition: IoComponentMgr.h:157
IIncidentListener.h
IoComponentMgr::m_dict_location
std::string m_dict_location
location of the python dictionary
Definition: IoComponentMgr.h:166
IoComponentMgr::IoComponentEntry::m_oldfname
std::string m_oldfname
Definition: IoComponentMgr.h:129
IoComponentMgr::io_finalize
StatusCode io_finalize() override
: finalize the I/O subsystem.
Definition: IoComponentMgr.cpp:379
IoComponentMgr::IoComponentEntry
Definition: IoComponentMgr.h:128
IoComponentMgr::IoComponentEntry::operator<<
friend std::ostream & operator<<(std::ostream &os, const IoComponentEntry &c)
Definition: IoComponentMgr.h:142
Incident
Definition: Incident.h:24
IoComponentMgr::IoComponentEntry::operator<
friend bool operator<(const IoComponentEntry &lhs, const IoComponentEntry &rhs)
Definition: IoComponentMgr.h:138
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:169
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:35
IoComponentMgr::io_reinitialize
StatusCode io_reinitialize() override
: reinitialize the I/O subsystem.
Definition: IoComponentMgr.cpp:273