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 
36  // Copy constructor:
37 
39  IoComponentMgr( const std::string& name, ISvcLocator* pSvcLocator );
40 
42  virtual ~IoComponentMgr();
43 
44  // Assignment operator:
45  //IoComponentMgr &operator=(const IoComponentMgr &alg);
46 
48 
49  virtual StatusCode initialize();
50  virtual StatusCode finalize();
51 
53 
54  void handle(const Incident&);
55 
57  // Const methods:
59 
62  virtual
63  bool io_hasitem (IIoComponent* iocomponent) const;
64 
68  virtual
69  bool io_contains (IIoComponent* iocomponent,
70  const std::string& fname) const;
71 
73  // Non-const methods:
75 
82  virtual
83  StatusCode io_register (IIoComponent* iocomponent);
84 
91  virtual
92  StatusCode io_register (IIoComponent* iocomponent,
94  const std::string& fname,
95  const std::string& pfn);
96 
100  virtual
101  StatusCode io_update (IIoComponent* iocomponent,
102  const std::string& old_fname,
103  const std::string& new_fname);
104 
108  virtual
109  StatusCode io_update (IIoComponent* iocomponent,
110  const std::string& work_dir);
111 
112  // VT. new method
115  virtual
116  StatusCode io_update_all (const std::string& work_dir);
117 
121  virtual
122  StatusCode io_retrieve (IIoComponent* iocomponent,
123  std::string& fname);
124 
129  virtual
131 
136  virtual
138 
140  // Private data:
142  private:
143 
146  std::string m_oldabspath; // VT. store absolute path
149 
150  IoComponentEntry():m_oldfname(""),m_oldabspath(""),m_newfname(""), // VT. changes
151  m_iomode(IIoComponentMgr::IoMode::INVALID) {}
152  IoComponentEntry(const std::string& f, const std::string& p, // VT. changes
154  : m_oldfname(f), m_oldabspath(p),m_newfname(""), m_iomode(t){} // VT. changes
155  IoComponentEntry(const IoComponentEntry& rhs):m_oldfname(rhs.m_oldfname),
156  m_oldabspath(rhs.m_oldabspath), // VT. changes
157  m_newfname(rhs.m_newfname),
158  m_iomode(rhs.m_iomode){}
159  bool operator < (IoComponentEntry const &rhs) const {
160  if (m_oldfname == rhs.m_oldfname) {
161  return (m_iomode < rhs.m_iomode);
162  } else {
163  return (m_oldfname < rhs.m_oldfname);
164  }
165  }
166 
168  os << "old: \"" << c.m_oldfname
169  << "\" absolute path: \"" << c.m_oldabspath
170  << "\" new: \"" << c.m_newfname
171  << "\" m: " << ( (c.m_iomode == IIoComponentMgr::IoMode::READ) ?
172  "R" : "W" );
173  return os;
174  }
175 
176  };
177 
178 
179 
181  IoComponentMgr();
182 
183  mutable MsgStream m_log;
184 
187  IoRegistry_t m_ioregistry;
188 
191  IoStack_t m_iostack;
192 
193 
194  // This is the registry
196  typedef IoDict_t::const_iterator iodITR;
197 
198  IoDict_t m_cdict;
199 
202 
203  bool findComp(IIoComponent*, const std::string&, iodITR& ) const;
205  bool findComp(const std::string&, std::pair<iodITR,iodITR>& ) const;
206 
207  std::string list() const;
208 
209 
210 };
211 
212 
213 #endif //> !GAUDIMP_IOCOMPONENTMGR_H
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual bool io_contains(IIoComponent *iocomponent, const std::string &fname) const
: check if the registry contains a given IIoComponent and that component had
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
std::string m_oldabspath
tuple c
Definition: gaudirun.py:391
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
void handle(const Incident &)
std::list< IIoComponent * > IoStack_t
virtual StatusCode io_update(IIoComponent *iocomponent, const std::string &old_fname, const std::string &new_fname)
: allow a IIoComponent to update the contents of the registry with a new file name ...
STL class.
std::string list() const
std::multimap< IIoComponent *, IoComponentEntry > IoDict_t
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
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
virtual StatusCode io_reinitialize()
: reinitialize the I/O subsystem.
virtual StatusCode io_finalize()
: finalize the I/O subsystem.
IoComponentMgr()
Default constructor:
IoComponentEntry()
virtual StatusCode initialize()
Gaudi Service Implementation.
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
Base class for all Incidents (computing events).
Definition: Incident.h:17
virtual bool io_hasitem(IIoComponent *iocomponent) const
: check if the registry contains a given IIoComponent
IoComponentEntry(const IoComponentEntry &rhs)
virtual ~IoComponentMgr()
Destructor:
virtual StatusCode io_retrieve(IIoComponent *iocomponent, std::string &fname)
: retrieve the new filename for a given IIoComponent and
IoStack_t m_iostack
Stack of IIoComponents to properly handle order of registration.
virtual StatusCode io_register(IIoComponent *iocomponent)
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
virtual StatusCode finalize()
std::string m_newfname
STL class.
virtual StatusCode io_update_all(const std::string &work_dir)
: Update all IIoComponents with a new work directory
friend std::ostream & operator<<(std::ostream &os, const IoComponentEntry &c)