GateInstructionService.hpp 1.28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef QUANTUM_GATE_GATEINSTRUCTIONSERVICE_HPP_
#define QUANTUM_GATE_GATEINSTRUCTIONSERVICE_HPP_

#include "XACC.hpp"
#include "Identifiable.hpp"
#include "GateInstruction.hpp"
#include "InstructionService.hpp"

namespace xacc {
namespace quantum {
class GateInstructionService: public InstructionService {

public:

	virtual std::shared_ptr<Instruction> create(const std::string name,
			std::vector<int> bits,
			std::vector<InstructionParameter> parameters = std::vector<
					InstructionParameter> { }) {

		std::shared_ptr<GateInstruction> inst =
				ServiceRegistry::instance()->getService<GateInstruction>(name);
		inst->setBits(bits);
		int idx = 0;
		for (auto& a : parameters) {
			inst->setParameter(idx, a);
			idx++;
		}

		return inst;
	}

	virtual std::vector<std::string> getInstructions() {
		std::vector<std::string> ret;
		for (auto i : ServiceRegistry::instance()->getRegisteredIds<GateInstruction>()) {
			ret.push_back(i);
		}
		return ret;
	}

	/**
	 * Return the name of this instance.
	 *
	 * @return name The string name
	 */
	virtual const std::string name() const {
		return "gate";
	}

	/**
	 * Return the description of this instance
	 * @return description The description of this object.
	 */
	virtual const std::string description() const {
		return "";
	}
};

}
}

#endif