OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Trace.h
Go to the documentation of this file.
1//
2// Class Trace
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_H__
22#define __TRACE_H__
23
24#include <string>
25#include <sstream>
26#include <vector>
27#include <map>
28
30
31class Trace {
32
33public:
34
35 Trace(std::string name)
36 : name_(name)
37 {}
38
40 {}
41
42 void registerComponent(std::string name,
43 std::shared_ptr<TraceComponent> component) {
44 nameToIdx_.insert(
45 std::pair<std::string, size_t>(name, pipeline_.size()));
46 pipeline_.push_back(component);
47 }
48
49 void unregisterComponent(std::string /*name*/) {
50 //TODO: set null @ idx
51 }
52
53 void log(std::ostringstream &dump) {
54 for(std::shared_ptr<TraceComponent> component : pipeline_) {
55 component->execute(dump);
56 }
57 }
58
59private:
60
61 std::string name_;
62
63 std::vector< std::shared_ptr<TraceComponent> > pipeline_;
64 std::map< std::string, size_t > nameToIdx_;
65
66};
67
68#endif
const std::string name
std::string name_
Definition Trace.h:61
void log(std::ostringstream &dump)
Definition Trace.h:53
Trace(std::string name)
Definition Trace.h:35
~Trace()
Definition Trace.h:39
void registerComponent(std::string name, std::shared_ptr< TraceComponent > component)
Definition Trace.h:42
std::vector< std::shared_ptr< TraceComponent > > pipeline_
Definition Trace.h:63
std::map< std::string, size_t > nameToIdx_
Definition Trace.h:64
void unregisterComponent(std::string)
Definition Trace.h:49