1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include <pch.hpp>
#include "cache.h"
#include "rowSet.h"
#include "rowProcessor.h"
#include "logger.h"
#include <boost/foreach.hpp>
Cache::Cache(const xmlpp::Element * p) :
IHaveParameters(p),
SourceObject(p),
inherit(p->get_attribute_value("inherit") != "false")
{
}
bool Cache::checkAndExecute(const Glib::ustring & n, const Glib::ustring & f, const RowProcessor * rp)
{
RowSetCPtr cached = getCachedRowSet(n, f, rp);
if (cached) {
try {
Logger()->messagef(LOG_ERR, "Executing from cache");
cached->execute(f, rp);
return true;
}
catch (...) {
Logger()->messagef(LOG_WARNING, "Cache failed");
}
}
return false;
}
void
Cache::applyKeys(const boost::function2<void, const std::string &, const VariableType &> & f, const IHaveParameters * ps) const
{
BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, allParameters()) {
f(p.first, p.second);
}
if (inherit) {
BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, ps->allParameters()) {
f(p.first, p.second);
}
}
}
|