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