OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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 
29 public:
30 
31  TraceComponent(std::string name) : name_(name)
32  {}
33 
35  {}
36 
37  virtual void execute(std::ostringstream &dump) = 0;
38 
39  void prepend(std::ostringstream &dump, std::ostringstream &prepender) {
40 
41  prepender << dump.str();
42  dump.str("");
43  dump.clear();
44  dump << prepender.str();
45  }
46 
47  void prepend(std::ostringstream &dump, std::string prepender) {
48 
49  std::ostringstream tmp;
50  tmp << prepender << dump.str();
51  dump.str("");
52  dump.clear();
53  dump << tmp.str();
54  }
55 
56 private:
57 
58  std::string name_;
59 
60 };
61 
62 #endif
const std::string name
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)