pflib v2.7.0-1-gd371ab6a
Polarfire Interaction Library
DetectorConfiguration.h
1#ifndef PFLIB_DETECTORCONFIGURATION_H
2#define PFLIB_DETECTORCONFIGURATION_H
3
4#include <string>
5#include <map>
6#include <vector>
7#include <memory>
8#include <functional>
9
10#include "pflib/Exception.h"
11
12namespace YAML {
13class Node;
14}
15
16namespace pflib {
17class PolarfireTarget;
18namespace detail {
19
28 public:
29 PolarfireSetting() = default;
30 virtual ~PolarfireSetting() = default;
32 virtual void import(YAML::Node val) = 0;
34 virtual void execute(PolarfireTarget* pft) = 0;
36 virtual void stream(std::ostream& s) = 0;
41 class Factory {
42 public:
43 static Factory& get() {
44 static Factory the_factory;
45 return the_factory;
46 }
47 template<typename DerivedType>
48 uint64_t declare(const std::string& name) {
49 library_[name] = &maker<DerivedType>;
50 return reinterpret_cast<std::uintptr_t>(&library_);
51 }
52 std::unique_ptr<PolarfireSetting> make(const std::string& full_name) {
53 auto lib_it{library_.find(full_name)};
54 if (lib_it == library_.end()) {
55 PFEXCEPTION_RAISE("BadFormat", "Unrecognized setting "+full_name);
56 }
57 return lib_it->second();
58 }
59 Factory(Factory const&) = delete;
60 void operator=(Factory const&) = delete;
61 private:
62 template <typename DerivedType>
64 return std::make_unique<DerivedType>();
65 }
66 Factory() = default;
68 }; // Factory
69}; // PolarfireSetting
70} // namespace detail
71
80 std::map<int, // roc index on this polarfire
82 std::string, // page
84 std::string, // parameter
85 int // value
86 >>> hgcrocs_;
87 void import(YAML::Node conf);
88 void apply(const std::string& host);
89 };
91 public:
96
102 void apply();
103
107 void stream(std::ostream& s) const;
108};
109}
110
112
113#endif
object for parsing a detector configuration file and (potentially) executing it
Definition: DetectorConfiguration.h:76
DetectorConfiguration(const std::string &config)
Parse the input file loading into us.
Definition: DetectorConfiguration.cxx:143
void apply()
apply the configuration to the detector, we need access to all the wishbones, so make sure no other i...
Definition: DetectorConfiguration.cxx:205
void stream(std::ostream &s) const
Print out the detector configuration for debugging purposes.
Definition: DetectorConfiguration.cxx:211
The object that can construct new polarfire settings given the name of the setting.
Definition: DetectorConfiguration.h:41
Object that can change a setting on a polarfire target.
Definition: DetectorConfiguration.h:27
virtual void execute(PolarfireTarget *pft)=0
apply the setting to the passed polarfire target
virtual void stream(std::ostream &s)=0
print the setting
Polarfire Interaction Library.
Definition: Backend.h:8
Definition: DetectorConfiguration.h:77
Interface to a single polarfire.
Definition: PolarfireTarget.h:33