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