From 3aad3441e3ae903f8206b5a2cf40a25ef721e4e7 Mon Sep 17 00:00:00 2001 From: randomdan Date: Mon, 2 Jun 2014 12:33:13 +0000 Subject: Fix naming clash with 'cache' --- project2/basics/caches/memoryCache.cpp | 6 ++-- project2/common/cache.cpp | 50 ---------------------------------- project2/common/cache.h | 31 --------------------- project2/common/rowProcessor.cpp | 2 +- project2/common/rowProcessor.h | 6 ++-- project2/common/rowSetCache.cpp | 50 ++++++++++++++++++++++++++++++++++ project2/common/rowSetCache.h | 31 +++++++++++++++++++++ project2/sql/sqlCache.cpp | 6 ++-- project2/xml/xmlCache.cpp | 6 ++-- 9 files changed, 94 insertions(+), 94 deletions(-) delete mode 100644 project2/common/cache.cpp delete mode 100644 project2/common/cache.h create mode 100644 project2/common/rowSetCache.cpp create mode 100644 project2/common/rowSetCache.h diff --git a/project2/basics/caches/memoryCache.cpp b/project2/basics/caches/memoryCache.cpp index 7ab271e..ee4f9b3 100644 --- a/project2/basics/caches/memoryCache.cpp +++ b/project2/basics/caches/memoryCache.cpp @@ -1,6 +1,6 @@ #include #include "logger.h" -#include "cache.h" +#include "rowSetCache.h" #include #include "options.h" #include "rowSet.h" @@ -10,7 +10,7 @@ #include #include -class MemoryCache : public Cache { +class MemoryCache : public RowSetCache { public: typedef std::vector Key; class CachedRowSet : public RowSet, public RowSetPresenter { @@ -96,7 +96,7 @@ class MemoryCache : public Cache { > > CacheStore; MemoryCache(ScriptNodePtr p) : - Cache(p) + RowSetCache(p) { } diff --git a/project2/common/cache.cpp b/project2/common/cache.cpp deleted file mode 100644 index 2a1d410..0000000 --- a/project2/common/cache.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "cache.h" -#include "rowSet.h" -#include "rowProcessor.h" -#include "logger.h" -#include -#include - -Cache::Cache(ScriptNodePtr p) : - IHaveParameters(p), - SourceObject(p), - inherit(p->value("inherit", true, NULL).as()) -{ -} - -bool Cache::checkAndExecute(ExecContext * ec, const Glib::ustring & n, const Glib::ustring & f, const IHaveParameters * p, const RowProcessorCallback & rp) -{ - RowSetCPtr cached = getCachedRowSet(ec, n, f, p); - if (cached) { - try { - Logger()->messagebf(LOG_DEBUG, "Executing from cache '%s'", name); - cached->execute(f, rp, ec); - return true; - } - catch (const Glib::Exception & e) { - Logger()->messagebf(LOG_WARNING, "Cache failed (%s)", e.what()); - } - catch (const std::exception & e) { - Logger()->messagef(LOG_WARNING, "Cache failed (%s)", e.what()); - } - catch (...) { - Logger()->message(LOG_WARNING, "Cache failed"); - } - } - return false; -} - -void -Cache::applyKeys(ExecContext * ec, const KeyApplier & f, const IHaveParameters * ps) const -{ - BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, allParameters()) { - f(p.first, p.second(ec)); - } - if (inherit) { - BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, ps->allParameters()) { - f(p.first, p.second(ec)); - } - } -} - diff --git a/project2/common/cache.h b/project2/common/cache.h deleted file mode 100644 index 0806c6f..0000000 --- a/project2/common/cache.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CACHE_H -#define CACHE_H - -#include "sourceObject.h" -#include "presenter.h" -#include "iHaveParameters.h" -#include "rowSet.h" - -class RowSet; -class RowState; -typedef boost::intrusive_ptr RowSetCPtr; - -class Cache : public IHaveParameters, public SourceObject { - public: - Cache(ScriptNodePtr p); - - bool checkAndExecute(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *, const RowProcessorCallback &); - virtual RowSetPresenterPtr openFor(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0; - virtual void save(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0; - virtual void discard(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0; - - protected: - virtual RowSetCPtr getCachedRowSet(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) const = 0; - typedef boost::function KeyApplier; - void applyKeys(ExecContext * ec, const KeyApplier & f, const IHaveParameters * ps) const; - const bool inherit; -}; -typedef boost::intrusive_ptr CachePtr; - -#endif - diff --git a/project2/common/rowProcessor.cpp b/project2/common/rowProcessor.cpp index 7ffaf7f..85cd698 100644 --- a/project2/common/rowProcessor.cpp +++ b/project2/common/rowProcessor.cpp @@ -32,7 +32,7 @@ RowProcessor::execute(ExecContext * ec, const RowProcessorCallback & cb) const boost::bind(&RowProcessor::saveCaches, this, ec), boost::bind((CROE ? &RowProcessor::saveCaches : &RowProcessor::discardCaches), this, ec), boost::bind(&TargetCaches::clear, &tc)); - BOOST_FOREACH(const CachePtr & c, caches) { + BOOST_FOREACH(const auto & c, caches) { if (c->checkAndExecute(ec, source->name, filter, this, cb)) { return; } diff --git a/project2/common/rowProcessor.h b/project2/common/rowProcessor.h index 70f453c..ca36b32 100644 --- a/project2/common/rowProcessor.h +++ b/project2/common/rowProcessor.h @@ -5,7 +5,7 @@ #include "sourceObject.h" #include "iHaveParameters.h" #include "rowSet.h" -#include "cache.h" +#include "rowSetCache.h" #include "test.h" #include "scriptStorage.h" @@ -33,9 +33,9 @@ class RowProcessor : public IHaveParameters { void rowReadyInternal(const RowState *, const RowProcessorCallback &, ExecContext *) const; typedef ANONSTORAGEOF(Test) Tests; Tests tests; - typedef ANONORDEREDSTORAGEOF(Cache) Caches; + typedef ANONORDEREDSTORAGEOF(RowSetCache) Caches; Caches caches; - typedef boost::tuple TargetCache; + typedef boost::tuple TargetCache; typedef boost::shared_ptr TargetCachePtr; typedef std::set TargetCaches; mutable TargetCaches tc; diff --git a/project2/common/rowSetCache.cpp b/project2/common/rowSetCache.cpp new file mode 100644 index 0000000..23ae177 --- /dev/null +++ b/project2/common/rowSetCache.cpp @@ -0,0 +1,50 @@ +#include +#include "rowSetCache.h" +#include "rowSet.h" +#include "rowProcessor.h" +#include "logger.h" +#include +#include + +RowSetCache::RowSetCache(ScriptNodePtr p) : + IHaveParameters(p), + SourceObject(p), + inherit(p->value("inherit", true, NULL).as()) +{ +} + +bool RowSetCache::checkAndExecute(ExecContext * ec, const Glib::ustring & n, const Glib::ustring & f, const IHaveParameters * p, const RowProcessorCallback & rp) +{ + RowSetCPtr cached = getCachedRowSet(ec, n, f, p); + if (cached) { + try { + Logger()->messagebf(LOG_DEBUG, "Executing from cache '%s'", name); + cached->execute(f, rp, ec); + return true; + } + catch (const Glib::Exception & e) { + Logger()->messagebf(LOG_WARNING, "Cache failed (%s)", e.what()); + } + catch (const std::exception & e) { + Logger()->messagef(LOG_WARNING, "Cache failed (%s)", e.what()); + } + catch (...) { + Logger()->message(LOG_WARNING, "Cache failed"); + } + } + return false; +} + +void +RowSetCache::applyKeys(ExecContext * ec, const KeyApplier & f, const IHaveParameters * ps) const +{ + BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, allParameters()) { + f(p.first, p.second(ec)); + } + if (inherit) { + BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, ps->allParameters()) { + f(p.first, p.second(ec)); + } + } +} + diff --git a/project2/common/rowSetCache.h b/project2/common/rowSetCache.h new file mode 100644 index 0000000..055b07e --- /dev/null +++ b/project2/common/rowSetCache.h @@ -0,0 +1,31 @@ +#ifndef ROWSETCACHE_H +#define ROWSETCACHE_H + +#include "sourceObject.h" +#include "presenter.h" +#include "iHaveParameters.h" +#include "rowSet.h" + +class RowSet; +class RowState; +typedef boost::intrusive_ptr RowSetCPtr; + +class RowSetCache : public IHaveParameters, public SourceObject { + public: + RowSetCache(ScriptNodePtr p); + + bool checkAndExecute(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *, const RowProcessorCallback &); + virtual RowSetPresenterPtr openFor(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0; + virtual void save(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0; + virtual void discard(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0; + + protected: + virtual RowSetCPtr getCachedRowSet(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) const = 0; + typedef boost::function KeyApplier; + void applyKeys(ExecContext * ec, const KeyApplier & f, const IHaveParameters * ps) const; + const bool inherit; +}; +typedef boost::intrusive_ptr RowSetCachePtr; + +#endif + diff --git a/project2/sql/sqlCache.cpp b/project2/sql/sqlCache.cpp index 2d40bdd..c495528 100644 --- a/project2/sql/sqlCache.cpp +++ b/project2/sql/sqlCache.cpp @@ -1,5 +1,5 @@ #include -#include "cache.h" +#include "rowSetCache.h" #include "sqlVariableBinder.h" #include "sqlHandleAsVariableType.h" #include "buffer.h" @@ -20,10 +20,10 @@ typedef boost::shared_ptr SelectPtr; typedef boost::shared_ptr ModifyPtr; -class SqlCache : public Cache { +class SqlCache : public RowSetCache { public: SqlCache(ScriptNodePtr p) : - Cache(p), + RowSetCache(p), db(NULL) { } diff --git a/project2/xml/xmlCache.cpp b/project2/xml/xmlCache.cpp index 85ef689..bfa9c91 100644 --- a/project2/xml/xmlCache.cpp +++ b/project2/xml/xmlCache.cpp @@ -1,5 +1,5 @@ #include -#include "cache.h" +#include "rowSetCache.h" #include "logger.h" #include "scriptLoader.h" #include "iHaveParameters.h" @@ -12,10 +12,10 @@ #include #include -class XmlCache : public Cache { +class XmlCache : public RowSetCache { public: XmlCache(ScriptNodePtr p) : - Cache(p) + RowSetCache(p) { } -- cgit v1.2.3