GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HistoDB.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2006 by Christophe Theisen & Olivier Stezowski *
3  * christophe.theisen(AT)cea.fr, stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef GW_HISTODB_H
24 #define GW_HISTODB_H
25 
26 // root's includes
27 #ifndef ROOT_TH1
28 #include <TH1.h>
29 #endif
30 
31 #ifndef ROOT_TH2
32 #include <TH2.h>
33 #endif
34 
35 #ifndef ROOT_THStack
36 #include <THStack.h>
37 #endif
38 
39 #ifndef ROOT_TString
40 #include <TString.h>
41 #endif
42 
43 // std's includes
44 #include <map>
45 #include <string>
46 #include <fstream>
47 
48 #ifndef GW_HISTOCONVERTER_H
49 #include "HistoConverter.h"
50 #endif
51 
52 namespace Gw {
53 
90 class HistoDB
91 {
92 
93 private:
94  std::map <const char *, HistoConverter *> fConnections; // list of open connections to DB services
95 
96  HistoConverter *fCurrentDB; // current DB system to read/write ROOT histograms
97 
98 public:
99  enum EStatus { kGood, kFail };
100 
101 protected:
102  int fStatus ; // current status of the last operation when using << and >>
103 
104 public:
105  HistoDB();
106  virtual ~HistoDB();
107 
109  virtual bool IsStatus(HistoDB::EStatus status) { return fStatus == status ; }
111  virtual void SetStatus(HistoDB::EStatus status = kGood) { fStatus = status ; }
112 
113  // ! set verbose level. 0 for no I/O messages. 1 (default) for I/O messages.
114  void SetVerboseLevel(const int);
115  // ! return verbose level
116  int GetVerboseLevel();
117 
118 
120  virtual void SetMode(Option_t *) ;
122  virtual void SetMode(const char *, Option_t *) ;
123 
125 
128  virtual TH1 *Get(int i);
130 
134  virtual TH1 *Get(const char *name);
135 
136 
138  virtual bool Write(const TH1 &);
140  virtual bool Write(const TH2 &);
141 
143  virtual HistoDB & operator << (const TH1 &);
145  virtual HistoDB & operator >> (TH1 &);
146 
148  virtual HistoDB & operator << (const TH2 &);
150  virtual HistoDB & operator >> (TH2 &);
151 
153  virtual HistoDB & operator << (const char *name) { SetCurrent(name) ; return (*this); }
154 
156  virtual HistoDB & operator << (const THStack &);
158  virtual HistoDB & operator >> (THStack &);
159 
161  virtual void SetCurrent(const char *);
162 
164 
176  virtual HistoConverter *Open(const char *, const char *);
177 
179 
185  virtual void ls(Option_t *opt = "cdb") ;
186 
188 
192  void MakeConverter(const char *classname) const ;
193 
195  void AddFileExt(const char* type, const char* ext);
196 
198  void AddOption(const char* type, Option_t* opt, const char* mode = "reset");
199 
201  ClassDef(HistoDB,0); // Service to read/write ROOT histograms to others DB systems
202 };
203 // inline members
204 
205 } // namespace
206 
207 #endif
virtual HistoDB & operator>>(TH1 &)
to read an histogram from the current Histo DB service
Definition: HistoDB.cpp:275
virtual void ls(Option_t *opt="cdb")
to list the current configuration
Definition: HistoDB.cpp:172
virtual void SetStatus(HistoDB::EStatus status=kGood)
modify the status flag for the HistoDB stream
Definition: HistoDB.h:111
void MakeConverter(const char *classname) const
Use it if you want to extend the DB types handled.
Definition: HistoDB.cpp:331
ClassDef(HistoDB, 0)
rootcint dictionary
void AddOption(const char *type, Option_t *opt, const char *mode="reset")
add option
Definition: HistoDB.cpp:71
virtual HistoConverter * Open(const char *, const char *)
to open a new DB service
Definition: HistoDB.cpp:93
header file for the HistoDB facility
void SetVerboseLevel(const int)
Definition: HistoDB.cpp:199
virtual HistoDB & operator<<(const TH1 &)
to write an histogram in the current Histo DB service
Definition: HistoDB.cpp:264
virtual bool IsStatus(HistoDB::EStatus status)
to get the current status flag for the HistoDB stream
Definition: HistoDB.h:109
virtual void SetCurrent(const char *)
change the current service. It uses the alias defined in open
Definition: HistoDB.cpp:87
virtual ~HistoDB()
Definition: HistoDB.cpp:47
void AddFileExt(const char *type, const char *ext)
add file extension
Definition: HistoDB.cpp:56
int fStatus
Definition: HistoDB.h:102
virtual bool Write(const TH1 &)
to write a TH1 histogram in the current Histo DB service
Definition: HistoDB.cpp:239
Service to read/write ROOT histograms from/to different DB systems.
Definition: HistoDB.h:90
virtual TH1 * Get(int i)
to get histo number i of the current DB
Definition: HistoDB.cpp:213
int GetVerboseLevel()
Definition: HistoDB.cpp:206
virtual void SetMode(Option_t *)
to change the mode (overwrite/version) of the current DB service
Definition: HistoDB.cpp:159