75 void set(
const std::string &key, py::object value) {
76 if (py::isinstance<py::bool_>(value)) {
77 this->blackboard->set<
bool>(key, value.cast<
bool>());
78 }
else if (py::isinstance<py::int_>(value)) {
80 this->blackboard->set<
int>(key, value.cast<
int>());
82 this->blackboard->set<
long>(key, value.cast<
long>());
84 }
else if (py::isinstance<py::float_>(value)) {
85 this->blackboard->set<
double>(key, value.cast<
double>());
86 }
else if (py::isinstance<py::str>(value)) {
87 this->blackboard->set<std::string>(key, value.cast<std::string>());
88 }
else if (py::isinstance<py::list>(value)) {
89 this->blackboard->set<py::object>(key, value);
90 }
else if (py::isinstance<py::dict>(value)) {
91 this->blackboard->set<py::object>(key, value);
92 }
else if (py::isinstance<py::tuple>(value)) {
93 this->blackboard->set<py::object>(key, value);
94 }
else if (py::isinstance<py::set>(value)) {
95 this->blackboard->set<py::object>(key, value);
97 this->blackboard->set<py::object>(key, value);
107 py::object
get(
const std::string &key) {
109 std::string type = this->blackboard->get_type(key);
113 if (type.find(
"pybind11::object") != std::string::npos ||
114 type.find(
"pybind11::int_") != std::string::npos ||
115 type.find(
"pybind11::float_") != std::string::npos ||
116 type.find(
"pybind11::str") != std::string::npos ||
117 type.find(
"pybind11::bool_") != std::string::npos ||
118 type.find(
"pybind11::list") != std::string::npos ||
119 type.find(
"pybind11::dict") != std::string::npos ||
120 type.find(
"pybind11::set") != std::string::npos ||
121 type.find(
"pybind11::tuple") != std::string::npos ||
122 type.find(
"pybind11::bytes") != std::string::npos ||
123 type.find(
"pybind11::none") != std::string::npos) {
124 return this->blackboard->get<py::object>(key);
127 else if (type.find(
"std::string") != std::string::npos ||
128 type.find(
"std::__cxx11::basic_string") != std::string::npos) {
129 std::string cpp_value = this->blackboard->get<std::string>(key);
130 return py::cast(cpp_value);
133 else if (type.find(
"std::vector") != std::string::npos) {
134 return this->blackboard->get<py::object>(key);
137 else if (type.find(
"std::map") != std::string::npos ||
138 type.find(
"std::unordered_map") != std::string::npos) {
139 return this->blackboard->get<py::object>(key);
142 else if (type.find(
"std::set") != std::string::npos ||
143 type.find(
"std::unordered_set") != std::string::npos) {
144 return this->blackboard->get<py::object>(key);
147 else if (type.find(
"std::list") != std::string::npos) {
148 return this->blackboard->get<py::object>(key);
151 else if (type.find(
"std::tuple") != std::string::npos) {
152 return this->blackboard->get<py::object>(key);
155 else if (type.find(
"int") != std::string::npos) {
156 int cpp_value = this->blackboard->get<
int>(key);
157 return py::cast(cpp_value);
160 else if (type.find(
"long") != std::string::npos) {
161 long cpp_value = this->blackboard->get<
long>(key);
162 return py::cast(cpp_value);
166 else if (type.find(
"float") != std::string::npos ||
167 type.find(
"double") != std::string::npos) {
168 double cpp_value = this->blackboard->get<
double>(key);
169 return py::cast(cpp_value);
172 else if (type.find(
"bool") != std::string::npos) {
173 bool cpp_value = this->blackboard->get<
bool>(key);
174 return py::cast(cpp_value);
178 return this->blackboard->get<py::object>(key);