CFEL - ASG Software Suite  2.5.0
CASS
rootfile_helper.h
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file rootfile_helper.h contains singleton definition for creating root files
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _ROOTFILE_HELPER_H_
10 #define _ROOTFILE_HELPER_H_
11 
12 #include <string>
13 #include <map>
14 
15 #include <QtCore/QMutex>
16 
17 class TFile;
18 
19 namespace cass
20 {
21 /** root file creation
22  *
23  * create an instance of a rootfile and return it. In case ROOT file aready
24  * exists return the instance of that root file.
25  *
26  * @author Lutz Foucar
27  */
29 {
30 private:
31  /** make default constructor private */
33 
34  /** easier code */
35  typedef std::map<std::string,TFile *> rootfiles_t;
36 
37 public:
38  /** create and return an instance of the rootfile
39  *
40  * create an instance of the root file with the given parameters. If the
41  * rootfile already exists don't create a new one but return the one already
42  * existing
43  *
44  * @return an instance of the TFile
45  * @param rootfilename filename of the rootfile
46  * @param options string containing the option with which the root file
47  * should be opened.
48  *
49  */
50  static TFile* create(const std::string& rootfilename,
51  const std::string& options = "RECREATE");
52 
53  /** close root file
54  *
55  * @param rootfile pointer to the root file instance. pointer should be the
56  * same as the one returned in create()
57  */
58  static void close(TFile* rootfile);
59 
60 private:
61  /** container for all the root files */
62  static rootfiles_t _rootfiles;
63 
64  /** Singleton Mutex to lock write operations*/
65  static QMutex _mutex;
66 };
67 }
68 
69 #endif
ROOTFileHelper()
make default constructor private
static TFile * create(const std::string &rootfilename, const std::string &options="RECREATE")
create and return an instance of the rootfile
std::map< std::string, TFile * > rootfiles_t
easier code
static QMutex _mutex
Singleton Mutex to lock write operations.
root file creation
static void close(TFile *rootfile)
close root file
static rootfiles_t _rootfiles
container for all the root files