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

Class wrapper for ArbCmd handles. More...

Inheritance diagram for dqcsim::wrap::ArbCmd:
dqcsim::wrap::Cmd dqcsim::wrap::Arb dqcsim::wrap::Handle

Public Member Functions

 ArbCmd (HandleIndex handle) noexcept
 Wraps the given ArbCmd handle. More...
 
 ArbCmd (const std::string &iface, const std::string &oper)
 Constructs an ArbCmd object. More...
 
 ArbCmd (const Cmd &src)
 Copy-constructs an ArbCmd object from any object supporting the Cmd interface. More...
 
 ArbCmd (const ArbCmd &src)
 Copy-constructs an ArbCmd object from another ArbCmd object. More...
 
void operator= (const ArbCmd &src)
 Copy assignment operator for ArbCmd objects. More...
 
 ArbCmd (ArbCmd &&)=default
 Default move constructor.
 
ArbCmdoperator= (ArbCmd &&)=default
 Default move assignment.
 
ArbCmdwith_json_string (const std::string &json)
 Sets the arbitrary JSON data to the given serialized JSON string (builder pattern). More...
 
ArbCmdwith_cbor_string (const std::string &cbor)
 Sets the arbitrary JSON data to the given serialized CBOR string (builder pattern). More...
 
template<class JSON >
ArbCmdwith_json (const JSON &json)
 Sets the arbitrary JSON data to the given JSON object from nlohmann::json (builder pattern). More...
 
ArbCmdwith_arg_string (const std::string &data)
 Pushes a (binary) string to the back of the arbitrary argument list (builder pattern). More...
 
template<typename T >
ArbCmdwith_arg (const T &data)
 Pushes a value of type T to the back of the arbitrary argument list (builder pattern). More...
 
- Public Member Functions inherited from dqcsim::wrap::Cmd
 Cmd (HandleIndex handle) noexcept
 Wraps the given cmd handle. More...
 
std::string get_iface () const
 Returns the interface identifier of this command. More...
 
bool is_iface (const std::string &iface) const
 Returns whether this command has the given interface identifier. More...
 
std::string get_oper () const
 Returns the operation identifier of this command. More...
 
bool is_oper (const std::string &oper) const
 Returns whether this command has the given operation identifier. More...
 
- Public Member Functions inherited from dqcsim::wrap::Arb
 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 ArbCmd handles.

ArbCmds, like ArbDatas, represent user-defined information that can be transferred between plugins. However, where ArbData represents only data, ArbCmds represent intent. Usually, where ArbCmds come into play, DQCsim will accept a queue of them rather than just one (ArbCmdQueue), where each command represents some custom action to be taken in some context. For instance, when allocating qubits, you can specify one or more ArbCmds to modify the behavior of the qubits, such as requesting that a certain error model be used, if available.

ArbCmds are essentially just ArbData objects with two required identifier strings attached to them in addition: the interface and operation identifiers. Their significance is as follows:

The identifiers must be matched case-sensitively.

The identifiers are specified when constructing an ArbCmd and are then immutable. The attached ArbData can be constructed, manipulated, and queried in the same way as ArbData objects.

Definition at line 2456 of file dqcsim.

Constructor & Destructor Documentation

◆ ArbCmd() [1/4]

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

Wraps the given ArbCmd handle.

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

Definition at line 2467 of file dqcsim.

◆ ArbCmd() [2/4]

dqcsim::wrap::ArbCmd::ArbCmd ( const std::string &  iface,
const std::string &  oper 
)
inline

Constructs an ArbCmd object.

Parameters
ifaceThe interface identifier for the command.
operThe operation identifier for the command.
Exceptions
std::runtime_errorWhen constructing the handle fails for some reason.

Definition at line 2478 of file dqcsim.

◆ ArbCmd() [3/4]

dqcsim::wrap::ArbCmd::ArbCmd ( const Cmd src)
inline

Copy-constructs an ArbCmd object from any object supporting the Cmd interface.

Parameters
srcThe cmd-like object to copy from.
Exceptions
std::runtime_errorWhen the source handle is invalid or constructing the new handle fails for some reason.

Definition at line 2491 of file dqcsim.

◆ ArbCmd() [4/4]

dqcsim::wrap::ArbCmd::ArbCmd ( const ArbCmd src)
inline

Copy-constructs an ArbCmd object from another ArbCmd object.

Parameters
srcThe cmd-like object to copy from.
Exceptions
std::runtime_errorWhen the source handle is invalid or constructing the new handle fails for some reason.

Definition at line 2504 of file dqcsim.

Member Function Documentation

◆ operator=()

void dqcsim::wrap::ArbCmd::operator= ( const ArbCmd src)
inline

Copy assignment operator for ArbCmd objects.

Parameters
srcThe cmd-like object to copy from.
Exceptions
std::runtime_errorWhen freeing the old handle fails, the source handle is invalid, or constructing the new handle fails for some reason.

Definition at line 2517 of file dqcsim.

◆ with_json_string()

ArbCmd& dqcsim::wrap::ArbCmd::with_json_string ( const std::string &  json)
inline

Sets the arbitrary JSON data to the given serialized JSON string (builder pattern).

Parameters
jsonA string representation of a JSON dictionary object to assign.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the string representation is invalid, or when the current handle is invalid.

Definition at line 2552 of file dqcsim.

◆ with_cbor_string()

ArbCmd& dqcsim::wrap::ArbCmd::with_cbor_string ( const std::string &  cbor)
inline

Sets the arbitrary JSON data to the given serialized CBOR string (builder pattern).

Parameters
cborA JSON object represented as a CBOR binary string.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the CBOR string is invalid, or when the current handle is invalid.

Definition at line 2566 of file dqcsim.

◆ with_json()

template<class JSON >
ArbCmd& dqcsim::wrap::ArbCmd::with_json ( const JSON &  json)
inline

Sets the arbitrary JSON data to the given JSON object from nlohmann::json (builder pattern).

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.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 2583 of file dqcsim.

◆ with_arg_string()

ArbCmd& dqcsim::wrap::ArbCmd::with_arg_string ( const std::string &  data)
inline

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

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

Definition at line 2597 of file dqcsim.

◆ with_arg()

template<typename T >
ArbCmd& dqcsim::wrap::ArbCmd::with_arg ( const T &  data)
inline

Pushes a value of type T to the back of the arbitrary argument list (builder pattern).

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.
Returns
&self, to continue building.
Exceptions
std::runtime_errorWhen the current handle is invalid.

Definition at line 2617 of file dqcsim.


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