![]() |
Q2NS dev
ns-3 module
|
Lightweight handle for one qubit inside a registry-managed state. More...
#include <q2ns-qubit.h>
Public Member Functions | |
| Qubit (QStateRegistry ®istry, StateId stateId, unsigned int index, std::string label="") | |
| Construct a qubit handle bound to a registry, state id, and index. | |
| QubitId | GetQubitId () const |
| Get the stable qubit id. | |
| StateId | GetStateId () const |
| Get the current backend state id. | |
| unsigned int | GetIndexInState () const |
| Get the current index within the backend state. | |
| const std::string & | GetLabel () const |
| Get the application-level label. | |
| void | SetLabel (std::string label) |
| Set the application-level label. | |
| Location | GetLocation () const |
| Return the registry-tracked current location of this qubit. | |
Private Member Functions | |
| void | SetQubitId (QubitId id) |
| Assign the stable qubit id. | |
| void | SetStateId (StateId stateId) |
| Update the current backend state id. | |
| void | SetIndexInState (unsigned int index) |
| Update the current index within the backend state. | |
| void | Rebind (StateId newStateId, std::size_t newIndex) |
| Rebind this handle to a different state id and index. | |
| void | SetLocationNode (uint32_t nodeId) |
| Mark this qubit as local to a node. | |
| void | SetLocationChannel (uint32_t channelId) |
| Mark this qubit as in transit on a channel. | |
| void | SetLocationLost () |
| Mark this qubit as lost. | |
Private Attributes | |
| QStateRegistry & | registry_ |
| Backing state registry. | |
| QubitId | qubitId_ {0} |
| Stable qubit id assigned by the registry. | |
| StateId | stateId_ {0} |
| Current backend state id. | |
| unsigned int | indexInState_ {} |
| Current zero-based index within the state. | |
| std::string | label_ |
| Optional human-readable label. | |
Friends | |
| class | QStateRegistry |
| class | QProcessor |
| class | QNetworker |
| class | QMap |
Lightweight handle for one qubit inside a registry-managed state.
Qubit does not own the underlying QState. Instead, it stores:
Resolution of the underlying backend state and tracked location is performed through QStateRegistry.
Qubit is intentionally a lightweight handle object. Most user-facing operations are performed through QNode rather than directly through Qubit.
Definition at line 48 of file q2ns-qubit.h.
| q2ns::Qubit::Qubit | ( | QStateRegistry & | registry, |
| StateId | stateId, | ||
| unsigned int | index, | ||
| std::string | label = "" |
||
| ) |
Construct a qubit handle bound to a registry, state id, and index.
The stable qubit id is assigned later by QStateRegistry::Register().
| registry | Backing state registry. |
| stateId | Current backend state id. |
| index | Index within that backend state. |
| label | Optional human-readable qubit label. |
Definition at line 29 of file q2ns-qubit.cc.
| unsigned int q2ns::Qubit::GetIndexInState | ( | ) | const |
Get the current index within the backend state.
Definition at line 60 of file q2ns-qubit.cc.
References indexInState_.
| const std::string & q2ns::Qubit::GetLabel | ( | ) | const |
Get the application-level label.
Definition at line 72 of file q2ns-qubit.cc.
References label_.
| Location q2ns::Qubit::GetLocation | ( | ) | const |
Return the registry-tracked current location of this qubit.
Definition at line 84 of file q2ns-qubit.cc.
References q2ns::QStateRegistry::GetLocation(), qubitId_, and registry_.
| QubitId q2ns::Qubit::GetQubitId | ( | ) | const |
Get the stable qubit id.
Definition at line 36 of file q2ns-qubit.cc.
References qubitId_.
| StateId q2ns::Qubit::GetStateId | ( | ) | const |
Get the current backend state id.
Definition at line 48 of file q2ns-qubit.cc.
References stateId_.
|
private |
Rebind this handle to a different state id and index.
This is an internal helper used during state rewrites such as merging or splitting.
| newStateId | New backend state id. |
| newIndex | New zero-based in-state index. |
Definition at line 120 of file q2ns-qubit.cc.
References indexInState_, and stateId_.
|
private |
Update the current index within the backend state.
| index | New zero-based in-state index. |
Definition at line 66 of file q2ns-qubit.cc.
References indexInState_.
| void q2ns::Qubit::SetLabel | ( | std::string | label | ) |
Set the application-level label.
| label | New label string. |
Definition at line 78 of file q2ns-qubit.cc.
References label_.
|
private |
Mark this qubit as in transit on a channel.
| channelId | Channel id. |
Definition at line 102 of file q2ns-qubit.cc.
References q2ns::Channel, q2ns::QStateRegistry::GetLocation(), q2ns::Lost, qubitId_, registry_, and q2ns::QStateRegistry::SetLocation().
|
private |
Mark this qubit as lost.
Definition at line 114 of file q2ns-qubit.cc.
References q2ns::Lost, registry_, and q2ns::QStateRegistry::SetLocation().
Referenced by q2ns::QMap::SetLost_().
|
private |
Mark this qubit as local to a node.
| nodeId | Owning node id. |
Definition at line 90 of file q2ns-qubit.cc.
References q2ns::QStateRegistry::GetLocation(), q2ns::Lost, q2ns::Node, qubitId_, registry_, and q2ns::QStateRegistry::SetLocation().
|
private |
Assign the stable qubit id.
| id | Stable qubit id. |
Definition at line 42 of file q2ns-qubit.cc.
References qubitId_.
|
private |
Update the current backend state id.
| stateId | New state id. |
Definition at line 54 of file q2ns-qubit.cc.
References stateId_.
|
friend |
Definition at line 163 of file q2ns-qubit.h.
|
friend |
Definition at line 162 of file q2ns-qubit.h.
|
friend |
Definition at line 161 of file q2ns-qubit.h.
|
friend |
Definition at line 160 of file q2ns-qubit.h.
|
private |
Current zero-based index within the state.
Definition at line 157 of file q2ns-qubit.h.
Referenced by GetIndexInState(), Rebind(), and SetIndexInState().
|
private |
Optional human-readable label.
Definition at line 158 of file q2ns-qubit.h.
Referenced by GetLabel(), and SetLabel().
|
private |
Stable qubit id assigned by the registry.
Definition at line 155 of file q2ns-qubit.h.
Referenced by GetLocation(), GetQubitId(), SetLocationChannel(), SetLocationNode(), and SetQubitId().
|
private |
Backing state registry.
Definition at line 153 of file q2ns-qubit.h.
Referenced by GetLocation(), SetLocationChannel(), SetLocationLost(), and SetLocationNode().
|
private |
Current backend state id.
Definition at line 156 of file q2ns-qubit.h.
Referenced by GetStateId(), Rebind(), and SetStateId().