QCOR
qcor_ir.hpp
1 #pragma once
2 #include <memory>
3 #include <vector>
4 
5 #include "Identifiable.hpp"
6 #include "heterogeneous.hpp"
7 #include "qcor_pimpl.hpp"
8 
9 // Leave Instruction opaque
10 namespace xacc {
11 class Instruction;
12 class CompositeInstruction;
13 }
14 
15 namespace qcor {
16 using LocalOpaqueInstPtr = std::shared_ptr<xacc::Instruction>;
17 
19  private:
22 
23  public:
26  CompositeInstruction(std::shared_ptr<xacc::Identifiable> impl);
27  CompositeInstruction(const std::string &&name);
28  CompositeInstruction(const std::string &name);
29  CompositeInstructionImpl *operator->();
30 
31  std::size_t nLogicalBits();
32  std::size_t nPhysicalBits();
33  std::size_t nVariables();
34  std::shared_ptr<CompositeInstruction> operator()(const std::vector<double>& x);
35 
36  std::shared_ptr<xacc::Identifiable> get_as_opaque();
37  std::shared_ptr<xacc::CompositeInstruction> as_xacc();
38 
39  const std::string name() const;
40  int nInstructions();
41  int nChildren();
42 
43  void setName(const std::string name);
44 
45  LocalOpaqueInstPtr getInstruction(const std::size_t idx);
46  std::vector<LocalOpaqueInstPtr> getInstructions();
47  void removeInstruction(const std::size_t idx);
48  void replaceInstruction(const std::size_t idx, LocalOpaqueInstPtr newInst);
49  void insertInstruction(const std::size_t idx, LocalOpaqueInstPtr newInst);
50 
51  void clear();
52 
53  void addInstruction(LocalOpaqueInstPtr instruction);
54  void addInstruction(std::shared_ptr<CompositeInstruction> composite);
55  void addInstructions(std::vector<LocalOpaqueInstPtr> &instruction);
56  void addInstructions(const std::vector<LocalOpaqueInstPtr> &instruction);
57  void addInstructions(const std::vector<LocalOpaqueInstPtr> &&insts,
58  bool shouldValidate = true);
59 
60  void attachMetadata(const int instId, xacc::HeterogeneousMap &&m);
61  std::string toString();
62  int depth();
63 
64 };
65 
66 } // namespace qcor
67 
qcor::qcor_pimpl
Definition: qcor_pimpl.hpp:7
qcor
Definition: qcor_syntax_handler.cpp:15
qcor::CompositeInstruction::CompositeInstructionImpl
————- CompositeInstruction Wrapper —————
Definition: qcor_ir.cpp:11
qcor::CompositeInstruction
Definition: qcor_ir.hpp:18