Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MultiFileCatalog.h
Go to the documentation of this file.
1 #ifndef GAUDIUTILS_MULTIFILECATALOG_H
2 #define GAUDIUTILS_MULTIFILECATALOG_H
3 
4 #include "GaudiKernel/Service.h"
7 
8 /*
9  * Gaudi namespace declaration
10  */
11 namespace Gaudi {
12 
20  class MultiFileCatalog: public extends2<Service, IFileCatalog, IFileCatalogMgr>
21  {
22  protected:
23  typedef const std::string& CSTR;
26 
27  template <class T> void _exec(T pmf) const {
29  ((*i)->*pmf)();
30  }
31  template <class A1,class F> std::string _find(A1& arg1,F pmf) const {
32  std::string result;
34  if ( !(result= ((*i)->*pmf)(arg1)).empty() ) break;
35  return result;
36  }
37  template <class A1,class F> void _collect(A1 arg1,F pmf) const {
38  A1 tmp;
39  for(Catalogs::const_iterator i=m_catalogs.begin();i!=m_catalogs.end();++i,tmp.clear()) {
40  ((*i)->*pmf)(tmp);
41  arg1.insert(arg1.end(),tmp.begin(),tmp.end());
42  }
43  }
44  template <class A1,class A2,class F> void _collect(A1 arg1,A2& arg2,F pmf) const {
45  A2 tmp;
46  for(Catalogs::const_iterator i=m_catalogs.begin();i!=m_catalogs.end();++i,tmp.clear()) {
47  ((*i)->*pmf)(arg1,tmp);
48  arg2.insert(arg2.end(),tmp.begin(),tmp.end());
49  }
50  }
51  public:
53  MultiFileCatalog(const std::string& nam, ISvcLocator* svc);
55  virtual ~MultiFileCatalog();
56 
58 
59  virtual StatusCode initialize();
61  virtual StatusCode finalize();
62 
64 
65  virtual std::string createFID() const;
67  virtual CSTR connectInfo() const;
69  virtual void init()
70  { _exec(&IFileCatalog::init); m_started=true; }
72  virtual void commit() { _exec(&IFileCatalog::commit); }
74  virtual void rollback() { _exec(&IFileCatalog::rollback); }
76  virtual bool readOnly() const;
78  virtual bool dirty() const;
80  virtual bool existsPFN(CSTR pfn) const
81  { return !lookupPFN(pfn).empty(); }
83  virtual std::string lookupPFN(CSTR pfn) const
84  { return _find(pfn,&IFileCatalog::lookupPFN); }
86  virtual bool existsLFN(CSTR lfn) const
87  { return !lookupLFN(lfn).empty(); }
89  virtual std::string lookupLFN(CSTR lfn) const
90  { return _find(lfn,&IFileCatalog::lookupLFN); }
92  virtual bool existsFID(CSTR fid) const
93  { return 0 != getCatalog(fid,false,false,false); }
95  virtual void getPFN(CSTR fid, Files& files) const
96  { _collect(fid,files,&IFileCatalog::getPFN); }
98  virtual void getLFN(CSTR fid, Files& files) const
99  { _collect(fid,files,&IFileCatalog::getLFN); }
100 
102  virtual void getFID(Strings& fids) const
103  { _collect(fids,&IFileCatalog::getFID); }
105  virtual void deleteFID(CSTR fid) const
106  { writeCatalog(fid)->deleteFID(fid); }
108  virtual void registerPFN(CSTR fid, CSTR pfn, CSTR ftype) const;
110  virtual void registerLFN(CSTR fid, CSTR lfn) const;
112  virtual void registerFID(CSTR fid) const
113  { writeCatalog()->registerFID(fid); }
115  virtual void getMetaData(CSTR fid, Attributes& attr) const
116  { _collect(fid,attr,&IFileCatalog::getMetaData); }
118  virtual std::string getMetaDataItem(CSTR fid, CSTR name) const;
120  virtual void setMetaData(CSTR fid, CSTR attr, CSTR val) const
121  { writeCatalog(fid)->setMetaData(fid,attr,val); }
123  virtual void dropMetaData(CSTR fid) const
124  { writeCatalog(fid)->dropMetaData(fid); }
126  virtual void dropMetaData(CSTR fid, CSTR attr) const
127  { writeCatalog(fid)->dropMetaData(fid,attr); }
128 
130 
131  virtual IFileCatalog* findCatalog(CSTR connect, bool must_be_writable) const;
133  virtual void addCatalog(CSTR connect);
135  virtual void addCatalog(IFileCatalog* cat);
137  virtual void removeCatalog(CSTR connect);
139  virtual void removeCatalog(const IFileCatalog* cat);
141  virtual Catalogs& catalogs() { return m_catalogs; }
143  virtual const Catalogs& catalogs() const { return m_catalogs; }
145  virtual IFileCatalog* writeCatalog(CSTR fid="") const
146  { return getCatalog(fid,true,true,false); }
148  virtual void setWriteCatalog(IFileCatalog* cat);
150  virtual void setWriteCatalog(CSTR connect);
151 
152  private:
154  IFileCatalog* getCatalog(CSTR fid, bool throw_if_not, bool writable=true, bool prt=true) const;
156  Catalogs::iterator i_findCatalog(CSTR connect, bool must_be_writable);
157 
160  void propHandler(Property& /* p */);
161 
162  void printError(CSTR msg, bool throw_exc=true) const;
163  std::string lookupFID(CSTR lfn) const;
164 
170  bool m_started;
173  };
174 } /* End namespace Gaudi */
175 #endif /* GAUDIUTILS_MULTIFILECATALOG_H */

Generated at Wed Jan 30 2013 17:13:41 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004