31 void AddResult(std::shared_ptr<Result> result);
34 void Merge(std::shared_ptr<ResultGroup> subGroup);
38 template <
typename R,
typename... Args>
39 std::shared_ptr<R>
BookResult(
const TString &name,
const TString &fname =
"", Args &&...args);
41 std::shared_ptr<R>
Get(
const TString &name);
44 std::map<TString, std::shared_ptr<Result>>
ResultMap;
47 std::shared_ptr<MSGTool>
msg;
57 template <
typename R,
typename... Args>
60 static_assert(!std::is_pointer<R>::value,
"class ResultGroup: Can not book result in pointer type");
61 static_assert(std::is_base_of<Result, R>::value,
"class ResulGroup: Input type must be or be inherited from Result class");
63 auto result = std::make_shared<R>(
msg,
config, rname, fname, std::forward<Args>(args)...);
67 msg->StartTitle(
"ResultGroup::BookResult");
68 msg->MSG(
MSGLevel::WARNING,
"Result ", rname,
" already exists, this book will be ignored and return null");
74 ResultMap.emplace(std::pair<TString, std::shared_ptr<Result>>(rname, std::dynamic_pointer_cast<R>(result)));
87 static_assert(!std::is_pointer<R>::value,
"class ResultGroup: Can not book result in pointer type");
88 static_assert(std::is_base_of<Result, R>::value,
"class ResultGroup: Input type must be or be inherited from Result class");
90 auto titleguard =
msg->StartTitleWithGuard(
"ResultGroup::Get");
91 std::shared_ptr<R> result =
nullptr;
94 result = std::dynamic_pointer_cast<R>(findresult->second);
95 if (result ==
nullptr)
Used to manipulate a group of Result objects., especially inside NAGASH::Job.
void Merge(std::shared_ptr< ResultGroup > subGroup)
Merge two ResultGroup into one.
std::map< TString, std::shared_ptr< Result > > ResultMap
void Write()
Write all the results inside, i.e. call Result::WriteToFile() for each result.
std::shared_ptr< ConfigTool > config
std::shared_ptr< MSGTool > msg
ResultGroup(std::shared_ptr< MSGTool > MSG, std::shared_ptr< ConfigTool > c)
Constructor.
std::shared_ptr< R > Get(const TString &name)
Get the result with the given name. If the given name is not find, the search will turn to fuzzy sear...
std::shared_ptr< R > BookResult(const TString &name, const TString &fname="", Args &&...args)
Book a result in this ResultGroup.
void AddResult(std::shared_ptr< Result > result)
Add a result to the group.