diff --git a/include/aidge/utils/Any.hpp b/include/aidge/utils/Any.hpp index d7ff22de23763e399d23fd7abb9e28a7a85aff5c..0310c38ccd855f64c8485a114962738203f03ef5 100644 --- a/include/aidge/utils/Any.hpp +++ b/include/aidge/utils/Any.hpp @@ -110,7 +110,7 @@ public: template<typename T, typename VT = _Decay_if_not_any<T>, std::enable_if_t<std::is_copy_constructible<VT>::value, bool> = true> explicit _any(T&& value) : _M_manager(&Manager<VT>::manage), - _M_data(new VT{std::forward<T>(value)}) + _M_data(new VT{std::forward<T>(value)}) {} ~_any() diff --git a/include/aidge/utils/CParameter.hpp b/include/aidge/utils/CParameter.hpp index 75c2b57ac179300ec3efbb1195c434e0534b62f3..6e8754537f41c995762a76bd6580607966055aec 100644 --- a/include/aidge/utils/CParameter.hpp +++ b/include/aidge/utils/CParameter.hpp @@ -80,7 +80,7 @@ public: std::string getParamType(std::string const &i_ParamName){ - return m_Types[i_ParamName]; + return m_Buffer[m_Params.at(i_ParamName)].type().name(); } std::vector<std::string> getParametersName(){ @@ -93,14 +93,6 @@ public: private: std::map<std::string, std::size_t> m_Params; // { Param name : offset } - ///\brief Map to check type error - /* Note : i tried this : `std::map<std::string, std::type_info const *> mTypes;` - but looks like the type_ingo object was destroyed. - I am not a hugde fan of storing a string and making string comparison. - Maybe we can use a custom enum type (or is there a standard solution ?) - */ - std::map<std::string, std::string> m_Types; - ///\brief All raw pointers to parameters values concatenated. Use custom any class compatible with C++14. std::vector<_any> m_Buffer = {}; }; diff --git a/python_binding/operator/pybind_GenericOperator.cpp b/python_binding/operator/pybind_GenericOperator.cpp index ee3ee74c14e58dd5160cb041a123c329ab0bbb84..bec59eaf2cecdc7f64d1da07580116c4b3334992 100644 --- a/python_binding/operator/pybind_GenericOperator.cpp +++ b/python_binding/operator/pybind_GenericOperator.cpp @@ -22,7 +22,7 @@ namespace Aidge { void init_GenericOperator(py::module& m) { py::class_<GenericOperator_Op, std::shared_ptr<GenericOperator_Op>, Operator>(m, "GenericOperatorOp", py::multiple_inheritance()) - .def("get_parameter_type", &GenericOperator_Op::getParameterType) + .def("get_parameter_type", &GenericOperator_Op::getParameterType) .def("get_parameters_name", &GenericOperator_Op::getParametersName) .def("add_parameter", &GenericOperator_Op::addParameter<bool>) .def("add_parameter", &GenericOperator_Op::addParameter<int>) @@ -34,10 +34,10 @@ void init_GenericOperator(py::module& m) { .def("add_parameter", &GenericOperator_Op::addParameter<std::vector<std::string>>) .def("get_parameter", [](GenericOperator_Op& self, std::string key) -> py::object { /* - This getParameter method returns the good python type without having to have + This getParameter method returns the good python type without having to have prior knowledge of the parameter type. */ - py::object res = py::none(); + py::object res = py::none(); std::string paramType = self.getParameterType(key); if(paramType == typeid(int).name()) res = py::cast(self.getParameter<int>(key));