GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TCompiledHistograms.h
Go to the documentation of this file.
1 #ifndef _TCOMPILEDHISTOGRAMS_H_
2 #define _TCOMPILEDHISTOGRAMS_H_
3 
4 #ifndef __CINT__
5 #include <mutex>
6 #endif
7 #include <memory>
8 #include <string>
9 
10 #include "TObject.h"
11 
12 #include "DynamicLibrary.h"
13 #include "TDetector.h"
14 #include "TRuntimeObjects.h"
15 
16 class TCompiledHistograms : public TObject {
17 public:
19  TCompiledHistograms(std::string libname);
20 
21  void Load(std::string libname);
22  void Fill(TUnpackedEvent& detectors);
23  void Reload();
24 
25  std::string GetLibraryName() const { return libname; }
26 
27  TList* GetVariables();
28  void SetReplaceVariable(const char* name, double value);
29  void RemoveVariable(const char* name);
30 
31  void SetDefaultDirectory(TDirectory* dir) { default_directory = dir; }
32  TDirectory* GetDefaultDirectory() { return default_directory; }
33 
34  void ClearHistograms();
35 
36  TList* GetObjects(){ return &objects; }
37 
38  void Write();
39 
40 private:
41  void swap_lib(TCompiledHistograms& other);
42  time_t get_timestamp();
43  bool file_exists();
44 
45  std::string libname;
46 #ifndef __CINT__
47  std::shared_ptr<DynamicLibrary> library;
48  std::mutex mutex;
49 #endif
50  void (*func)(TRuntimeObjects&);
51  time_t last_modified;
52  time_t last_checked;
53 
55 
56  TList objects;
57  TList variables;
58 
59  TDirectory* default_directory;
60 
62 };
63 
64 #endif /* _TCOMPILEDHISTOGRAMS_H_ */