File indexing completed on 2025-08-06 08:17:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef FUN4ALL_PHTFILESERVER_H
0014 #define FUN4ALL_PHTFILESERVER_H
0015
0016 #include <TFile.h>
0017
0018 #include <map>
0019 #include <sstream>
0020 #include <string>
0021
0022
0023
0024
0025
0026
0027
0028 class PHTFileServer
0029 {
0030 public:
0031
0032 static PHTFileServer& get(void)
0033 {
0034 static PHTFileServer singleton;
0035 return singleton;
0036 }
0037
0038
0039 virtual ~PHTFileServer();
0040
0041
0042
0043
0044
0045 static void open(const std::string& filename, const std::string& type = "RECREATE");
0046
0047
0048 static bool flush(const std::string& filename);
0049
0050
0051 static bool cd(const std::string& filename);
0052
0053
0054
0055
0056
0057 static bool write(const std::string& filename);
0058
0059
0060 static void close(void);
0061
0062 private:
0063
0064 PHTFileServer(void)
0065 {
0066 }
0067
0068
0069 class SafeTFile : public TFile
0070 {
0071 public:
0072
0073 SafeTFile(const std::string& filename, const std::string& type = "RECREATE")
0074 : TFile(filename.c_str(), type.c_str())
0075 , _filename(filename)
0076 , _counter(1)
0077 {
0078 }
0079
0080
0081 ~SafeTFile(void) override;
0082
0083
0084 int& counter()
0085 {
0086 return _counter;
0087 }
0088
0089
0090 const int& counter() const
0091 {
0092 return _counter;
0093 }
0094
0095
0096 typedef std::map<std::string, SafeTFile*> TFileMap;
0097
0098 static TFileMap& file_map(void)
0099 {
0100 return _map;
0101 }
0102
0103 private:
0104
0105 std::string _filename;
0106
0107
0108 int _counter;
0109
0110
0111 static TFileMap _map;
0112 };
0113 };
0114
0115 #endif