summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-08-23 18:38:07 +0000
committerrandomdan <randomdan@localhost>2011-08-23 18:38:07 +0000
commit2988566cc30f84761b2a8dc9e7d1a90ddcc94c1b (patch)
treeba68267fcafdc4368b31b9c304913f58df40f3df
parentShuffle a bit of code (diff)
downloadproject2-2988566cc30f84761b2a8dc9e7d1a90ddcc94c1b.tar.bz2
project2-2988566cc30f84761b2a8dc9e7d1a90ddcc94c1b.tar.xz
project2-2988566cc30f84761b2a8dc9e7d1a90ddcc94c1b.zip
Allow specifying extra or replacement key parameters for a cache instance
Don't crash when trying to clear an non-existant cache directory
-rw-r--r--project2/cache.cpp4
-rw-r--r--project2/cache.h5
-rw-r--r--project2/xmlCache.cpp11
-rw-r--r--project2/xmlObjectLoader.cpp6
4 files changed, 20 insertions, 6 deletions
diff --git a/project2/cache.cpp b/project2/cache.cpp
index 0db108b..bdf012b 100644
--- a/project2/cache.cpp
+++ b/project2/cache.cpp
@@ -4,7 +4,9 @@
#include "logger.h"
Cache::Cache(const xmlpp::Element * p) :
- SourceObject(p)
+ IHaveParameters(p),
+ SourceObject(p),
+ inherit(p->get_attribute_value("inherit") != "false")
{
}
diff --git a/project2/cache.h b/project2/cache.h
index 358d933..9678356 100644
--- a/project2/cache.h
+++ b/project2/cache.h
@@ -3,14 +3,14 @@
#include "sourceObject.h"
#include "presenter.h"
+#include "iHaveParameters.h"
class RowProcessor;
-class IHaveParameters;
class RowSet;
class RowState;
typedef boost::intrusive_ptr<const RowSet> RowSetCPtr;
-class Cache : public SourceObject {
+class Cache : public IHaveParameters, public SourceObject {
public:
Cache(const xmlpp::Element * p);
@@ -20,6 +20,7 @@ class Cache : public SourceObject {
protected:
virtual RowSetCPtr getCachedRowSet(const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) const = 0;
+ const bool inherit;
};
typedef boost::intrusive_ptr<Cache> CachePtr;
diff --git a/project2/xmlCache.cpp b/project2/xmlCache.cpp
index 0a166e8..22937d6 100644
--- a/project2/xmlCache.cpp
+++ b/project2/xmlCache.cpp
@@ -61,13 +61,20 @@ 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);
+ }
+ cache /= FileName;
+ return cache;
+ }
+ static void appendPath(boost::filesystem::path & cache, const IHaveParameters * ps)
+ {
BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, ps->allParameters()) {
std::string v = p.second->value();
cache /= p.first.raw();
cache /= v;
}
- cache /= FileName;
- return cache;
}
XmlPresenterPtr writeTo;
diff --git a/project2/xmlObjectLoader.cpp b/project2/xmlObjectLoader.cpp
index 5cc28f0..14d2972 100644
--- a/project2/xmlObjectLoader.cpp
+++ b/project2/xmlObjectLoader.cpp
@@ -106,7 +106,11 @@ void
LoaderBase::onAllComponents(const boost::function1<void, ComponentLoader *> & func)
{
BOOST_FOREACH(ComponentLoaderSet::value_type l, *componentLoaders()) {
- func(l.get());
+ try {
+ func(l.get());
+ }
+ catch (...) {
+ }
}
}