Commit d90bf446 authored by PACANOWSKI Romain's avatar PACANOWSKI Romain

Added comments to explain a little bit more the code.

Added output for debugging that will be removed later.
parent 748e1e63
......@@ -21,6 +21,9 @@
#include <stdio.h>
#include <list>
//#define DEBUG
//! Add dynamic library extension (.so or .dll) to a dynamic object as well as
//! prepending 'lib' depending on the plateform.
std::string library_name(const std::string name)
......@@ -230,6 +233,11 @@ function* plugins_manager::get_function(const std::string& filename)
//! Return NULL if none exists.
function* plugins_manager::get_function(const arguments& args)
{
#ifdef DEBUG
std::cout << __FILE__ << " " << __LINE__ << std::endl;
std::cout << " INitial args = " << args << std::endl;
#endif
if(!args.is_defined("func"))
{
#ifdef DEBUG
......@@ -241,8 +249,12 @@ function* plugins_manager::get_function(const arguments& args)
// The function to be returned.
function* func = NULL;
if(args.is_vec("func"))
if(args.is_vec("func")) //Checking if the argument prodived with --func is of the form --func [ arg1, arg2, arg3]
{
#ifdef DEBUG
std::cout << __FILE__ << " " << __LINE__ << " ARGUMENTS of --func are forming a VECTOR " << std::endl;
#endif
std::vector<std::string> args_vec = args.get_vec("func");
// Treating the case []
......@@ -261,14 +273,18 @@ function* plugins_manager::get_function(const arguments& args)
{
std::string n("--func ");
n.append(args_vec[i]);
#ifdef DEBUG
#ifdef DEBUG
std::cout << __FILE__ << " " << __LINE__ << std::endl
<< " at i=" << i << " n=" << n << std::endl;
std::cout << "<<DEBUG>> load function with args: " << n << std::endl;
#endif
#endif
arguments temp_args = arguments::create_arguments(n);
//Recursive call
function* f = get_function(temp_args);
if(dynamic_cast<nonlinear_function*>(f) == NULL)
{
std::cerr << "<<ERROR>> only non-linear function are compatible with a compound" << std::endl;
std::cerr << "<<ERROR>> only non-linear functions are compatible with a compound" << std::endl;
}
else
{
......@@ -278,8 +294,11 @@ function* plugins_manager::get_function(const arguments& args)
//! return the compound class
func = compound;
#ifdef DEBUG
std::cout << __FILE__ << " " << __LINE__ << " WE HAVE A COMPOUND " << std::endl;
#endif
}
else
else //Here we check if the argument provided with --func is file describing a function
{
const std::string filename = args["func"];
FunctionPrototype myFunction = open_library<FunctionPrototype>(filename, "provide_function");
......@@ -300,6 +319,11 @@ function* plugins_manager::get_function(const arguments& args)
// Treat the case of the Fresnel
if(args.is_defined("fresnel"))
{
#ifdef DEBUG
std::cout << __FILE__ << " " << __LINE__ << std::endl;
std::cout << " INSIDE fresnel args = " << args << std::endl;
#endif
// Cast into a non linear function, only those are permitted to use
// a Fresnel term.
nonlinear_function* nl_func = dynamic_cast<nonlinear_function*>(func);
......@@ -332,6 +356,11 @@ function* plugins_manager::get_function(const arguments& args)
}
}
#ifdef DEBUG
std::cout << __FILE__ << " " << __LINE__ << std::endl;
std::cout << " n = " << n << std::endl;
#endif
nonlinear_function* func_fres = dynamic_cast<nonlinear_function*>(get_function(arguments::create_arguments(n)));
if(func_fres != NULL)
{
......
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