diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-01-06 21:40:46 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-01-06 21:40:46 +0000 |
commit | 32b6333389994700f077a79d01f79b79e41c7714 (patch) | |
tree | 945a376777ef71bc37d1d788eda635c6a0287c14 | |
parent | Have cache elements keep a const shared_ptr<const T> for items and return a s... (diff) | |
download | libadhocutil-32b6333389994700f077a79d01f79b79e41c7714.tar.bz2 libadhocutil-32b6333389994700f077a79d01f79b79e41c7714.tar.xz libadhocutil-32b6333389994700f077a79d01f79b79e41c7714.zip |
Rename add functions to avoid ambigious call errors all over the placelibadhocutil-0.3.4
-rw-r--r-- | libadhocutil/cache.h | 6 | ||||
-rw-r--r-- | libadhocutil/cache.impl.h | 6 | ||||
-rw-r--r-- | libadhocutil/unittests/testCache.cpp | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/libadhocutil/cache.h b/libadhocutil/cache.h index 4e66e55..4f53a53 100644 --- a/libadhocutil/cache.h +++ b/libadhocutil/cache.h @@ -95,7 +95,7 @@ class DLL_PUBLIC Cache { * @param t The item to cache. * @param validUntil The absolute time the cache item should expire. */ - void add(const K & k, Value & t, time_t validUntil); + void addPointer(const K & k, Value & t, time_t validUntil); /** Add a callback item to the cache. * The callback will be called on first hit of the cache item, at which * point the return value of the function will be cached. @@ -103,7 +103,7 @@ class DLL_PUBLIC Cache { * @param tf The callback function to cache. * @param validUntil The absolute time the cache item should expire. */ - void add(const K & k, const Factory & tf, time_t validUntil); + void addFactory(const K & k, const Factory & tf, time_t validUntil); /** Add a pointer callback item to the cache. * The callback will be called on first hit of the cache item, at which * point the return value of the function will be cached. @@ -111,7 +111,7 @@ class DLL_PUBLIC Cache { * @param tf The callback function to cache. * @param validUntil The absolute time the cache item should expire. */ - void add(const K & k, const PointerFactory & tf, time_t validUntil); + void addPointerFactory(const K & k, const PointerFactory & tf, time_t validUntil); /** Get an Element from the cache. The element represents the key, item and expiry time. * Returns null on cache-miss. * @param k Cache key to get. */ diff --git a/libadhocutil/cache.impl.h b/libadhocutil/cache.impl.h index dffed7f..5f51c36 100644 --- a/libadhocutil/cache.impl.h +++ b/libadhocutil/cache.impl.h @@ -94,7 +94,7 @@ Cache<T, K>::add(const K & k, const T & t, time_t validUntil) template<typename T, typename K> void -Cache<T, K>::add(const K & k, Value & t, time_t validUntil) +Cache<T, K>::addPointer(const K & k, Value & t, time_t validUntil) { Lock(lock); cached.insert(Element(new ObjectCacheable<T, K>(t, k, validUntil))); @@ -102,7 +102,7 @@ Cache<T, K>::add(const K & k, Value & t, time_t validUntil) template<typename T, typename K> void -Cache<T, K>::add(const K & k, const Factory & tf, time_t validUntil) +Cache<T, K>::addFactory(const K & k, const Factory & tf, time_t validUntil) { Lock(lock); cached.insert(Element(new CallCacheable<T, K>(tf, k, validUntil))); @@ -110,7 +110,7 @@ Cache<T, K>::add(const K & k, const Factory & tf, time_t validUntil) template<typename T, typename K> void -Cache<T, K>::add(const K & k, const PointerFactory & tf, time_t validUntil) +Cache<T, K>::addPointerFactory(const K & k, const PointerFactory & tf, time_t validUntil) { Lock(lock); cached.insert(Element(new PointerCallCacheable<T, K>(tf, k, validUntil))); diff --git a/libadhocutil/unittests/testCache.cpp b/libadhocutil/unittests/testCache.cpp index 89ae556..4468ca2 100644 --- a/libadhocutil/unittests/testCache.cpp +++ b/libadhocutil/unittests/testCache.cpp @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE( callcache ) int callCount = 0; auto vu = time(NULL) + 5; BOOST_REQUIRE_EQUAL(nullptr, tc.get("key")); - tc.add("key", TestCache::Factory([&callCount]{ callCount++; return 3; }), vu); + tc.addFactory("key", [&callCount]{ callCount++; return 3; }, vu); BOOST_REQUIRE_EQUAL(0, callCount); BOOST_REQUIRE_EQUAL(3, *tc.get("key")); BOOST_REQUIRE_EQUAL(1, callCount); @@ -130,7 +130,7 @@ BOOST_AUTO_TEST_CASE( pointercallcache ) int callCount = 0; auto vu = time(NULL) + 5; BOOST_REQUIRE_EQUAL(nullptr, tc.get("key")); - tc.add("key", TestCache::PointerFactory([&callCount]{ callCount++; return TestCache::Value(new Obj(3)); }), vu); + tc.addPointerFactory("key", [&callCount]{ callCount++; return TestCache::Value(new Obj(3)); }, vu); BOOST_REQUIRE_EQUAL(0, callCount); BOOST_REQUIRE_EQUAL(3, *tc.get("key")); BOOST_REQUIRE_EQUAL(1, callCount); @@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE( addPointer ) { TestCache tc; auto v = TestCache::Value(new Obj(3)); - tc.add("key", v, time(NULL) + 1); + tc.addPointer("key", v, time(NULL) + 1); auto h = tc.get("key"); BOOST_REQUIRE(h); BOOST_REQUIRE_EQUAL(3, *h); |