The Gaudi Framework  v29r0 (ff2e7097)
IoComponentMgr.h
Go to the documentation of this file.
1 // IoComponentMgr.h
3 // Header file for class IoComponentMgr
4 // Author: S.Binet<binet@cern.ch>
6 #ifndef GAUDIMP_IOCOMPONENTMGR_H
7 #define GAUDIMP_IOCOMPONENTMGR_H 1
8 
9 // Python includes
10 #include <Python.h>
11 
12 // STL includes
13 #include <list>
14 #include <map>
15 #include <string>
16 
17 // FrameWork includes
18 #include "GaudiKernel/Service.h"
19 
20 // GaudiKernel
24 
25 // Forward declaration
26 class ISvcLocator;
27 
28 class IoComponentMgr : public extends<Service, IIoComponentMgr, IIncidentListener>
29 {
31  // Public methods:
33 public:
35  using extends::extends;
36 
38  ~IoComponentMgr() override = default;
39 
41 
42  StatusCode initialize() override;
43  StatusCode finalize() override;
45 
46  void handle( const Incident& ) override;
47 
49  // Const methods:
51 
54  bool io_hasitem( IIoComponent* iocomponent ) const override;
55 
59  bool io_contains( IIoComponent* iocomponent, const std::string& fname ) const override;
60 
62  // Non-const methods:
64 
71  StatusCode io_register( IIoComponent* iocomponent ) override;
72 
80  const std::string& pfn ) override;
81 
85  StatusCode io_update( IIoComponent* iocomponent, const std::string& old_fname,
86  const std::string& new_fname ) override;
87 
91  StatusCode io_update( IIoComponent* iocomponent, const std::string& work_dir ) override;
92 
93  // VT. new method
96  StatusCode io_update_all( const std::string& work_dir ) override;
97 
101  StatusCode io_retrieve( IIoComponent* iocomponent, std::string& fname ) override;
102 
107  StatusCode io_reinitialize() override;
108 
113  StatusCode io_finalize() override;
114 
116  // Private data:
118 private:
121  std::string m_oldabspath; // VT. store absolute path
124 
126  : m_oldfname( "" )
127  , m_oldabspath( "" )
128  , m_newfname( "" )
129  , // VT. changes
130  m_iomode( IIoComponentMgr::IoMode::INVALID )
131  {
132  }
133  IoComponentEntry( const std::string& f, const std::string& p, // VT. changes
135  : m_oldfname( f ), m_oldabspath( p ), m_newfname( "" ), m_iomode( t )
136  {
137  } // VT. changes
139  : m_oldfname( rhs.m_oldfname )
140  , m_oldabspath( rhs.m_oldabspath )
141  , // VT. changes
142  m_newfname( rhs.m_newfname )
143  , m_iomode( rhs.m_iomode )
144  {
145  }
146  bool operator<( IoComponentEntry const& rhs ) const
147  {
148  if ( m_oldfname == rhs.m_oldfname ) {
149  return ( m_iomode < rhs.m_iomode );
150  } else {
151  return ( m_oldfname < rhs.m_oldfname );
152  }
153  }
154 
156  {
157  os << "old: \"" << c.m_oldfname << "\" absolute path: \"" << c.m_oldabspath << "\" new: \"" << c.m_newfname
158  << "\" m: " << ( ( c.m_iomode == IIoComponentMgr::IoMode::READ ) ? "R" : "W" );
159  return os;
160  }
161  };
162 
164  IoComponentMgr() = delete;
165 
168  IoRegistry_t m_ioregistry;
169 
172  IoStack_t m_iostack;
173 
174  // This is the registry
176  typedef IoDict_t::const_iterator iodITR;
177 
178  IoDict_t m_cdict;
179 
182 
183  bool findComp( IIoComponent*, const std::string&, iodITR& ) const;
185  bool findComp( const std::string&, std::pair<iodITR, iodITR>& ) const;
186 
187  std::string list() const;
188 };
189 
190 #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:25
bool io_contains(IIoComponent *iocomponent, const std::string &fname) const override
: check if the registry contains a given IIoComponent and that component had
std::string m_oldabspath
IoDict_t::const_iterator iodITR
std::map< std::string, IIoComponent * > IoRegistry_t
IoRegistry_t m_ioregistry
Registry of IIoComponents.
bool operator<(IoComponentEntry const &rhs) const
std::list< IIoComponent * > IoStack_t
void handle(const Incident &) override
STL class.
IoComponentMgr()=delete
Default constructor:
std::string list() const
StatusCode initialize() override
Gaudi Service Implementation.
bool findComp(IIoComponent *, const std::string &, iodITR &) const
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:28
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 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:10
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:17
IoComponentEntry(const IoComponentEntry &rhs)
StatusCode io_retrieve(IIoComponent *iocomponent, std::string &fname) override
: retrieve the new filename for a given IIoComponent and
StatusCode io_finalize() override
: finalize the I/O subsystem.
StatusCode io_reinitialize() override
: reinitialize the I/O subsystem.
~IoComponentMgr() override=default
Destructor:
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_hasitem(IIoComponent *iocomponent) const override
: check if the registry contains a given IIoComponent