Commit 1ae1adb7 authored by Ludovic Courtès's avatar Ludovic Courtès

params: Implement proper params::output value-to-name mapping.

parent dbd140ee
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2014 CNRS
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2015 Inria
This file is part of ALTA.
......@@ -81,6 +81,31 @@ static const std::map<params::input, const param_info> input_map = create_map();
//};
//#endif
static std::map<params::output, std::string> create_output_map()
{
std::map<params::output, std::string> result;
#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)
#define DEFINE_MAPPING(name) \
result[params::name] = STRINGIFY(name);
DEFINE_MAPPING(INV_STERADIAN);
DEFINE_MAPPING(INV_STERADIAN_COSINE_FACTOR);
DEFINE_MAPPING(ENERGY);
DEFINE_MAPPING(RGB_COLOR);
DEFINE_MAPPING(XYZ_COLOR);
#undef DEFINE_MAPPING
#undef STRINGIFY
#undef STRINGIFY_
return result;
}
static const std::map<params::output, std::string> output_map =
create_output_map();
void params::to_cartesian(const double* invec, params::input intype,
double* outvec)
{
......@@ -566,6 +591,18 @@ std::string params::get_name(const params::input param)
return std::string("UNKNOWN_INPUT");
}
std::string params::get_name(const params::output param)
{
std::map<params::output, std::string>::const_iterator it = output_map.find(param);
if (it != output_map.end())
{
return it->second;
}
static const std::string unknown = "UNKNOWN_OUTPUT";
return unknown;
}
int params::dimension(params::input t)
{
std::map<params::input, const param_info>::const_iterator it = input_map.find(t);
......
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions
Copyright (C) 2014 CNRS
Copyright (C) 2013, 2014 Inria
Copyright (C) 2013, 2014, 2015 Inria
This file is part of ALTA.
......@@ -135,10 +135,7 @@ class params
//! type.
//! \todo Finish this implementation. It requires another static
//! object.
static std::string get_name(const params::output)
{
return std::string("UNKNOWN_OUTPUT");
}
static std::string get_name(const params::output);
//! \brief static function for input type convertion. This
//! function allocate the resulting vector.
......
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