Commit d2e65afe authored by Laurent Belcour's avatar Laurent Belcour

[Update][Big] Updating the inteface of plugins_manager::get_data to allo

to specify a configuration in arguments. This allow to specify
configuration at the creation of the plugin object.
parent 8af56aba
......@@ -437,7 +437,7 @@ ptr<function> plugins_manager::get_function(const std::string& n)
}
ptr<data> plugins_manager::get_data(const std::string& n)
ptr<data> plugins_manager::get_data(const std::string& n, const arguments& args)
{
if(n.empty())
{
......@@ -453,7 +453,7 @@ ptr<data> plugins_manager::get_data(const std::string& n)
#ifdef DEBUG
std::cout << "<<DEBUG>> using data provider in file \"" << n << "\"" << std::endl;
#endif
return myData();
return myData(args);
}
else
{
......
......@@ -50,7 +50,7 @@ class plugins_manager
//! \brief get an instance of the data that is defined in the plugin with
//! filename n. Return null if no one exist.
static ptr<data> get_data(const std::string& n) ;
static ptr<data> get_data(const std::string& n, const arguments& args = arguments());
//! \brief get an instance of the fitter that is defined in the plugin with
//! filename n. Return null if no one exist.
......@@ -75,5 +75,5 @@ class plugins_manager
// Object provider prototypes
typedef function* (*FunctionPrototype)();
typedef fitter* (*FitterPrototype)();
typedef data* (*DataPrototype)();
typedef data* (*DataPrototype)(const arguments&);
} ;
......@@ -207,7 +207,7 @@ int data_interpolant::size() const
return _data->size();
}
ALTA_DLL_EXPORT data* provide_data()
ALTA_DLL_EXPORT data* provide_data(const arguments&)
{
return new data_interpolant();
}
......
......@@ -186,7 +186,7 @@ int data_interpolant::size() const
return _data->size();
}
ALTA_DLL_EXPORT data* provide_data()
ALTA_DLL_EXPORT data* provide_data(const arguments&)
{
return new data_interpolant();
}
......
......@@ -120,7 +120,7 @@ public: //methods
}
};
ALTA_DLL_EXPORT data* provide_data()
ALTA_DLL_EXPORT data* provide_data(const arguments&)
{
return new ASTM();
}
......
......@@ -424,7 +424,7 @@ private: //methods
};
ALTA_DLL_EXPORT data* provide_data()
ALTA_DLL_EXPORT data* provide_data(const arguments&)
{
return new MERL();
}
......@@ -22,7 +22,7 @@ class BrdfSlice : public data {
int width, height, slice;
double* _data;
BrdfSlice() : data()
BrdfSlice(const arguments& args) : data()
{
// Allocate data
width = 512; height = 512;
......@@ -34,6 +34,19 @@ class BrdfSlice : public data {
_out_param = params::RGB_COLOR;
_nX = 2;
_nY = 3;
// Allow to load a different parametrization depending on the
// parameters provided.
if(args.is_defined("param")) {
params::input param = params::parse_input(args["param"]);
if(params::dimension(param) == 2) {
std::cout << "<<INFO>> Specified param \"" << args["param"] << "\"" << std::endl;
this->setParametrization(param);
} else {
std::cout << "<<ERROR>> Invalid specified param \"" << args["param"] << "\"" << std::endl;
std::cout << "<<ERROR>> Must have 2D input dimension" << std::endl;
}
}
}
~BrdfSlice()
......@@ -51,18 +64,6 @@ class BrdfSlice : public data {
{
load(filename);
// Allow to load a different parametrization depending on the
// parameters provided.
if(args.is_defined("param")) {
params::input param = params::parse_input(args["param"]);
if(params::dimension(param) == 2) {
std::cout << "<<INFO>> Specified param \"" << args["param"] << "\"" << std::endl;
this->setParametrization(param);
} else {
std::cout << "<<ERROR>> Invalid specified param \"" << args["param"] << "\"" << std::endl;
std::cout << "<<ERROR>> Must have 2D input dimension" << std::endl;
}
}
}
void save(const std::string& filename) const
......@@ -186,9 +187,9 @@ class BrdfSlice : public data {
}
};
ALTA_DLL_EXPORT data* provide_data()
ALTA_DLL_EXPORT data* provide_data(const arguments& args)
{
return new BrdfSlice();
return new BrdfSlice(args);
}
......@@ -331,7 +331,7 @@ public:
}
};
ALTA_DLL_EXPORT data* provide_data()
ALTA_DLL_EXPORT data* provide_data(const arguments&)
{
return new UTIA();
}
......@@ -91,7 +91,12 @@ ptr<data> load_data(const std::string& plugin_name, const std::string& filename)
d->load(filename);
return d;
}
ptr<data> get_data_with_args(const std::string& plugin_name, const python_arguments& args) {
return plugins_manager::get_data(plugin_name, args);
}
ptr<data> get_data(const std::string& plugin_name) {
return plugins_manager::get_data(plugin_name);
}
/* Creating functions for the plugins_manager calls
*
......@@ -159,6 +164,7 @@ BOOST_PYTHON_MODULE(alta)
.def(bp::init<>())
.def(bp::init<bp::dict>())
.def("update", &arguments::update);
bp::implicitly_convertible<bp::dict, python_arguments>();
// Vector class
......@@ -193,7 +199,8 @@ BOOST_PYTHON_MODULE(alta)
//.def("set", &data::set)
.def("load", static_cast< void(data::*)(const std::string&)>(&data::load))
.def("save", &data::save);
bp::def("get_data", plugins_manager::get_data);
bp::def("get_data", get_data);
bp::def("get_data", get_data_with_args);
bp::def("load_data", load_data);
......@@ -202,9 +209,9 @@ BOOST_PYTHON_MODULE(alta)
bp::class_<fitter, ptr<fitter>, boost::noncopyable>("fitter", bp::no_init)
.def("fit_data", &fitter::fit_data);
bp::def("get_fitter", plugins_manager::get_fitter);
bp::def("fit_data", &fit_data);
bp::def("fit_data", fit_data);
// Softs
//
bp::def("data2data", &data2data);
bp::def("data2data", data2data);
}
......@@ -68,7 +68,7 @@ int main(int argc, char** argv)
}
// Get the associated data object and load the file is any
ptr<data> d = plugins_manager::get_data(args["data"]) ;
ptr<data> d = plugins_manager::get_data(args["data"], args) ;
if(args.is_defined("data-file"))
{
try
......@@ -80,7 +80,7 @@ int main(int argc, char** argv)
// Get the output object. In the case where it is not a VS file, we use
// the load object.
ptr<data> d_out = plugins_manager::get_data(args["data"]);
ptr<data> d_out = plugins_manager::get_data(args["data"], args);
if(dynamic_pointer_cast<vertical_segment>(d))
{
d_out->setDimX(d->dimX());
......
......@@ -77,7 +77,7 @@ int main(int argc, char** argv)
// Load a data file
if(args.is_defined("data") || args.is_defined("data-file"))
{
ptr<data> d = plugins_manager::get_data(args["data"]);
ptr<data> d = plugins_manager::get_data(args["data"], args);
// Load data file if the plugin manager created a plugin object.
if(d)
......
......@@ -113,7 +113,7 @@ int main(int argc, char** argv)
fit->set_parameters(args) ;
ptr<function> f = plugins_manager::get_function(args);
ptr<data> d = plugins_manager::get_data(args["data"]);
ptr<data> d = plugins_manager::get_data(args["data"], args);
try
{
......
......@@ -110,7 +110,7 @@ int main(int argc, char** argv)
// Import data
ptr<data> d_in = plugins_manager::get_data(args["in-data"]) ;
ptr<data> d_in = plugins_manager::get_data(args["in-data"], args) ;
try
{
d_in->load(args["input"], args);
......@@ -122,7 +122,7 @@ int main(int argc, char** argv)
std::cout << "<<INFO>> input data will be treated as ALTA format" << std::endl;
}
ptr<data> d_out = plugins_manager::get_data(args["out-data"]) ;
ptr<data> d_out = plugins_manager::get_data(args["out-data"], args) ;
if(!d_out)
{
std::cout << "<<INFO>> data will be outputed to ALTA format" << std::endl;
......
......@@ -79,7 +79,7 @@ int main(int argc, char** argv)
// Import data
ptr<data> d = NULL ;
d = plugins_manager::get_data(args["data"]) ;
d = plugins_manager::get_data(args["data"], args) ;
if(dynamic_pointer_cast<vertical_segment>(d)) {
std::cerr << "<<ERROR>> this data object is not interpolant." << std::endl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment