NAGASH 0.9.8
Next Generation Analysis System
Loading...
Searching...
No Matches
ResultGroup.cxx
Go to the documentation of this file.
1//***************************************************************************************
4//***************************************************************************************
5
7
8using namespace NAGASH;
9using namespace std;
10
11void ResultGroup::AddResult(std::shared_ptr<Result> result)
12{
13 auto titlegurad = msg->StartTitleWithGuard("ResultGroup::AddResult");
14 if (result == nullptr)
15 {
16 msg->MSG_ERROR("Input result is NULL");
17 return;
18 }
19
20 auto name = result->GetResultName();
21 auto findresult = this->ResultMap.find(name);
22 if (findresult != this->ResultMap.end())
23 msg->MSG_WARNING("Result ", name, " already exists, this book will be ignored");
24 else
25 this->ResultMap.emplace(name, result);
26}
27
28void ResultGroup::Merge(std::shared_ptr<ResultGroup> subGroup)
29{
30 auto titlegurad = msg->StartTitleWithGuard("ResultGroup::Merge");
31 if (subGroup == nullptr)
32 {
33 msg->MSG_ERROR("Input sub ResultGroup is NULL");
34 return;
35 }
36
37 // if this ResultGroup is empty, just copy its info
38 if (this->ResultMap.size() == 0)
39 {
40 this->ResultMap = subGroup->ResultMap;
41 return;
42 }
43
44 for (auto &t : subGroup->ResultMap)
45 {
46 auto findresult = this->ResultMap.find(t.first);
47 if (findresult != this->ResultMap.end())
48 {
49 findresult->second->Combine(t.second);
50 }
51 else
52 {
53 this->ResultMap.emplace(std::pair<TString, std::shared_ptr<Result>>(t.first, t.second));
54 }
55 }
56}
57
59{
60 for (auto &t : ResultMap)
61 t.second->WriteToFile();
62}
void Merge(std::shared_ptr< ResultGroup > subGroup)
Merge two ResultGroup into one.
std::map< TString, std::shared_ptr< Result > > ResultMap
Definition ResultGroup.h:44
void Write()
Write all the results inside, i.e. call Result::WriteToFile() for each result.
std::shared_ptr< MSGTool > msg
Definition ResultGroup.h:47
void AddResult(std::shared_ptr< Result > result)
Add a result to the group.