14 inline T get_optional(
const json & j,
const char * property) {
15 if (j.find(property) != j.end()) {
16 return j.at(property).get<T>();
22 inline std::shared_ptr<T> get_optional(
const json & j, std::string property) {
23 return get_optional<T>(j,
property.data());
34 std::int64_t control = 0;
35 double rotation = 0.0;
38 const std::string & get_gate()
const {
return gate; }
39 std::string & get_mutable_gate() {
return gate; }
40 void set_gate(
const std::string & value) { this->gate = value; }
42 const int64_t & get_target()
const {
return target; }
43 int64_t & get_mutable_target() {
return target; }
44 void set_target(
const std::int64_t & value) { this->target = value; }
46 std::int64_t get_control()
const {
return control; }
47 void set_control(std::int64_t value) { this->control = value; }
49 double get_rotation()
const {
return rotation; }
50 void set_rotation(
double value) { this->rotation = value; }
56 virtual ~
Body() =
default;
60 std::vector<CircuitInstruction> circuit;
63 const int64_t & get_qubits()
const {
return qubits; }
64 int64_t & get_mutable_qubits() {
return qubits; }
65 void set_qubits(
const int64_t & value) { this->qubits = value; }
67 const std::vector<CircuitInstruction> & get_circuit()
const {
return circuit; }
68 std::vector<CircuitInstruction> & get_mutable_circuit() {
return circuit; }
69 void set_circuit(
const std::vector<CircuitInstruction> & value) { this->circuit = value; }
78 std::string lang =
"json";
84 const std::string & get_lang()
const {
return lang; }
85 std::string & get_mutable_lang() {
return lang; }
86 void set_lang(
const std::string & value) { this->lang = value; }
88 const std::string & get_target()
const {
return target; }
89 std::string & get_mutable_target() {
return target; }
90 void set_target(
const std::string & value) { this->target = value; }
92 const std::int64_t & get_shots()
const {
return shots; }
93 std::int64_t & get_mutable_shots() {
return shots; }
94 void set_shots(
const std::int64_t & value) { this->shots = value; }
96 const Body & get_body()
const {
return body; }
97 Body & get_mutable_body() {
return body; }
98 void set_body(
const Body & value) { this->body = value; }
114 x.set_gate(j.at(
"gate").get<std::string>());
115 x.set_target(j.at(
"target").get<std::int64_t>());
116 x.set_control(xacc::ionq::get_optional<std::int64_t>(j,
"control"));
117 x.set_rotation(xacc::ionq::get_optional<double>(j,
"rotation"));
122 j[
"gate"] = x.get_gate();
123 j[
"target"] = x.get_target();
124 if (x.get_gate() ==
"cnot") {
125 j[
"control"] = x.get_control();
127 if (x.get_gate() ==
"rx" ||x.get_gate() ==
"ry" || x.get_gate() ==
"rz") {
128 j[
"rotation"] = x.get_rotation();
133 x.set_qubits(j.at(
"qubits").get<std::int64_t>());
134 x.set_circuit(j.at(
"circuit").get<std::vector<xacc::ionq::CircuitInstruction>>());
139 j[
"qubits"] = x.get_qubits();
140 j[
"circuit"] = x.get_circuit();
144 x.set_lang(j.at(
"lang").get<std::string>());
145 x.set_target(j.at(
"target").get<std::string>());
146 x.set_shots(j.at(
"shots").get<std::int64_t>());
152 j[
"lang"] = x.get_lang();
153 j[
"target"] = x.get_target();
154 j[
"shots"] = x.get_shots();
155 j[
"body"] = x.get_body();
Definition: Accelerator.hpp:25
Definition: ionq_program.hpp:72
Definition: Backends.hpp:24
Definition: ionq_program.hpp:26
Definition: ionq_program.hpp:53