BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Result.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef COMPRESULT_H
19#define COMPRESULT_H
20
21#include <ostream>
22#include <sstream>
23#include <string>
24
35class Result
36{
37public:
38 Result(std::string nameIn, std::string objTypeIn):
39 name(nameIn),
40 objtype(objTypeIn),
41 passed(true)
42 {;}
43
44 Result():
45 name(""),
46 objtype(""),
47 passed(true)
48 {;}
49
50 virtual ~Result() {}
51
52 std::string name;
53 std::string objtype;
54 bool passed;
55
57 virtual std::string print() const
58 {
59 std::stringstream ss;
60 ss << "Comparison of \"" << name << "\" of type " << objtype << " ";
61 passed ? ss<<"Passed" : ss<<"Failed";
62 ss << "\n";
63 return ss.str();
64 }
65
67 friend std::ostream& operator<<(std::ostream &ostr, const Result& rhs)
68 {
69 ostr << rhs.print();
70 return ostr;
71 }
72};
73
74#endif
Base class of a result.
Definition Result.hh:36
friend std::ostream & operator<<(std::ostream &ostr, const Result &rhs)
Overload ostream for easy printing.
Definition Result.hh:67
virtual std::string print() const
Print the result of the test - ie information store in the class.
Definition Result.hh:57
std::string name
Name of object being compared in files.
Definition Result.hh:52
bool passed
Whether it passed or not.
Definition Result.hh:54
std::string objtype
Name of class of object being compared in files.
Definition Result.hh:53
virtual ~Result()
Virtual destructor.
Definition Result.hh:50