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

Class wrapper for handles that support the arb interface. More...

Inheritance diagram for dqcsim::wrap::Arb:
dqcsim::wrap::Handle dqcsim::wrap::ArbData dqcsim::wrap::Cmd dqcsim::wrap::Gate dqcsim::wrap::Measurement dqcsim::wrap::ArbCmd dqcsim::wrap::ArbCmdQueue

Public Member Functions

 Arb (HandleIndex handle) noexcept
 Wraps the given arb handle. More...
 
std::string get_arb_json_string () const
 Returns the current arbitrary JSON data as a serialized JSON string. More...
 
void set_arb_json_string (const std::string &json)
 Sets the arbitrary JSON data to the given serialized JSON string. More...
 
std::string get_arb_cbor_string () const
 Returns the current arbitrary JSON data as a serialized CBOR string. More...
 
void set_arb_cbor_string (const std::string &cbor)
 Sets the arbitrary JSON data to the given serialized CBOR string. More...
 
template<class JSON >
JSON get_arb_json () const
 Returns the current arbitrary JSON data as a JSON object from nlohmann::json. More...
 
template<class JSON >
void set_arb_json (const JSON &json)
 Sets the arbitrary JSON data to the given JSON object from nlohmann::json. More...
 
std::string get_arb_arg_string (ssize_t index) const
 Returns the arbitrary argument at the given index as a (binary) string. More...
 
template<typename T >
get_arb_arg_as (ssize_t index) const
 Returns the arbitrary argument at the given index as the given type. More...
 
template<typename T >
void set_arb_arg_strings (const T &strings)
 Sets the arbitrary argument list to the given iterable of std::strings. More...
 
void set_arb_arg_string (ssize_t index, const std::string &data)
 Sets the arbitrary argument at the given index to a (binary) string. More...
 
template<typename T >
void set_arb_arg (ssize_t index, const T &data)
 Sets the arbitrary argument at the given index to a value of type T. More...
 
void push_arb_arg_string (const std::string &data)
 Pushes a (binary) string to the back of the arbitrary argument list. More...
 
template<typename T >
void push_arb_arg (const T &data)
 Pushes a value of type T to the back of the arbitrary argument list. More...
 
std::string pop_arb_arg_string ()
 Pops from the back of the arbitrary argument list as a (binary) string. More...
 
template<typename T >
pop_arb_arg_as () const
 Pops from the back of the arbitrary argument list as a value of type T. More...
 
void insert_arb_arg_string (ssize_t index, const std::string &data)
 Inserts an arbitrary argument at the given index using a (binary) string. More...
 
template<typename T >
void insert_arb_arg (ssize_t index, const T &data)
 Inserts an arbitrary argument at the given index using a value of type T. More...
 
void remove_arb_arg (ssize_t index)
 Removes the arbitrary argument at the given index. More...
 
size_t get_arb_arg_count () const
 Returns the number of arbitrary arguments. More...
 
void clear_arb_args ()
 Clears the arbitrary argument list. More...
 
void set_arb (const Arb &src)
 Assigns all arb data from the given arb to this one. More...
 
- 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...
 

Additional Inherited Members

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

Detailed Description

Class wrapper for handles that support the arb interface.

You normally wouldn't instantiate this directly (see ArbData).

Definition at line 1810 of file dqcsim.

Constructor & Destructor Documentation

◆ Arb()

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

Wraps the given arb handle.

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

Definition at line 1821 of file dqcsim.

Member Function Documentation

◆ get_arb_json_string()

std::string dqcsim::wrap::Arb::get_arb_json_string ( ) const
inline

Returns the current arbitrary JSON data as a serialized JSON string.

Returns
A string representation of the current JSON object.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 1830 of file dqcsim.

◆ set_arb_json_string()

void dqcsim::wrap::Arb::set_arb_json_string ( const std::string &  json)
inline

Sets the arbitrary JSON data to the given serialized JSON string.

Note
DQCsim internally stores the JSON object in CBOR format. Therefore, if after calling this you subsequently call get_arb_json_string() you may get a different string representation for the same JSON object.
Parameters
jsonA string representation of a JSON dictionary object.
Exceptions
std::runtime_errorWhen the string representation is invalid, or when the current handle is invalid.

Definition at line 1849 of file dqcsim.

◆ get_arb_cbor_string()

std::string dqcsim::wrap::Arb::get_arb_cbor_string ( ) const
inline

Returns the current arbitrary JSON data as a serialized CBOR string.

Note
A single JSON object may be represented with CBOR in many different ways, similar to how it may have different string representations (spacing, dictionary order, etc.). Therefore, never use a simple binary comparison on the CBOR object to check if two JSON objects are equivalent!
Returns
A CBOR string representing the current JSON object.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 1865 of file dqcsim.

◆ set_arb_cbor_string()

void dqcsim::wrap::Arb::set_arb_cbor_string ( const std::string &  cbor)
inline

Sets the arbitrary JSON data to the given serialized CBOR string.

Parameters
cborA JSON object represented as a CBOR binary string.
Exceptions
std::runtime_errorWhen the CBOR string is invalid, or when the current handle is invalid.

Definition at line 1880 of file dqcsim.

◆ get_arb_json()

template<class JSON >
JSON dqcsim::wrap::Arb::get_arb_json ( ) const
inline

Returns the current arbitrary JSON data as a JSON object from nlohmann::json.

Since that is a header-only library that isn't usually installed system-wide and be using a specific version in your project already, you need to specify the nlohmann::json type as a generic to this function.

Warning
This function returns a copy of the JSON data embedded in the ArbData. Therefore, modifying the returned JSON object does not modify the original ArbData. To modify, you need to pass the modified JSON object to set_arb_json().
Returns
A copy of the embedded JSON object, in the form of a C++ JSON object wrapper.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 1903 of file dqcsim.

◆ set_arb_json()

template<class JSON >
void dqcsim::wrap::Arb::set_arb_json ( const JSON &  json)
inline

Sets the arbitrary JSON data to the given JSON object from nlohmann::json.

Since that is a header-only library that isn't usually installed system-wide and be using a specific version in your project already, you need to specify the nlohmann::json type as a generic to this function.

Parameters
jsonThe C++ JSON object representation of the object to set.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 1924 of file dqcsim.

◆ get_arb_arg_string()

std::string dqcsim::wrap::Arb::get_arb_arg_string ( ssize_t  index) const
inline

Returns the arbitrary argument at the given index as a (binary) string.

Negative indices are relative to the back of the list, as in Python.

Parameters
indexThe index of the argument to retrieve.
Returns
The (binary) string representation of the argument.
Exceptions
std::runtime_errorWhen the current handle is invalid or the argument index is out of range.

Definition at line 1939 of file dqcsim.

◆ get_arb_arg_as()

template<typename T >
T dqcsim::wrap::Arb::get_arb_arg_as ( ssize_t  index) const
inline

Returns the arbitrary argument at the given index as the given type.

Negative indices are relative to the back of the list, as in Python.

Warning
Type T must be a primitive value (like an int) or a struct thereof, without pointers or any other "complicated" constructs. DQCsim just copies the bytes over. It is up to you to ensure that that's what you want to happen; unfortunately C++11 does not provide a way to statically ensure that this is the case.
Parameters
indexThe index of the argument to retrieve.
Returns
The C object representation of the argument.
Exceptions
std::runtime_errorWhen the current handle is invalid, the argument index is out of range, or the size of the requested object type differs from the size of the stored argument.

Definition at line 1964 of file dqcsim.

◆ set_arb_arg_strings()

template<typename T >
void dqcsim::wrap::Arb::set_arb_arg_strings ( const T &  strings)
inline

Sets the arbitrary argument list to the given iterable of std::strings.

Parameters
stringsSome object that can be used as an iterator over const std::string&s.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 1986 of file dqcsim.

◆ set_arb_arg_string()

void dqcsim::wrap::Arb::set_arb_arg_string ( ssize_t  index,
const std::string &  data 
)
inline

Sets the arbitrary argument at the given index to a (binary) string.

Negative indices are relative to the back of the list, as in Python.

Parameters
indexThe index of the argument to set.
dataThe new argument data, represented as a (binary) string.
Exceptions
std::runtime_errorWhen the current handle is invalid or the index is out of range.

Definition at line 2002 of file dqcsim.

◆ set_arb_arg()

template<typename T >
void dqcsim::wrap::Arb::set_arb_arg ( ssize_t  index,
const T &  data 
)
inline

Sets the arbitrary argument at the given index to a value of type T.

Negative indices are relative to the back of the list, as in Python.

Warning
Type T must be a primitive value (like an int) or a struct thereof, without pointers or any other "complicated" constructs. DQCsim just copies the bytes over. It is up to you to ensure that that's what you want to happen; unfortunately C++11 does not provide a way to statically ensure that this is the case.
Parameters
indexThe index of the argument to set.
dataThe C object representation of the argument data to set.
Exceptions
std::runtime_errorWhen the current handle is invalid or the index is out of range.

Definition at line 2022 of file dqcsim.

◆ push_arb_arg_string()

void dqcsim::wrap::Arb::push_arb_arg_string ( const std::string &  data)
inline

Pushes a (binary) string to the back of the arbitrary argument list.

Parameters
dataThe data for the new argument, represented as a (binary) string.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 2033 of file dqcsim.

◆ push_arb_arg()

template<typename T >
void dqcsim::wrap::Arb::push_arb_arg ( const T &  data)
inline

Pushes a value of type T to the back of the arbitrary argument list.

Warning
Type T must be a primitive value (like an int) or a struct thereof, without pointers or any other "complicated" constructs. DQCsim just copies the bytes over. It is up to you to ensure that that's what you want to happen; unfortunately C++11 does not provide a way to statically ensure that this is the case.
Parameters
dataThe data for the new argument, represented as some C object.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 2050 of file dqcsim.

◆ pop_arb_arg_string()

std::string dqcsim::wrap::Arb::pop_arb_arg_string ( )
inline

Pops from the back of the arbitrary argument list as a (binary) string.

Returns
The data of the popped argument, represented as a (binary) string.
Exceptions
std::runtime_errorWhen the current handle is invalid or the argument list is empty.

Definition at line 2062 of file dqcsim.

◆ pop_arb_arg_as()

template<typename T >
T dqcsim::wrap::Arb::pop_arb_arg_as ( ) const
inline

Pops from the back of the arbitrary argument list as a value of type T.

Note
If there is an object size mismatch, the argument is not popped.
Warning
Type T must be a primitive value (like an int) or a struct thereof, without pointers or any other "complicated" constructs. DQCsim just copies the bytes over. It is up to you to ensure that that's what you want to happen; unfortunately C++11 does not provide a way to statically ensure that this is the case.
Returns
The data of the popped argument, represented as some C object.
Exceptions
std::runtime_errorWhen the current handle is invalid, the argument list is empty, or there is a size mismatch.

Definition at line 2087 of file dqcsim.

◆ insert_arb_arg_string()

void dqcsim::wrap::Arb::insert_arb_arg_string ( ssize_t  index,
const std::string &  data 
)
inline

Inserts an arbitrary argument at the given index using a (binary) string.

Negative indices are relative to the back of the list, as in Python.

Parameters
indexThe index of the argument to insert at.
dataThe new argument data, represented as a (binary) string.
Exceptions
std::runtime_errorWhen the current handle is invalid or the index is out of range.

Definition at line 2110 of file dqcsim.

◆ insert_arb_arg()

template<typename T >
void dqcsim::wrap::Arb::insert_arb_arg ( ssize_t  index,
const T &  data 
)
inline

Inserts an arbitrary argument at the given index using a value of type T.

Negative indices are relative to the back of the list, as in Python.

Warning
Type T must be a primitive value (like an int) or a struct thereof, without pointers or any other "complicated" constructs. DQCsim just copies the bytes over. It is up to you to ensure that that's what you want to happen; unfortunately C++11 does not provide a way to statically ensure that this is the case.
Parameters
indexThe index of the argument to insert at.
dataThe C object representation of the argument data to set.
Exceptions
std::runtime_errorWhen the current handle is invalid or the index is out of range.

Definition at line 2131 of file dqcsim.

◆ remove_arb_arg()

void dqcsim::wrap::Arb::remove_arb_arg ( ssize_t  index)
inline

Removes the arbitrary argument at the given index.

Negative indices are relative to the back of the list, as in Python.

Parameters
indexThe index of the argument to remove.
Exceptions
std::runtime_errorWhen the current handle is invalid or the index is out of range.

Definition at line 2143 of file dqcsim.

◆ get_arb_arg_count()

size_t dqcsim::wrap::Arb::get_arb_arg_count ( ) const
inline

Returns the number of arbitrary arguments.

Returns
The number of binary string arguments.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 2153 of file dqcsim.

◆ clear_arb_args()

void dqcsim::wrap::Arb::clear_arb_args ( )
inline

Clears the arbitrary argument list.

Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 2162 of file dqcsim.

◆ set_arb()

void dqcsim::wrap::Arb::set_arb ( const Arb src)
inline

Assigns all arb data from the given arb to this one.

Parameters
srcThe arb-like object to copy the data from.
Exceptions
std::runtime_errorWhen either handle is invalid.

Definition at line 2172 of file dqcsim.


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