Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
SimulatorObserver.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#ifndef _SIMULATOR_OBSERVER_H_
15#define _SIMULATOR_OBSERVER_H_
16
17#include <memory>
18#include <vector>
19
20#include "../Types.h"
21
22namespace Simulators {
23
33// either derive from this or use the following proxy class (advantage for that:
34// no need to derive the Impl class from the interface, just implement 'Update')
36 : public std::enable_shared_from_this<ISimulatorObserver> {
37public:
43 virtual ~ISimulatorObserver() = default;
44
52 virtual void Update(const Types::qubits_vector &qubits) = 0;
53
61 std::shared_ptr<ISimulatorObserver> getptr() { return shared_from_this(); }
62};
63
76template <class Impl> class SimulatorObserverProxy : public ISimulatorObserver {
77public:
85 SimulatorObserverProxy(const std::shared_ptr<Impl> &impl) : impl(impl) {}
86
94 void Update(const Types::qubits_vector &qubits) override {
95 if (impl)
96 impl->Update(qubits);
97 }
98
99private:
100 std::shared_ptr<Impl>
101 impl;
102};
103
104} // namespace Simulators
105
106#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.
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
Definition Types.h:21