Skip to content
Snippets Groups Projects
Commit 1786b36a authored by Maxence Naud's avatar Maxence Naud
Browse files

[Fix] Type call for GenericOperator parameters

parent 5f3ac9c8
No related branches found
No related tags found
2 merge requests!15Remove CParameter memory leak,!3[Fix] Memory leak due to containers serialization
Pipeline #31165 failed
......@@ -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()
......
......@@ -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 = {};
};
......
......@@ -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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment