summaryrefslogtreecommitdiff
path: root/project2/xmlCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/xmlCache.cpp')
-rw-r--r--project2/xmlCache.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/project2/xmlCache.cpp b/project2/xmlCache.cpp
index 22937d6..86b098a 100644
--- a/project2/xmlCache.cpp
+++ b/project2/xmlCache.cpp
@@ -9,7 +9,6 @@
#include <boost/program_options.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/convenience.hpp>
-#include <libxml++/nodes/textnode.h>
#include <libxml++/document.h>
class XmlCache : public Cache {
@@ -37,15 +36,15 @@ class XmlCache : public Cache {
return NULL;
}
- PresenterPtr openFor(const Glib::ustring & n, const Glib::ustring & f, const IHaveParameters * ps)
+ PresenterPtr openFor(const Glib::ustring & n, const Glib::ustring &, const IHaveParameters *)
{
- target = getCacheFile(n, f, ps);
writeTo = new XmlPresenter(n, Glib::ustring(), Glib::ustring());
return writeTo;
}
- void close()
+ void close(const Glib::ustring & n, const Glib::ustring & f, const IHaveParameters * ps)
{
+ boost::filesystem::path target = getCacheFile(n, f, ps);
try {
boost::filesystem::create_directories(target.parent_path());
const xmlpp::Document * d = *writeTo;
@@ -61,24 +60,18 @@ class XmlCache : public Cache {
boost::filesystem::path getCacheFile(const Glib::ustring & n, const Glib::ustring & f, const IHaveParameters * ps) const
{
boost::filesystem::path cache = Store / n.raw() / f.raw();
- appendPath(cache, this);
- if (inherit) {
- appendPath(cache, ps);
- }
+ applyKeys(boost::bind(&appendPath, &cache, _1, _2), ps);
cache /= FileName;
return cache;
}
- static void appendPath(boost::filesystem::path & cache, const IHaveParameters * ps)
+
+ static void appendPath(boost::filesystem::path * cache, const std::string & n, const VariableType & v)
{
- BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, ps->allParameters()) {
- std::string v = p.second->value();
- cache /= p.first.raw();
- cache /= v;
- }
+ *cache /= n;
+ *cache /= v.operator const std::string &();
}
XmlPresenterPtr writeTo;
- boost::filesystem::path target;
friend class CustomXmlCacheLoader;
static boost::filesystem::path Store;