Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
PackageTable.cxx
1/*
2 * PackageTable.cxx
3 *
4 * Created on: 22 cze 2023
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "PackageTable.h"
11#include "HtmlCore.h"
12#include "HtmlFile.h"
13#include "HtmlObject.h"
14#include "HtmlTable.h"
15#include "Parameter.h"
16
17#include "Cout.h"
18#include "Std.h"
19
20#include <initializer_list>
21#include <iostream>
22#include <vector>
23
24#include <RtypesCore.h>
25#include <TString.h>
26#include <TSystem.h>
27
28namespace Hal {
29
30 PackageTable::PackageTable(std::initializer_list<TString> list) {
31 auto vec = Std::GetVector(list);
32 fArray.push_back(vec);
33 }
34
35 void PackageTable::AddRow(std::initializer_list<TString> list) {
36 auto vec = Std::GetVector(list);
37 if (fArray.size() > 0) {
38 if (fArray[0].size() != vec.size()) {
39 std::cout << "Cannot add row" << __FILE__ << " " << __LINE__ << std::endl;
40 return;
41 }
42 }
43 fArray.push_back(vec);
44 }
45
46 TString PackageTable::GetExtractType() const { return "Page"; }
47
48 TString PackageTable::HTMLExtract(Int_t no, TString path) const {
49 path = Form("%s/ptable_%i", path.Data(), no);
50 gSystem->mkdir(path);
51 HtmlFile F(Form("%s/ptable.html", path.Data()), kFALSE);
52 HtmlTable table;
53 table.SetDefaultClass();
54
55 for (unsigned int i = 0; i < fArray.size(); i++) {
56 auto vec = fArray[i];
57 HtmlRow row;
58 TString style = HtmlTableRowClass::LightBlue();
59 if (i == 0) { style = HtmlTableRowClass::DarkBlue(); }
60 for (unsigned int j = 0; j < vec.size(); j++) {
61 auto rec = vec[j];
62 HtmlCell cell;
63 cell.SetStringContent(rec);
64 row.AddContent(cell);
65 }
66 row.SetClass(style);
67 table.AddContent(row);
68 }
69 F.AddContent(table);
70 F.Save();
71 return HtmlCore::GetUrl(Form("ptable_%i/ptable.html", no), ClassName());
72 }
73
74 Long64_t PackageTable::Merge(TCollection* collection) {
75 if (collection) {
76 PackageTable* pack = NULL;
77 TIter iterator(collection);
78 while ((pack = (PackageTable*) iterator())) {
79 if (pack->fArray.size() != this->fArray.size()) {
80 Cout::PrintInfo("Different Y-size of PackageTable!", EInfo::kError);
81 return 1;
82 }
83 for (unsigned int i = 0; i < fArray.size(); i++) {
84 if (fArray[i].size() != pack->fArray[i].size()) {
85 Cout::PrintInfo("Different X-size of PackageTable!", EInfo::kError);
86 return 1;
87 }
88 for (unsigned int j = 0; j < fArray[i].size(); j++) {
89 auto str = fArray[i][j];
90 auto str2 = pack->fArray[i][j];
91 if (!str.EqualTo(str2)) { Cout::PrintInfo(Form("Different content of PackageTable [%i,%i]!", i, j), EInfo::kError); }
92 }
93 }
94 }
95 }
96
97 return 1;
98 }
99
100} // namespace Hal
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
static TString GetUrl(TString adress, TString text)
Definition HtmlCore.cxx:164
void SetClass(TString className)
Definition HtmlObject.h:40
virtual void AddContent(const HtmlObject &obj)
Definition HtmlTable.cxx:29
void SetDefaultClass()
Definition HtmlTable.h:40
virtual void AddContent(const HtmlObject &obj)
Definition HtmlTable.cxx:17
virtual TString HTMLExtract(Int_t no, TString path) const
virtual TString GetExtractType() const
Long64_t Merge(TCollection *collection)