Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RootDataConnection.h
Go to the documentation of this file.
1 // $Id: RootDataConnection.h,v 1.9 2010-09-17 09:00:12 frankb Exp $
2 #ifndef GAUDIROOT_ROOTDATACONNECTION_H
3 #define GAUDIROOT_ROOTDATACONNECTION_H
4 
5 // Framework include files
6 #include "GaudiKernel/ClassID.h"
8 #include <string>
9 #include <vector>
10 #include <map>
11 #include <set>
12 
13 #include "TFile.h"
14 #include "RootCnv/RootRefs.h"
15 
16 // Forward declarations
17 class TTree;
18 class TClass;
19 class TBranch;
20 class TTreePerfStats;
21 
22 class MsgStream;
23 class IRegistry;
24 class DataObject;
25 class IIncidentSvc;
26 
27 /*
28  * Gaudi namespace declaration
29  */
30 namespace Gaudi {
31 
43  public:
46  protected:
48  virtual ~RootConnectionSetup();
50  int refCount;
55 
56  public:
64  int cacheSize;
67 
71  void addRef();
73  void release();
74 
76  static long setCompression(const std::string& compression);
78  static int compression();
79 
81  void setMessageSvc(MsgStream* m);
83  MsgStream& msgSvc() const { return *m_msgSvc; }
84 
86  void setIncidentSvc(IIncidentSvc* m);
88  IIncidentSvc* incidentSvc() const { return m_incidentSvc; }
89  };
90 
99  class GAUDI_API RootDataConnection : virtual public Gaudi::IDataConnection {
100  public:
101 
102  enum { ROOT_READ_ERROR = 0x2,
103  ROOT_OPEN_ERROR = 0x4
104  };
105 
118  ContainerSection() : start(-1), length(0) {}
120  ContainerSection(int s, int l) : start(s), length(l) {}
122  ContainerSection(const ContainerSection& s) : start(s.start), length(s.length) {}
125  if ( this != &s ) {
126  start=s.start;
127  length=s.length;
128  }
129  return *this;
130  }
132  int start;
134  int length;
135  };
136 
151 
153  MsgStream& msgSvc() const { return m_setup->msgSvc(); }
154 
155 
156  protected:
160  TTreePerfStats* m_statistics;
162  TFile* m_file;
164  TTree *m_refs;
185 
187  const std::string& empty() const;
188 
190  StatusCode saveRefs();
191 
192  public:
202  class Tool {
203  protected:
211 
214  public:
215  TTree* refs() const { return c->m_refs; }
216  StringVec& dbs() const { return c->m_dbs; }
217  StringVec& conts() const { return c->m_conts; }
218  StringVec& links() const { return c->m_links; }
219  ParamMap& params() const { return c->m_params; }
220  MsgStream& msgSvc() const { return c->msgSvc(); }
221  const std::string& name() const { return c->m_name; }
222  Sections& sections() const { return c->m_sections; }
223  LinkSections& linkSections() const { return c->m_linkSects; }
224  MergeSections& mergeSections() const { return c->m_mergeSects; }
225 
227  virtual ~Tool() {}
229  virtual void release() { delete this; }
231  virtual TBranch* getBranch(const std::string& section, const std::string& n) = 0;
233  virtual RootRef poolRef(size_t /* which */) const { return RootRef(); }
234 
236  virtual StatusCode readRefs() = 0;
238  virtual StatusCode saveRefs() = 0;
240  virtual int loadRefs(const std::string& section, const std::string& cnt, unsigned long entry, RootObjectRefs& refs) = 0;
241  } *m_tool;
242  friend class Tool;
243 
245  Tool* makeTool();
246 
247  public:
248 
250  RootDataConnection(const IInterface* own, const std::string& nam, RootConnectionSetup* setup);
252  virtual ~RootDataConnection();
253 
255  TFile* file() const { return m_file; }
257  virtual bool isConnected() const { return m_file != 0; }
259  bool isWritable() const { return m_file != 0 && m_file->IsWritable(); }
261  Tool* tool() const { return m_tool; }
263  const MergeSections& mergeSections() const { return m_mergeSects; }
265  const StringVec& mergeFIDs() const { return m_mergeFIDs; }
266 
267 
269  void addClient(const IInterface* client);
271  size_t removeClient(const IInterface* client);
273  bool lookupClient(const IInterface* client) const;
274 
276  void badWriteError(const std::string& msg) const;
277 
279  std::pair<const RootRef*,const ContainerSection*> getMergeSection(const std::string& container, int entry) const;
280 
282  void enableStatistics(const std::string& section);
284  void saveStatistics(const std::string& statisticsFile);
285 
287  int loadObj(const std::string& section, const std::string& cnt, unsigned long entry, DataObject*& pObj);
288 
290  int loadRefs(const std::string& section, const std::string& cnt, unsigned long entry, RootObjectRefs& refs);
291 
293  std::pair<int,unsigned long> saveObj(const std::string& section,const std::string& cnt, TClass* cl, DataObject* pObj, int buff_siz, int split_lvl,bool fill_missing=false);
295  std::pair<int,unsigned long> save(const std::string& section,const std::string& cnt, TClass* cl, void* pObj, int buff_siz, int split_lvl,bool fill_missing=false);
296 
297 
299  virtual StatusCode connectRead();
301  virtual StatusCode connectWrite(IoType typ);
303  virtual StatusCode disconnect();
305  virtual StatusCode read(void* const, size_t) { return StatusCode::FAILURE; }
307  virtual StatusCode write(const void*, int) { return StatusCode::FAILURE; }
309  virtual long long int seek(long long int, int) { return -1; }
310 
312  TTree* getSection(const std::string& sect, bool create=false);
313 
315  TBranch* getBranch(const std::string& section,const std::string& branch_name)
316  { return m_tool->getBranch(section,branch_name); }
318  TBranch* getBranch(const std::string& section, const std::string& branch_name, TClass* cl, void* ptr, int buff_siz, int split_lvl);
319 
321  void makeRef(IRegistry* pA, RootRef& ref);
323  void makeRef(const std::string& name, long clid, int tech, const std::string& db, const std::string& cnt, int entry, RootRef& ref);
324 
326  int makeLink(const std::string& p);
327 
329  const std::string& getDb(int which) const;
330 
332  const std::string& getCont(int which) const
333  { return (which>=0)&&(size_t(which)<m_conts.size()) ? *(m_conts.begin()+which) : empty(); }
334 
336  const std::string& getLink(int which) const
337  { return (which>=0)&&(size_t(which)<m_links.size()) ? *(m_links.begin()+which) : empty(); }
338  };
339 } // End namespace Gaudi
340 #endif // GAUDIROOT_ROOTDATACONNECTION_H

Generated at Mon Feb 17 2014 14:37:50 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004