OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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 
29 #include "boost/smart_ptr.hpp"
30 
32 
33 class Trace {
34 
35 public:
36 
37  Trace(std::string name)
38  : name_(name)
39  {}
40 
42  {}
43 
44  void registerComponent(std::string name,
45  boost::shared_ptr<TraceComponent> component) {
46  nameToIdx_.insert(
47  std::pair<std::string, size_t>(name, pipeline_.size()));
48  pipeline_.push_back(component);
49  }
50 
51  void unregisterComponent(std::string /*name*/) {
52  //TODO: set null @ idx
53  }
54 
55  void log(std::ostringstream &dump) {
56  for(boost::shared_ptr<TraceComponent> component : pipeline_) {
57  component->execute(dump);
58  }
59  }
60 
61 private:
62 
63  std::string name_;
64 
65  std::vector< boost::shared_ptr<TraceComponent> > pipeline_;
66  std::map< std::string, size_t > nameToIdx_;
67 
68 };
69 
70 #endif
const std::string name
Definition: Trace.h:33
std::vector< boost::shared_ptr< TraceComponent > > pipeline_
Definition: Trace.h:65
std::string name_
Definition: Trace.h:63
void log(std::ostringstream &dump)
Definition: Trace.h:55
Trace(std::string name)
Definition: Trace.h:37
~Trace()
Definition: Trace.h:41
void registerComponent(std::string name, boost::shared_ptr< TraceComponent > component)
Definition: Trace.h:44
std::map< std::string, size_t > nameToIdx_
Definition: Trace.h:66
void unregisterComponent(std::string)
Definition: Trace.h:51