HAL
data_container.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  py::class_<DataContainer, RawPtrWrapper<DataContainer>> py_data_container(m, "DataContainer", R"(
8  Container to hold data that is associated with an entity.
9  )");
10 
11  py_data_container.def(py::init<>(), R"(
12  Construct a new data container.
13  )");
14 
15  py_data_container.def("set_data", &DataContainer::set_data, py::arg("category"), py::arg("key"), py::arg("data_type"), py::arg("value"), py::arg("log_with_info_level") = false, R"(
16  Add a data entry.<br>
17  May overwrite an existing entry.
18 
19  :param str category: The data key category.
20  :param str key: The data key.
21  :param str data_type: The data type.
22  :param str value: The data value.
23  :param bool log_with_info_level: Force explicit logging channel 'netlist' with log level 'info' to trace GUI events.
24  :returns: True on success, false otherwise.
25  :rtype: bool
26  )");
27 
28  py_data_container.def("has_data", &DataContainer::has_data, py::arg("category"), py::arg("key"), R"(
29  Determine whether an entry of given category and key exists.
30 
31  :param str category: The data key category.
32  :param str key: The data key.
33  :returns: True if the entry exists, False otherwise.
34  :rtype: bool
35  )");
36 
37  py_data_container.def("get_data", &DataContainer::get_data, py::arg("category"), py::arg("key"), R"(
38  Get the data entry specified by the given category and key.
39 
40  :param str category: The data key category.
41  :param str key: The data key.
42  :returns: The tuple ((1) type, (2) value).
43  :rtype: tuple(str,str)
44  )");
45 
46  py_data_container.def("delete_data", &DataContainer::delete_data, py::arg("category"), py::arg("key"), py::arg("log_with_info_level") = false, R"(
47  Delete a data entry.
48 
49  :param str category: The data key category.
50  :param str key: The data key.
51  :param bool log_with_info_level: Force explicit logging channel 'netlist' with log level 'info' to trace GUI events.
52  :returns: True on success, false otherwise.
53  :rtype: bool
54  )");
55 
56  py_data_container.def_property_readonly("data", &DataContainer::get_data_map, R"(
57  A dict from ((1) category, (2) key) to ((1) type, (2) value) containing all stored data entries.
58 
59  :type: dict[tuple(str,str),tuple(str,str)]
60  )");
61 
62  py_data_container.def("get_data_map", &DataContainer::get_data_map, R"(
63  Get a dict from ((1) category, (2) key) to ((1) type, (2) value) containing all stored data entries.
64 
65  :returns: The stored data as a dict.
66  :rtype: dict[tuple(str,str),tuple(str,str)]
67  )");
68  }
69 } // namespace hal
const std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string > > & get_data_map() const
std::tuple< std::string, std::string > get_data(const std::string &category, const std::string &key) const
bool set_data(const std::string &category, const std::string &key, const std::string &data_type, const std::string &value, const bool log_with_info_level=false)
bool has_data(const std::string &category, const std::string &key) const
bool delete_data(const std::string &category, const std::string &key, const bool log_with_info_level=false)
void data_container_init(py::module &m)
const Module * module(const Gate *g, const NodeBoxes &boxes)