OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
TraceComponent.h
Go to the documentation of this file.
1//
2// Class TraceComponent
3//
4// Copyright (c) 2010 - 2013, Yves Ineichen, ETH Zürich
5// All rights reserved
6//
7// Implemented as part of the PhD thesis
8// "Toward massively parallel multi-objective optimization with application to
9// particle accelerators" (https://doi.org/10.3929/ethz-a-009792359)
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
21#ifndef __TRACE_COMPONENT_H__
22#define __TRACE_COMPONENT_H__
23
24#include <string>
25#include <sstream>
26
28
29public:
30
31 TraceComponent(std::string name) : name_(name)
32 {}
33
34 virtual ~TraceComponent() = default;
35
36 virtual void execute(std::ostringstream &dump) = 0;
37
38 void prepend(std::ostringstream &dump, std::ostringstream &prepender) {
39
40 prepender << dump.str();
41 dump.str("");
42 dump.clear();
43 dump << prepender.str();
44 }
45
46 void prepend(std::ostringstream &dump, std::string prepender) {
47
48 std::ostringstream tmp;
49 tmp << prepender << dump.str();
50 dump.str("");
51 dump.clear();
52 dump << tmp.str();
53 }
54
55private:
56
57 std::string name_;
58
59};
60
61#endif
const std::string name
virtual ~TraceComponent()=default
std::string name_
virtual void execute(std::ostringstream &dump)=0
void prepend(std::ostringstream &dump, std::ostringstream &prepender)
void prepend(std::ostringstream &dump, std::string prepender)
TraceComponent(std::string name)