Maestro 0.3.1
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Network/Configuration.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#ifndef _NETWORK_CONFIGURATION_H_
13#define _NETWORK_CONFIGURATION_H_
14
15#include "Network.h"
17
18namespace Network {
19
20template <typename Time = Types::time_type>
22 public:
28 Configuration() = default;
29
35 virtual ~Configuration() = default;
36
42 Configuration(const Configuration&) = default;
43
50
57
64
73 void SetConfiguration(const std::string& key, const std::string& value) {
74 simulatorConfig.SetConfiguration(key, value);
75 }
76
77 void SetConfiguration(const std::string& key, long long int value) {
78 simulatorConfig.SetConfiguration(key, value);
79 }
80
81 void SetConfiguration(const std::string& key, double value) {
82 simulatorConfig.SetConfiguration(key, value);
83 }
84
93 bool IsSet(const std::string& key) const { return simulatorConfig.IsSet(key); }
94
103 std::string GetConfiguration(const std::string& key) const {
104 return simulatorConfig.GetConfiguration(key);
105 }
106
107 long long int GetConfigurationAsInt(const std::string& key) const {
108 return simulatorConfig.GetConfigurationAsInt(key);
109 }
110
111 double GetConfigurationAsDouble(const std::string& key) const {
112 return simulatorConfig.GetConfigurationAsDouble(key);
113 }
114
115 bool CanBeAppliedOnInitializedSimulator(const std::string& key) const {
116 return simulatorConfig.CanBeAppliedOnInitializedSimulator(key);
117 }
118
120 simulatorConfig = config;
121 }
122
124 const std::shared_ptr<Simulators::IState>& simulator) const {
125 simulatorConfig.ApplyConfigurationToSimulator(simulator);
126 }
127
129 const std::shared_ptr<Simulators::IState>& simulator) {
130 simulatorConfig.ApplyConfigurationFromSimulator(simulator);
131 }
132
134 const std::shared_ptr<INetwork<Time>>& network) {
135 if (!network) return;
136 ApplyConfigurationFromMap(network->GetConfigMap());
137 }
138
140 const std::shared_ptr<INetwork<Time>>& network) const {
141 for (const auto& [key, value] : simulatorConfig.GetConfigMap())
142 network->Configure(key.c_str(), value.c_str());
143 }
144
145 const std::unordered_map<std::string, std::string>& GetConfigMap() const {
146 return simulatorConfig.GetConfigMap();
147 }
148
149 bool WasApplied(const std::string& key, const std::string& value) const {
150 return simulatorConfig.WasApplied(key, value);
151 }
152
153 private:
155 simulatorConfig;
156};
157
158}
159
160#endif
std::string GetConfiguration(const std::string &key) const
Get a configuration value.
void SetSimulatorConfiguration(const Simulators::Configuration &config)
void ApplyConfigurationFromSimulator(const std::shared_ptr< Simulators::IState > &simulator)
bool IsSet(const std::string &key) const
Check if a configuration value is set.
virtual ~Configuration()=default
The destructor.
void SetConfiguration(const std::string &key, long long int value)
Configuration & operator=(Configuration &&)=default
The move assignment operator.
bool CanBeAppliedOnInitializedSimulator(const std::string &key) const
Configuration(const Configuration &)=default
The copy constructor.
void ApplyConfigurationFromNetwork(const std::shared_ptr< INetwork< Time > > &network)
double GetConfigurationAsDouble(const std::string &key) const
Configuration()=default
The constructor.
long long int GetConfigurationAsInt(const std::string &key) const
void ApplyConfigurationToSimulator(const std::shared_ptr< Simulators::IState > &simulator) const
void ApplyConfigurationToNetwork(const std::shared_ptr< INetwork< Time > > &network) const
bool WasApplied(const std::string &key, const std::string &value) const
Configuration & operator=(const Configuration &)=default
The copy assignment operator.
Configuration(Configuration &&)=default
The move constructor.
const std::unordered_map< std::string, std::string > & GetConfigMap() const
void SetConfiguration(const std::string &key, double value)
void SetConfiguration(const std::string &key, const std::string &value)
Set a configuration value.
The network interface.
Definition Network.h:58