Maestro 0.2.5
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
SimulatorObserver.h
Go to the documentation of this file.
1
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
34// either derive from this or use the following proxy class (advantage for that:
35// no need to derive the Impl class from the interface, just implement 'Update')
37 : public std::enable_shared_from_this<ISimulatorObserver> {
38 public:
44 virtual ~ISimulatorObserver() = default;
45
53 virtual void Update(const Types::qubits_vector &qubits) = 0;
54
62 std::shared_ptr<ISimulatorObserver> getptr() { return shared_from_this(); }
63};
64
77template <class Impl>
79 public:
87 SimulatorObserverProxy(const std::shared_ptr<Impl> &impl) : impl(impl) {}
88
96 void Update(const Types::qubits_vector &qubits) override {
97 if (impl) impl->Update(qubits);
98 }
99
100 private:
101 std::shared_ptr<Impl>
102 impl;
103};
104
105} // namespace Simulators
106
107#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.
A proxy class for a quantum computing simulator observer.
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:23