http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ProxyRemoteQueryService.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ProxyRemoteQueryService.cpp b/src/cppcache/src/ProxyRemoteQueryService.cpp index d1adc86..da66e0b 100644 --- a/src/cppcache/src/ProxyRemoteQueryService.cpp +++ b/src/cppcache/src/ProxyRemoteQueryService.cpp @@ -19,21 +19,19 @@ #include <geode/PoolManager.hpp> #include "CqQueryImpl.hpp" -ProxyRemoteQueryService::ProxyRemoteQueryService(ProxyCache* cptr) { - ProxyCachePtr pcp(cptr); - m_proxyCache = pcp; -} +ProxyRemoteQueryService::ProxyRemoteQueryService(ProxyCachePtr cptr) + : m_proxyCache(cptr) {} QueryPtr ProxyRemoteQueryService::newQuery(const char* querystring) { if (!m_proxyCache->isClosed()) { - PoolPtr userAttachedPool = m_proxyCache->m_userAttributes->getPool(); - PoolPtr pool = PoolManager::find(userAttachedPool->getName()); - if (pool != NULLPTR && pool.ptr() == userAttachedPool.ptr() && + auto userAttachedPool = m_proxyCache->m_userAttributes->getPool(); + auto pool = PoolManager::find(userAttachedPool->getName()); + if (pool != nullptr && pool.get() == userAttachedPool.get() && !pool->isDestroyed()) { GuardUserAttribures gua(m_proxyCache); - ThinClientPoolDMPtr pooDM(static_cast<ThinClientPoolDM*>(pool.ptr())); - if (!pooDM->isDestroyed()) { - return pooDM->getQueryServiceWithoutCheck()->newQuery(querystring); + auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool); + if (!poolDM->isDestroyed()) { + return poolDM->getQueryServiceWithoutCheck()->newQuery(querystring); } } throw IllegalStateException("Pool has been closed."); @@ -54,14 +52,14 @@ CqQueryPtr ProxyRemoteQueryService::newCq(const char* querystr, CqAttributesPtr& cqAttr, bool isDurable) { if (!m_proxyCache->isClosed()) { - PoolPtr userAttachedPool = m_proxyCache->m_userAttributes->getPool(); - PoolPtr pool = PoolManager::find(userAttachedPool->getName()); - if (pool != NULLPTR && pool.ptr() == userAttachedPool.ptr() && + auto userAttachedPool = m_proxyCache->m_userAttributes->getPool(); + auto pool = PoolManager::find(userAttachedPool->getName()); + if (pool != nullptr && pool.get() == userAttachedPool.get() && !pool->isDestroyed()) { GuardUserAttribures gua(m_proxyCache); - ThinClientPoolDMPtr pooDM(static_cast<ThinClientPoolDM*>(pool.ptr())); + auto pooDM = std::static_pointer_cast<ThinClientPoolDM>(pool); if (!pooDM->isDestroyed()) { - CqQueryPtr cqQuery = pooDM->getQueryServiceWithoutCheck()->newCq( + auto cqQuery = pooDM->getQueryServiceWithoutCheck()->newCq( querystr, cqAttr, isDurable); addCqQuery(cqQuery); return cqQuery; @@ -82,14 +80,14 @@ CqQueryPtr ProxyRemoteQueryService::newCq(const char* name, CqAttributesPtr& cqAttr, bool isDurable) { if (!m_proxyCache->isClosed()) { - PoolPtr userAttachedPool = m_proxyCache->m_userAttributes->getPool(); - PoolPtr pool = PoolManager::find(userAttachedPool->getName()); - if (pool != NULLPTR && pool.ptr() == userAttachedPool.ptr() && + auto userAttachedPool = m_proxyCache->m_userAttributes->getPool(); + auto pool = PoolManager::find(userAttachedPool->getName()); + if (pool != nullptr && pool.get() == userAttachedPool.get() && !pool->isDestroyed()) { GuardUserAttribures gua(m_proxyCache); - ThinClientPoolDMPtr pooDM(static_cast<ThinClientPoolDM*>(pool.ptr())); - if (!pooDM->isDestroyed()) { - CqQueryPtr cqQuery = pooDM->getQueryServiceWithoutCheck()->newCq( + auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool); + if (!poolDM->isDestroyed()) { + auto cqQuery = poolDM->getQueryServiceWithoutCheck()->newCq( name, querystr, cqAttr, isDurable); addCqQuery(cqQuery); return cqQuery; @@ -105,14 +103,14 @@ void ProxyRemoteQueryService::closeCqs() { closeCqs(false); } void ProxyRemoteQueryService::closeCqs(bool keepAlive) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock); - for (int32_t i = 0; i < m_cqQueries.size(); i++) { - std::string cqName = m_cqQueries[i]->getName(); + for (auto& q : m_cqQueries) { + std::string cqName = q->getName(); try { - if (!(m_cqQueries[i]->isDurable() && keepAlive)) { - m_cqQueries[i]->close(); + if (!(q->isDurable() && keepAlive)) { + q->close(); } else { // need to just cleanup client side data structure - CqQueryImpl* cqImpl = static_cast<CqQueryImpl*>(m_cqQueries[i].ptr()); + auto cqImpl = std::static_pointer_cast<CqQueryImpl>(q); cqImpl->close(false); } } catch (QueryException& qe) { @@ -127,24 +125,21 @@ void ProxyRemoteQueryService::closeCqs(bool keepAlive) { } } -void ProxyRemoteQueryService::getCqs(VectorOfCqQuery& vec) { +void ProxyRemoteQueryService::getCqs(query_container_type& vec) { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock); - - for (int32_t i = 0; i < m_cqQueries.size(); i++) { - vec.push_back(m_cqQueries[i]); - } + vec = m_cqQueries; } CqQueryPtr ProxyRemoteQueryService::getCq(const char* name) { if (!m_proxyCache->isClosed()) { - PoolPtr userAttachedPool = m_proxyCache->m_userAttributes->getPool(); - PoolPtr pool = PoolManager::find(userAttachedPool->getName()); - if (pool != NULLPTR && pool.ptr() == userAttachedPool.ptr() && + auto userAttachedPool = m_proxyCache->m_userAttributes->getPool(); + auto pool = PoolManager::find(userAttachedPool->getName()); + if (pool != nullptr && pool.get() == userAttachedPool.get() && !pool->isDestroyed()) { GuardUserAttribures gua(m_proxyCache); - ThinClientPoolDMPtr pooDM(static_cast<ThinClientPoolDM*>(pool.ptr())); - if (!pooDM->isDestroyed()) { - return pooDM->getQueryServiceWithoutCheck()->getCq(name); + auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool); + if (!poolDM->isDestroyed()) { + return poolDM->getQueryServiceWithoutCheck()->getCq(name); } } throw IllegalStateException("Pool has been closed."); @@ -155,10 +150,10 @@ CqQueryPtr ProxyRemoteQueryService::getCq(const char* name) { void ProxyRemoteQueryService::executeCqs() { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock); - for (int32_t i = 0; i < m_cqQueries.size(); i++) { - std::string cqName = m_cqQueries[i]->getName(); + for (auto& q : m_cqQueries) { + std::string cqName = q->getName(); try { - m_cqQueries[i]->execute(); + q->execute(); } catch (QueryException& qe) { Log::fine(("Failed to excecue the CQ, CqName : " + cqName + " Error : " + qe.getMessage()) @@ -174,10 +169,10 @@ void ProxyRemoteQueryService::executeCqs() { void ProxyRemoteQueryService::stopCqs() { ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_cqQueryListLock); - for (int32_t i = 0; i < m_cqQueries.size(); i++) { - std::string cqName = m_cqQueries[i]->getName(); + for (auto& q : m_cqQueries) { + std::string cqName = q->getName(); try { - m_cqQueries[i]->stop(); + q->stop(); } catch (QueryException& qe) { Log::fine(("Failed to stop the CQ, CqName : " + cqName + " Error : " + qe.getMessage()) @@ -192,10 +187,10 @@ void ProxyRemoteQueryService::stopCqs() { CqServiceStatisticsPtr ProxyRemoteQueryService::getCqServiceStatistics() { unSupportedException("getCqServiceStatistics()"); - return NULLPTR; + return nullptr; } CacheableArrayListPtr ProxyRemoteQueryService::getAllDurableCqsFromServer() { unSupportedException("getAllDurableCqsFromServer()"); - return NULLPTR; + return nullptr; }
http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ProxyRemoteQueryService.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ProxyRemoteQueryService.hpp b/src/cppcache/src/ProxyRemoteQueryService.hpp index 7eb3cbf..dcc36b6 100644 --- a/src/cppcache/src/ProxyRemoteQueryService.hpp +++ b/src/cppcache/src/ProxyRemoteQueryService.hpp @@ -38,7 +38,7 @@ class ThinClientPoolDM; class CPPCACHE_EXPORT ProxyRemoteQueryService : public QueryService { public: - ProxyRemoteQueryService(ProxyCache* cptr); + ProxyRemoteQueryService(ProxyCachePtr cptr); QueryPtr newQuery(const char* querystring); @@ -48,7 +48,7 @@ class CPPCACHE_EXPORT ProxyRemoteQueryService : public QueryService { virtual CqQueryPtr newCq(const char* name, const char* querystr, CqAttributesPtr& cqAttr, bool isDurable = false); virtual void closeCqs(); - virtual void getCqs(VectorOfCqQuery& vec); + virtual void getCqs(query_container_type& vec); virtual CqQueryPtr getCq(const char* name); virtual void executeCqs(); virtual void stopCqs(); @@ -62,7 +62,7 @@ class CPPCACHE_EXPORT ProxyRemoteQueryService : public QueryService { QueryServicePtr m_realQueryService; ProxyCachePtr m_proxyCache; - VectorOfCqQuery m_cqQueries; + query_container_type m_cqQueries; // lock for cqQuery list; ACE_Recursive_Thread_Mutex m_cqQueryListLock; friend class ProxyCache; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PutAllPartialResult.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PutAllPartialResult.cpp b/src/cppcache/src/PutAllPartialResult.cpp index 4ca4b68..24929b6 100644 --- a/src/cppcache/src/PutAllPartialResult.cpp +++ b/src/cppcache/src/PutAllPartialResult.cpp @@ -22,7 +22,7 @@ namespace client { PutAllPartialResult::PutAllPartialResult( int totalMapSize, ACE_Recursive_Thread_Mutex& responseLock) { - m_succeededKeys = new VersionedCacheableObjectPartList( + m_succeededKeys = std::make_shared<VersionedCacheableObjectPartList>( new VectorOfCacheableKey(), responseLock); m_totalMapSize = totalMapSize; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PutAllPartialResult.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PutAllPartialResult.hpp b/src/cppcache/src/PutAllPartialResult.hpp index 6b44b7b..6240b09 100644 --- a/src/cppcache/src/PutAllPartialResult.hpp +++ b/src/cppcache/src/PutAllPartialResult.hpp @@ -57,11 +57,11 @@ class PutAllPartialResult : public Serializable { void addKeys(VectorOfCacheableKeyPtr m_keys); void saveFailedKey(CacheableKeyPtr key, ExceptionPtr cause) { - if (key == NULLPTR) { + if (key == nullptr) { return; } // TODO:: Do we need to handle server cancelException. - if (m_firstFailedKey == NULLPTR /*|| cause instanceof CaccelException */) { + if (m_firstFailedKey == nullptr /*|| cause instanceof CaccelException */) { m_firstFailedKey = key; m_firstCauseOfFailure = cause; } @@ -73,14 +73,14 @@ class PutAllPartialResult : public Serializable { CacheableKeyPtr getFirstFailedKey() { return m_firstFailedKey; } // Returns there's failedKeys - bool hasFailure() { return m_firstFailedKey != NULLPTR; } + bool hasFailure() { return m_firstFailedKey != nullptr; } // Returns there's saved succeed keys bool hasSucceededKeys(); virtual CacheableStringPtr toString() const { char msgStr1[1024]; - if (m_firstFailedKey != NULLPTR) { + if (m_firstFailedKey != nullptr) { ACE_OS::snprintf(msgStr1, 1024, "[ Key =%s ]", m_firstFailedKey->toString()->asChar()); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/PutAllPartialResultServerException.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PutAllPartialResultServerException.cpp b/src/cppcache/src/PutAllPartialResultServerException.cpp index b0c9a2a..1585e70 100644 --- a/src/cppcache/src/PutAllPartialResultServerException.cpp +++ b/src/cppcache/src/PutAllPartialResultServerException.cpp @@ -29,7 +29,7 @@ PutAllPartialResultServerException::PutAllPartialResultServerException( PutAllPartialResultServerException::PutAllPartialResultServerException() { LOGDEBUG("Partial keys are processed in putAll"); ACE_Recursive_Thread_Mutex responseLock; - m_result = new PutAllPartialResult(-1, responseLock); + m_result = std::make_shared<PutAllPartialResult>(-1, responseLock); } void PutAllPartialResultServerException::consolidate( http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionAttributes.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionAttributes.cpp b/src/cppcache/src/RegionAttributes.cpp index 6b6cecd..6eee620 100644 --- a/src/cppcache/src/RegionAttributes.cpp +++ b/src/cppcache/src/RegionAttributes.cpp @@ -35,10 +35,10 @@ RegionAttributes::RegionAttributes() m_entryTimeToLiveExpirationAction(ExpirationAction::INVALIDATE), m_entryIdleTimeoutExpirationAction(ExpirationAction::INVALIDATE), m_lruEvictionAction(ExpirationAction::LOCAL_DESTROY), - m_cacheWriter(NULLPTR), - m_cacheLoader(NULLPTR), - m_cacheListener(NULLPTR), - m_partitionResolver(NULLPTR), + m_cacheWriter(nullptr), + m_cacheLoader(nullptr), + m_cacheListener(nullptr), + m_partitionResolver(nullptr), m_lruEntriesLimit(0), m_caching(true), m_maxValueDistLimit(100 * 1024), @@ -62,8 +62,8 @@ RegionAttributes::RegionAttributes() m_clientNotificationEnabled(false), m_persistenceLibrary(NULL), m_persistenceFactory(NULL), - m_persistenceProperties(NULLPTR), - m_persistenceManager(NULLPTR), + m_persistenceProperties(nullptr), + m_persistenceManager(nullptr), m_poolName(NULL), m_isClonable(false), m_isConcurrencyChecksEnabled(true) {} @@ -240,98 +240,98 @@ void* getFactoryFunc(const char* lib, const char* funcName) { } // namespace apache CacheLoaderPtr RegionAttributes::getCacheLoader() { - if ((m_cacheLoader == NULLPTR) && (m_cacheLoaderLibrary != NULL)) { + if ((m_cacheLoader == nullptr) && (m_cacheLoaderLibrary != NULL)) { if (CacheXmlParser::managedCacheLoaderFn != NULL && strchr(m_cacheLoaderFactory, '.') != NULL) { // this is a managed library - m_cacheLoader = (*CacheXmlParser::managedCacheLoaderFn)( - m_cacheLoaderLibrary, m_cacheLoaderFactory); + m_cacheLoader.reset((*CacheXmlParser::managedCacheLoaderFn)( + m_cacheLoaderLibrary, m_cacheLoaderFactory)); } else { CacheLoader* (*funcptr)(); funcptr = reinterpret_cast<CacheLoader* (*)()>( apache::geode::client::impl::getFactoryFunc(m_cacheLoaderLibrary, m_cacheLoaderFactory)); - m_cacheLoader = funcptr(); + m_cacheLoader.reset(funcptr()); } } return m_cacheLoader; } CacheWriterPtr RegionAttributes::getCacheWriter() { - if ((m_cacheWriter == NULLPTR) && (m_cacheWriterLibrary != NULL)) { + if ((m_cacheWriter == nullptr) && (m_cacheWriterLibrary != NULL)) { if (CacheXmlParser::managedCacheWriterFn != NULL && strchr(m_cacheWriterFactory, '.') != NULL) { // this is a managed library - m_cacheWriter = (*CacheXmlParser::managedCacheWriterFn)( - m_cacheWriterLibrary, m_cacheWriterFactory); + m_cacheWriter.reset((*CacheXmlParser::managedCacheWriterFn)( + m_cacheWriterLibrary, m_cacheWriterFactory)); } else { CacheWriter* (*funcptr)(); funcptr = reinterpret_cast<CacheWriter* (*)()>( apache::geode::client::impl::getFactoryFunc(m_cacheWriterLibrary, m_cacheWriterFactory)); - m_cacheWriter = funcptr(); + m_cacheWriter.reset(funcptr()); } } return m_cacheWriter; } CacheListenerPtr RegionAttributes::getCacheListener() { - if ((m_cacheListener == NULLPTR) && (m_cacheListenerLibrary != NULL)) { + if ((m_cacheListener == nullptr) && (m_cacheListenerLibrary != NULL)) { if (CacheXmlParser::managedCacheListenerFn != NULL && strchr(m_cacheListenerFactory, '.') != NULL) { // LOGDEBUG( "RegionAttributes::getCacheListener: Trying to create // instance from managed library." ); // this is a managed library - m_cacheListener = (*CacheXmlParser::managedCacheListenerFn)( - m_cacheListenerLibrary, m_cacheListenerFactory); + m_cacheListener.reset((*CacheXmlParser::managedCacheListenerFn)( + m_cacheListenerLibrary, m_cacheListenerFactory)); } else { CacheListener* (*funcptr)(); funcptr = reinterpret_cast<CacheListener* (*)()>( apache::geode::client::impl::getFactoryFunc(m_cacheListenerLibrary, m_cacheListenerFactory)); - m_cacheListener = funcptr(); + m_cacheListener.reset(funcptr()); } } return m_cacheListener; } PartitionResolverPtr RegionAttributes::getPartitionResolver() { - if ((m_partitionResolver == NULLPTR) && + if ((m_partitionResolver == nullptr) && (m_partitionResolverLibrary != NULL)) { if (CacheXmlParser::managedPartitionResolverFn != NULL && strchr(m_partitionResolverFactory, '.') != NULL) { // LOGDEBUG( "RegionAttributes::getCacheListener: Trying to create // instance from managed library." ); // this is a managed library - m_partitionResolver = (*CacheXmlParser::managedPartitionResolverFn)( - m_partitionResolverLibrary, m_partitionResolverFactory); + m_partitionResolver.reset((*CacheXmlParser::managedPartitionResolverFn)( + m_partitionResolverLibrary, m_partitionResolverFactory)); } else { PartitionResolver* (*funcptr)(); funcptr = reinterpret_cast<PartitionResolver* (*)()>( apache::geode::client::impl::getFactoryFunc( m_partitionResolverLibrary, m_partitionResolverFactory)); - m_partitionResolver = funcptr(); + m_partitionResolver.reset(funcptr()); } } return m_partitionResolver; } PersistenceManagerPtr RegionAttributes::getPersistenceManager() { - if ((m_persistenceManager == NULLPTR) && (m_persistenceLibrary != NULL)) { + if ((m_persistenceManager == nullptr) && (m_persistenceLibrary != NULL)) { if (CacheXmlParser::managedPartitionResolverFn != NULL && strchr(m_persistenceFactory, '.') != NULL) { LOGDEBUG( "RegionAttributes::getPersistenceManager: Trying to create instance " "from managed library."); // this is a managed library - m_persistenceManager = (*CacheXmlParser::managedPersistenceManagerFn)( - m_persistenceLibrary, m_persistenceFactory); + m_persistenceManager.reset((*CacheXmlParser::managedPersistenceManagerFn)( + m_persistenceLibrary, m_persistenceFactory)); } else { PersistenceManager* (*funcptr)(); funcptr = reinterpret_cast<PersistenceManager* (*)()>( apache::geode::client::impl::getFactoryFunc(m_persistenceLibrary, m_persistenceFactory)); - m_persistenceManager = funcptr(); + m_persistenceManager.reset(funcptr()); } } return m_persistenceManager; @@ -653,27 +653,27 @@ bool RegionAttributes::operator!=(const RegionAttributes& other) const { /* Throws IllegalStateException when attributes targetted for use on a server do * not meet requirements. */ void RegionAttributes::validateSerializableAttributes() { - if (m_cacheLoader != NULLPTR) { + if (m_cacheLoader != nullptr) { throw IllegalStateException( "CacheLoader must be set with setCacheLoader(library, factory) in " "members of type SERVER"); } - if (m_cacheWriter != NULLPTR) { + if (m_cacheWriter != nullptr) { throw IllegalStateException( "CacheWriter must be set with setCacheWriter(library, factory) in " "members of type SERVER"); } - if (m_cacheListener != NULLPTR) { + if (m_cacheListener != nullptr) { throw IllegalStateException( "CacheListener must be set with setCacheListener(library, factory) in " "members of type SERVER"); } - if (m_partitionResolver != NULLPTR) { + if (m_partitionResolver != nullptr) { throw IllegalStateException( "PartitionResolver must be set with setPartitionResolver(library, " "factory) in members of type SERVER"); } - if (m_persistenceManager != NULLPTR) { + if (m_persistenceManager != nullptr) { throw IllegalStateException( "persistenceManager must be set with setPersistenceManager(library, " "factory,config) in members of type SERVER"); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionCommit.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionCommit.cpp b/src/cppcache/src/RegionCommit.cpp index ca60857..62e26c8 100644 --- a/src/cppcache/src/RegionCommit.cpp +++ b/src/cppcache/src/RegionCommit.cpp @@ -27,14 +27,6 @@ namespace apache { namespace geode { namespace client { -RegionCommit::RegionCommit() { - // TODO Auto-generated constructor stub -} - -RegionCommit::~RegionCommit() { - // TODO Auto-generated destructor stub -} - void RegionCommit::fromData(DataInput& input) { input.readObject(m_regionPath); input.readObject(m_parentRegionPath); @@ -48,7 +40,7 @@ void RegionCommit::fromData(DataInput& input) { input.readObject(dsMember); uint16_t memId = CacheImpl::getMemberListForVersionStamp()->add(dsMember); for (int i = 0; i < size; i++) { - FarSideEntryOpPtr entryOp(new FarSideEntryOp(this)); + auto entryOp = std::make_shared<FarSideEntryOp>(this); entryOp->fromData(input, largeModCount, memId); m_farSideEntryOps.push_back(entryOp); } @@ -56,22 +48,19 @@ void RegionCommit::fromData(DataInput& input) { } void RegionCommit::apply(Cache* cache) { - for (VectorOfSharedBase::Iterator iter = m_farSideEntryOps.begin(); - m_farSideEntryOps.end() != iter; iter++) { - FarSideEntryOpPtr entryOp = staticCast<FarSideEntryOpPtr>(*iter); - RegionPtr region = cache->getRegion(m_regionPath->asChar()); - if (region == NULLPTR && m_parentRegionPath != NULLPTR) { + for (auto& entryOp : m_farSideEntryOps) { + auto region = cache->getRegion(m_regionPath->asChar()); + if (region == nullptr && m_parentRegionPath != nullptr) { region = cache->getRegion(m_parentRegionPath->asChar()); } - entryOp->apply(region); + std::static_pointer_cast<FarSideEntryOp>(entryOp)->apply(region); } } void RegionCommit::fillEvents(Cache* cache, std::vector<FarSideEntryOpPtr>& ops) { - for (VectorOfSharedBase::Iterator iter = m_farSideEntryOps.begin(); - m_farSideEntryOps.end() != iter; iter++) { - ops.push_back(*iter); + for (auto& entryOp : m_farSideEntryOps) { + ops.push_back(std::static_pointer_cast<FarSideEntryOp>(entryOp)); } } } // namespace client http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionCommit.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionCommit.hpp b/src/cppcache/src/RegionCommit.hpp index 541614d..2de98b3 100644 --- a/src/cppcache/src/RegionCommit.hpp +++ b/src/cppcache/src/RegionCommit.hpp @@ -43,8 +43,8 @@ _GF_PTR_DEF_(RegionCommit, RegionCommitPtr); class RegionCommit : public apache::geode::client::SharedBase { public: - RegionCommit(); - virtual ~RegionCommit(); + RegionCommit(){}; + virtual ~RegionCommit(){}; void fromData(DataInput& input); void apply(Cache* cache); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionEntry.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionEntry.cpp b/src/cppcache/src/RegionEntry.cpp index 96cfbf2..fbf6246 100644 --- a/src/cppcache/src/RegionEntry.cpp +++ b/src/cppcache/src/RegionEntry.cpp @@ -21,15 +21,15 @@ using namespace apache::geode::client; -RegionEntry::RegionEntry(const RegionPtr& region, const CacheableKeyPtr& key, +RegionEntry::RegionEntry(Region* region, const CacheableKeyPtr& key, const CacheablePtr& value) : m_region(region), m_key(key), m_value(value), m_destroyed(false) {} RegionEntry::~RegionEntry() {} CacheableKeyPtr RegionEntry::getKey() { return m_key; } CacheablePtr RegionEntry::getValue() { - return CacheableToken::isInvalid(m_value) ? NULLPTR : m_value; + return CacheableToken::isInvalid(m_value) ? nullptr : m_value; } -void RegionEntry::getRegion(RegionPtr& region) { region = m_region; } +void RegionEntry::getRegion(Region* region) { region = m_region; } void RegionEntry::getStatistics(CacheStatisticsPtr& csptr) { csptr = m_statistics; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionExpiryHandler.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionExpiryHandler.cpp b/src/cppcache/src/RegionExpiryHandler.cpp index 3def51b..66e74c5 100644 --- a/src/cppcache/src/RegionExpiryHandler.cpp +++ b/src/cppcache/src/RegionExpiryHandler.cpp @@ -89,7 +89,7 @@ void RegionExpiryHandler::DoTheExpirationAction() { "RegionExpiryHandler::DoTheExpirationAction INVALIDATE " "region [%s]", m_regionPtr->getFullPath()); - m_regionPtr->invalidateRegionNoThrow(NULLPTR, + m_regionPtr->invalidateRegionNoThrow(nullptr, CacheEventFlags::EXPIRATION); break; } @@ -99,7 +99,7 @@ void RegionExpiryHandler::DoTheExpirationAction() { "region [%s]", m_regionPtr->getFullPath()); m_regionPtr->invalidateRegionNoThrow( - NULLPTR, CacheEventFlags::EXPIRATION | CacheEventFlags::LOCAL); + nullptr, CacheEventFlags::EXPIRATION | CacheEventFlags::LOCAL); break; } case ExpirationAction::DESTROY: { @@ -107,7 +107,7 @@ void RegionExpiryHandler::DoTheExpirationAction() { "RegionExpiryHandler::DoTheExpirationAction DESTROY " "region [%s]", m_regionPtr->getFullPath()); - m_regionPtr->destroyRegionNoThrow(NULLPTR, true, + m_regionPtr->destroyRegionNoThrow(nullptr, true, CacheEventFlags::EXPIRATION); break; } @@ -117,7 +117,7 @@ void RegionExpiryHandler::DoTheExpirationAction() { "region [%s]", m_regionPtr->getFullPath()); m_regionPtr->destroyRegionNoThrow( - NULLPTR, true, CacheEventFlags::EXPIRATION | CacheEventFlags::LOCAL); + nullptr, true, CacheEventFlags::EXPIRATION | CacheEventFlags::LOCAL); break; } default: { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionFactory.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionFactory.cpp b/src/cppcache/src/RegionFactory.cpp index c94255d..cd40cef 100644 --- a/src/cppcache/src/RegionFactory.cpp +++ b/src/cppcache/src/RegionFactory.cpp @@ -37,22 +37,22 @@ namespace client { RegionFactory::RegionFactory(RegionShortcut preDefinedRegion) { m_preDefinedRegion = preDefinedRegion; - AttributesFactoryPtr afPtr(new AttributesFactory()); - m_attributeFactory = afPtr; + m_attributeFactory = std::make_shared<AttributesFactory>(); + ; setRegionShortcut(); } RegionFactory::~RegionFactory() {} RegionPtr RegionFactory::create(const char* name) { - RegionPtr retRegionPtr = NULLPTR; + RegionPtr retRegionPtr = nullptr; RegionAttributesPtr regAttr = m_attributeFactory->createRegionAttributes(); // assuming pool name is not DEFAULT_POOL_NAME if (regAttr->getPoolName() != NULL && strlen(regAttr->getPoolName()) > 0) { // poolname is set CachePtr cache = CacheFactory::getAnyInstance(); - CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.ptr()); + CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get()); cacheImpl->createRegion(name, regAttr, retRegionPtr); } else { // need to look default Pool @@ -60,7 +60,7 @@ RegionPtr RegionFactory::create(const char* name) { // if local region no need to create default pool if (m_preDefinedRegion != LOCAL) { PoolPtr pool = CacheFactory::createOrGetDefaultPool(); - if (pool == NULLPTR) { + if (pool == nullptr) { throw IllegalStateException("Pool is not defined create region."); } m_attributeFactory->setPoolName(pool->getName()); @@ -68,7 +68,7 @@ RegionPtr RegionFactory::create(const char* name) { regAttr = m_attributeFactory->createRegionAttributes(); CachePtr cache = CacheFactory::getAnyInstance(); - CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.ptr()); + CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache.get()); cacheImpl->createRegion(name, regAttr, retRegionPtr); } @@ -82,82 +82,70 @@ void RegionFactory::setRegionShortcut() { RegionFactoryPtr RegionFactory::setCacheLoader( const CacheLoaderPtr& cacheLoader) { m_attributeFactory->setCacheLoader(cacheLoader); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setCacheWriter( const CacheWriterPtr& cacheWriter) { m_attributeFactory->setCacheWriter(cacheWriter); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setCacheListener( const CacheListenerPtr& aListener) { m_attributeFactory->setCacheListener(aListener); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setPartitionResolver( const PartitionResolverPtr& aResolver) { m_attributeFactory->setPartitionResolver(aResolver); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setCacheLoader(const char* lib, const char* func) { m_attributeFactory->setCacheLoader(lib, func); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setCacheWriter(const char* lib, const char* func) { m_attributeFactory->setCacheWriter(lib, func); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setCacheListener(const char* lib, const char* func) { m_attributeFactory->setCacheListener(lib, func); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setPartitionResolver(const char* lib, const char* func) { m_attributeFactory->setPartitionResolver(lib, func); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setEntryIdleTimeout( ExpirationAction::Action action, int idleTimeout) { m_attributeFactory->setEntryIdleTimeout(action, idleTimeout); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setEntryTimeToLive( ExpirationAction::Action action, int timeToLive) { m_attributeFactory->setEntryTimeToLive(action, timeToLive); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setRegionIdleTimeout( ExpirationAction::Action action, int idleTimeout) { m_attributeFactory->setRegionIdleTimeout(action, idleTimeout); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setRegionTimeToLive( ExpirationAction::Action action, int timeToLive) { m_attributeFactory->setRegionTimeToLive(action, timeToLive); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setInitialCapacity(int initialCapacity) { @@ -167,71 +155,60 @@ RegionFactoryPtr RegionFactory::setInitialCapacity(int initialCapacity) { throw IllegalArgumentException(excpStr); } m_attributeFactory->setInitialCapacity(initialCapacity); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setLoadFactor(float loadFactor) { m_attributeFactory->setLoadFactor(loadFactor); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setConcurrencyLevel(uint8_t concurrencyLevel) { m_attributeFactory->setConcurrencyLevel(concurrencyLevel); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setConcurrencyChecksEnabled(bool enable) { m_attributeFactory->setConcurrencyChecksEnabled(enable); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setLruEntriesLimit( const uint32_t entriesLimit) { m_attributeFactory->setLruEntriesLimit(entriesLimit); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setDiskPolicy( const DiskPolicyType::PolicyType diskPolicy) { m_attributeFactory->setDiskPolicy(diskPolicy); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setCachingEnabled(bool cachingEnabled) { m_attributeFactory->setCachingEnabled(cachingEnabled); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setPersistenceManager( const PersistenceManagerPtr& persistenceManager, const PropertiesPtr& config) { m_attributeFactory->setPersistenceManager(persistenceManager, config); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setPersistenceManager( const char* lib, const char* func, const PropertiesPtr& config) { m_attributeFactory->setPersistenceManager(lib, func, config); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setPoolName(const char* name) { m_attributeFactory->setPoolName(name); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } RegionFactoryPtr RegionFactory::setCloningEnabled(bool isClonable) { m_attributeFactory->setCloningEnabled(isClonable); - RegionFactoryPtr rfPtr(this); - return rfPtr; + return shared_from_this(); } } // namespace client } // namespace geode http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionInternal.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionInternal.cpp b/src/cppcache/src/RegionInternal.cpp index d81ac75..512cf1d 100644 --- a/src/cppcache/src/RegionInternal.cpp +++ b/src/cppcache/src/RegionInternal.cpp @@ -105,129 +105,129 @@ TombstoneListPtr RegionInternal::getTombstoneList() { RegionEntryPtr RegionInternal::createRegionEntry(const CacheableKeyPtr& key, const CacheablePtr& value) { - return RegionEntryPtr(new RegionEntry(RegionPtr(this), key, value)); + return RegionEntryPtr(new RegionEntry(this, key, value)); } void RegionInternal::setLruEntriesLimit(uint32_t limit) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_lruEntriesLimit = limit; } } void RegionInternal::setRegionTimeToLiveExpirationAction( ExpirationAction::Action action) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_regionTimeToLiveExpirationAction = action; } } void RegionInternal::setRegionIdleTimeoutExpirationAction( ExpirationAction::Action action) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_regionIdleTimeoutExpirationAction = action; } } void RegionInternal::setEntryTimeToLiveExpirationAction( ExpirationAction::Action action) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_entryTimeToLiveExpirationAction = action; } } void RegionInternal::setEntryIdleTimeoutExpirationAction( ExpirationAction::Action action) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_entryIdleTimeoutExpirationAction = action; } } void RegionInternal::setRegionTimeToLive(int32_t duration) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_regionTimeToLive = duration; } } void RegionInternal::setRegionIdleTimeout(int32_t duration) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_regionIdleTimeout = duration; } } void RegionInternal::setEntryTimeToLive(int32_t duration) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_entryTimeToLive = duration; } } void RegionInternal::setEntryIdleTimeout(int32_t duration) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_entryIdleTimeout = duration; } } void RegionInternal::setCacheListener(const CacheListenerPtr& aListener) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_cacheListener = aListener; } } void RegionInternal::setCacheListener(const char* libpath, const char* factoryFuncName) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->setCacheListener(libpath, factoryFuncName); } } void RegionInternal::setPartitionResolver( const PartitionResolverPtr& aResolver) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_partitionResolver = aResolver; } } void RegionInternal::setPartitionResolver(const char* libpath, const char* factoryFuncName) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->setPartitionResolver(libpath, factoryFuncName); } } void RegionInternal::setCacheLoader(const CacheLoaderPtr& aLoader) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_cacheLoader = aLoader; } } void RegionInternal::setCacheLoader(const char* libpath, const char* factoryFuncName) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->setCacheLoader(libpath, factoryFuncName); } } void RegionInternal::setCacheWriter(const CacheWriterPtr& aWriter) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_cacheWriter = aWriter; } } void RegionInternal::setCacheWriter(const char* libpath, const char* factoryFuncName) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->setCacheWriter(libpath, factoryFuncName); } } void RegionInternal::setEndpoints(const char* endpoints) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->setEndpoints(endpoints); } } void RegionInternal::setClientNotificationEnabled( bool clientNotificationEnabled) { - if (m_regionAttributes != NULLPTR) { + if (m_regionAttributes != nullptr) { m_regionAttributes->m_clientNotificationEnabled = clientNotificationEnabled; } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionInternal.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionInternal.hpp b/src/cppcache/src/RegionInternal.hpp index fcadee8..8478a29 100644 --- a/src/cppcache/src/RegionInternal.hpp +++ b/src/cppcache/src/RegionInternal.hpp @@ -135,13 +135,13 @@ class RegionInternal : public Region { bool receiveValues = true); virtual void unregisterKeys(const VectorOfCacheableKey& keys); virtual void registerAllKeys(bool isDurable = false, - VectorOfCacheableKeyPtr resultKeys = NULLPTR, + VectorOfCacheableKeyPtr resultKeys = nullptr, bool getInitialValues = false, bool receiveValues = true); virtual void unregisterAllKeys(); virtual void registerRegex(const char* regex, bool isDurable = false, - VectorOfCacheableKeyPtr resultKeys = NULLPTR, + VectorOfCacheableKeyPtr resultKeys = nullptr, bool getInitialValues = false, bool receiveValues = true); virtual void unregisterRegex(const char* regex); @@ -172,7 +172,7 @@ class RegionInternal : public Region { const CacheEventFlags eventFlags, VersionTagPtr versionTag, DataInput* delta = NULL, - EventIdPtr eventId = NULLPTR) = 0; + EventIdPtr eventId = nullptr) = 0; virtual GfErrType createNoThrow(const CacheableKeyPtr& key, const CacheablePtr& value, const UserDataPtr& aCallbackArgument, @@ -227,7 +227,7 @@ class RegionInternal : public Region { virtual bool cacheEnabled() = 0; virtual bool isDestroyed() const = 0; virtual void evict(int32_t percentage) = 0; - virtual CacheImpl* getCacheImpl() = 0; + virtual CacheImpl* getCacheImpl() const = 0; virtual TombstoneListPtr getTombstoneList(); // KN: added now. http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RegionXmlCreation.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionXmlCreation.cpp b/src/cppcache/src/RegionXmlCreation.cpp index b9b4aba..3c937e2 100644 --- a/src/cppcache/src/RegionXmlCreation.cpp +++ b/src/cppcache/src/RegionXmlCreation.cpp @@ -43,17 +43,17 @@ void RegionXmlCreation::fillIn(RegionPtr regionPtr) { void RegionXmlCreation::createRoot(Cache* cache) { GF_D_ASSERT(this->isRoot); - RegionPtr rootRegPtr = NULLPTR; + RegionPtr rootRegPtr = nullptr; if (Cache_CreatedFromCacheFactory) { - // if(cache->m_cacheImpl->getDefaultPool() == NULLPTR) + // if(cache->m_cacheImpl->getDefaultPool() == nullptr) { // we may need to initialize default pool if (regAttrs->getEndpoints() == NULL) { if (regAttrs->getPoolName() == NULL) { PoolPtr pool = CacheFactory::createOrGetDefaultPool(); - if (pool == NULLPTR) { + if (pool == nullptr) { throw IllegalStateException("Pool is not defined create region."); } regAttrs->setPoolName(pool->getName()); @@ -69,14 +69,14 @@ void RegionXmlCreation::createRoot(Cache* cache) { void RegionXmlCreation::create(RegionPtr parent) { GF_D_ASSERT(!(this->isRoot)); - RegionPtr subRegPtr = NULLPTR; + RegionPtr subRegPtr = nullptr; subRegPtr = parent->createSubregion(regionName.c_str(), regAttrs); fillIn(subRegPtr); } RegionXmlCreation::RegionXmlCreation(char* name, bool isRootRegion) - : regAttrs(NULLPTR) { + : regAttrs(nullptr) { std::string tempName(name); regionName = tempName; isRoot = isRootRegion; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RemoteQuery.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RemoteQuery.cpp b/src/cppcache/src/RemoteQuery.cpp index cf617ce..3fbb411 100644 --- a/src/cppcache/src/RemoteQuery.cpp +++ b/src/cppcache/src/RemoteQuery.cpp @@ -39,16 +39,16 @@ RemoteQuery::RemoteQuery(const char* querystr, SelectResultsPtr RemoteQuery::execute(uint32_t timeout) { GuardUserAttribures gua; - if (m_proxyCache != NULLPTR) { + if (m_proxyCache != nullptr) { gua.setProxyCache(m_proxyCache); } - return execute(timeout, "Query::execute", m_tccdm, NULLPTR); + return execute(timeout, "Query::execute", m_tccdm, nullptr); } SelectResultsPtr RemoteQuery::execute(CacheableVectorPtr paramList, uint32_t timeout) { GuardUserAttribures gua; - if (m_proxyCache != NULLPTR) { + if (m_proxyCache != nullptr) { gua.setProxyCache(m_proxyCache); } return execute(timeout, "Query::execute", m_tccdm, paramList); @@ -88,7 +88,7 @@ SelectResultsPtr RemoteQuery::execute(uint32_t timeout, const char* func, if (sizeOfFieldNamesVec == 0) { LOGFINEST("%s: creating ResultSet for query: %s", func, m_queryString.c_str()); - sr = new ResultSetImpl(values); + sr = std::make_shared<ResultSetImpl>(values); } else { if (values->size() % fieldNameVec.size() != 0) { char exMsg[1024]; @@ -100,7 +100,7 @@ SelectResultsPtr RemoteQuery::execute(uint32_t timeout, const char* func, } else { LOGFINEST("%s: creating StructSet for query: %s", func, m_queryString.c_str()); - sr = new StructSetImpl(values, fieldNameVec); + sr = std::make_shared<StructSetImpl>(values, fieldNameVec); } } @@ -127,10 +127,10 @@ GfErrType RemoteQuery::executeNoThrow(uint32_t timeout, TcrMessageReply& reply, } LOGDEBUG("%s: creating QUERY TcrMessage for query: %s", func, m_queryString.c_str()); - if (paramList != NULLPTR) { + if (paramList != nullptr) { // QUERY_WITH_PARAMETERS TcrMessageQueryWithParameters msg( - m_queryString, NULLPTR, paramList, + m_queryString, nullptr, paramList, static_cast<int>(timeout * 1000) /* in milli second */, tcdm); msg.setTimeout(timeout); reply.setTimeout(timeout); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RemoteQuery.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RemoteQuery.hpp b/src/cppcache/src/RemoteQuery.hpp index b9daad7..3a44ce3 100644 --- a/src/cppcache/src/RemoteQuery.hpp +++ b/src/cppcache/src/RemoteQuery.hpp @@ -51,7 +51,7 @@ class CPPCACHE_EXPORT RemoteQuery : public Query { public: RemoteQuery(const char* querystr, const RemoteQueryServicePtr& queryService, - ThinClientBaseDM* tccdmptr, ProxyCachePtr proxyCache = NULLPTR); + ThinClientBaseDM* tccdmptr, ProxyCachePtr proxyCache = nullptr); //@TODO check the return type, is it ok. second option could be to pass // SelectResults by reference as a parameter. @@ -59,7 +59,7 @@ class CPPCACHE_EXPORT RemoteQuery : public Query { //@TODO check the return type, is it ok. second option could be to pass // SelectResults by reference as a parameter. - SelectResultsPtr execute(CacheableVectorPtr paramList = NULLPTR, + SelectResultsPtr execute(CacheableVectorPtr paramList = nullptr, uint32_t timeout = DEFAULT_QUERY_RESPONSE_TIMEOUT); // executes a query using a given distribution manager http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RemoteQueryService.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RemoteQueryService.cpp b/src/cppcache/src/RemoteQueryService.cpp index 791f13d..9240243 100644 --- a/src/cppcache/src/RemoteQueryService.cpp +++ b/src/cppcache/src/RemoteQueryService.cpp @@ -26,7 +26,7 @@ using namespace apache::geode::client; RemoteQueryService::RemoteQueryService(CacheImpl* cptr, ThinClientPoolDM* poolDM) - : m_invalid(true), m_cqService(NULLPTR) { + : m_invalid(true), m_cqService(nullptr) { if (poolDM) { m_tccdm = poolDM; } else { @@ -62,8 +62,7 @@ QueryPtr RemoteQueryService::newQuery(const char* querystring) { "QueryService::newQuery: Cache has been closed."); } LOGDEBUG("RemoteQueryService: creating a new query: %s", querystring); - return QueryPtr( - new RemoteQuery(querystring, RemoteQueryServicePtr(this), m_tccdm)); + return QueryPtr(new RemoteQuery(querystring, shared_from_this(), m_tccdm)); } else { UserAttributesPtr ua = TSSUserAttributesWrapper::s_geodeTSSUserAttributes->getUserAttributes(); @@ -74,18 +73,18 @@ QueryPtr RemoteQueryService::newQuery(const char* querystring) { "QueryService::newQuery: Cache has been closed."); } LOGDEBUG("RemoteQueryService: creating a new query: %s", querystring); - return QueryPtr(new RemoteQuery(querystring, RemoteQueryServicePtr(this), - m_tccdm, ua->getProxyCache())); + return QueryPtr(new RemoteQuery(querystring, shared_from_this(), m_tccdm, + ua->getProxyCache())); } } void RemoteQueryService::close() { LOGFINEST("RemoteQueryService::close: starting close"); TryWriteGuard guard(m_rwLock, m_invalid); - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { LOGFINEST("RemoteQueryService::close: starting CQ service close"); m_cqService->closeCqService(); - m_cqService = NULLPTR; + m_cqService = nullptr; LOGFINEST("RemoteQueryService::close: completed CQ service close"); } if (dynamic_cast<ThinClientCacheDistributionManager*>(m_tccdm)) { @@ -113,7 +112,7 @@ GfErrType RemoteQueryService::executeAllCqs(TcrEndpoint* endpoint) { return GF_NOERR; } - if (m_cqService == NULLPTR) { + if (m_cqService == nullptr) { LOGFINE( "RemoteQueryService: no cq to execute after failover to endpoint[%s]", endpoint->name().c_str()); @@ -134,7 +133,7 @@ void RemoteQueryService::executeAllCqs(bool failover) { return; } /*if cq has not been started, then failover will not start it.*/ - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { LOGFINE("RemoteQueryService: execute all cqs after failover"); m_cqService->executeAllClientCqs(failover); } else { @@ -178,19 +177,19 @@ void RemoteQueryService::closeCqs() { return; } // If cqService has not started, then no cq exists - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { m_cqService->closeAllCqs(); } } -void RemoteQueryService::getCqs(VectorOfCqQuery& vec) { +void RemoteQueryService::getCqs(CqService::query_container_type& vec) { TryReadGuard guard(m_rwLock, m_invalid); if (m_invalid) { throw CacheClosedException("QueryService::getCqs: Cache has been closed."); } // If cqService has not started, then no cq exists - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { m_cqService->getAllCqs(vec); } } @@ -202,11 +201,11 @@ CqQueryPtr RemoteQueryService::getCq(const char* name) { throw CacheClosedException("QueryService::getCq: Cache has been closed."); } // If cqService has not started, then no cq exists - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { std::string nm(name); return m_cqService->getCq(nm); } - return NULLPTR; + return nullptr; } void RemoteQueryService::executeCqs() { @@ -217,7 +216,7 @@ void RemoteQueryService::executeCqs() { "QueryService::executeCqs: Cache has been closed."); } // If cqService has not started, then no cq exists - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { m_cqService->executeAllClientCqs(); } } @@ -230,7 +229,7 @@ void RemoteQueryService::stopCqs() { return; } // If cqService has not started, then no cq exists - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { m_cqService->stopAllClientCqs(); } } @@ -243,11 +242,10 @@ CqServiceStatisticsPtr RemoteQueryService::getCqServiceStatistics() { "QueryService::getCqServiceStatistics: Cache has been closed."); } // If cqService has not started, then no cq exists - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { return m_cqService->getCqServiceStatistics(); } - CqServiceStatisticsPtr ptr(new CqServiceVsdStats()); - return ptr; + return std::make_shared<CqServiceVsdStats>(); } void RemoteQueryService::receiveNotification(TcrMessage* msg) { @@ -258,7 +256,7 @@ void RemoteQueryService::receiveNotification(TcrMessage* msg) { return; } /*if cq has not been started, then no cq exists */ - if (m_cqService == NULLPTR) { + if (m_cqService == nullptr) { return; } if (!m_cqService->checkAndAcquireLock()) { @@ -276,16 +274,16 @@ CacheableArrayListPtr RemoteQueryService::getAllDurableCqsFromServer() { "QueryService::getAllDurableCqsFromServer: Cache has been closed."); } // If cqService has not started, then no cq exists - if (m_cqService != NULLPTR) { + if (m_cqService != nullptr) { return m_cqService->getAllDurableCqsFromServer(); } else { - return NULLPTR; + return nullptr; } } void RemoteQueryService::invokeCqConnectedListeners(ThinClientPoolDM* pool, bool connected) { - if (m_cqService == NULLPTR) { + if (m_cqService == nullptr) { return; } std::string poolName; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/RemoteQueryService.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RemoteQueryService.hpp b/src/cppcache/src/RemoteQueryService.hpp index 3c14c5b..c5bf8fb 100644 --- a/src/cppcache/src/RemoteQueryService.hpp +++ b/src/cppcache/src/RemoteQueryService.hpp @@ -35,9 +35,11 @@ namespace client { class CacheImpl; class ThinClientPoolDM; typedef std::map<std::string, bool> CqPoolsConnected; -class CPPCACHE_EXPORT RemoteQueryService : public QueryService { +class CPPCACHE_EXPORT RemoteQueryService + : public QueryService, + public std::enable_shared_from_this<RemoteQueryService> { public: - RemoteQueryService(CacheImpl* cptr, ThinClientPoolDM* poolDM = NULL); + RemoteQueryService(CacheImpl* cptr, ThinClientPoolDM* poolDM = nullptr); void init(); @@ -54,7 +56,7 @@ class CPPCACHE_EXPORT RemoteQueryService : public QueryService { virtual CqQueryPtr newCq(const char* name, const char* querystr, CqAttributesPtr& cqAttr, bool isDurable = false); virtual void closeCqs(); - virtual void getCqs(VectorOfCqQuery& vec); + virtual void getCqs(QueryService::query_container_type& vec); virtual CqQueryPtr getCq(const char* name); virtual void executeCqs(); virtual void stopCqs(); @@ -69,9 +71,9 @@ class CPPCACHE_EXPORT RemoteQueryService : public QueryService { void invokeCqConnectedListeners(ThinClientPoolDM* pool, bool connected); // For Lazy Cq Start-no use, no start inline void initCqService() { - if (m_cqService == NULLPTR) { + if (m_cqService == nullptr) { LOGFINE("RemoteQueryService: starting cq service"); - m_cqService = new CqService(m_tccdm); + m_cqService = std::make_shared<CqService>(m_tccdm); LOGFINE("RemoteQueryService: started cq service"); } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ResultSetImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ResultSetImpl.cpp b/src/cppcache/src/ResultSetImpl.cpp index 63610bf..2e8df44 100644 --- a/src/cppcache/src/ResultSetImpl.cpp +++ b/src/cppcache/src/ResultSetImpl.cpp @@ -42,7 +42,7 @@ const SerializablePtr ResultSetImpl::operator[](int32_t index) const { } SelectResultsIterator ResultSetImpl::getIterator() { - return SelectResultsIterator(m_resultSetVector, SelectResultsPtr(this)); + return SelectResultsIterator(m_resultSetVector, shared_from_this()); } SelectResults::Iterator ResultSetImpl::begin() const { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ResultSetImpl.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ResultSetImpl.hpp b/src/cppcache/src/ResultSetImpl.hpp index ff3891d..5eba661 100644 --- a/src/cppcache/src/ResultSetImpl.hpp +++ b/src/cppcache/src/ResultSetImpl.hpp @@ -36,7 +36,9 @@ namespace apache { namespace geode { namespace client { -class CPPCACHE_EXPORT ResultSetImpl : public ResultSet { +class CPPCACHE_EXPORT ResultSetImpl + : public ResultSet, + public std::enable_shared_from_this<ResultSetImpl> { public: ResultSetImpl(const CacheableVectorPtr& response); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/SelectResultsIterator.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/SelectResultsIterator.cpp b/src/cppcache/src/SelectResultsIterator.cpp index 69a0a46..12c9cce 100644 --- a/src/cppcache/src/SelectResultsIterator.cpp +++ b/src/cppcache/src/SelectResultsIterator.cpp @@ -34,7 +34,7 @@ bool SelectResultsIterator::hasNext() const { } const SerializablePtr SelectResultsIterator::next() { - if (!hasNext()) return NULLPTR; + if (!hasNext()) return nullptr; return m_vectorSR->operator[](m_nextIndex++); } @@ -49,7 +49,7 @@ bool SelectResultsIterator::moveNext() { } const SerializablePtr SelectResultsIterator::current() const { - if (m_nextIndex == 0 || m_nextIndex > m_vectorSR->size()) return NULLPTR; + if (m_nextIndex == 0 || m_nextIndex > m_vectorSR->size()) return nullptr; return m_vectorSR->operator[](m_nextIndex - 1); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/SerializationRegistry.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/SerializationRegistry.cpp b/src/cppcache/src/SerializationRegistry.cpp index e7f7c27..b9ff536 100644 --- a/src/cppcache/src/SerializationRegistry.cpp +++ b/src/cppcache/src/SerializationRegistry.cpp @@ -339,7 +339,7 @@ TheTypeMap::TheTypeMap() { typedef ACE_Singleton<TheTypeMap, ACE_Thread_Mutex> theTypeMap; -PdxSerializerPtr SerializationRegistry::m_pdxSerializer = NULLPTR; +PdxSerializerPtr SerializationRegistry::m_pdxSerializer = nullptr; /** This starts at reading the typeid.. assumes the length has been read. */ SerializablePtr SerializationRegistry::deserialize(DataInput& input, @@ -353,7 +353,7 @@ SerializablePtr SerializationRegistry::deserialize(DataInput& input, LOGDEBUG("SerializationRegistry::deserialize typeid = %d currentTypeId= %d ", typeId, currentTypeId); if (compId == GeodeTypeIds::NullObj) { - return NULLPTR; + return nullptr; } else if (compId == GeodeTypeIds::CacheableNullString) { return SerializablePtr(CacheableString::createDeserializable()); } else if (compId == GeodeTypeIdsImpl::CacheableUserData) { @@ -414,7 +414,11 @@ SerializablePtr SerializationRegistry::deserialize(DataInput& input, } SerializablePtr obj(createType()); // This assignment allows the fromData method to return a different object. - return SerializablePtr(obj->fromData(input)); + auto tmp = obj->fromData(input); + if (obj.get() == tmp) { + return obj; + } + return tmp->shared_from_this(); } void SerializationRegistry::addType(TypeFactoryMethod func) { @@ -453,12 +457,12 @@ void SerializationRegistry::init() { } PdxSerializablePtr SerializationRegistry::getPdxType(char* className) { - TypeFactoryMethodPdx objectType = NULL; + TypeFactoryMethodPdx objectType = nullptr; theTypeMap::instance()->findPdxType(className, objectType); PdxSerializablePtr pdxObj; - if (objectType == NULL) { + if (nullptr == objectType) { try { - pdxObj = new PdxWrapper((const char*)className); + pdxObj = std::make_shared<PdxWrapper>((const char*)className); } catch (const Exception&) { LOGERROR( "Unregistered class %s during PDX deserialization: Did the " @@ -468,7 +472,7 @@ PdxSerializablePtr SerializationRegistry::getPdxType(char* className) { "Unregistered class or serializer in PDX deserialization"); } } else { - pdxObj = objectType(); + pdxObj.reset(objectType()); } return pdxObj; } @@ -483,7 +487,7 @@ PdxSerializerPtr SerializationRegistry::getPdxSerializer() { int32_t SerializationRegistry::GetPDXIdForType(const char* poolName, SerializablePtr pdxType) { - PoolPtr pool = NULLPTR; + PoolPtr pool = nullptr; if (poolName == NULL) { const HashMapOfPools& pools = PoolManager::getAll(); @@ -499,16 +503,16 @@ int32_t SerializationRegistry::GetPDXIdForType(const char* poolName, pool = PoolManager::find(poolName); } - if (pool == NULLPTR) { + if (pool == nullptr) { throw IllegalStateException("Pool not found, Pdx operation failed"); } - return static_cast<ThinClientPoolDM*>(pool.ptr())->GetPDXIdForType(pdxType); + return static_cast<ThinClientPoolDM*>(pool.get())->GetPDXIdForType(pdxType); } SerializablePtr SerializationRegistry::GetPDXTypeById(const char* poolName, int32_t typeId) { - PoolPtr pool = NULLPTR; + PoolPtr pool = nullptr; if (poolName == NULL) { const HashMapOfPools& pools = PoolManager::getAll(); @@ -521,38 +525,37 @@ SerializablePtr SerializationRegistry::GetPDXTypeById(const char* poolName, pool = PoolManager::find(poolName); } - if (pool == NULLPTR) { + if (pool == nullptr) { throw IllegalStateException("Pool not found, Pdx operation failed"); } - return static_cast<ThinClientPoolDM*>(pool.ptr())->GetPDXTypeById(typeId); + return static_cast<ThinClientPoolDM*>(pool.get())->GetPDXTypeById(typeId); } int32_t SerializationRegistry::GetEnumValue(SerializablePtr enumInfo) { PoolPtr pool = getPool(); - if (pool == NULLPTR) { + if (pool == nullptr) { throw IllegalStateException("Pool not found, Pdx operation failed"); } - return static_cast<ThinClientPoolDM*>(pool.ptr())->GetEnumValue(enumInfo); + return static_cast<ThinClientPoolDM*>(pool.get())->GetEnumValue(enumInfo); } SerializablePtr SerializationRegistry::GetEnum(int32_t val) { PoolPtr pool = getPool(); - if (pool == NULLPTR) { + if (pool == nullptr) { throw IllegalStateException("Pool not found, Pdx operation failed"); } - return static_cast<ThinClientPoolDM*>(pool.ptr())->GetEnum(val); + return static_cast<ThinClientPoolDM*>(pool.get())->GetEnum(val); } PoolPtr SerializationRegistry::getPool() { - PoolPtr pool = NULLPTR; + PoolPtr pool = nullptr; const HashMapOfPools& pools = PoolManager::getAll(); if (pools.size() > 0) { for (HashMapOfPools::Iterator iter = pools.begin(); iter != pools.end(); ++iter) { - PoolPtr currPool(iter.second()); - pool = currPool; + pool = iter.second(); break; } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/SerializationRegistry.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/SerializationRegistry.hpp b/src/cppcache/src/SerializationRegistry.hpp index 85783f7..211c35e 100644 --- a/src/cppcache/src/SerializationRegistry.hpp +++ b/src/cppcache/src/SerializationRegistry.hpp @@ -107,7 +107,7 @@ class CPPCACHE_EXPORT SerializationRegistry { } inline static void serialize(const SerializablePtr& obj, DataOutput& output) { - serialize(obj.ptr(), output); + serialize(obj.get(), output); } /** http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ServerLocation.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ServerLocation.cpp b/src/cppcache/src/ServerLocation.cpp index e35c9c6..fbb1c2e 100644 --- a/src/cppcache/src/ServerLocation.cpp +++ b/src/cppcache/src/ServerLocation.cpp @@ -22,7 +22,7 @@ namespace apache { namespace geode { namespace client { void ServerLocation::makeEpString() { - if (m_serverName != NULLPTR) { + if (m_serverName != nullptr) { char epstring[1024] = {0}; ACE_OS::snprintf(epstring, 1024, "%s:%d", m_serverName->asChar(), m_port); m_epString = epstring; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/ServerLocation.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ServerLocation.hpp b/src/cppcache/src/ServerLocation.hpp index 417020a..aea711e 100644 --- a/src/cppcache/src/ServerLocation.hpp +++ b/src/cppcache/src/ServerLocation.hpp @@ -45,7 +45,7 @@ class CPPCACHE_EXPORT ServerLocation : public Serializable { } ServerLocation() : Serializable(), - m_serverName(NULLPTR), + m_serverName(nullptr), m_port(-1) // Default constructor for deserialiozation. {} @@ -62,7 +62,7 @@ class CPPCACHE_EXPORT ServerLocation : public Serializable { } std::string getServerName() const { - if (m_serverName != NULLPTR) { + if (m_serverName != nullptr) { return m_serverName->asChar(); } return ""; @@ -70,7 +70,7 @@ class CPPCACHE_EXPORT ServerLocation : public Serializable { void setServername(CacheableStringPtr sn) { m_serverName = sn; } int getPort() const { return m_port; } void toData(DataOutput& output) const { - if (m_serverName != NULLPTR) { + if (m_serverName != nullptr) { // output.writeObject( m_serverName ); output.writeNativeString(m_serverName->asChar()); // changed } @@ -84,7 +84,7 @@ class CPPCACHE_EXPORT ServerLocation : public Serializable { return this; } uint32_t objectSize() const { - if (m_serverName != NULLPTR) { + if (m_serverName != nullptr) { return static_cast<uint32_t>(sizeof(int)) + (m_serverName->length()) * static_cast<uint32_t>(sizeof(char)); } @@ -132,7 +132,7 @@ class CPPCACHE_EXPORT ServerLocation : public Serializable { /*char server1[256]; char server2[256]; size_t len = 0; - if (m_serverName != NULLPTR && rhs.getServerName( ).c_str() != NULL) { + if (m_serverName != nullptr && rhs.getServerName( ).c_str() != NULL) { ACE_INET_Addr addr1( m_port, m_serverName->asChar() ); len = strlen(addr1.get_host_addr()); memcpy(server1, addr1.get_host_addr(), len); @@ -149,7 +149,7 @@ class CPPCACHE_EXPORT ServerLocation : public Serializable { } inline bool isValid() const { - if (m_serverName == NULLPTR) return false; + if (m_serverName == nullptr) return false; return m_serverName->length() > 0 && m_port >= 0; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/SharedBase.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/SharedBase.cpp b/src/cppcache/src/SharedBase.cpp deleted file mode 100644 index 976942d..0000000 --- a/src/cppcache/src/SharedBase.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <geode/SharedBase.hpp> -#include <HostAsm.hpp> - -#include <typeinfo> - -namespace apache { -namespace geode { -namespace client { - -void SharedBase::preserveSB() const { HostAsm::atomicAdd(m_refCount, 1); } - -void SharedBase::releaseSB() const { - if (HostAsm::atomicAdd(m_refCount, -1) == 0) { - delete this; - } -} - -// dummy instance to use for NULLPTR -const NullSharedBase* const NullSharedBase::s_instancePtr = NULL; -} // namespace client -} // namespace geode -} // namespace apache http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/Struct.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/Struct.cpp b/src/cppcache/src/Struct.cpp index d046e22..314b5ee 100644 --- a/src/cppcache/src/Struct.cpp +++ b/src/cppcache/src/Struct.cpp @@ -112,7 +112,7 @@ const char* Struct::getFieldName(int32_t index) { const SerializablePtr Struct::operator[](int32_t index) const { if (index >= m_fieldValues.size()) { - return NULLPTR; + return nullptr; } return m_fieldValues[index]; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/StructSetImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/StructSetImpl.cpp b/src/cppcache/src/StructSetImpl.cpp index 6c09a24..3c8ce0f 100644 --- a/src/cppcache/src/StructSetImpl.cpp +++ b/src/cppcache/src/StructSetImpl.cpp @@ -47,7 +47,7 @@ StructSetImpl::StructSetImpl( for (size_t i = 0; i < numOfFields; i++) { tmpVec.push_back(response->operator[](valStoredCnt++)); } - StructPtr siPtr(new Struct(this, tmpVec)); + auto siPtr = std::make_shared<Struct>(this, tmpVec); m_structVector->push_back(siPtr); } } @@ -65,7 +65,7 @@ const SerializablePtr StructSetImpl::operator[](int32_t index) const { } SelectResultsIterator StructSetImpl::getIterator() { - return SelectResultsIterator(m_structVector, SelectResultsPtr(this)); + return SelectResultsIterator(m_structVector, shared_from_this()); } int32_t StructSetImpl::getFieldIndex(const char* fieldname) { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/StructSetImpl.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/StructSetImpl.hpp b/src/cppcache/src/StructSetImpl.hpp index 5c7eb0c..28f5368 100644 --- a/src/cppcache/src/StructSetImpl.hpp +++ b/src/cppcache/src/StructSetImpl.hpp @@ -40,7 +40,9 @@ namespace apache { namespace geode { namespace client { -class CPPCACHE_EXPORT StructSetImpl : public StructSet { +class CPPCACHE_EXPORT StructSetImpl + : public StructSet, + public std::enable_shared_from_this<StructSetImpl> { public: StructSetImpl(const CacheableVectorPtr& values, const std::vector<CacheableStringPtr>& fieldNames); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/SystemProperties.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/SystemProperties.cpp b/src/cppcache/src/SystemProperties.cpp index a1b2185..e17c1e5 100644 --- a/src/cppcache/src/SystemProperties.cpp +++ b/src/cppcache/src/SystemProperties.cpp @@ -202,11 +202,11 @@ SystemProperties::SystemProperties(const PropertiesPtr& propertiesPtr, m_redundancyMonitorInterval(DefaultRedundancyMonitorInterval), m_notifyAckInterval(DefaultNotifyAckInterval), m_notifyDupCheckLife(DefaultNotifyDupCheckLife), - m_AuthIniLoaderLibrary(NULLPTR), - m_AuthIniLoaderFactory(NULLPTR), - m_securityClientDhAlgo(NULLPTR), - m_securityClientKsPath(NULLPTR), - m_authInitializer(NULLPTR), + m_AuthIniLoaderLibrary(nullptr), + m_AuthIniLoaderFactory(nullptr), + m_securityClientDhAlgo(nullptr), + m_securityClientKsPath(nullptr), + m_authInitializer(nullptr), m_durableClientId(NULL), m_durableTimeout(DefaultDurableTimeout), m_connectTimeout(DefaultConnectTimeout), @@ -252,7 +252,7 @@ SystemProperties::SystemProperties(const PropertiesPtr& propertiesPtr, void visit(CacheableKeyPtr& key, CacheablePtr& value) { CacheableStringPtr prop = key->toString(); CacheableStringPtr val; - if (value != NULLPTR) { + if (value != nullptr) { val = value->toString(); } m_sysProps->processProperty(prop->asChar(), val->asChar()); @@ -283,7 +283,7 @@ SystemProperties::SystemProperties(const PropertiesPtr& propertiesPtr, givenConfigPtr->foreach (processPropsVisitor); // Now consume any properties provided by the Properties object in code. - if (propertiesPtr != NULLPTR) { + if (propertiesPtr != nullptr) { propertiesPtr->foreach (processPropsVisitor); } @@ -925,25 +925,25 @@ void SystemProperties::logSettings() { } AuthInitializePtr SystemProperties::getAuthLoader() { - if ((m_authInitializer == NULLPTR) && (m_AuthIniLoaderLibrary != NULLPTR && - m_AuthIniLoaderFactory != NULLPTR)) { + if ((m_authInitializer == nullptr) && (m_AuthIniLoaderLibrary != nullptr && + m_AuthIniLoaderFactory != nullptr)) { if (managedAuthInitializeFn != NULL && strchr(m_AuthIniLoaderFactory->asChar(), '.') != NULL) { // this is a managed library - m_authInitializer = (*managedAuthInitializeFn)( - m_AuthIniLoaderLibrary->asChar(), m_AuthIniLoaderFactory->asChar()); + m_authInitializer.reset((*managedAuthInitializeFn)( + m_AuthIniLoaderLibrary->asChar(), m_AuthIniLoaderFactory->asChar())); } else { AuthInitialize* (*funcptr)(); funcptr = reinterpret_cast<AuthInitialize* (*)()>(getFactoryFunc( m_AuthIniLoaderLibrary->asChar(), m_AuthIniLoaderFactory->asChar())); if (funcptr == NULL) { LOGERROR("Failed to acquire handle to AuthInitialize library"); - return NULLPTR; + return nullptr; } AuthInitialize* p = funcptr(); - m_authInitializer = p; + m_authInitializer.reset(p); } - } else if (m_authInitializer == NULLPTR) { + } else if (m_authInitializer == nullptr) { LOGFINE("No AuthInitialize library or factory configured"); } return m_authInitializer; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/TXCleaner.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TXCleaner.cpp b/src/cppcache/src/TXCleaner.cpp index 3c9a0fc..7073e90 100644 --- a/src/cppcache/src/TXCleaner.cpp +++ b/src/cppcache/src/TXCleaner.cpp @@ -42,7 +42,7 @@ TXCleaner::~TXCleaner() { } } void TXCleaner::clean() { - if (m_txState != NULL && m_txState->getTransactionId().ptr() != NULL) { + if (m_txState != NULL && m_txState->getTransactionId().get() != NULL) { m_cacheTxMgr->removeTx(m_txState->getTransactionId()->getId()); } if (m_txStateWrapper != NULL && m_txState != NULL) { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/TXCommitMessage.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TXCommitMessage.cpp b/src/cppcache/src/TXCommitMessage.cpp index 03f92e7..ba7e15b 100644 --- a/src/cppcache/src/TXCommitMessage.cpp +++ b/src/cppcache/src/TXCommitMessage.cpp @@ -88,7 +88,7 @@ m_processorId = -1; int32_t regionSize; input.readInt(®ionSize); for (int32_t i = 0; i < regionSize; i++) { - RegionCommitPtr rc(new RegionCommit(/*this*/)); + auto rc = std::make_shared<RegionCommit>(); rc->fromData(input); m_regions.push_back(rc); } @@ -164,7 +164,7 @@ Serializable* TXCommitMessage::create() { return new TXCommitMessage(); } void TXCommitMessage::apply(Cache* cache) { for (VectorOfSharedBase::Iterator iter = m_regions.begin(); m_regions.end() != iter; iter++) { - RegionCommitPtr regionCommit = staticCast<RegionCommitPtr>(*iter); + RegionCommitPtr regionCommit = std::static_pointer_cast<GF_UNWRAP_SP(RegionCommitPtr)>(*iter); regionCommit->apply(cache); } } @@ -177,7 +177,7 @@ VectorOfEntryEvent TXCommitMessage::getEvents(Cache* cache) m_regions.end() != iter; iter++) { RegionCommitPtr regionCommit = -staticCast<RegionCommitPtr>(*iter); +std::static_pointer_cast<GF_UNWRAP_SP(RegionCommitPtr)>(*iter); regionCommit->fillEvents(cache, ops); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/TXState.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TXState.cpp b/src/cppcache/src/TXState.cpp index 2249b7b..89f327a 100644 --- a/src/cppcache/src/TXState.cpp +++ b/src/cppcache/src/TXState.cpp @@ -60,7 +60,7 @@ CacheablePtr TXState::replay(bool isRollback) { GfErrTypeThrowException("Replay is unsupported", GF_NOTSUP); int retryAttempts = 3; - CacheablePtr result = NULLPTR; + CacheablePtr result = nullptr; ReplayControl replayControl(this); m_dirty = false; @@ -84,7 +84,7 @@ CacheablePtr TXState::replay(bool isRollback) { for (VectorOfSharedBase::Iterator iter = m_operations.begin(); m_operations.end() != iter; iter++) { TransactionalOperationPtr operation = - staticCast<TransactionalOperationPtr>(*iter); + std::static_pointer_cast<GF_UNWRAP_SP(TransactionalOperationPtr)>(*iter); result = operation->replay(m_cache); } @@ -103,7 +103,7 @@ CacheablePtr TXState::replay(bool isRollback) { GfErrTypeThrowException( "Unable to reestablish transaction context on servers", GF_EUNDEF); - return NULLPTR; + return nullptr; } void TXState::releaseStickyConnection() { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/TcrChunkedContext.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TcrChunkedContext.hpp b/src/cppcache/src/TcrChunkedContext.hpp index 3f3d760..c1c12a3 100644 --- a/src/cppcache/src/TcrChunkedContext.hpp +++ b/src/cppcache/src/TcrChunkedContext.hpp @@ -58,7 +58,7 @@ class TcrChunkedResult : public SharedBase { public: inline TcrChunkedResult() : m_finalizeSema(NULL), - m_ex(NULLPTR), + m_ex(nullptr), m_inSameThread(false), appDomainContext(createAppDomainContext()), m_dsmemId(0) {} @@ -117,9 +117,9 @@ class TcrChunkedResult : public SharedBase { // getters/setters for the exception, if any, during chunk processing - inline bool exceptionOccurred() const { return (m_ex != NULLPTR); } + inline bool exceptionOccurred() const { return (m_ex != nullptr); } - inline void setException(Exception& ex) { m_ex = ex.clone(); } + inline void setException(Exception& ex) { m_ex.reset(ex.clone()); } inline ExceptionPtr& getException() { return m_ex; } }; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/TcrConnection.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TcrConnection.cpp b/src/cppcache/src/TcrConnection.cpp index 874ba42..865203e 100644 --- a/src/cppcache/src/TcrConnection.cpp +++ b/src/cppcache/src/TcrConnection.cpp @@ -198,7 +198,7 @@ bool TcrConnection::InitTcrConnection( LOGDEBUG("TcrConnection this->m_endpointObj->isMultiUserMode() = %d ", this->m_endpointObj->isMultiUserMode()); if (this->m_endpointObj->isMultiUserMode()) { - if (dhalgo != NULLPTR && dhalgo->length() > 0) isDhOn = true; + if (dhalgo != nullptr && dhalgo->length() > 0) isDhOn = true; } } @@ -233,7 +233,7 @@ bool TcrConnection::InitTcrConnection( LOGFINER("TcrConnection: about to invoke authloader"); PropertiesPtr tmpSecurityProperties = tmpSystemProperties->getSecurityProperties(); - if (tmpSecurityProperties == NULLPTR) { + if (tmpSecurityProperties == nullptr) { LOGWARN("TcrConnection: security properties not found."); } // AuthInitializePtr authInitialize = @@ -242,7 +242,7 @@ bool TcrConnection::InitTcrConnection( if (isClientNotification) { AuthInitializePtr authInitialize = DistributedSystem::m_impl->getAuthLoader(); - if (authInitialize != NULLPTR) { + if (authInitialize != nullptr) { LOGFINER( "TcrConnection: acquired handle to authLoader, " "invoking getCredentials"); @@ -266,7 +266,7 @@ bool TcrConnection::InitTcrConnection( if (isDhOn) { CacheableStringPtr ksPath = tmpSecurityProperties->find("security-client-kspath"); - requireServerAuth = (ksPath != NULLPTR && ksPath->length() > 0); + requireServerAuth = (ksPath != nullptr && ksPath->length() > 0); handShakeMsg.writeBoolean(requireServerAuth); LOGFINE( "HandShake: Server authentication using RSA signature %s required", @@ -323,9 +323,9 @@ bool TcrConnection::InitTcrConnection( if (error == CONN_NOERR) { CacheableBytesPtr acceptanceCode = readHandshakeData(1, connectTimeout); - LOGDEBUG(" Handshake: Got Accept Code %d", acceptanceCode[0]); + LOGDEBUG(" Handshake: Got Accept Code %d", (*acceptanceCode)[0]); /* adongre */ - if (acceptanceCode[0] == REPLY_SSL_ENABLED && + if ((*acceptanceCode)[0] == REPLY_SSL_ENABLED && !tmpSystemProperties->sslEnabled()) { LOGERROR("SSL is enabled on server, enable SSL in client as well"); AuthenticationRequiredException ex( @@ -335,7 +335,7 @@ bool TcrConnection::InitTcrConnection( } // if diffie-hellman based credential encryption is enabled - if (isDhOn && acceptanceCode[0] == REPLY_OK) { + if (isDhOn && (*acceptanceCode)[0] == REPLY_OK) { // read the server's DH public key CacheableBytesPtr pubKeyBytes = readHandshakeByteArray(connectTimeout); LOGDEBUG(" Handshake: Got pubKeySize %d", pubKeyBytes->length()); @@ -387,7 +387,7 @@ bool TcrConnection::InitTcrConnection( if (error == CONN_NOERR) { acceptanceCode = readHandshakeData(1, connectTimeout); - LOGDEBUG("Handshake: Got acceptanceCode Finally %d", acceptanceCode[0]); + LOGDEBUG("Handshake: Got acceptanceCode Finally %d", (*acceptanceCode)[0]); } else { int32_t lastError = ACE_OS::last_error(); LOGERROR("Handshake failed, errno: %d, server may not be running", @@ -409,9 +409,9 @@ bool TcrConnection::InitTcrConnection( // TESTING: Durable clients - set server queue status. // 0 - Non-Redundant , 1- Redundant , 2- Primary - if (serverQueueStatus[0] == 1) { + if ((*serverQueueStatus)[0] == 1) { m_hasServerQueue = REDUNDANT_SERVER; - } else if (serverQueueStatus[0] == 2) { + } else if ((*serverQueueStatus)[0] == 2) { m_hasServerQueue = PRIMARY_SERVER; } else { m_hasServerQueue = NON_REDUNDANT_SERVER; @@ -443,16 +443,16 @@ bool TcrConnection::InitTcrConnection( if (!isClientNotification) { // Read and ignore the DistributedMember object CacheableBytesPtr arrayLenHeader = readHandshakeData(1, connectTimeout); - int32_t recvMsgLen = static_cast<int32_t>(arrayLenHeader[0]); + int32_t recvMsgLen = static_cast<int32_t>((*arrayLenHeader)[0]); // now check for array length headers - since GFE 5.7 - if (static_cast<int8_t>(arrayLenHeader[0]) == -2) { + if (static_cast<int8_t>((*arrayLenHeader)[0]) == -2) { CacheableBytesPtr recvMsgLenBytes = readHandshakeData(2, connectTimeout); DataInput dI2(recvMsgLenBytes->value(), recvMsgLenBytes->length()); int16_t recvMsgLenShort = 0; dI2.readInt(&recvMsgLenShort); recvMsgLen = recvMsgLenShort; - } else if (static_cast<int8_t>(arrayLenHeader[0]) == -3) { + } else if (static_cast<int8_t>((*arrayLenHeader)[0]) == -3) { CacheableBytesPtr recvMsgLenBytes = readHandshakeData(4, connectTimeout); DataInput dI2(recvMsgLenBytes->value(), recvMsgLenBytes->length()); @@ -488,11 +488,11 @@ bool TcrConnection::InitTcrConnection( ThinClientBaseDM::setDeltaEnabledOnServer(isDeltaEnabledOnServer); } - switch (acceptanceCode[0]) { + switch ((*acceptanceCode)[0]) { case REPLY_OK: case SUCCESSFUL_SERVER_TO_CLIENT: - LOGFINER("Handshake reply: %u,%u,%u", acceptanceCode[0], - serverQueueStatus[0], recvMsgLen2); + LOGFINER("Handshake reply: %u,%u,%u", (*acceptanceCode)[0], + (*serverQueueStatus)[0], recvMsgLen2); if (isClientNotification) readHandshakeInstantiatorMsg(connectTimeout); break; case REPLY_AUTHENTICATION_FAILED: { @@ -532,7 +532,7 @@ bool TcrConnection::InitTcrConnection( LOGERROR( "Unknown error[%d] received from server [%s] in handshake: " "%s", - acceptanceCode[0], m_endpointObj->name().c_str(), + (*acceptanceCode)[0], m_endpointObj->name().c_str(), recvMessage->value()); MessageException ex( "TcrConnection::TcrConnection: Unknown error" @@ -1231,7 +1231,7 @@ CacheableBytesPtr TcrConnection::readHandshakeData(int32_t msgLength, return CacheableBytes::createNoCopy(reinterpret_cast<uint8_t*>(recvMessage), msgLength + 1); } - return NULLPTR; + return nullptr; } // read just the bytes without the trailing null terminator @@ -1247,7 +1247,7 @@ CacheableBytesPtr TcrConnection::readHandshakeRawData(int32_t msgLength, msgLength = 0; } if (msgLength == 0) { - return NULLPTR; + return nullptr; } char* recvMessage; GF_NEW(recvMessage, char[msgLength]); @@ -1267,7 +1267,7 @@ CacheableBytesPtr TcrConnection::readHandshakeRawData(int32_t msgLength, "Handshake failure")); } // not expected to be reached - return NULLPTR; + return nullptr; } else { return CacheableBytes::createNoCopy(reinterpret_cast<uint8_t*>(recvMessage), msgLength); @@ -1424,7 +1424,7 @@ CacheableStringPtr TcrConnection::readHandshakeString(uint32_t connectTimeout) { uint32_t length = 0; switch (static_cast<int8_t>(cstypeid)) { case GeodeTypeIds::CacheableNullString: { - return NULLPTR; + return nullptr; break; } case GF_STRING: { @@ -1446,7 +1446,7 @@ CacheableStringPtr TcrConnection::readHandshakeString(uint32_t connectTimeout) { LOGDEBUG(" Received string len %d", length); if (length == 0) { - return NULLPTR; + return nullptr; } char* recvMessage; @@ -1471,7 +1471,7 @@ CacheableStringPtr TcrConnection::readHandshakeString(uint32_t connectTimeout) { "Handshake failure reading string bytes")); } // not expected to be reached - return NULLPTR; + return nullptr; } else { LOGDEBUG(" Received string data [%s]", recvMessage); CacheableStringPtr retval = http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/src/TcrConnectionManager.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TcrConnectionManager.cpp b/src/cppcache/src/TcrConnectionManager.cpp index 67d7d01..f46e2d0 100644 --- a/src/cppcache/src/TcrConnectionManager.cpp +++ b/src/cppcache/src/TcrConnectionManager.cpp @@ -84,7 +84,7 @@ void TcrConnectionManager::init(bool isPool) { const char *endpoints; m_redundancyManager->m_HAenabled = false; - if (cacheAttributes != NULLPTR && + if (cacheAttributes != nullptr && (cacheAttributes->getRedundancyLevel() > 0 || m_isDurable) && (endpoints = cacheAttributes->getEndpoints()) != NULL && strcmp(endpoints, "none") != 0) { @@ -158,7 +158,7 @@ void TcrConnectionManager::close() { } CacheAttributesPtr cacheAttributes = m_cache->getAttributes(); - if (cacheAttributes != NULLPTR && + if (cacheAttributes != nullptr && (cacheAttributes->getRedundancyLevel() > 0 || m_isDurable)) { if (m_servermonitorTaskId > 0) { CacheImpl::expiryTaskManager->cancelTask(m_servermonitorTaskId);