DQCsim
Public Member Functions | Static Public Member Functions | List of all members
dqcsim::wrap::MeasurementSet Class Reference

Represents a set of measurements. More...

Inheritance diagram for dqcsim::wrap::MeasurementSet:
dqcsim::wrap::Handle

Public Member Functions

 MeasurementSet (HandleIndex handle) noexcept
 Wraps the given measurement set handle. More...
 
 MeasurementSet ()
 Constructs an empty measurement set.
 
void set (Measurement &&measurement)
 Moves the given measurement object into the set. More...
 
void set (const Measurement &measurement)
 Copies the given measurement object into the set. More...
 
MeasurementSet && with (Measurement &&measurement)
 Moves the given measurement object into the set (builder pattern). More...
 
MeasurementSet && with (const Measurement &measurement)
 Copies the given measurement object into the set (builder pattern). More...
 
Measurement get (const QubitRef &qubit) const
 Returns a copy of the measurement object for the given qubit. More...
 
Measurement take (const QubitRef &qubit)
 Moves the measurement object for the given qubit out of the set. More...
 
Measurement take_any ()
 Moves any measurement object out of the set. More...
 
void remove (const QubitRef &qubit)
 Removes the measurement object for the given qubit from the set. More...
 
size_t size () const
 Returns the number of measurements in the set. More...
 
bool contains (const QubitRef &qubit) const
 Returns whether the set contains measurement data for the given qubit. More...
 
std::vector< Measurementdrain_into_vector ()
 Drains the measurement set into a vector. More...
 
std::vector< Measurementcopy_into_vector ()
 Copies the qubit set into a vector. More...
 
 MeasurementSet (MeasurementSet &src)
 Copy-constructs a measurement set object. More...
 
MeasurementSetoperator= (MeasurementSet &src)
 Copy-assigns a measurement set object. More...
 
 MeasurementSet (MeasurementSet &&handle)=default
 Default move constructor.
 
MeasurementSetoperator= (MeasurementSet &&)=default
 Default move assignment.
 
- Public Member Functions inherited from dqcsim::wrap::Handle
 Handle () noexcept
 Constructs an empty wrapper. More...
 
 Handle (HandleIndex handle) noexcept
 Wraps the given raw handle. More...
 
virtual ~Handle () noexcept
 Delete the handle and its wrapper.
 
void free ()
 Explicitly delete the handle, allowing errors to be caught. More...
 
bool is_valid () const noexcept
 Returns whether this wrapper (still) contains a valid handle. More...
 
HandleIndex get_handle () const noexcept
 Returns the raw handle without relinquishing ownership. More...
 
HandleIndex take_handle () noexcept
 Returns the raw handle and relinquishes ownership. More...
 
 Handle (const Handle &)=delete
 
void operator= (const Handle &)=delete
 
 Handle (Handle &&src)
 Move constructor; simply moves ownership of the handle from the source object to the constructed object. More...
 
Handleoperator= (Handle &&src)
 Move constructor; simply moves ownership of the handle from the source object to the assignment target. More...
 
std::string dump () const
 Returns a string containing a debug dump of the handle. More...
 
HandleType type () const
 Returns the type of this handle. More...
 

Static Public Member Functions

template<class T >
static MeasurementSet from_iter (const T &measurements)
 Constructs a measurement set object from an iterable of measurements. More...
 

Additional Inherited Members

- Protected Attributes inherited from dqcsim::wrap::Handle
HandleIndex handle
 The wrapped handle.
 

Detailed Description

Represents a set of measurements.

Measurement sets contain Measurement data for zero or more qubits.

Definition at line 5789 of file dqcsim.

Constructor & Destructor Documentation

◆ MeasurementSet() [1/2]

dqcsim::wrap::MeasurementSet::MeasurementSet ( HandleIndex  handle)
inlinenoexcept

Wraps the given measurement set handle.

Note
This constructor does not verify that the handle is actually valid.
Parameters
handleThe raw handle to wrap.

Definition at line 5800 of file dqcsim.

◆ MeasurementSet() [2/2]

dqcsim::wrap::MeasurementSet::MeasurementSet ( MeasurementSet src)
inline

Copy-constructs a measurement set object.

Note
This requires destructive iteration, so the function is not const; if an exception occurs, the state of the measurement set may be changed.
Parameters
srcThe object to be copied.
Exceptions
std::runtime_errorWhen the src handle is invalid or construction of the new measurement set object fails for some reason.

Definition at line 6011 of file dqcsim.

Member Function Documentation

◆ from_iter()

template<class T >
static MeasurementSet dqcsim::wrap::MeasurementSet::from_iter ( const T &  measurements)
inlinestatic

Constructs a measurement set object from an iterable of measurements.

Parameters
measurementsAn object that can be iterated over, capable of yielding const Measurement&s.
Returns
The new measurement set.
Exceptions
std::runtime_errorWhen construction of the measurement set (handle) failed for some reason or any measurement handle within the measurements iterable is invalid.

Definition at line 5820 of file dqcsim.

◆ set() [1/2]

void dqcsim::wrap::MeasurementSet::set ( Measurement &&  measurement)
inline

Moves the given measurement object into the set.

If the set already contained measurement data for the qubit associated with the measurement object, the previous measurement data is overwritten.

Parameters
measurementThe measurement object to move into the set.
Exceptions
std::runtime_errorWhen the measurement handle or the current handle is invalid.

Definition at line 5837 of file dqcsim.

◆ set() [2/2]

void dqcsim::wrap::MeasurementSet::set ( const Measurement measurement)
inline

Copies the given measurement object into the set.

If the set already contained measurement data for the qubit associated with the measurement object, the previous measurement data is overwritten.

Parameters
measurementThe measurement object to copy into the set.
Exceptions
std::runtime_errorWhen the measurement handle or the current handle is invalid.

Definition at line 5850 of file dqcsim.

◆ with() [1/2]

MeasurementSet&& dqcsim::wrap::MeasurementSet::with ( Measurement &&  measurement)
inline

Moves the given measurement object into the set (builder pattern).

If the set already contained measurement data for the qubit associated with the measurement object, the previous measurement data is overwritten.

Parameters
measurementThe measurement object to move into the set.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the measurement handle or the current handle is invalid.

Definition at line 5864 of file dqcsim.

◆ with() [2/2]

MeasurementSet&& dqcsim::wrap::MeasurementSet::with ( const Measurement measurement)
inline

Copies the given measurement object into the set (builder pattern).

If the set already contained measurement data for the qubit associated with the measurement object, the previous measurement data is overwritten.

Parameters
measurementThe measurement object to copy into the set.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the measurement handle or the current handle is invalid.

Definition at line 5879 of file dqcsim.

◆ get()

Measurement dqcsim::wrap::MeasurementSet::get ( const QubitRef qubit) const
inline

Returns a copy of the measurement object for the given qubit.

Parameters
qubitA reference to the qubit to query the measurement result for.
Returns
The measurement result.
Exceptions
std::runtime_errorWhen the current handle is invalid, construction of the new measurement handle failed, or no measurement data is available for the requested qubit.

Definition at line 5894 of file dqcsim.

◆ take()

Measurement dqcsim::wrap::MeasurementSet::take ( const QubitRef qubit)
inline

Moves the measurement object for the given qubit out of the set.

An exception is thrown if no data is available for this qubit.

Parameters
qubitA reference to the qubit to query the measurement result for.
Returns
The measurement result.
Exceptions
std::runtime_errorWhen the current handle is invalid, construction of the new measurement handle failed, or no measurement data is available for the requested qubit.

Definition at line 5909 of file dqcsim.

◆ take_any()

Measurement dqcsim::wrap::MeasurementSet::take_any ( )
inline

Moves any measurement object out of the set.

An exception is thrown if the set is empty.

Returns
The measurement result for any qubit in the measurement result set.
Exceptions
std::runtime_errorWhen the current handle is invalid, it is empty, or construction of the new measurement handle failed.

Definition at line 5922 of file dqcsim.

◆ remove()

void dqcsim::wrap::MeasurementSet::remove ( const QubitRef qubit)
inline

Removes the measurement object for the given qubit from the set.

Parameters
qubitA reference to the qubit to query the measurement result for.
Exceptions
std::runtime_errorWhen the current handle is invalid, or no measurement data was available for the requested qubit.

Definition at line 5934 of file dqcsim.

◆ size()

size_t dqcsim::wrap::MeasurementSet::size ( ) const
inline

Returns the number of measurements in the set.

Returns
The number of measurements in the set.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 5944 of file dqcsim.

◆ contains()

bool dqcsim::wrap::MeasurementSet::contains ( const QubitRef qubit) const
inline

Returns whether the set contains measurement data for the given qubit.

Parameters
qubitA reference to the qubit to query the measurement result for.
Returns
Whether the set contains measurement data for the given qubit.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 5956 of file dqcsim.

◆ drain_into_vector()

std::vector<Measurement> dqcsim::wrap::MeasurementSet::drain_into_vector ( )
inline

Drains the measurement set into a vector.

That is, the measurement set object remains valid, but is emptied after this call.

Returns
A std::vector containing the individual measurement objects in arbitrary order.
Exceptions
std::runtime_errorWhen the current handle is invalid or construction of any of the individual measurement objects fails for some reason.

Definition at line 5972 of file dqcsim.

◆ copy_into_vector()

std::vector<Measurement> dqcsim::wrap::MeasurementSet::copy_into_vector ( )
inline

Copies the qubit set into a vector.

Note
This requires destructive iteration, so the function is not const; if an exception occurs, the state of the measurement set may be changed.
Returns
A std::vector containing the individual measurement objects in arbitrary order.
Exceptions
std::runtime_errorWhen the current handle is invalid or construction of any of the individual measurement objects fails for some reason.

Definition at line 5992 of file dqcsim.

◆ operator=()

MeasurementSet& dqcsim::wrap::MeasurementSet::operator= ( MeasurementSet src)
inline

Copy-assigns a measurement set object.

Note
This requires destructive iteration, so the function is not const; if an exception occurs, the state of the measurement set may be changed.
Parameters
srcThe object to be copied.
Exceptions
std::runtime_errorWhen the src handle or the current handle is invalid.

Definition at line 6025 of file dqcsim.


The documentation for this class was generated from the following file: