Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit e3eaa038 authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Cleaning the the interface of the plugin manager.

Corrections in the code of some softs.
parent d497acce
......@@ -2,11 +2,6 @@
#include "rational_function.h"
#include "vertical_segment.h"
/*
#include <QCoreApplication>
#include <QDir>
*/
#ifdef _WIN32
#include <windows.h>
#else
......@@ -68,136 +63,6 @@ template<typename T> T open_library(const std::string& filename, const char* fun
#endif
}
// Create the object, parse the argument and load all the plugins
plugins_manager::plugins_manager(const arguments&)
{
/*
QDir pluginsDir;
if(args.is_defined("plugins"))
{
pluginsDir = QDir(args["plugins"].c_str()) ;
}
else if(QCoreApplication::instance() != NULL)
{
pluginsDir = QDir(QCoreApplication::instance()->applicationDirPath());
}
*/
/*
foreach (QString fileName, pluginsDir.entryList(QDir::Files))
{
QPluginLoader loader ;
loader.setLoadHints(QLibrary::ExportExternalSymbolsHint) ;
loader.setFileName(pluginsDir.absoluteFilePath(fileName));
// Convert filename for outputing
std::string filename(fileName.toStdString()) ;
if(!loader.load())
{
#ifdef DEBUG
std::cout << "<<DEBUG>> " << loader.errorString().toStdString() << std::endl ;
#endif
continue ;
}
QObject *plugin = loader.instance();
if (plugin != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> loading plugin " << filename << std::endl ;
#endif
if(dynamic_cast<function*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a function" << std::endl ;
#endif
_functions.insert(std::pair<std::string, function*>(filename, dynamic_cast<function*>(plugin))) ;
}
if(dynamic_cast<data*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a data loader" << std::endl ;
#endif
_datas.insert(std::pair<std::string, data*>(filename, dynamic_cast<data*>(plugin))) ;
}
if(dynamic_cast<fitter*>(plugin) != NULL)
{
#ifdef DEBUG
std::cout << "<<DEBUG>> -> it is a fitter" << std::endl ;
#endif
_fitters.insert(std::pair<std::string, fitter*>(filename, dynamic_cast<fitter*>(plugin))) ;
}
}
else
{
#ifdef DEBUG
std::cout << "<<DEBUG>> " << loader.errorString().toStdString() << std::endl ;
#endif
}
}
*/
}
// Get instances of the function, the data and the
// fitter
//
function* plugins_manager::get_function()
{
#ifdef USING_STATIC
return new rational_function() ;
#else
if(_functions.empty())
{
return new rational_function() ;
}
else
{
return _functions.begin()->second ;
}
#endif
}
data* plugins_manager::get_data()
{
//if(_datas.empty())
{
#ifdef DEBUG
std::cout << "<<DEBUG>> using vertical segment data loader" << std::endl ;
#endif
return new vertical_segment() ;
}/*
else
{
#ifdef DEBUG
std::cout << "<<DEBUG>> using \"" << _datas.begin()->first << "\" data loader" << std::endl ;
#endif
return _datas.begin()->second ;
}*/
}
fitter* plugins_manager::get_fitter()
{
#ifdef USING_STATIC
return NULL;
#else
if(_fitters.empty())
{
return NULL ;
}
else
{
#ifdef DEBUG
std::cout << "<<DEBUG>> using \"" << _fitters.begin()->first << "\"" << std::endl ;
#endif
return _fitters.begin()->second ;
}
#endif
}
//! \brief load a function from the ALTA input file.
function* plugins_manager::get_function(const std::string& filename)
{
......
......@@ -10,8 +10,6 @@
#include "args.h"
#include "clustering.h"
#define USING_STATIC
/*! \brief This class handles the loading of plugins and insure that they can
* talk to each others through coordinates transforms.
*
......@@ -21,52 +19,20 @@ class plugins_manager
{
public: //functions
//! \brief Create the object, parse the argument and load all the plugins
plugins_manager(const arguments& args) ;
//! \brief Get instances of the function, the data and the fitter. Select
//! the first in the map,
#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 an instance of the function that is defined in the plugin with
//! filename n. Return null if no one exist.
#ifdef USING_STATIC
static
#endif
function* get_function(const arguments& args) ;
static function* get_function(const arguments& args) ;
//! \brief load a function from the ALTA input file.
#ifdef USING_STATIC
static
#endif
function* get_function(const std::string& filename);
static function* get_function(const std::string& filename);
//! \brief get an instance of the data that is defined in the plugin with
//! filename n. Return null if no one exist.
#ifdef USING_STATIC
static
#endif
data* get_data(const std::string& n) ;
static data* get_data(const std::string& n) ;
//! \brief get an instance of the fitter that is defined in the plugin with
//! filename n. Return null if no one exist.
#ifdef USING_STATIC
static
#endif
fitter* get_fitter(const std::string& n) ;
static fitter* get_fitter(const std::string& n) ;
//! \brief check if a data object and a function object are compatibles.
......
......@@ -96,8 +96,15 @@ int main(int argc, char** argv)
{
// Copy the input vector
vec x = d->get(i);
params::convert(&x[0], d->parametrization(), f->parametrization(), &temp[0]);
// Convert the data to the function's input space.
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
memcpy(&temp[0], &x[0], f->dimX()*sizeof(double));
}
else
{
params::convert(&x[0], d->parametrization(), f->parametrization(), &temp[0]);
}
vec y = f->value(temp);
for(int j=0; j<d->dimY(); ++j)
......
#include <core/args.h>
#include <core/data.h>
#include <core/function.h>
#include <core/vertical_segment.h>
#include <core/fitter.h>
#include <core/plugins_manager.h>
......@@ -21,16 +22,18 @@ int main(int argc, char** argv)
std::cout << " -> input, and output parameters are mandatory parameters" << std::endl ;
std::cout << std::endl;
std::cout << "Options:" << std::endl;
std::cout << " --data [filename] produce a data by using the abcissas of the [filename]" << std::endl;
std::cout << " data file." << std::endl;
std::cout << " --polar-plot produce a polar data by sampling regularly the elevation" << std::endl;
std::cout << " angle. Use parameter --inc-angle to define the incoming" << std::endl;
std::cout << " angle. Use parameter --samples to define the number of" << std::endl;
std::cout << " samples on this domain." << std::endl;
std::cout << " --inc-angle [float] set the incoming light elevation in radian for the polar" << std::endl;
std::cout << " plot export." << std::endl;
std::cout << " --samples [int] set the points used for the polar plot export." << std::endl;
std::cout << " --cos-plot export the BRDF*cosine instead of the BRDF alone." << std::endl;
std::cout << " --data [filename] data plugin module used to define the abcissas for the." << std::endl;
std::cout << " export, or to load the --in-data file.." << std::endl;
std::cout << " --data-file [filename] produce a data by using the abcissas of the [filename]" << std::endl;
std::cout << " data file." << std::endl;
std::cout << " --polar-plot produce a polar data by sampling regularly the elevation" << std::endl;
std::cout << " angle. Use parameter --inc-angle to define the incoming" << std::endl;
std::cout << " angle. Use parameter --samples to define the number of" << std::endl;
std::cout << " samples on this domain." << std::endl;
std::cout << " --inc-angle [float] set the incoming light elevation in radian for the polar" << std::endl;
std::cout << " plot export." << std::endl;
std::cout << " --samples [int] set the points used for the polar plot export." << std::endl;
std::cout << " --cos-plot export the BRDF*cosine instead of the BRDF alone." << std::endl;
return 0;
}
......@@ -65,11 +68,13 @@ int main(int argc, char** argv)
// Load a data file
data* d = NULL ;
if(args.is_defined("data"))
if(args.is_defined("data") || args.is_defined("in-data"))
{
std::cout << "<<INFO>> Using data file \"" << args["data"] << "\"" << std::endl ;
d = plugins_manager::get_data() ;
d->load(args["data"], args) ;
d = plugins_manager::get_data(args["data"]);
if(dynamic_cast<vertical_segment*>(d) != NULL)
{
d->load(args["in-data"]);
}
// Print the distance to the data to check if it correspond to the value
// computed prior.
......
......@@ -81,7 +81,8 @@ int main(int argc, char** argv)
fitter* fit = plugins_manager::get_fitter(args["fitter"]) ;
if(fit == NULL)
{
fit = plugins_manager::get_fitter() ;
std::cerr << "<<ERROR>> unable to load the fitter plugin \"" << args["fitter"] << "\"" << std::endl;
return 1;
}
if(args.is_defined("available_params"))
......
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