HAL
gate_library_manager.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  auto py_gate_library_manager = m.def_submodule("GateLibraryManager", R"(
8  The gate library manager keeps track of all gate libraries that are used within HAL. Further, it takes care of loading and saving gate libraries on demnand.
9  )");
10 
11  py_gate_library_manager.def(
12  "load",
13  [](std::filesystem::path file_path, bool reload) { return RawPtrWrapper<GateLibrary>(gate_library_manager::load(file_path, reload)); },
14  py::arg("file_path"),
15  py::arg("reload") = false,
16  R"(
17  Load a gate library from file.
18 
19  :param pathlib.Path file_path: The input path.
20  :param bool reload: If true, reloads the library in case it is already loaded.
21  :returns: The gate library on success, None otherwise.
22  :rtype: hal_py.GateLibrary or None
23  )");
24 
25  py_gate_library_manager.def("load_all", &gate_library_manager::load_all, py::arg("reload") = false, R"(
26  Load all gate libraries available in standard gate library directories.
27 
28  :param bool reload: If true, reloads all libraries that have already been loaded.
29  )");
30 
31  py_gate_library_manager.def("save", &gate_library_manager::save, py::arg("file_path"), py::arg("gate_lib"), py::arg("overwrite") = false, R"(
32  Save a gate library to file.
33 
34  :param pathlib.Path file_path: The output path.
35  :param hal_py.GateLibrary gate_lib: The gate library.
36  :param bool overwrite: If true, overwrites already existing files.
37  :returns: True on success, false otherwise.
38  :rtype: bool
39  )");
40 
41  py_gate_library_manager.def(
42  "get_gate_library", [](const std::string& file_name) { return RawPtrWrapper<GateLibrary>(gate_library_manager::get_gate_library(file_name)); }, py::arg("file_path"), R"(
43  Get a gate library by file path. If no library with the given name is loaded, loading the gate library from file will be attempted.
44 
45  :param str file_path: The input path.
46  :returns: The gate library on success, None otherwise.
47  :rtype: hal_py.GateLibrary or None
48  )");
49 
50  py_gate_library_manager.def(
51  "get_gate_library_by_name",
52  [](const std::string& lib_name) { return RawPtrWrapper<GateLibrary>(gate_library_manager::get_gate_library_by_name(lib_name)); },
53  py::arg("lib_name"),
54  R"(
55  Get a gate library by name. If no library with the given name is loaded, None will be returned.
56 
57  :param str lib_name: The name of the gate library.
58  :returns: The gate library on success, None otherwise.
59  :rtype: hal_py.GateLibrary or None
60  )");
61 
62  py_gate_library_manager.def(
63  "get_gate_libraries",
64  [] {
65  std::vector<RawPtrWrapper<GateLibrary>> result;
67  {
68  result.emplace_back(lib);
69  }
70  return result;
71  },
72  R"(
73  Get all loaded gate libraries.
74 
75  :returns: A list of gate libraries.
76  :rtype: list[hal_py.GateLibrary]
77  )");
78  }
79 } // namespace hal
std::unique_ptr< T, py::nodelete > RawPtrWrapper
void gate_library_manager_init(py::module &m)
const Module * module(const Gate *g, const NodeBoxes &boxes)
GateLibrary * get_gate_library_by_name(const std::string &lib_name)
std::vector< GateLibrary * > get_gate_libraries()
GateLibrary * get_gate_library(const std::string &file_path)
GateLibrary * load(std::filesystem::path file_path, bool reload)
bool save(std::filesystem::path file_path, GateLibrary *gate_lib, bool overwrite)