Commit 5a863615 authored by Laurent Belcour's avatar Laurent Belcour

[Update] Changing the interface of get_function to be consistent with

data and fitter. This is linked to the update of the python interface.
[Update] Allowing the python interface to compile with OpenMP support.
parent 6d72918e
......@@ -151,7 +151,7 @@ return NULL;
}
//! \brief load a function from the ALTA input file.
function* plugins_manager::get_function(const std::string& filename)
function* plugins_manager::load_function(const std::string& filename)
{
std::ifstream file;
file.open(filename.c_str()) ;
......@@ -409,6 +409,34 @@ function* plugins_manager::get_function(const arguments& args)
return func;
}
ptr<function> plugins_manager::get_function(const std::string& n)
{
if(n.empty())
{
#ifdef DEBUG
std::cout << "<<DEBUG>> no function plugin specified, returning nothing" << std::endl;
#endif
return NULL;
}
FunctionPrototype myFunc = open_library<FunctionPrototype>(n, "provide_function");
if(myFunc != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> using function provider in file \"" << n << "\"" << std::endl;
#endif
return myFunc();
}
else
{
std::cerr << "<<ERROR>> no function provider found in file \"" << n << "\"" << std::endl;
return NULL;
}
}
ptr<data> plugins_manager::get_data(const std::string& n)
{
if(n.empty())
......
......@@ -43,7 +43,10 @@ class plugins_manager
static function* get_function(const arguments& args) ;
//! \brief load a function from the ALTA input file.
static function* get_function(const std::string& filename);
static function* load_function(const std::string& filename);
//! \brief load a function from the ALTA input file.
static ptr<function> get_function(const std::string& n);
//! \brief get an instance of the data that is defined in the plugin with
//! filename n. Return null if no one exist.
......
......@@ -7,7 +7,15 @@ build_lib = False
if library_available(env, pkgspec='python-2.7',
inc_var='PYTHON_INC', lib_var='PYTHON_DIR',
lib='PYTHON_LIB', header='Python.h'):
conf = Configure(env)
# Check if OpenMP is available
env.AppendUnique(CCFLAGS = env['OPENMP_FLAG'])
if conf.CheckLib(env['OPENMP_LIB']):
env.AppendUnique(LIBS = env['OPENMP_LIB'])
#end
# On GNU/Linux the '-mt' suffix is no longer used, but it is still
# used on some other platforms (see
......
......@@ -99,8 +99,8 @@ ptr<data> load_data(const std::string& plugin_name, const std::string& filename)
* Those function should disapear when the return type of get_Function
* in the plugin_manager will be ptr<function>.
*/
ptr<function> get_function(const std::string& filename) {
ptr<function> func(plugins_manager::get_function(filename));
ptr<function> get_function(const std::string& plugin_name) {
ptr<function> func(plugins_manager::get_function(plugin_name));
if(!func) {
std::cerr << "<<ERROR>> no function created" << std::endl;
}
......@@ -143,6 +143,10 @@ void data2data(const data* d_in, data* d_out) {
}
}
void fit_data(ptr<fitter>& f, const ptr<data>& d, ptr<function>& fn, const arguments& args) {
f->fit_data(d, fn, args);
}
/* Exporting the ALTA module
*/
......@@ -173,12 +177,13 @@ BOOST_PYTHON_MODULE(alta)
//
bp::class_<function, ptr<function>, boost::noncopyable>("function", bp::no_init)
.def("value", &function::value)
.def("load", &function::load)
.def("load", &function::load)
.def("save", &function::save);
bp::def("get_function", get_function);
bp::def("get_function", get_function_from_args);
// Data interface
//
bp::class_<data, ptr<data>, boost::noncopyable>("data", bp::no_init)
......@@ -196,7 +201,7 @@ 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);
// Softs
//
......
......@@ -59,7 +59,7 @@ int main(int argc, char** argv)
}
// Load the function
function* f = plugins_manager::get_function(args["input"]);
function* f = plugins_manager::load_function(args["input"]);
// Save it
f->save(args["output"], args) ;
......
......@@ -90,7 +90,7 @@ int main(int argc, char** argv)
// Get the function file
function* f = NULL;
f = plugins_manager::get_function(args["input"]);
f = plugins_manager::load_function(args["input"]);
if(f == NULL)
{
std::cerr << "<<ERROR>> cannot open the function file" << std::endl;
......
......@@ -63,7 +63,7 @@ int main(int argc, char** argv)
// Load a function file
function* f = plugins_manager::get_function(args["input"]) ;
function* f = plugins_manager::load_function(args["input"]) ;
if(f == NULL)
{
return 1;
......
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