diff --git a/Control/SGTools/SGTools/DataProxy.h b/Control/SGTools/SGTools/DataProxy.h index abd00db60632ddb5e0fc433c0f6d331b88afbbff..aaf39ba6ee8964171ef26b2109b001a11a4def2d 100755 --- a/Control/SGTools/SGTools/DataProxy.h +++ b/Control/SGTools/SGTools/DataProxy.h @@ -150,7 +150,7 @@ namespace SG { void resetOnly(const bool& flag) { m_resetFlag = flag; } /// Check reset only: - const bool& isResetOnly() const { return m_resetFlag; } + bool isResetOnly() const { return m_resetFlag; } bool bindHandle(IResetable* ir); void unbindHandle(IResetable* ir); diff --git a/Control/SGTools/SGTools/SGVersionedKey.h b/Control/SGTools/SGTools/SGVersionedKey.h index f79c2f6d0e7d2cc9af1768df19e510048ca0c3bf..5e7d97eb20593da2381e29846b1b37bd162b706d 100644 --- a/Control/SGTools/SGTools/SGVersionedKey.h +++ b/Control/SGTools/SGTools/SGVersionedKey.h @@ -28,7 +28,9 @@ namespace SG { **/ class VersionedKey { friend class ::StoreGateSvc; //call copyVK +#ifdef ATHENAHIVE friend class ::SGImplSvc; //call copyVK +#endif public: ///quickly determine whether a string has the right format to be a VK static bool isVersionedKey(const char *); diff --git a/Control/SGTools/SGTools/StringPool.h b/Control/SGTools/SGTools/StringPool.h index 3897312a354a2faf545d5e497888ac28c5ddede8..9b71299e9f0760284b912522c9b7e8e107a150a7 100755 --- a/Control/SGTools/SGTools/StringPool.h +++ b/Control/SGTools/SGTools/StringPool.h @@ -97,10 +97,20 @@ public: /** * @brief Debugging dump. Write to cout. */ - void dump () const; + void dump() const; + + + /** + * @brief Empty the pool and release all allocated memory. + */ + void clear(); private: - StringPoolImpl* m_impl; + /// Helpers to retrieve the impl object, creating it if needed. + const StringPoolImpl* impl() const; + StringPoolImpl* impl(); + + mutable StringPoolImpl* m_impl; // Don't allow copying. StringPool (const StringPool&); diff --git a/Control/SGTools/share/StringPool_test.ref b/Control/SGTools/share/StringPool_test.ref index 94db96eba5c6144cacb615a17106269685c6e21a..df2ff9364b6742338158d98459d56a2d25aeb90a 100755 --- a/Control/SGTools/share/StringPool_test.ref +++ b/Control/SGTools/share/StringPool_test.ref @@ -11,3 +11,4 @@ pool dump 3979421c 4 paks aspdk pok asd fd9252c 1 MNIIQGNLVGTGLKIGIVVGRFNDFITSKLLSGAEDALLRHGVDTNDIDVAWVPGAFEIPFAAKKMAETKKYDAIITLGTVIRGATTSYDYVCNEAAKGIAQAANTTGVPVIFGIVTTENIEQAIERAGTKAGNKGVDCAVSAIEMANLNRSFE 1b269909 5 asd laskjkd lkajsd +pool dump2 diff --git a/Control/SGTools/src/StringPool.cxx b/Control/SGTools/src/StringPool.cxx index 6ebfe4b7dfd979ad15fc8cd902ebaef35e000a14..6f3ed27b147a40b915119c9a9c11d61125f94769 100755 --- a/Control/SGTools/src/StringPool.cxx +++ b/Control/SGTools/src/StringPool.cxx @@ -128,7 +128,7 @@ void StringPoolImpl::dump() const * @brief Constructor. */ StringPool::StringPool() - : m_impl (new StringPoolImpl) + : m_impl (nullptr) { } @@ -138,7 +138,7 @@ StringPool::StringPool() */ StringPool::~StringPool() { - delete m_impl; + clear(); } @@ -156,7 +156,7 @@ StringPool::sgkey_t StringPool::stringToKey (const std::string& str, uint64_t crc = crc64 (str); if (aux) crc = crc64addint (crc, aux); sgkey_t key = (crc & sgkey_t_max); - if (!m_impl->registerKey (key, str, aux)) + if (!impl()->registerKey (key, str, aux)) std::abort(); return key; } @@ -172,7 +172,7 @@ StringPool::sgkey_t StringPool::stringToKey (const std::string& str, const std::string* StringPool::keyToString (sgkey_t key) const { sgaux_t aux; - return m_impl->keyToString (key, aux); + return impl()->keyToString (key, aux); } @@ -187,7 +187,7 @@ const std::string* StringPool::keyToString (sgkey_t key) const const std::string* StringPool::keyToString (sgkey_t key, sgaux_t& aux) const { - return m_impl->keyToString (key, aux); + return impl()->keyToString (key, aux); } @@ -208,7 +208,7 @@ bool StringPool::registerKey (sgkey_t key, { // Make sure the primary mapping is registered first. stringToKey (str, aux); - return m_impl->registerKey (key, str, aux); + return impl()->registerKey (key, str, aux); } @@ -217,7 +217,39 @@ bool StringPool::registerKey (sgkey_t key, */ void StringPool::dump () const { - m_impl->dump(); + impl()->dump(); +} + + +/** + * @brief Empty the pool and release all allocated memory. + */ +void StringPool::clear() +{ + delete m_impl; + m_impl = nullptr; +} + + +/** + * @brief Helper to retrieve the impl object, creating it if needed. + */ +StringPoolImpl* StringPool::impl() +{ + if (!m_impl) + m_impl = new StringPoolImpl; + return m_impl; +} + + +/** + * @brief Helper to retrieve the impl object, creating it if needed. + */ +const StringPoolImpl* StringPool::impl() const +{ + if (!m_impl) + m_impl = new StringPoolImpl; + return m_impl; } diff --git a/Control/SGTools/test/StringPool_test.cxx b/Control/SGTools/test/StringPool_test.cxx index 796666ba91ac9a8348e603c31d1529f51192b9b1..b003d0d42a53d41e6676e4b57dfaa1df9e9ae5c4 100755 --- a/Control/SGTools/test/StringPool_test.cxx +++ b/Control/SGTools/test/StringPool_test.cxx @@ -95,6 +95,10 @@ void test1() assert (sp.registerKey (keys[10], strings[10], aux[10])); assert (!sp.registerKey (keys[10], strings[11], aux[10])); assert (!sp.registerKey (keys[10], strings[10], aux[11])); + + sp.clear(); + std::cout << "pool dump2\n"; + sp.dump(); }