Maestro 0.3.11
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
16#include "Network.h"
17
18namespace Network
19{
20
21template <typename Time = Types::time_type> class Configuration
22{
23 public:
29 Configuration() = default;
30
36 virtual ~Configuration() = default;
37
43 Configuration(const Configuration &) = default;
44
51
58
65
74 void SetConfiguration(const std::string &key, const std::string &value)
75 {
76 simulatorConfig.SetConfiguration(key, value);
77 }
78
79 void SetConfiguration(const std::string &key, long long int value)
80 {
81 simulatorConfig.SetConfiguration(key, value);
82 }
83
84 void SetConfiguration(const std::string &key, double value)
85 {
86 simulatorConfig.SetConfiguration(key, value);
87 }
88
97 bool IsSet(const std::string &key) const
98 {
99 return simulatorConfig.IsSet(key);
100 }
101
110 std::string GetConfiguration(const std::string &key) const
111 {
112 return simulatorConfig.GetConfiguration(key);
113 }
114
115 long long int GetConfigurationAsInt(const std::string &key) const
116 {
117 return simulatorConfig.GetConfigurationAsInt(key);
118 }
119
120 double GetConfigurationAsDouble(const std::string &key) const
121 {
122 return simulatorConfig.GetConfigurationAsDouble(key);
123 }
124
125 bool CanBeAppliedOnInitializedSimulator(const std::string &key) const
126 {
127 return simulatorConfig.CanBeAppliedOnInitializedSimulator(key);
128 }
129
131 {
132 simulatorConfig = config;
133 }
134
135 void ApplyConfigurationToSimulator(const std::shared_ptr<Simulators::IState> &simulator) const
136 {
137 simulatorConfig.ApplyConfigurationToSimulator(simulator);
138 }
139
140 void ApplyConfigurationFromSimulator(const std::shared_ptr<Simulators::IState> &simulator)
141 {
142 simulatorConfig.ApplyConfigurationFromSimulator(simulator);
143 }
144
145 void ApplyConfigurationFromNetwork(const std::shared_ptr<INetwork<Time>> &network)
146 {
147 if (!network)
148 return;
149 ApplyConfigurationFromMap(network->GetConfigMap());
150 }
151
152 void ApplyConfigurationToNetwork(const std::shared_ptr<INetwork<Time>> &network) const
153 {
154 for (const auto &[key, value] : simulatorConfig.GetConfigMap())
155 network->Configure(key.c_str(), value.c_str());
156 }
157
158 const std::unordered_map<std::string, std::string> &GetConfigMap() const
159 {
160 return simulatorConfig.GetConfigMap();
161 }
162
163 bool WasApplied(const std::string &key, const std::string &value) const
164 {
165 return simulatorConfig.WasApplied(key, value);
166 }
167
168 private:
169 Simulators::Configuration simulatorConfig;
170};
171
172} // namespace Network
173
174#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:60