Maestro 0.3.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
SimulatorObserver.h
Go to the documentation of this file.
1
12
13#pragma once
14
15#ifndef _SIMULATOR_OBSERVER_H_
16#define _SIMULATOR_OBSERVER_H_
17
18#include <memory>
19#include <vector>
20
21#include "../../Types.h"
22
23namespace Simulators
24{
25
35// either derive from this or use the following proxy class (advantage for that:
36// no need to derive the Impl class from the interface, just implement 'Update')
37class ISimulatorObserver : public std::enable_shared_from_this<ISimulatorObserver>
38{
39 public:
45 virtual ~ISimulatorObserver() = default;
46
54 virtual void Update(const Types::qubits_vector &qubits) = 0;
55
63 std::shared_ptr<ISimulatorObserver> getptr()
64 {
65 return shared_from_this();
66 }
67};
68
81template <class Impl> class SimulatorObserverProxy : public ISimulatorObserver
82{
83 public:
91 SimulatorObserverProxy(const std::shared_ptr<Impl> &impl) : impl(impl)
92 {
93 }
94
102 void Update(const Types::qubits_vector &qubits) override
103 {
104 if (impl)
105 impl->Update(qubits);
106 }
107
108 private:
109 std::shared_ptr<Impl> impl;
110};
111
112} // namespace Simulators
113
114#endif // _SIMULATOR_OBSERVER_H_
Interface class for a quantum computing simulator observer.
virtual void Update(const Types::qubits_vector &qubits)=0
Update function that is called each time an update is done.
std::shared_ptr< ISimulatorObserver > getptr()
Get a shared pointer to this object.
virtual ~ISimulatorObserver()=default
Virtual destructor.
SimulatorObserverProxy(const std::shared_ptr< Impl > &impl)
Constructor.
void Update(const Types::qubits_vector &qubits) override
Update function that is called each time an update is done.
Bounded online routing based on current physical bond dimensions.
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
Definition Types.h:24