libqasm
library for handling cQASM files
cqasm-v1-instruction.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "cqasm-v1-types.hpp"
10 #include "cqasm-v1-values.hpp"
11 
12 namespace cqasm {
13 namespace v1 {
14 
19 namespace instruction {
20 
46 class Instruction : public tree::Base {
47 public:
48 
52  std::string name;
53 
58 
64 
69 
77 
84 
98  explicit Instruction(
99  const std::string &name,
100  const std::string &param_types = "",
101  bool allow_conditional = true,
102  bool allow_parallel = true,
103  bool allow_reused_qubits = false,
104  bool allow_different_index_sizes = false
105  );
106 
110  bool operator==(const Instruction& rhs) const;
111 
115  inline bool operator!=(const Instruction& rhs) const {
116  return !(*this == rhs);
117  }
118 
119 };
120 
125 
129 std::ostream &operator<<(std::ostream &os, const Instruction &insn);
130 
134 std::ostream &operator<<(std::ostream &os, const InstructionRef &insn);
135 
136 } // namespace instruction
137 
138 namespace primitives {
139 
140 template <>
141 void serialize(const instruction::InstructionRef &obj, ::tree::cbor::MapWriter &map);
142 template <>
143 instruction::InstructionRef deserialize(const ::tree::cbor::MapReader &map);
144 
145 } // namespace primitives
146 } // namespace v1
147 } // namespace cqasm
::tree::base::Base Base
Definition: cqasm-tree.hpp:20
::tree::base::Maybe< T > Maybe
Definition: cqasm-tree.hpp:23
tree::Maybe< Instruction > InstructionRef
Optional reference to an instruction, used within the semantic tree.
std::ostream & operator<<(std::ostream &os, const Instruction &insn)
Stream << overload for instructions.
error_model::ErrorModelRef deserialize(const ::tree::cbor::MapReader &map)
Deserializes the given primitive object from CBOR.
Toplevel namespace with entry points for the new API.
bool allow_reused_qubits
Whether to allow usage of the same qubit in different arguments.
bool allow_conditional
Whether this instruction supports conditional execution by means of the c- notation.
Defines classes representing the values (collective name for constants, references, and dynamically evaluated expressions) available within cQASM&#39;s type system, as well as some utility functions.
bool allow_parallel
Whether this instruction can be used in a bundle.
void serialize(const error_model::ErrorModelRef &obj, ::tree::cbor::MapWriter &map)
Representation of an available instruction (also known as gate) in the instruction set...
bool operator==(const Instruction &rhs) const
Equality operator.
types::Types param_types
The vector of parameter types that this instruction expects.
Namespace for the "new" cQASM 1.x API.
Instruction(const std::string &name, const std::string &param_types="", bool allow_conditional=true, bool allow_parallel=true, bool allow_reused_qubits=false, bool allow_different_index_sizes=false)
Creates a new instruction.
tree::Any< TypeBase > Types
Zero or more cQASM types.
bool operator!=(const Instruction &rhs) const
Inequality operator.
Defines the types of values available within cQASM&#39;s type system, as well as some utility functions...
bool allow_different_index_sizes
Whether different index sizes are allowed.
std::string name
The name of the instruction.