From 32b6333389994700f077a79d01f79b79e41c7714 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 6 Jan 2016 21:40:46 +0000 Subject: Rename add functions to avoid ambigious call errors all over the place --- libadhocutil/cache.h | 6 +++--- libadhocutil/cache.impl.h | 6 +++--- 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::add(const K & k, const T & t, time_t validUntil) template void -Cache::add(const K & k, Value & t, time_t validUntil) +Cache::addPointer(const K & k, Value & t, time_t validUntil) { Lock(lock); cached.insert(Element(new ObjectCacheable(t, k, validUntil))); @@ -102,7 +102,7 @@ Cache::add(const K & k, Value & t, time_t validUntil) template void -Cache::add(const K & k, const Factory & tf, time_t validUntil) +Cache::addFactory(const K & k, const Factory & tf, time_t validUntil) { Lock(lock); cached.insert(Element(new CallCacheable(tf, k, validUntil))); @@ -110,7 +110,7 @@ Cache::add(const K & k, const Factory & tf, time_t validUntil) template void -Cache::add(const K & k, const PointerFactory & tf, time_t validUntil) +Cache::addPointerFactory(const K & k, const PointerFactory & tf, time_t validUntil) { Lock(lock); cached.insert(Element(new PointerCallCacheable(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); -- cgit v1.2.3