All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 <string>
14 #include <map>
15 #include <list>
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,
29  IIoComponentMgr,
30  IIncidentListener> {
32  // Public methods:
34  public:
35 
37  using extends::extends;
38 
40  ~IoComponentMgr() override = default;
41 
43 
44  StatusCode initialize() override;
45  StatusCode finalize() override;
47 
48  void handle(const Incident&) override;
49 
51  // Const methods:
53 
56  bool io_hasitem (IIoComponent* iocomponent) const override;
57 
61  bool io_contains (IIoComponent* iocomponent,
62  const std::string& fname) const override;
63 
65  // Non-const methods:
67 
74  StatusCode io_register (IIoComponent* iocomponent) override;
75 
82  StatusCode io_register (IIoComponent* iocomponent,
84  const std::string& fname,
85  const std::string& pfn) override;
86 
90  StatusCode io_update (IIoComponent* iocomponent,
91  const std::string& old_fname,
92  const std::string& new_fname) override;
93 
97  StatusCode io_update (IIoComponent* iocomponent,
98  const std::string& work_dir) override;
99 
100  // VT. new method
103  StatusCode io_update_all (const std::string& work_dir) override;
104 
108  StatusCode io_retrieve (IIoComponent* iocomponent,
109  std::string& fname) override;
110 
115  StatusCode io_reinitialize () override;
116 
121  StatusCode io_finalize () override;
122 
124  // Private data:
126  private:
127 
130  std::string m_oldabspath; // VT. store absolute path
133 
134  IoComponentEntry():m_oldfname(""),m_oldabspath(""),m_newfname(""), // VT. changes
135  m_iomode(IIoComponentMgr::IoMode::INVALID) {}
136  IoComponentEntry(const std::string& f, const std::string& p, // VT. changes
138  : m_oldfname(f), m_oldabspath(p),m_newfname(""), m_iomode(t){} // VT. changes
139  IoComponentEntry(const IoComponentEntry& rhs):m_oldfname(rhs.m_oldfname),
140  m_oldabspath(rhs.m_oldabspath), // VT. changes
141  m_newfname(rhs.m_newfname),
142  m_iomode(rhs.m_iomode){}
143  bool operator < (IoComponentEntry const &rhs) const {
144  if (m_oldfname == rhs.m_oldfname) {
145  return (m_iomode < rhs.m_iomode);
146  } else {
147  return (m_oldfname < rhs.m_oldfname);
148  }
149  }
150 
152  os << "old: \"" << c.m_oldfname
153  << "\" absolute path: \"" << c.m_oldabspath
154  << "\" new: \"" << c.m_newfname
155  << "\" m: " << ( (c.m_iomode == IIoComponentMgr::IoMode::READ) ?
156  "R" : "W" );
157  return os;
158  }
159 
160  };
161 
162 
164  IoComponentMgr() = delete;
165 
168  IoRegistry_t m_ioregistry;
169 
172  IoStack_t m_iostack;
173 
174 
175  // This is the registry
177  typedef IoDict_t::const_iterator iodITR;
178 
179  IoDict_t m_cdict;
180 
183 
184  bool findComp(IIoComponent*, const std::string&, iodITR& ) const;
186  bool findComp(const std::string&, std::pair<iodITR,iodITR>& ) const;
187 
188  std::string list() const;
189 
190 
191 };
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: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
std::multimap< IIoComponent *, IoComponentEntry > IoDict_t
StatusCode initialize() override
Gaudi Service Implementation.
bool findComp(IIoComponent *, const std::string &, iodITR &) const
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:26
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