The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
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
36class ISvcLocator;
37
38class IoComponentMgr : public extends<Service, IIoComponentMgr, IIncidentListener> {
40 // Public methods:
42public:
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:
127private:
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};
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Base class for all Incidents (computing events).
Definition Incident.h:24
bool io_hasitem(IIoComponent *iocomponent) const override
: check if the registry contains a given IIoComponent
StatusCode io_register(IIoComponent *iocomponent) override
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
Gaudi::Property< std::vector< std::string > > m_directio_patterns
search patterns for special file names (direct I/O protocols)
std::multimap< IIoComponent *, IoComponentEntry > IoDict_t
std::list< IIoComponent * > IoStack_t
StatusCode finalize() override
IoComponentMgr()=delete
Default constructor:
StatusCode io_update_all(const std::string &work_dir) override
: Update all IIoComponents with a new work directory
StatusCode initialize() override
Gaudi Service Implementation.
std::vector< std::string > io_retrieve(IIoComponent *iocomponent) override
: retrieve all registered filenames for a given IIoComponent
bool findComp(IIoComponent *, const std::string &, iodITR &) const
IoDict_t::const_iterator iodITR
std::string m_dict_location
location of the python dictionary
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
StatusCode io_reinitialize() override
: reinitialize the I/O subsystem.
bool io_contains(IIoComponent *iocomponent, const std::string &fname) const override
: check if the registry contains a given IIoComponent and that component had
IoRegistry_t m_ioregistry
Registry of IIoComponents.
std::string list() const
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
StatusCode io_finalize() override
: finalize the I/O subsystem.
std::map< std::string, IIoComponent * > IoRegistry_t
void handle(const Incident &) override
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
Base class used to extend a class implementing other interfaces.
Definition extends.h:19
std::string m_newfname
IoComponentEntry()=default
IoComponentEntry(const std::string &f, const std::string &p, const IIoComponentMgr::IoMode::Type &t)
friend std::ostream & operator<<(std::ostream &os, const IoComponentEntry &c)
friend bool operator<(const IoComponentEntry &lhs, const IoComponentEntry &rhs)
std::string m_oldfname
std::string m_oldabspath
IIoComponentMgr::IoMode::Type m_iomode