14#include "ns3/q2ns-qnode.h"
16#include "ns3/q2ns-qnet-device.h"
17#include "ns3/q2ns-qstate-registry.h"
18#include "ns3/q2ns-qstate.h"
19#include "ns3/q2ns-qubit.h"
25NS_OBJECT_ENSURE_REGISTERED(QNode);
28 static ns3::TypeId tid = ns3::TypeId(
"q2ns::QNode").SetParent<ns3::Node>().SetGroupName(
"q2ns");
35 : registry_(registry), processor_(std::make_unique<
QProcessor>(registry_, *this)),
36 networker_(std::make_unique<
QNetworker>(*this)) {}
53 ns3::Node::AddDevice(device);
57 if (
auto qdev = ns3::DynamicCast<q2ns::QNetDevice>(device)) {
72 const std::string& label) {
127 const std::shared_ptr<Qubit>& b) {
134 return networker_->Send(std::move(q), dstNodeId);
Lightweight gate descriptor used by QState backends.
Internal helper owned by QNode for node-local quantum networking.
std::pair< std::shared_ptr< Qubit >, std::shared_ptr< Qubit > > CreateBellPair()
Create a local Bell pair in the |Phi+> state.
int Measure(const std::shared_ptr< Qubit > &q, q2ns::Basis basis=q2ns::Basis::Z)
Measure a local qubit in the given basis.
std::shared_ptr< QState > GetState(const std::shared_ptr< Qubit > &q)
Get the current backend state of a qubit.
QNode(QStateRegistry ®istry)
Construct a node bound to a shared state registry.
~QNode() override
Destructor.
std::shared_ptr< Qubit > GetQubit(const std::string &label) const
Lookup a local qubit by application label.
static ns3::TypeId GetTypeId(void)
Get the ns-3 TypeId.
void AddDevice(ns3::Ptr< ns3::NetDevice > device)
Register a device with this node.
void SetRecvCallback(RecvCallback cb)
Set the application-level receive callback.
bool Send(std::shared_ptr< Qubit > q, uint32_t dstNodeId)
Send a qubit toward a destination node.
std::unique_ptr< QProcessor > processor_
Internal local quantum processor.
void AddRoute(uint32_t dstNodeId, uint32_t oif)
Add or replace a simple host route for quantum transmission.
std::unique_ptr< QNetworker > networker_
Internal networking component.
std::shared_ptr< Qubit > CreateQubit(const std::string &label="")
Create a new local qubit initialized in the |0> state.
std::pair< int, int > MeasureBell(const std::shared_ptr< Qubit > &a, const std::shared_ptr< Qubit > &b)
Perform a Bell-state measurement on two local qubits.
std::vector< std::shared_ptr< Qubit > > GetLocalQubits() const
Return the qubits currently located at this node.
void AdoptQubit(const std::shared_ptr< Qubit > &q)
Mark a qubit as local to this node.
bool Apply(const QGate &gate, const std::vector< std::shared_ptr< Qubit > > &qs)
Apply a gate to one or more local qubits.
Internal helper owned by a QNode to handle local quantum operations.
Internal registry that owns backend states and tracks qubit membership and location.
ns3::Callback< void, std::shared_ptr< Qubit > > RecvCallback
Callback invoked when a qubit is successfully received at a node.
std::uint64_t QubitId
Stable identifier for a registered qubit handle.
Eigen::MatrixXcd Matrix
Dynamic complex matrix type used for custom gates and matrix-based states.
Basis
Measurement basis for single-qubit projective measurement.
QGate Custom(const Matrix &U, ns3::Time d=ns3::Seconds(0))
Return a custom gate descriptor by copying a matrix.
Declares q2ns::QNetworker, an internal per-node networking component for quantum transmission and rec...
Declares q2ns::QProcessor, a per-node processor that handles local quantum state operations.