CbmRoot
Loading...
Searching...
No Matches
CbmReport.h
Go to the documentation of this file.
1/* Copyright (C) 2011-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer], Florian Uhlig */
4
12#ifndef CBMREPORT_H_
13#define CBMREPORT_H_
14
15#include <Rtypes.h> // for THashConsistencyHolder, ClassDef
16#include <RtypesCore.h> // for Int_t, Option_t
17#include <TObject.h> // for TObject
18
19#include <iostream> // for string, ostream
20#include <vector> // for vector
21
23class TCanvas;
24
38
45class CbmReport : public TObject {
46public:
50 CbmReport();
51
55 virtual ~CbmReport();
56
61 const CbmReportElement* R() const { return fR; }
62
66 std::ostream& Out() const { return *fOut; }
67
68 /* Setters */
69 void SetReportName(const std::string& name) { fReportName = name; }
70 void SetReportTitle(const std::string& title) { fReportTitle = title; }
71 void SetOutputDir(const std::string& outputDir) { fOutputDir = outputDir; }
72
73 /* Accessors */
74 const std::string& GetReportName() const { return fReportName; }
75 const std::string& GetReportTitle() const { return fReportTitle; }
76 const std::string& GetOutputDir() const { return fOutputDir; }
77
78protected:
84 virtual void Create() = 0;
85
91 virtual void Draw() = 0;
92
97 void Draw(Option_t*) { ; }
98
99
103 void CreateReports();
104
110 TCanvas* CreateCanvas(const char* name, const char* title, Int_t ww, Int_t wh);
111
115 void SaveCanvasesAsImages() const;
116
120 void WriteCanvases() const;
121
125 void PrintCanvases() const;
126
127private:
132 void CreateReportElement(ReportType reportType);
133
137 void DeleteReportElement();
138
139 std::string fReportName; // Name of report
140 std::string fReportTitle; // Title of report
141 std::string fOutputDir; // Output directory for the report files
142 ReportType fReportType; // Current report type
143 CbmReportElement* fR; // Report element tool
144 mutable std::ostream* fOut; // Output stream
145
146 // Storage for TCanvas. All Canvases in this vector will be automatically saved
147 // to image and printed in the report.
148 // User can use CreateCanvas function which automatically push created canvas in this vector.
149 std::vector<TCanvas*> fCanvases;
150
151 //private:
152
155
156 ClassDef(CbmReport, 1)
157};
158
159#endif /* CBMREPORT_H_ */
ReportType
Enumeration defines different report types.
Definition CbmReport.h:32
@ kTextReport
Definition CbmReport.h:36
@ kHtmlReport
Definition CbmReport.h:34
@ kLatexReport
Definition CbmReport.h:35
@ kCoutReport
Definition CbmReport.h:33
Abstract class for basic report elements (headers, tables, images etc.).
Base class for reports.
Definition CbmReport.h:45
void WriteCanvases() const
Write canvases to file.
std::ostream & Out() const
All text output goes to this stream.
Definition CbmReport.h:66
CbmReport & operator=(const CbmReport &)
void SetOutputDir(const std::string &outputDir)
Definition CbmReport.h:71
std::string fOutputDir
Definition CbmReport.h:141
CbmReport()
Constructor.
Definition CbmReport.cxx:28
void DeleteReportElement()
Delete report element. Normally should be called at the end of Create function.
Definition CbmReport.cxx:65
ReportType fReportType
Definition CbmReport.h:142
void SaveCanvasesAsImages() const
Save all canvases to images.
void CreateReportElement(ReportType reportType)
Create concrete CbmReportElement instance based on report type.
Definition CbmReport.cxx:42
CbmReportElement * fR
Definition CbmReport.h:143
std::vector< TCanvas * > fCanvases
Definition CbmReport.h:149
virtual ~CbmReport()
Destructor.
Definition CbmReport.cxx:40
void SetReportName(const std::string &name)
Definition CbmReport.h:69
void PrintCanvases() const
Print images created from canvases in the report.
const std::string & GetReportTitle() const
Definition CbmReport.h:75
std::string fReportName
Definition CbmReport.h:139
CbmReport(const CbmReport &)
std::string fReportTitle
Definition CbmReport.h:140
void SetReportTitle(const std::string &title)
Definition CbmReport.h:70
virtual void Draw()=0
Pure abstract function which is called from public Create() function. This function has to draw all n...
const std::string & GetReportName() const
Definition CbmReport.h:74
std::ostream * fOut
Definition CbmReport.h:144
const CbmReportElement * R() const
Accessor to CbmReportElement object. User has to write the report using available tags from CbmReport...
Definition CbmReport.h:61
void CreateReports()
Create all available report types.
Definition CbmReport.cxx:71
TCanvas * CreateCanvas(const char *name, const char *title, Int_t ww, Int_t wh)
Create canvas and put it to vector of TCanvases. Canvases created with this function will be automati...
Definition CbmReport.cxx:94
const std::string & GetOutputDir() const
Definition CbmReport.h:76
void Draw(Option_t *)
Inherited from TObject. This method is implemented in order to avoid warnings.
Definition CbmReport.h:97
virtual void Create()=0
Pure abstract function which is called from public Create() function. This function has to write repo...