Commit bda19515 authored by Laurent Belcour's avatar Laurent Belcour

Adding a hack to load symbols using the static way

parent 5c944269
......@@ -79,7 +79,6 @@ plugins_manager::plugins_manager(const arguments& args)
}
}
#define USING_STATIC
#ifdef USING_STATIC
typedef function* (*FunctionPrototype)();
typedef fitter* (*FitterPrototype)();
......@@ -105,7 +104,7 @@ function* plugins_manager::get_function()
#endif
}
data* plugins_manager::get_data() const
data* plugins_manager::get_data()
{
//if(_datas.empty())
{
......@@ -122,8 +121,11 @@ data* plugins_manager::get_data() const
return _datas.begin()->second ;
}*/
}
fitter* plugins_manager::get_fitter() const
fitter* plugins_manager::get_fitter()
{
#ifdef USING_STATIC
return NULL;
#else
if(_fitters.empty())
{
return NULL ;
......@@ -135,6 +137,7 @@ fitter* plugins_manager::get_fitter() const
#endif
return _fitters.begin()->second ;
}
#endif
}
......@@ -153,7 +156,15 @@ function* plugins_manager::get_function(const std::string& n)
}
#ifdef USING_STATIC
FunctionPrototype myFunction = (FunctionPrototype) QLibrary::resolve(QString(n.c_str()), "_Z16provide_functionv");
QString path = QDir::currentPath() + QString(n.c_str()) ;
QLibrary function_lib(path);
if(!function_lib.isLoaded())
{
std::cerr << "<<ERROR>> unable to load file \"" << path.toStdString() << "\"" << std::endl;
return NULL;
}
FunctionPrototype myFunction = (FunctionPrototype) function_lib.resolve("_Z16provide_functionv");
if(myFunction != NULL)
{
......@@ -190,7 +201,15 @@ data* plugins_manager::get_data(const std::string& n)
}
#ifdef USING_STATIC
DataPrototype myData = (DataPrototype) QLibrary::resolve(QString(n.c_str()), "_Z16provide_datav");
QString path = QDir::currentPath() + QString(n.c_str()) ;
QLibrary data_lib(path);
if(!data_lib.isLoaded())
{
std::cerr << "<<ERROR>> unable to load file \"" << path.toStdString() << "\"" << std::endl;
return NULL;
}
DataPrototype myData = (DataPrototype) data_lib.resolve("_Z16provide_datav");
if(myData != NULL)
{
......@@ -216,7 +235,7 @@ data* plugins_manager::get_data(const std::string& n)
}
#endif
}
fitter* plugins_manager::get_fitter(const std::string& n) const
fitter* plugins_manager::get_fitter(const std::string& n)
{
if(n.empty())
{
......@@ -226,8 +245,16 @@ fitter* plugins_manager::get_fitter(const std::string& n) const
return NULL;
}
#ifndef USING_STATIC
FitterPrototype myFitter = (FitterPrototype) QLibrary::resolve(QString(n.c_str()), "_Z16provide_fitter");
#ifdef USING_STATIC
QString path = QDir::currentPath() + QString(n.c_str()) ;
QLibrary fitting_lib(path);
if(!fitting_lib.isLoaded())
{
std::cerr << "<<ERROR>> unable to load file \"" << path.toStdString() << "\"" << std::endl;
return NULL;
}
FitterPrototype myFitter = (FitterPrototype) fitting_lib.resolve("_Z14provide_fitterv");
if(myFitter != NULL)
{
......@@ -238,8 +265,8 @@ fitter* plugins_manager::get_fitter(const std::string& n) const
}
else
{
std::cerr << "<<ERROR>> no data provider found in file \"" << n << "\"" << std::endl;
return new NULL() ;
std::cerr << "<<ERROR>> no fitter provider found in file \"" << n << "\"" << std::endl;
return NULL ;
}
#else
if(_fitters.count(n) == 0)
......
......@@ -8,6 +8,8 @@
#include "fitter.h"
#include "args.h"
#define USING_STATIC
/*! \brief This class handles the loading of plugins and insure that they can
* talk to each others through coordinates transforms.
*
......@@ -25,15 +27,33 @@ class plugins_manager
//! \brief Get instances of the function, the data and the fitter. Select
//! the first in the map,
static function* get_function() ;
data* get_data() const ;
fitter* get_fitter() const ;
#ifdef USING_STATIC
static
#endif
function* get_function() ;
#ifdef USING_STATIC
static
#endif
data* get_data() ;
#ifdef USING_STATIC
static
#endif
fitter* get_fitter() ;
//! \brief Get instances of the function, the data and the fitter, select one
//! based on the name. Return null if no one exist.
static function* get_function(const std::string& n) ;
static data* get_data(const std::string& n) ;
fitter* get_fitter(const std::string& n) const ;
#ifdef USING_STATIC
static
#endif
function* get_function(const std::string& n) ;
#ifdef USING_STATIC
static
#endif
data* get_data(const std::string& n) ;
#ifdef USING_STATIC
static
#endif
fitter* get_fitter(const std::string& n) ;
//! \brief check if a data object and a function object are compatibles.
//! this has to be done before fitting to ensure that the
......
......@@ -13,6 +13,11 @@
#include <QTime>
fitter* provide_fitter()
{
return new nonlinear_fitter_eigen();
}
struct EigenFunctor
{
EigenFunctor(nonlinear_function* f) : _f(f)
......@@ -70,7 +75,7 @@ bool nonlinear_fitter_eigen::fit_data(const data* d, function* fit, const argume
if(dynamic_cast<nonlinear_function*>(fit) == NULL)
{
std::cerr << "<<ERROR>> the function is non a non-linear function" << std::endl;
std::cerr << "<<ERROR>> the function is not a non-linear function" << std::endl;
return false;
}
nonlinear_function* nf = dynamic_cast<nonlinear_function*>(fit);
......
TARGET = nonlinear_levenberf_eigen
TARGET = nonlinear_levenberg_eigen
TEMPLATE = lib
CONFIG *= qt \
plugin \
......
......@@ -66,6 +66,18 @@ int main(int argc, char** argv)
f << x << "\t" << y << "\t" << z << "\t" << 0.1f << std::endl ;
}
}
else if(k == 5)
{
f << "#DIM 1 1" << std::endl ;
f << "#PARAM_IN COS_TH" << std::endl;
for(int i=0; i<nbx; ++i)
{
const float x = i / (float)nbx ;
const float z = exp(-10.0 * x*x) + 0.1 ;
f << x << "\t" << z << std::endl ;
}
}
return 0 ;
}
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