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
21 #include "GaudiKernel/IIoComponent.h"
22 #include "GaudiKernel/IIoComponentMgr.h"
23 #include "GaudiKernel/IIncidentListener.h"
24 
25 // Forward declaration
26 class ISvcLocator;
27 
28 class IoComponentMgr: public extends2<Service, IIoComponentMgr,
29  IIncidentListener> {
31  // Public methods:
33  public:
34 
35  // Copy constructor:
36 
38  IoComponentMgr( const std::string& name, ISvcLocator* pSvcLocator );
39 
41  virtual ~IoComponentMgr();
42 
43  // Assignment operator:
44  //IoComponentMgr &operator=(const IoComponentMgr &alg);
45 
47 
48  virtual StatusCode initialize();
49  virtual StatusCode finalize();
50 
52 
53  void handle(const Incident&);
54 
56  // Const methods:
58 
61  virtual
62  bool io_hasitem (IIoComponent* iocomponent) const;
63 
67  virtual
68  bool io_contains (IIoComponent* iocomponent,
69  const std::string& fname) const;
70 
72  // Non-const methods:
74 
81  virtual
82  StatusCode io_register (IIoComponent* iocomponent);
83 
90  virtual
91  StatusCode io_register (IIoComponent* iocomponent,
93  const std::string& fname,
94  const std::string& pfn);
95 
99  virtual
100  StatusCode io_update (IIoComponent* iocomponent,
101  const std::string& old_fname,
102  const std::string& new_fname);
103 
107  virtual
108  StatusCode io_update (IIoComponent* iocomponent,
109  const std::string& work_dir);
110 
111  // VT. new method
114  virtual
115  StatusCode io_update_all (const std::string& work_dir);
116 
120  virtual
121  StatusCode io_retrieve (IIoComponent* iocomponent,
122  std::string& fname);
123 
128  virtual
130 
135  virtual
137 
139  // Private data:
141  private:
142 
144  std::string m_oldfname;
145  std::string m_oldabspath; // VT. store absolute path
146  std::string m_newfname;
148 
149  IoComponentEntry():m_oldfname(""),m_oldabspath(""),m_newfname(""), // VT. changes
150  m_iomode(IIoComponentMgr::IoMode::INVALID) {}
151  IoComponentEntry(const std::string& f, const std::string& p, // VT. changes
153  : m_oldfname(f), m_oldabspath(p),m_newfname(""), m_iomode(t){} // VT. changes
154  IoComponentEntry(const IoComponentEntry& rhs):m_oldfname(rhs.m_oldfname),
155  m_oldabspath(rhs.m_oldabspath), // VT. changes
156  m_newfname(rhs.m_newfname),
157  m_iomode(rhs.m_iomode){}
158  bool operator < (IoComponentEntry const &rhs) const {
159  if (m_oldfname == rhs.m_oldfname) {
160  return (m_iomode < rhs.m_iomode);
161  } else {
162  return (m_oldfname < rhs.m_oldfname);
163  }
164  }
165 
166  friend std::ostream& operator<< ( std::ostream& os, const IoComponentEntry& c) {
167  os << "old: \"" << c.m_oldfname
168  << "\" absolute path: \"" << c.m_oldabspath
169  << "\" new: \"" << c.m_newfname
170  << "\" m: " << ( (c.m_iomode == IIoComponentMgr::IoMode::READ) ?
171  "R" : "W" );
172  return os;
173  }
174 
175  };
176 
177 
178 
180  IoComponentMgr();
181 
182  mutable MsgStream m_log;
183 
184  typedef std::map<std::string, IIoComponent*> IoRegistry_t;
186  IoRegistry_t m_ioregistry;
187 
188  typedef std::list<IIoComponent*> IoStack_t;
190  IoStack_t m_iostack;
191 
192 
193  // This is the registry
194  typedef std::multimap<IIoComponent*, IoComponentEntry > IoDict_t;
195  typedef IoDict_t::const_iterator iodITR;
196 
197  IoDict_t m_cdict;
198 
200  std::string m_dict_location;
201 
202  bool findComp(IIoComponent*, const std::string&, iodITR& ) const;
203  bool findComp(IIoComponent*, std::pair<iodITR,iodITR>& ) const;
204  bool findComp(const std::string&, std::pair<iodITR,iodITR>& ) const;
205 
206  std::string list() const;
207 
208 
209 };
210 
211 
212 #endif //> !GAUDIMP_IOCOMPONENTMGR_H
tuple c
Definition: gaudirun.py:391
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
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 ...
std::string list() const
std::multimap< IIoComponent *, IoComponentEntry > IoDict_t
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:16
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
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)