ipa: raspberrypi: Return an error code from Algorithm::read()
When encountering errors, the Algorithm::read() function either uses LOG(Fatal) or throws exceptions from the boost property_tree functions. To prepare for replacing boost JSON parse with the YamlParser class, give the Algorithm::read() function the ability to return an error code, and propagate it all the way to the IPA module init() function. All algorithm classes return a hardcoded 0 value for now, subsequent commits will change that. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
parent
0c84c67e39
commit
f357b1bf6e
31 changed files with 151 additions and 75 deletions
|
@ -39,7 +39,7 @@ Matrix::Matrix(double m0, double m1, double m2, double m3, double m4, double m5,
|
|||
m[0][0] = m0, m[0][1] = m1, m[0][2] = m2, m[1][0] = m3, m[1][1] = m4,
|
||||
m[1][2] = m5, m[2][0] = m6, m[2][1] = m7, m[2][2] = m8;
|
||||
}
|
||||
void Matrix::read(boost::property_tree::ptree const ¶ms)
|
||||
int Matrix::read(boost::property_tree::ptree const ¶ms)
|
||||
{
|
||||
double *ptr = (double *)m;
|
||||
int n = 0;
|
||||
|
@ -50,6 +50,7 @@ void Matrix::read(boost::property_tree::ptree const ¶ms)
|
|||
}
|
||||
if (n < 9)
|
||||
LOG(RPiCcm, Fatal) << "Ccm: too few values in CCM";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ccm::Ccm(Controller *controller)
|
||||
|
@ -60,21 +61,32 @@ char const *Ccm::name() const
|
|||
return NAME;
|
||||
}
|
||||
|
||||
void Ccm::read(boost::property_tree::ptree const ¶ms)
|
||||
int Ccm::read(boost::property_tree::ptree const ¶ms)
|
||||
{
|
||||
if (params.get_child_optional("saturation"))
|
||||
config_.saturation.read(params.get_child("saturation"));
|
||||
int ret;
|
||||
|
||||
if (params.get_child_optional("saturation")) {
|
||||
ret = config_.saturation.read(params.get_child("saturation"));
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (auto &p : params.get_child("ccms")) {
|
||||
CtCcm ctCcm;
|
||||
ctCcm.ct = p.second.get<double>("ct");
|
||||
ctCcm.ccm.read(p.second.get_child("ccm"));
|
||||
ret = ctCcm.ccm.read(p.second.get_child("ccm"));
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!config_.ccms.empty() &&
|
||||
ctCcm.ct <= config_.ccms.back().ct)
|
||||
LOG(RPiCcm, Fatal) << "Ccm: CCM not in increasing colour temperature order";
|
||||
config_.ccms.push_back(std::move(ctCcm));
|
||||
}
|
||||
|
||||
if (config_.ccms.empty())
|
||||
LOG(RPiCcm, Fatal) << "Ccm: no CCMs specified";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Ccm::setSaturation(double saturation)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue