CbmRoot
Loading...
Searching...
No Matches
CbmQaReportBuilder.h
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#pragma once
11
12#include "CbmQaReportDefines.h"
13#include "CbmQaReportEngine.h"
14#include "CbmQaReportHeader.h"
15#include "CbmQaReportSection.h"
16#include "CbmQaReportTail.h"
17
18class TCanvas;
19
20namespace cbm::qa::report
21{
24 class Builder {
25 public:
29 Builder(std::string_view title, fs::path outPath);
30
32 virtual ~Builder() = default;
33
35 void AddSection(std::shared_ptr<Section> pSection) { fvpSections.push_back(pSection); }
36
38 std::shared_ptr<Header> GetHeader() { return fpHeader; }
39
41 std::shared_ptr<Tail> GetTail() { return fpTail; }
42
46 void CreateScript(Engine& engine, bool bCompile = true);
47
50 std::string PathInSource(fs::path path) const { return fs::relative(path, fScriptsPath).string(); }
51
54 std::string AbsFigurePath(fs::path relPath) const { return (fFiguresPath / relPath).string(); }
55
61 std::string SaveCanvas(const TCanvas* canv, const std::string& relPath) const;
62
64 void SetFigureExtention(std::string_view figExtention) { fsFigureExtention = figExtention; }
65
66 private:
67 static constexpr std::string_view ksSourceName = "source";
68
69 std::vector<std::shared_ptr<Section>> fvpSections;
70 std::string fsFigureExtention = "pdf";
71 fs::path fScriptsPath;
72 fs::path fFiguresPath;
73 std::shared_ptr<Header> fpHeader = nullptr;
74 std::shared_ptr<Tail> fpTail = nullptr;
75 };
76} // namespace cbm::qa::report
Common definitions for cbm::qa::report.
Base class for the report header (header)
Base class for the report section (header)
std::string fsFigureExtention
Figure extention.
void CreateScript(Engine &engine, bool bCompile=true)
Saves script.
std::string SaveCanvas(const TCanvas *canv, const std::string &relPath) const
Saves canvas.
virtual ~Builder()=default
Destructor.
std::shared_ptr< Tail > GetTail()
Gets tail.
std::string AbsFigurePath(fs::path relPath) const
Returns absolute path to the figure.
fs::path fFiguresPath
Figures path.
std::shared_ptr< Header > GetHeader()
Gets header.
std::shared_ptr< Tail > fpTail
Tail of the report.
void AddSection(std::shared_ptr< Section > pSection)
Adds section.
fs::path fScriptsPath
Scripts path.
static constexpr std::string_view ksSourceName
Name of source.
std::vector< std::shared_ptr< Section > > fvpSections
List of report sections.
std::shared_ptr< Header > fpHeader
Header of the report.
void SetFigureExtention(std::string_view figExtention)
Sets figure extention.
Builder(std::string_view title, fs::path outPath)
Constructor.
std::string PathInSource(fs::path path) const
Converts path of the object in the code to one in the document source.
A base abstract class to provide an interface for element body (a visitor in the Visitor pattern)