http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/RegionAttributes.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/RegionAttributes.hpp b/src/cppcache/include/geode/RegionAttributes.hpp index f526f93..85d7319 100644 --- a/src/cppcache/include/geode/RegionAttributes.hpp +++ b/src/cppcache/include/geode/RegionAttributes.hpp @@ -76,28 +76,28 @@ class CPPCACHE_EXPORT RegionAttributes : public Serializable { public: /** Gets the cache loader for the region. * @return a pointer that points to the region's , - * <code>CacheLoader</code> , NULLPTR if there is no CacheLoader for this + * <code>CacheLoader</code> , nullptr if there is no CacheLoader for this * region. */ CacheLoaderPtr getCacheLoader(); /** Gets the cache writer for the region. * @return a pointer that points to the region's , - * <code>CacheWriter</code> , NULLPTR if there is no CacheWriter for this + * <code>CacheWriter</code> , nullptr if there is no CacheWriter for this * region */ CacheWriterPtr getCacheWriter(); /** Gets the cache listener for the region. * @return a pointer that points to the region's , - * <code>CacheListener</code> , NULLPTR if there is no CacheListener defined + * <code>CacheListener</code> , nullptr if there is no CacheListener defined * for this region. */ CacheListenerPtr getCacheListener(); /** Gets the partition resolver for the partition region. * @return a pointer that points to the region's , - * <code>PartitionResolver</code> , NULLPTR if there is no PartitionResolver + * <code>PartitionResolver</code> , nullptr if there is no PartitionResolver * defined * for this region. */ @@ -292,7 +292,7 @@ class CPPCACHE_EXPORT RegionAttributes : public Serializable { /** Gets the persistence for the region. * @return a pointer that points to the region's , - * <code>PersistenceManager</code> , NULLPTR if there is no PersistenceManager + * <code>PersistenceManager</code> , nullptr if there is no PersistenceManager * for this * region. */ @@ -395,6 +395,8 @@ class CPPCACHE_EXPORT RegionAttributes : public Serializable { private: const RegionAttributes& operator=(const RegionAttributes&); + + FRIEND_STD_SHARED_PTR(RegionAttributes) }; } // namespace client } // namespace geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/RegionEntry.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/RegionEntry.hpp b/src/cppcache/include/geode/RegionEntry.hpp index c6b3e7d..0f50951 100644 --- a/src/cppcache/include/geode/RegionEntry.hpp +++ b/src/cppcache/include/geode/RegionEntry.hpp @@ -59,7 +59,7 @@ class CPPCACHE_EXPORT RegionEntry : public SharedBase { /** Returns the value of this entry in the local cache. Does not invoke * a <code>CacheLoader</code>, * - * @return the value or <code>NULLPTR</code> if this entry is invalid + * @return the value or <code>nullptr</code> if this entry is invalid */ CacheablePtr getValue(); @@ -67,7 +67,7 @@ class CPPCACHE_EXPORT RegionEntry : public SharedBase { * * @return the Region that contains this entry */ - void getRegion(RegionPtr& region); + void getRegion(Region* region); /** Returns the statistics for this entry. * @@ -95,9 +95,9 @@ class CPPCACHE_EXPORT RegionEntry : public SharedBase { * @brief constructors * created by region */ - RegionEntry(const RegionPtr& region, const CacheableKeyPtr& key, + RegionEntry(Region* region, const CacheableKeyPtr& key, const CacheablePtr& value); - RegionPtr m_region; + Region* m_region; CacheableKeyPtr m_key; CacheablePtr m_value; CacheStatisticsPtr m_statistics; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/RegionFactory.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/RegionFactory.hpp b/src/cppcache/include/geode/RegionFactory.hpp index d411ab0..b2729a2 100644 --- a/src/cppcache/include/geode/RegionFactory.hpp +++ b/src/cppcache/include/geode/RegionFactory.hpp @@ -31,7 +31,9 @@ namespace apache { namespace geode { namespace client { class CacheImpl; -class CPPCACHE_EXPORT RegionFactory : public SharedBase { +class CPPCACHE_EXPORT RegionFactory + : public SharedBase, + public std::enable_shared_from_this<RegionFactory> { public: /* * To create the (@link Region}. @@ -44,26 +46,26 @@ class CPPCACHE_EXPORT RegionFactory : public SharedBase { RegionPtr create(const char* name); /** Sets the cache loader for the next <code>RegionAttributes</code> created. - * @param cacheLoader the cache loader or NULLPTR if no loader + * @param cacheLoader the cache loader or nullptr if no loader * @return a reference to <code>this</code> */ RegionFactoryPtr setCacheLoader(const CacheLoaderPtr& cacheLoader); /** Sets the cache writer for the next <code>RegionAttributes</code> created. - * @param cacheWriter the cache writer or NULLPTR if no cache writer + * @param cacheWriter the cache writer or nullptr if no cache writer * @return a reference to <code>this</code> */ RegionFactoryPtr setCacheWriter(const CacheWriterPtr& cacheWriter); /** Sets the CacheListener for the next <code>RegionAttributes</code> created. - * @param aListener a user defined CacheListener, NULLPTR if no listener + * @param aListener a user defined CacheListener, nullptr if no listener * @return a reference to <code>this</code> */ RegionFactoryPtr setCacheListener(const CacheListenerPtr& aListener); /** Sets the PartitionResolver for the next <code>RegionAttributes</code> * created. - * @param aResolver a user defined PartitionResolver, NULLPTR if no resolver + * @param aResolver a user defined PartitionResolver, nullptr if no resolver * @return a reference to <code>this</code> */ RegionFactoryPtr setPartitionResolver(const PartitionResolverPtr& aResolver); @@ -149,17 +151,17 @@ class CPPCACHE_EXPORT RegionFactory : public SharedBase { */ RegionFactoryPtr setPersistenceManager(const char* libpath, const char* factoryFuncName, - const PropertiesPtr& config = NULLPTR); + const PropertiesPtr& config = nullptr); /** Sets the PersistenceManager for the next <code>RegionAttributes</code> * created. - * @param persistenceManager a user defined PersistenceManager, NULLPTR if no + * @param persistenceManager a user defined PersistenceManager, nullptr if no * persistenceManager * @return a reference to <code>this</code> */ RegionFactoryPtr setPersistenceManager( const PersistenceManagerPtr& persistenceManager, - const PropertiesPtr& config = NULLPTR); + const PropertiesPtr& config = nullptr); // MAP ATTRIBUTES /** Sets the entry initial capacity for the next <code>RegionAttributes</code> @@ -263,6 +265,7 @@ class CPPCACHE_EXPORT RegionFactory : public SharedBase { ~RegionFactory(); friend class CacheImpl; + FRIEND_STD_SHARED_PTR(RegionFactory) }; } // namespace client } // namespace geode http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/RegionService.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/RegionService.hpp b/src/cppcache/include/geode/RegionService.hpp index 8f8ae67..f031141 100644 --- a/src/cppcache/include/geode/RegionService.hpp +++ b/src/cppcache/include/geode/RegionService.hpp @@ -87,7 +87,7 @@ class CPPCACHE_EXPORT RegionService : public SharedBase { /** Look up a region with the name. * * @param name the region's name, such as <code>root</code>. - * @returns region, or NULLPTR if no such region exists. + * @returns region, or nullptr if no such region exists. */ virtual RegionPtr getRegion(const char* name) = 0; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/SelectResultsIterator.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/SelectResultsIterator.hpp b/src/cppcache/include/geode/SelectResultsIterator.hpp index b51cdd0..1a61c96 100644 --- a/src/cppcache/include/geode/SelectResultsIterator.hpp +++ b/src/cppcache/include/geode/SelectResultsIterator.hpp @@ -56,7 +56,7 @@ class CPPCACHE_EXPORT SelectResultsIterator : public SharedBase { /** * Get the next item from the SelectResultsIterator. * - * @returns a smart pointer to the next item from the iterator or NULLPTR if + * @returns a smart pointer to the next item from the iterator or nullptr if * no further items are available. */ const SerializablePtr next(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/Serializable.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/Serializable.hpp b/src/cppcache/include/geode/Serializable.hpp index 5a16d7d..2305f09 100644 --- a/src/cppcache/include/geode/Serializable.hpp +++ b/src/cppcache/include/geode/Serializable.hpp @@ -50,7 +50,9 @@ typedef PdxSerializable* (*TypeFactoryMethodPdx)(); * in the cache that can be serialized. */ -class CPPCACHE_EXPORT Serializable : public SharedBase { +class CPPCACHE_EXPORT Serializable + : public SharedBase, + public std::enable_shared_from_this<Serializable> { public: /** *@brief serialize this object http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/Serializer.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/Serializer.hpp b/src/cppcache/include/geode/Serializer.hpp index 3c40e3d..19d9965 100644 --- a/src/cppcache/include/geode/Serializer.hpp +++ b/src/cppcache/include/geode/Serializer.hpp @@ -325,7 +325,7 @@ inline uint32_t objectSize(const _VectorOfCacheable& value) { uint32_t objectSize = 0; for (_VectorOfCacheable::Iterator iter = value.begin(); iter != value.end(); ++iter) { - if (*iter != NULLPTR) { + if (*iter != nullptr) { objectSize += (*iter)->objectSize(); } } @@ -366,7 +366,7 @@ inline uint32_t objectSize(const _HashMapOfCacheable& value) { for (_HashMapOfCacheable::Iterator iter = value.begin(); iter != value.end(); ++iter) { objectSize += iter.first()->objectSize(); - if (iter.second() != NULLPTR) { + if (iter.second() != nullptr) { objectSize += iter.second()->objectSize(); } } @@ -406,7 +406,7 @@ inline uint32_t objectSize(const _HashSetOfCacheableKey& value) { uint32_t objectSize = 0; for (_HashSetOfCacheableKey::Iterator iter = value.begin(); iter != value.end(); ++iter) { - if (*iter != NULLPTR) { + if (*iter != nullptr) { objectSize += (*iter)->objectSize(); } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/SharedBase.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/SharedBase.hpp b/src/cppcache/include/geode/SharedBase.hpp index 97cb0ae..642ed0a 100644 --- a/src/cppcache/include/geode/SharedBase.hpp +++ b/src/cppcache/include/geode/SharedBase.hpp @@ -3,8 +3,6 @@ #ifndef GEODE_SHAREDBASE_H_ #define GEODE_SHAREDBASE_H_ -// SharedBase.hpp -*- mode: c++ -*- - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -34,58 +32,23 @@ namespace client { /** * @class SharedBase SharedBase.hpp * - * This abstract base class is the base class of all user objects - * that have the shared capability of reference counting. + * This abstract base class is the base class of all user objects. */ class CPPCACHE_EXPORT SharedBase { public: /** Constructor. */ - inline SharedBase() : m_refCount(0) {} - - /** Atomically increment reference count */ - void preserveSB() const; - - /** - * Atomically decrement reference count, the SharedBase object is - * automatically deleted when its reference count goes to zero - */ - void releaseSB() const; + inline SharedBase() {} - /** @return the reference count */ - inline int32_t refCount() { return m_refCount; } + void operator=(const SharedBase& rhs) = delete; protected: inline SharedBase(bool noInit) {} virtual ~SharedBase() {} - - private: - mutable volatile int32_t m_refCount; - - void operator=(const SharedBase& rhs); }; -/** - * Class encapsulating a NULL SharedBase smart pointer. This is for passing - * NULL pointers implicitly to copy constructor of <code>SharedPtr</code> - * class. - */ -class CPPCACHE_EXPORT NullSharedBase : public SharedBase { - public: - static const NullSharedBase* const s_instancePtr; - - private: - NullSharedBase() {} - // never defined - NullSharedBase(const NullSharedBase&); - NullSharedBase& operator=(const NullSharedBase&); - - friend class SharedBase; // just to get rid of warning with gcc3.x -}; } // namespace client } // namespace geode } // namespace apache -#define NULLPTR ::apache::geode::client::NullSharedBase::s_instancePtr - #endif // GEODE_SHAREDBASE_H_ http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/SharedPtr.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/SharedPtr.hpp b/src/cppcache/include/geode/SharedPtr.hpp index 99d5632..610b08e 100644 --- a/src/cppcache/include/geode/SharedPtr.hpp +++ b/src/cppcache/include/geode/SharedPtr.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_SHAREDPTR_H_ -#define GEODE_SHAREDPTR_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,264 +15,22 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_SHAREDPTR_H_ +#define GEODE_SHAREDPTR_H_ + +// TODO shared_ptr - remove this file. + #include "SharedBase.hpp" -#include "Assert.hpp" -#include "TypeHelper.hpp" -#include <typeinfo> #include "SharedPtrHelper.hpp" -/** @file -*/ - namespace apache { namespace geode { namespace client { -#if GF_DEVEL_ASSERTS == 1 -#define GF_CHECK_NPE(x) \ - if (x != NULL) { \ - } else \ - apache::geode::client::SPEHelper::throwNullPointerException( \ - typeid(*this).name()) -#else -#define GF_CHECK_NPE(x) -#endif - -class MapEntry; -class MapEntryImpl; - -template <class Target> -/** Defines a reference counted shared pointer -*/ -class SharedPtr { - public: - /** Constructor. */ - inline SharedPtr() : m_ptr(NULL) {} - - /** Constructor for the NULL pointer */ - inline SharedPtr(const NullSharedBase* ptr) : m_ptr(NULL) {} - - /** Explicit copy constructor, given a pointer. - * @throws ClassCastException if <code>Target</code> pointer cannot be - * converted to <code>SharedBase</code> pointer (dynamic_cast to - * <code>SharedBase*</code> fails). - */ - inline explicit SharedPtr(const Target* ptr) - : m_ptr(const_cast<Target*>(ptr)) { - if (NULL != m_ptr) getSB(m_ptr)->preserveSB(); - } - - /** Constructor, given another SharedPtr. */ - inline SharedPtr(const SharedPtr& other) : m_ptr(other.m_ptr) { - if (NULL != m_ptr) getSB(m_ptr)->preserveSB(); - } - - /** Constructor, given another SharedPtr. - * @throws ClassCastException if <code>Other</code> pointer cannot be - * converted to <code>Target</code> pointer (dynamic_cast to - * <code>Target*</code> fails). - */ - template <class Other> - inline SharedPtr(const SharedPtr<Other>& other) - : m_ptr(getTarget<Target>(other.ptr())) { - if (NULL != m_ptr) getSB(m_ptr)->preserveSB(); - } - - /** Destructor. */ - inline ~SharedPtr() { - if (NULL != m_ptr) getSB(m_ptr)->releaseSB(); - - m_ptr = NULL; - } - - inline Target* operator->() const { - GF_CHECK_NPE(m_ptr); - GF_DEV_ASSERT(getSB(m_ptr)->refCount() > 0); - - return m_ptr; - } - - inline Target& operator*() const { - GF_CHECK_NPE(m_ptr); - return *m_ptr; - } - - /** Assigns a pointer. - * @throws ClassCastException if <code>Target</code> pointer cannot be - * converted to <code>SharedBase</code> pointer (dynamic_cast to - * <code>SharedBase*</code> fails). - */ - inline SharedPtr& operator=(Target* other) { - if (NULL != other) getSB(other)->preserveSB(); - - if (NULL != m_ptr) getSB(m_ptr)->releaseSB(); - - m_ptr = other; - - return *this; - } - - inline SharedPtr& operator=(const SharedPtr& other) { - Target* otherPtr = other.m_ptr; - - if (NULL != otherPtr) { - getSB(otherPtr)->preserveSB(); - } - if (NULL != m_ptr) { - getSB(m_ptr)->releaseSB(); - } - m_ptr = otherPtr; - - GF_DEV_ASSERT(otherPtr == other.m_ptr); - - return *this; - } - - /** Assigns a pointer of type <code>Other</code> from a <code>SharedPtr</code> - * object. - * @throws ClassCastException if <code>Other</code> pointer cannot be - * converted to <code>Target</code> pointer (dynamic_cast to - * <code>Target*</code> fails). - */ - template <class Other> - inline SharedPtr& operator=(const SharedPtr<Other>& other) { - Other* otherPtr = other.ptr(); - - Target* otherTargetPtr = getTarget<Target>(otherPtr); - - if (NULL != otherPtr) { - getSB(otherPtr)->preserveSB(); - } - if (NULL != m_ptr) { - getSB(m_ptr)->releaseSB(); - } - m_ptr = otherTargetPtr; - - GF_DEV_ASSERT(otherPtr == other.ptr()); - - return *this; - } - - inline SharedPtr& operator=(const NullSharedBase* nullOther) { - if (m_ptr != NULL) { - getSB(m_ptr)->releaseSB(); - } - m_ptr = NULL; - return *this; - } - - /** Assigns a pointer of type <code>Other</code>. - * @throws ClassCastException if <code>Other</code> pointer cannot be - * converted to <code>Target</code> pointer (dynamic_cast to - * <code>Target*</code> fails), - * or if <code>Other</code> pointer cannot be converted to - * <code>SharedBase</code> pointer (dynamic_cast to <code>SharedBase*</code> - * fails). - */ - template <class Other> - inline SharedPtr& operator=(Other* other) { - Target* otherTargetPtr = getTarget<Target>(other); - - if (NULL != other) { - getSB(other)->preserveSB(); - } - if (NULL != m_ptr) { - getSB(m_ptr)->releaseSB(); - } - m_ptr = otherTargetPtr; - - return *this; - } - - inline bool operator==(const Target* other) const { return m_ptr == other; } - - inline bool operator!=(const Target* other) const { return m_ptr != other; } - - inline bool operator==(const NullSharedBase* nullOther) const { - return m_ptr == NULL; - } - - inline bool operator!=(const NullSharedBase* nullOther) const { - return m_ptr != NULL; - } - - inline bool operator==(const SharedPtr& other) const { - return m_ptr == other.m_ptr; - } - - inline bool operator!=(const SharedPtr& other) const { - return m_ptr != other.m_ptr; - } - - template <class Other> - inline bool operator==(const SharedPtr<Other>& other) { - return ((const void*)m_ptr) == ((const void*)other.ptr()); - } - - template <class Other> - inline bool operator!=(const SharedPtr<Other>& other) { - return !operator==(other); - } - - inline Target* ptr() const { return m_ptr; } - - private: - /** this constructor deliberately skips touching m_ptr or anything */ - inline explicit SharedPtr(bool noInit) {} - - Target* m_ptr; - - friend class MapEntry; - friend class MapEntryImpl; -}; - typedef SharedPtr<SharedBase> SharedBasePtr; -/** Statically cast the underlying pointer to the given type. The behaviour - * is similar to <code>static_cast</code>. - * - * Make use of this cast with care since it does not offer protection - * against incorrect casts. For most purposes <code>dynCast</code> is the - * better choice and this should be used only where the programmer knows - * the cast to be safe. - * - * Setting the macro <code>GF_DEBUG_ASSERTS</code> enables dynamic checking - * of the cast throwing an <code>AssertionException</code> if the cast fails. - */ -template <class TargetSP, class Other> -TargetSP staticCast(const SharedPtr<Other>& other) { - GF_D_ASSERT((other.ptr() == NULL) || - (dynamic_cast<GF_UNWRAP_SP(TargetSP)*>(other.ptr()) != NULL)); - - return TargetSP(static_cast<GF_UNWRAP_SP(TargetSP)*>(other.ptr())); -} - -/** Dynamically cast the underlying pointer to the given type and throw - * <code>ClassCastException</code> if the cast fails. - */ -template <class TargetSP, class Other> -TargetSP dynCast(const SharedPtr<Other>& other) { - GF_UNWRAP_SP(TargetSP) * otherPtr; - - if ((other.ptr() == NULL)) { - return NULLPTR; - } else if ((otherPtr = dynamic_cast<GF_UNWRAP_SP(TargetSP)*>(other.ptr())) != - NULL) { - return TargetSP(otherPtr); - } else { - SPEHelper::throwClassCastException( - "dynCast: cast failed", typeid(other).name(), typeid(TargetSP).name()); - return NULLPTR; - } -} - -/** - * Dynamically check if the underlying pointer is of the given SharedPtr type. - */ -template <class TargetSP, class Other> -bool instanceOf(const SharedPtr<Other>& other) { - return (dynamic_cast<GF_UNWRAP_SP(TargetSP)*>(other.ptr()) != NULL); -} } // namespace client } // namespace geode } // namespace apache http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/SharedPtrHelper.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/SharedPtrHelper.hpp b/src/cppcache/include/geode/SharedPtrHelper.hpp index a276f14..177770b 100644 --- a/src/cppcache/include/geode/SharedPtrHelper.hpp +++ b/src/cppcache/include/geode/SharedPtrHelper.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_SHAREDPTRHELPER_H_ -#define GEODE_SHAREDPTRHELPER_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,9 +15,17 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_SHAREDPTRHELPER_H_ +#define GEODE_SHAREDPTRHELPER_H_ + +// TODO shared_ptr - remove this file. + +#include <typeinfo> + #include "geode_globals.hpp" #include "TypeHelper.hpp" -#include <typeinfo> namespace apache { namespace geode { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/Struct.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/Struct.hpp b/src/cppcache/include/geode/Struct.hpp index b88bf31..13411f0 100644 --- a/src/cppcache/include/geode/Struct.hpp +++ b/src/cppcache/include/geode/Struct.hpp @@ -61,7 +61,7 @@ class CPPCACHE_EXPORT Struct : public Serializable { * Get the field value for the given index number. * * @param index the index number of the field value to get. - * @returns A smart pointer to the field value or NULLPTR if index out of + * @returns A smart pointer to the field value or nullptr if index out of * bounds. */ const SerializablePtr operator[](int32_t index) const; @@ -100,7 +100,7 @@ class CPPCACHE_EXPORT Struct : public Serializable { /** * Get the next field value item available in this Struct. * - * @returns A smart pointer to the next item in the Struct or NULLPTR if no + * @returns A smart pointer to the next item in the Struct or nullptr if no * more available. */ const SerializablePtr next(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/SystemProperties.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/SystemProperties.hpp b/src/cppcache/include/geode/SystemProperties.hpp index 5db43c7..7dc6131 100644 --- a/src/cppcache/include/geode/SystemProperties.hpp +++ b/src/cppcache/include/geode/SystemProperties.hpp @@ -299,28 +299,28 @@ class CPPCACHE_EXPORT SystemProperties { /** Return the security auth library */ inline const char* authInitLibrary() const { - return (m_AuthIniLoaderLibrary == NULLPTR + return (m_AuthIniLoaderLibrary == nullptr ? "" : m_AuthIniLoaderLibrary->asChar()); } /** Return the security auth factory */ inline const char* authInitFactory() const { - return (m_AuthIniLoaderFactory == NULLPTR + return (m_AuthIniLoaderFactory == nullptr ? "" : m_AuthIniLoaderFactory->asChar()); } /** Return the security diffie hellman secret key algo */ const char* securityClientDhAlgo() { - return (m_securityClientDhAlgo == NULLPTR + return (m_securityClientDhAlgo == nullptr ? "" : m_securityClientDhAlgo->asChar()); } /** Return the keystore (.pem file ) path */ const char* securityClientKsPath() { - return (m_securityClientKsPath == NULLPTR + return (m_securityClientKsPath == nullptr ? "" : m_securityClientKsPath->asChar()); } @@ -336,8 +336,8 @@ class CPPCACHE_EXPORT SystemProperties { * @return bool value. */ inline bool isSecurityOn() const { - return (m_AuthIniLoaderFactory != NULLPTR && - m_AuthIniLoaderLibrary != NULLPTR); + return (m_AuthIniLoaderFactory != nullptr && + m_AuthIniLoaderLibrary != nullptr); } /** Checks whether list of endpoint is shuffeled or not. @@ -352,7 +352,7 @@ class CPPCACHE_EXPORT SystemProperties { * @return bool flag to indicate whether DH for credentials is on. */ bool isDhOn() { - return isSecurityOn() && m_securityClientDhAlgo != NULLPTR && + return isSecurityOn() && m_securityClientDhAlgo != nullptr && m_securityClientDhAlgo->length() > 0; } @@ -489,7 +489,7 @@ class CPPCACHE_EXPORT SystemProperties { /** Gets the authInitialize loader for the system. * @return a pointer that points to the system's , - * <code>AuthLoader</code> , NULLPTR if there is no AuthLoader for this + * <code>AuthLoader</code> , nullptr if there is no AuthLoader for this * system. */ AuthInitializePtr getAuthLoader(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/TypeHelper.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/TypeHelper.hpp b/src/cppcache/include/geode/TypeHelper.hpp index b96684e..149ea80 100644 --- a/src/cppcache/include/geode/TypeHelper.hpp +++ b/src/cppcache/include/geode/TypeHelper.hpp @@ -25,22 +25,23 @@ */ #include "geode_globals.hpp" +#include <memory> namespace apache { namespace geode { namespace client { -// Forward declaration of SharedPtr<T> -template <typename Target> -class SharedPtr; -// Forward declaration of SharedArrayPtr<T, ID> -template <typename Target, int8_t TYPEID> -class SharedArrayPtr; +// TODO share_ptr - remove this and replace with explicit std::shared_ptr defs. +template <class Target> +using SharedPtr = std::shared_ptr<Target>; // Forward declaration of CacheableArrayType<T, ID> template <typename Target, int8_t TYPEID> class CacheableArrayType; +template <typename TObj, int8_t TYPEID> +using SharedArrayPtr = SharedPtr<CacheableArrayType<TObj, TYPEID>>; + /** * @brief Helper type traits and other structs/classes to determine type * information at compile time using typename. http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/VectorOfSharedBase.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/VectorOfSharedBase.hpp b/src/cppcache/include/geode/VectorOfSharedBase.hpp index 8976af3..537fb4c 100644 --- a/src/cppcache/include/geode/VectorOfSharedBase.hpp +++ b/src/cppcache/include/geode/VectorOfSharedBase.hpp @@ -121,7 +121,7 @@ class CPPCACHE_EXPORT VectorOfSharedBase { /** copy constructor */ VectorOfSharedBase(const VectorOfSharedBase& other); - /** destructor, sets all SharedPtr elements to NULLPTR */ + /** destructor, sets all SharedPtr elements to nullptr */ ~VectorOfSharedBase(); /** assignment operator */ @@ -157,7 +157,7 @@ class CPPCACHE_EXPORT VectorOfSharedBase { /** inserts or erases elements at the end such that size becomes n. * Not to be confused with reserve which simply allocates the space, * resize fills the space with active elements. */ - void resize(int32_t n, const SharedBasePtr& t = NULLPTR); + void resize(int32_t n, const SharedBasePtr& t = nullptr); /** insert object at the given index. */ void insert(int32_t index, const SharedBasePtr& t); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/VectorT.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/VectorT.hpp b/src/cppcache/include/geode/VectorT.hpp index 48cd8fb..b223112 100644 --- a/src/cppcache/include/geode/VectorT.hpp +++ b/src/cppcache/include/geode/VectorT.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_VECTORT_H_ -#define GEODE_VECTORT_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,13 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_VECTORT_H_ +#define GEODE_VECTORT_H_ + +// TODO shared_ptr - replace with std::vector + #include "geode_globals.hpp" #include "VectorOfSharedBase.hpp" #include "Cacheable.hpp" @@ -51,7 +53,7 @@ class VectorT { public: inline const PTR_TYPE operator*() const { - return staticCast<PTR_TYPE>(*m_iter); + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(*m_iter); } inline Iterator& operator++() { @@ -95,20 +97,22 @@ class VectorT { /** Return the n'th element */ inline PTR_TYPE operator[](int32_t n) { - return staticCast<PTR_TYPE>(m_vector[n]); + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector[n]); } /** Return the n'th element */ inline const PTR_TYPE operator[](int32_t n) const { - return staticCast<PTR_TYPE>(m_vector[n]); + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector[n]); } /** Return the n'th element with bounds checking. */ - inline PTR_TYPE at(int32_t n) { return staticCast<PTR_TYPE>(m_vector.at(n)); } + inline PTR_TYPE at(int32_t n) { + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.at(n)); + } /** Return the n'th element with bounds checking. */ inline const PTR_TYPE at(int32_t n) const { - return staticCast<PTR_TYPE>(m_vector.at(n)); + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.at(n)); } /** Get an iterator pointing to the start of vector. */ @@ -129,7 +133,7 @@ class VectorT { /** copy constructor */ inline VectorT(const VectorT& other) : m_vector(other.m_vector) {} - /** destructor, sets all SharedPtr elements to NULLPTR */ + /** destructor, sets all SharedPtr elements to nullptr */ inline ~VectorT() { // destructor of m_vector field does all the work. } @@ -144,19 +148,23 @@ class VectorT { inline void reserve(int32_t n) { m_vector.reserve(n); } /** returns the first element. */ - inline PTR_TYPE front() { return staticCast<PTR_TYPE>(m_vector.front()); } + inline PTR_TYPE front() { + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.front()); + } /** returns the first element. */ inline const PTR_TYPE front() const { - return staticCast<PTR_TYPE>(m_vector.front()); + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.front()); } /** returns the last element. */ - inline PTR_TYPE back() { return staticCast<PTR_TYPE>(m_vector.back()); } + inline PTR_TYPE back() { + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.back()); + } /** returns the last element. */ inline const PTR_TYPE back() const { - return staticCast<PTR_TYPE>(m_vector.back()); + return std::static_pointer_cast<GF_UNWRAP_SP(PTR_TYPE)>(m_vector.back()); } /** insert a new element at the end. */ @@ -174,7 +182,7 @@ class VectorT { /** inserts or erases elements at the end such that size becomes n. * Not to be confused with reserve which simply allocates the space, * resize fills the space with active elements. */ - inline void resize(int32_t n, const PTR_TYPE& t = NULLPTR) { + inline void resize(int32_t n, const PTR_TYPE& t = nullptr) { m_vector.resize(n, t); } @@ -192,8 +200,6 @@ typedef VectorT<CacheableKeyPtr> _VectorOfCacheableKey; typedef VectorT<RegionEntryPtr> VectorOfRegionEntry; typedef VectorT<RegionPtr> VectorOfRegion; typedef VectorT<CacheableStringPtr> VectorOfCacheableString; -typedef VectorT<CqListenerPtr> VectorOfCqListener; -typedef VectorT<CqQueryPtr> VectorOfCqQuery; /** * A vector of <code>Cacheable</code> objects that also extends http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/include/geode/geode_base.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/include/geode/geode_base.hpp b/src/cppcache/include/geode/geode_base.hpp index eeeca7c..369f830 100644 --- a/src/cppcache/include/geode/geode_base.hpp +++ b/src/cppcache/include/geode/geode_base.hpp @@ -1,8 +1,3 @@ -#pragma once - -#ifndef GEODE_BASE_H_ -#define GEODE_BASE_H_ - /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,6 +15,11 @@ * limitations under the License. */ +#pragma once + +#ifndef GEODE_BASE_H_ +#define GEODE_BASE_H_ + #if defined(_WIN32) /** Library Export */ #define LIBEXP __declspec(dllexport) @@ -314,4 +314,22 @@ void operator delete[](void *p); x = NULL; \ } +// TODO shared_ptre - make C+11 library dependent or make constructor destructor +// public +#if defined(__clang__) +#define FRIEND_STD_SHARED_PTR(_T) \ + friend std::__libcpp_compressed_pair_imp<std::allocator<_T>, _T, 1>; \ + friend std::__shared_ptr_emplace<_T, std::allocator<_T> >; \ + friend std::default_delete<_T>; +#elif defined(__GNUC__) || defined(__SUNPRO_CC) +#define FRIEND_STD_SHARED_PTR(_T) \ + friend __gnu_cxx::new_allocator<_T>; +#elif defined(_MSC_VER) +#define FRIEND_STD_SHARED_PTR(_T) \ + friend std::_Ref_count_obj<_T>; \ + friend std::default_delete<_T>; +#else +#define FRIEND_STD_SHARED_PTR(_T) +#endif + #endif // GEODE_BASE_H_ http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp b/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp index 6140394..be32e3f 100644 --- a/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp +++ b/src/cppcache/integration-test/BuiltinCacheableWrappers.hpp @@ -182,7 +182,7 @@ class CacheableBooleanWrapper : public CacheableWrapper { public: // Constructor and factory function - inline CacheableBooleanWrapper() : CacheableWrapper(NULLPTR) {} + inline CacheableBooleanWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableBooleanWrapper(); } @@ -201,7 +201,7 @@ class CacheableBooleanWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableBoolean* obj = - dynamic_cast<const CacheableBoolean*>(object.ptr()); + dynamic_cast<const CacheableBoolean*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<uint8_t>(obj->value() ? 1 : 0); } @@ -211,7 +211,7 @@ class CacheableByteWrapper : public CacheableWrapper { public: // Constructor and factory function - inline CacheableByteWrapper() : CacheableWrapper(NULLPTR) {} + inline CacheableByteWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableByteWrapper(); } @@ -229,7 +229,7 @@ class CacheableByteWrapper : public CacheableWrapper { } virtual uint32_t getCheckSum(const CacheablePtr object) const { - const CacheableByte* obj = dynamic_cast<const CacheableByte*>(object.ptr()); + const CacheableByte* obj = dynamic_cast<const CacheableByte*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<uint8_t>(obj->value()); } @@ -239,7 +239,7 @@ class CacheableDoubleWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableDoubleWrapper() : CacheableWrapper(NULLPTR) {} + CacheableDoubleWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableDoubleWrapper(); } @@ -258,7 +258,7 @@ class CacheableDoubleWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableDouble* obj = - dynamic_cast<const CacheableDouble*>(object.ptr()); + dynamic_cast<const CacheableDouble*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<double>(obj->value()); } @@ -268,7 +268,7 @@ class CacheableDateWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableDateWrapper() : CacheableWrapper(NULLPTR) {} + CacheableDateWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableDateWrapper(); } @@ -294,7 +294,7 @@ class CacheableDateWrapper : public CacheableWrapper { } virtual uint32_t getCheckSum(const CacheablePtr object) const { - const CacheableDate* obj = dynamic_cast<const CacheableDate*>(object.ptr()); + const CacheableDate* obj = dynamic_cast<const CacheableDate*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<int64_t>(obj->milliseconds()); } @@ -304,7 +304,7 @@ class CacheableFileNameWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableFileNameWrapper() : CacheableWrapper(NULLPTR) {} + CacheableFileNameWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableFileNameWrapper(); } @@ -347,7 +347,7 @@ class CacheableFileNameWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableFileName* obj = - dynamic_cast<const CacheableFileName*>(object.ptr()); + dynamic_cast<const CacheableFileName*>(object.get()); return (obj != NULL ? CacheableHelper::crc32((uint8_t*)obj->asChar(), obj->length()) : 0); @@ -358,7 +358,7 @@ class CacheableFloatWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableFloatWrapper() : CacheableWrapper(NULLPTR) {} + CacheableFloatWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableFloatWrapper(); } @@ -377,7 +377,7 @@ class CacheableFloatWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableFloat* obj = - dynamic_cast<const CacheableFloat*>(object.ptr()); + dynamic_cast<const CacheableFloat*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<float>(obj->value()); } @@ -387,7 +387,7 @@ class CacheableInt16Wrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableInt16Wrapper() : CacheableWrapper(NULLPTR) {} + CacheableInt16Wrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt16Wrapper(); } @@ -406,7 +406,7 @@ class CacheableInt16Wrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableInt16* obj = - dynamic_cast<const CacheableInt16*>(object.ptr()); + dynamic_cast<const CacheableInt16*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<int16_t>(obj->value()); } @@ -416,7 +416,7 @@ class CacheableInt32Wrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableInt32Wrapper() : CacheableWrapper(NULLPTR) {} + CacheableInt32Wrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt32Wrapper(); } @@ -435,7 +435,7 @@ class CacheableInt32Wrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableInt32* obj = - dynamic_cast<const CacheableInt32*>(object.ptr()); + dynamic_cast<const CacheableInt32*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<int32_t>(obj->value()); } @@ -445,7 +445,7 @@ class CacheableInt64Wrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableInt64Wrapper() : CacheableWrapper(NULLPTR) {} + CacheableInt64Wrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt64Wrapper(); } @@ -465,7 +465,7 @@ class CacheableInt64Wrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableInt64* obj = - dynamic_cast<const CacheableInt64*>(object.ptr()); + dynamic_cast<const CacheableInt64*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<int64_t>(obj->value()); } @@ -475,7 +475,7 @@ class CacheableStringWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableStringWrapper() : CacheableWrapper(NULLPTR) {} + CacheableStringWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableStringWrapper(); } @@ -506,7 +506,7 @@ class CacheableStringWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableString* obj = - dynamic_cast<const CacheableString*>(object.ptr()); + dynamic_cast<const CacheableString*>(object.get()); return (obj != NULL ? CacheableHelper::crc32((uint8_t*)obj->asChar(), obj->length()) : 0); @@ -517,7 +517,7 @@ class CacheableHugeStringWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableHugeStringWrapper() : CacheableWrapper(NULLPTR) {} + CacheableHugeStringWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableHugeStringWrapper(); } @@ -551,7 +551,7 @@ class CacheableHugeStringWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableString* obj = - dynamic_cast<const CacheableString*>(object.ptr()); + dynamic_cast<const CacheableString*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32((uint8_t*)obj->asChar(), obj->length()); } @@ -561,7 +561,7 @@ class CacheableHugeUnicodeStringWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableHugeUnicodeStringWrapper() : CacheableWrapper(NULLPTR) {} + CacheableHugeUnicodeStringWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableHugeUnicodeStringWrapper(); @@ -597,7 +597,7 @@ class CacheableHugeUnicodeStringWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableString* obj = - dynamic_cast<const CacheableString*>(object.ptr()); + dynamic_cast<const CacheableString*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32((uint8_t*)obj->asWChar(), obj->length() * sizeof(wchar_t)); @@ -608,7 +608,7 @@ class CacheableUnicodeStringWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableUnicodeStringWrapper() : CacheableWrapper(NULLPTR) {} + CacheableUnicodeStringWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableUnicodeStringWrapper(); @@ -641,7 +641,7 @@ class CacheableUnicodeStringWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableString* obj = - dynamic_cast<const CacheableString*>(object.ptr()); + dynamic_cast<const CacheableString*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32((uint8_t*)obj->asWChar(), obj->length() * sizeof(wchar_t)); @@ -652,7 +652,7 @@ class CacheableWideCharWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableWideCharWrapper() : CacheableWrapper(NULLPTR) {} + CacheableWideCharWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableWideCharWrapper(); } @@ -672,7 +672,7 @@ class CacheableWideCharWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableWideChar* obj = - dynamic_cast<const CacheableWideChar*>(object.ptr()); + dynamic_cast<const CacheableWideChar*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32<wchar_t>(obj->value()); } @@ -685,7 +685,7 @@ class CacheableHashMapTypeWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableHashMapTypeWrapper<HMAPTYPE>() : CacheableWrapper(NULLPTR) {} + CacheableHashMapTypeWrapper<HMAPTYPE>() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableHashMapTypeWrapper<HMAPTYPE>(); @@ -695,7 +695,7 @@ class CacheableHashMapTypeWrapper : public CacheableWrapper { virtual void initRandomValue(int32_t maxSize) { m_cacheableObject = HMAPTYPE::create(maxSize); - HMAPTYPE* chmp = dynamic_cast<HMAPTYPE*>(m_cacheableObject.ptr()); + HMAPTYPE* chmp = dynamic_cast<HMAPTYPE*>(m_cacheableObject.get()); ASSERT(chmp != NULL, "initRandomValue: null object."); std::vector<int8_t> keyTypeIds = CacheableWrapperFactory::getRegisteredKeyTypes(); @@ -738,8 +738,9 @@ class CacheableHashMapTypeWrapper : public CacheableWrapper { ASSERT(valWrapper != NULL, "initRandomValue: valWrapper null object."); keyWrapper->initKey(((*keyIter) << 8) + item, maxSize); valWrapper->initRandomValue(maxSize); - chmp->insert(dynCast<CacheableKeyPtr>(keyWrapper->getCacheable()), - valWrapper->getCacheable()); + chmp->insert( + std::dynamic_pointer_cast<CacheableKey>(keyWrapper->getCacheable()), + valWrapper->getCacheable()); delete keyWrapper; delete valWrapper; item++; @@ -748,7 +749,7 @@ class CacheableHashMapTypeWrapper : public CacheableWrapper { } virtual uint32_t getCheckSum(const CacheablePtr object) const { - const HMAPTYPE* obj = dynamic_cast<const HMAPTYPE*>(object.ptr()); + const HMAPTYPE* obj = dynamic_cast<const HMAPTYPE*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); uint32_t chksum = 0; @@ -758,7 +759,7 @@ class CacheableHashMapTypeWrapper : public CacheableWrapper { CacheableWrapperFactory::createInstance(iter.first()->typeId()); CacheablePtr cwpObj = iter.second(); uint32_t cwpObjCkSum = 0; - if (cwpObj != NULLPTR) { + if (cwpObj != nullptr) { CacheableWrapper* cwpVal = CacheableWrapperFactory::createInstance(cwpObj->typeId()); cwpObjCkSum = cwpVal->getCheckSum(cwpObj); @@ -785,7 +786,7 @@ class CacheableHashSetTypeWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableHashSetTypeWrapper<HSETTYPE>() : CacheableWrapper(NULLPTR) {} + CacheableHashSetTypeWrapper<HSETTYPE>() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableHashSetTypeWrapper<HSETTYPE>(); @@ -806,14 +807,15 @@ class CacheableHashSetTypeWrapper : public CacheableWrapper { CacheableWrapperFactory::createInstance(keyTypeId); wrapper->initRandomValue(maxSize); CacheablePtr cptr = wrapper->getCacheable(); - set->insert(dynCast<CacheableKeyPtr>(wrapper->getCacheable())); + set->insert( + std::dynamic_pointer_cast<CacheableKey>(wrapper->getCacheable())); delete wrapper; } - m_cacheableObject = set; + m_cacheableObject = std::shared_ptr<Serializable>(set); } virtual uint32_t getCheckSum(const CacheablePtr object) const { - const HSETTYPE* obj = dynamic_cast<const HSETTYPE*>(object.ptr()); + const HSETTYPE* obj = dynamic_cast<const HSETTYPE*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); uint32_t checkSum = 0; @@ -838,7 +840,7 @@ class CacheableBytesWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableBytesWrapper() : CacheableWrapper(NULLPTR) {} + CacheableBytesWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableBytesWrapper(); } @@ -853,7 +855,7 @@ class CacheableBytesWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableBytes* obj = - dynamic_cast<const CacheableBytes*>(object.ptr()); + dynamic_cast<const CacheableBytes*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32(obj->value(), obj->length()); } @@ -863,7 +865,7 @@ class CacheableDoubleArrayWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableDoubleArrayWrapper() : CacheableWrapper(NULLPTR) {} + CacheableDoubleArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableDoubleArrayWrapper(); @@ -881,7 +883,7 @@ class CacheableDoubleArrayWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableDoubleArray* obj = - dynamic_cast<const CacheableDoubleArray*>(object.ptr()); + dynamic_cast<const CacheableDoubleArray*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32Array(obj->value(), obj->length()); } @@ -891,7 +893,7 @@ class CacheableFloatArrayWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableFloatArrayWrapper() : CacheableWrapper(NULLPTR) {} + CacheableFloatArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableFloatArrayWrapper(); } @@ -907,7 +909,7 @@ class CacheableFloatArrayWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableFloatArray* obj = - dynamic_cast<const CacheableFloatArray*>(object.ptr()); + dynamic_cast<const CacheableFloatArray*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32Array(obj->value(), obj->length()); } @@ -917,7 +919,7 @@ class CacheableInt16ArrayWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableInt16ArrayWrapper() : CacheableWrapper(NULLPTR) {} + CacheableInt16ArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt16ArrayWrapper(); } @@ -932,7 +934,7 @@ class CacheableInt16ArrayWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableInt16Array* obj = - dynamic_cast<const CacheableInt16Array*>(object.ptr()); + dynamic_cast<const CacheableInt16Array*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32Array(obj->value(), obj->length()); } @@ -942,7 +944,7 @@ class CacheableInt32ArrayWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableInt32ArrayWrapper() : CacheableWrapper(NULLPTR) {} + CacheableInt32ArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt32ArrayWrapper(); } @@ -957,7 +959,7 @@ class CacheableInt32ArrayWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableInt32Array* obj = - dynamic_cast<const CacheableInt32Array*>(object.ptr()); + dynamic_cast<const CacheableInt32Array*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32Array(obj->value(), obj->length()); } @@ -967,7 +969,7 @@ class CacheableInt64ArrayWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableInt64ArrayWrapper() : CacheableWrapper(NULLPTR) {} + CacheableInt64ArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableInt64ArrayWrapper(); } @@ -982,7 +984,7 @@ class CacheableInt64ArrayWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableInt64Array* obj = - dynamic_cast<const CacheableInt64Array*>(object.ptr()); + dynamic_cast<const CacheableInt64Array*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); return CacheableHelper::crc32Array(obj->value(), obj->length()); } @@ -992,7 +994,7 @@ class CacheableNullStringWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableNullStringWrapper() : CacheableWrapper(NULLPTR) {} + CacheableNullStringWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableNullStringWrapper(); } @@ -1003,7 +1005,7 @@ class CacheableNullStringWrapper : public CacheableWrapper { } virtual uint32_t getCheckSum(const CacheablePtr object) const { - ASSERT(object == NULLPTR, "getCheckSum: expected null object"); + ASSERT(object == nullptr, "getCheckSum: expected null object"); return 0; } }; @@ -1012,7 +1014,7 @@ class CacheableStringArrayWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableStringArrayWrapper() : CacheableWrapper(NULLPTR) {} + CacheableStringArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableStringArrayWrapper(); @@ -1046,7 +1048,7 @@ class CacheableStringArrayWrapper : public CacheableWrapper { virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableStringArray* obj = - dynamic_cast<const CacheableStringArray*>(object.ptr()); + dynamic_cast<const CacheableStringArray*>(object.get()); ASSERT(obj != NULL, "getCheckSum: null object."); uint32_t checkSum = 0; CacheableStringPtr str; @@ -1068,14 +1070,15 @@ class CacheableUndefinedWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableUndefinedWrapper() : CacheableWrapper(NULLPTR) {} + CacheableUndefinedWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableUndefinedWrapper(); } // CacheableWrapper members virtual void initRandomValue(int32_t maxSize) { - m_cacheableObject = CacheableUndefined::createDeserializable(); + m_cacheableObject = std::shared_ptr<Serializable>( + CacheableUndefined::createDeserializable()); } virtual uint32_t getCheckSum(const CacheablePtr object) const { return 0; } @@ -1086,7 +1089,7 @@ class CacheableVectorTypeWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableVectorTypeWrapper<VECTTYPE>() : CacheableWrapper(NULLPTR) {} + CacheableVectorTypeWrapper<VECTTYPE>() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableVectorTypeWrapper<VECTTYPE>(); @@ -1111,16 +1114,16 @@ class CacheableVectorTypeWrapper : public CacheableWrapper { delete wrapper; } } - m_cacheableObject = vec; + m_cacheableObject = std::shared_ptr<Serializable>(vec); } virtual uint32_t getCheckSum(const CacheablePtr object) const { - const VECTTYPE* vec = dynamic_cast<const VECTTYPE*>(object.ptr()); + const VECTTYPE* vec = dynamic_cast<const VECTTYPE*>(object.get()); ASSERT(vec != NULL, "getCheckSum: null object."); uint32_t checkSum = 0; for (uint32_t index = 0; index < (uint32_t)vec->size(); ++index) { CacheablePtr obj = vec->at(index); - if (obj == NULLPTR) { + if (obj == nullptr) { continue; } int8_t typeId = obj->typeId(); @@ -1147,7 +1150,7 @@ class CacheableObjectArrayWrapper : public CacheableWrapper { public: // Constructor and factory function - CacheableObjectArrayWrapper() : CacheableWrapper(NULLPTR) {} + CacheableObjectArrayWrapper() : CacheableWrapper(nullptr) {} static CacheableWrapper* create() { return new CacheableObjectArrayWrapper(); @@ -1172,18 +1175,18 @@ class CacheableObjectArrayWrapper : public CacheableWrapper { delete wrapper; } } - m_cacheableObject = arr; + m_cacheableObject = std::shared_ptr<Serializable>(arr); } virtual uint32_t getCheckSum(const CacheablePtr object) const { const CacheableObjectArray* arr = - dynamic_cast<const CacheableObjectArray*>(object.ptr()); + dynamic_cast<const CacheableObjectArray*>(object.get()); ASSERT(arr != NULL, "getCheckSum: null object."); uint32_t checkSum = 0; for (uint32_t index = 0; index < static_cast<uint32_t>(arr->size()); ++index) { const CacheablePtr obj = arr->at(index); - if (obj == NULLPTR) { + if (obj == nullptr) { continue; } int8_t typeId = obj->typeId(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/CMakeLists.txt b/src/cppcache/integration-test/CMakeLists.txt index 71ee174..ff49485 100644 --- a/src/cppcache/integration-test/CMakeLists.txt +++ b/src/cppcache/integration-test/CMakeLists.txt @@ -127,7 +127,6 @@ set_property(TEST testAttributesFactory PROPERTY LABELS STABLE QUICK) set_property(TEST testXmlCacheCreationWithOverFlow PROPERTY LABELS STABLE QUICK) set_property(TEST testNativeCompareBasic PROPERTY LABELS STABLE QUICK) set_property(TEST testConnect PROPERTY LABELS STABLE QUICK) -set_property(TEST testSharedPtr PROPERTY LABELS STABLE QUICK) set_property(TEST testThinClientRemoveAllLocal PROPERTY LABELS STABLE QUICK) set_property(TEST testDunit PROPERTY LABELS STABLE QUICK) set_property(TEST testAttributesMutator PROPERTY LABELS STABLE QUICK) http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/CacheHelper.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/CacheHelper.cpp b/src/cppcache/integration-test/CacheHelper.cpp index b6dd35d..61bfc23 100644 --- a/src/cppcache/integration-test/CacheHelper.cpp +++ b/src/cppcache/integration-test/CacheHelper.cpp @@ -77,7 +77,7 @@ CacheHelper& CacheHelper::getHelper() { CacheHelper::CacheHelper(const char* member_id, const PropertiesPtr& configPtr, const bool noRootRegion) { PropertiesPtr pp = configPtr; - if (pp == NULLPTR) { + if (pp == nullptr) { pp = Properties::create(); } @@ -102,7 +102,7 @@ CacheHelper::CacheHelper(const char* member_id, const PropertiesPtr& configPtr, CacheHelper::CacheHelper(const char* member_id, const char* cachexml, const PropertiesPtr& configPtr) { PropertiesPtr pp = configPtr; - if (pp == NULLPTR) { + if (pp == nullptr) { pp = Properties::create(); } if (cachexml != NULL) { @@ -119,7 +119,7 @@ CacheHelper::CacheHelper(const char* member_id, const char* cachexml, CacheHelper::CacheHelper(const PropertiesPtr& configPtr, const bool noRootRegion) { PropertiesPtr pp = configPtr; - if (pp == NULLPTR) { + if (pp == nullptr) { pp = Properties::create(); } @@ -144,7 +144,7 @@ CacheHelper::CacheHelper(const bool isThinclient, const PropertiesPtr& configPtr, const bool noRootRegion) { PropertiesPtr pp = configPtr; - if (pp == NULLPTR) { + if (pp == nullptr) { pp = Properties::create(); } try { @@ -163,7 +163,7 @@ CacheHelper::CacheHelper(const bool isThinclient, bool pdxIgnoreUnreadFields, bool pdxReadSerialized, const PropertiesPtr& configPtr, const bool noRootRegion) { PropertiesPtr pp = configPtr; - if (pp == NULLPTR) { + if (pp == nullptr) { pp = Properties::create(); } try { @@ -190,7 +190,7 @@ CacheHelper::CacheHelper(const bool isthinClient, const char* poolName, bool isMultiuserMode, bool prSingleHop, bool threadLocal) { PropertiesPtr pp = configPtr; - if (pp == NULLPTR) { + if (pp == nullptr) { pp = Properties::create(); } @@ -233,7 +233,7 @@ CacheHelper::CacheHelper(const bool isthinClient, const char* poolName, CacheHelper::CacheHelper(const int redundancyLevel, const PropertiesPtr& configPtr) { PropertiesPtr pp = configPtr; - if (pp == NULLPTR) { + if (pp == nullptr) { pp = Properties::create(); } @@ -253,7 +253,7 @@ void CacheHelper::closePool(const char* poolName, bool keepAlive) { } void CacheHelper::disconnect(bool keepalive) { - if (cachePtr == NULLPTR) { + if (cachePtr == nullptr) { return; } @@ -265,11 +265,11 @@ void CacheHelper::disconnect(bool keepalive) { } // rootRegionPtr->localDestroyRegion(); - rootRegionPtr = NULLPTR; + rootRegionPtr = nullptr; LOG("Destroyed root region."); try { LOG("Closing cache."); - if (cachePtr != NULLPTR) { + if (cachePtr != nullptr) { cachePtr->close(keepalive); } LOG("Closing cache complete."); @@ -280,7 +280,7 @@ void CacheHelper::disconnect(bool keepalive) { LOG("exception throw while closing cache"); } - cachePtr = NULLPTR; + cachePtr = nullptr; LOG("Closed cache."); try { if (m_doDisconnect) { @@ -312,7 +312,7 @@ void CacheHelper::createPlainRegion(const char* regionName, showRegionAttributes(*regAttrs); // This is using subregions (deprecated) so not placing the new cache API here regionPtr = rootRegionPtr->createSubregion(regionName, regAttrs); - ASSERT(regionPtr != NULLPTR, "failed to create region."); + ASSERT(regionPtr != nullptr, "failed to create region."); } void CacheHelper::createLRURegion(const char* regionName, @@ -331,7 +331,7 @@ void CacheHelper::createLRURegion(const char* regionName, RegionPtr& regionPtr, showRegionAttributes(*regAttrs); // This is using subregions (deprecated) so not placing the new cache API here regionPtr = rootRegionPtr->createSubregion(regionName, regAttrs); - ASSERT(regionPtr != NULLPTR, "failed to create region."); + ASSERT(regionPtr != nullptr, "failed to create region."); } void CacheHelper::createDistRegion(const char* regionName, @@ -351,7 +351,7 @@ void CacheHelper::createDistRegion(const char* regionName, RegionPtr& regionPtr, showRegionAttributes(*regAttrs); // This is using subregions (deprecated) so not placing the new cache API here regionPtr = rootRegionPtr->createSubregion(regionName, regAttrs); - ASSERT(regionPtr != NULLPTR, "failed to create region."); + ASSERT(regionPtr != nullptr, "failed to create region."); } RegionPtr CacheHelper::getRegion(const char* name) { @@ -366,7 +366,7 @@ RegionPtr CacheHelper::createRegion(const char* name, bool ack, bool caching, int32_t tombstonetimeout) { AttributesFactory af; af.setCachingEnabled(caching); - if (listener != NULLPTR) { + if (listener != nullptr) { af.setCacheListener(listener); } if (concurrencyCheckEnabled) { @@ -375,7 +375,7 @@ RegionPtr CacheHelper::createRegion(const char* name, bool ack, bool caching, RegionAttributesPtr rattrsPtr = af.createRegionAttributes(); - CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cachePtr.ptr()); + CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cachePtr.get()); RegionPtr regionPtr; cacheImpl->createRegion(name, rattrsPtr, regionPtr); return regionPtr; @@ -396,7 +396,7 @@ RegionPtr CacheHelper::createRegion(const char* name, bool ack, bool caching, RegionAttributesPtr rattrsPtr = af.createRegionAttributes(); - CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cachePtr.ptr()); + CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cachePtr.get()); RegionPtr regionPtr; cacheImpl->createRegion(name, rattrsPtr, regionPtr); return regionPtr; @@ -507,7 +507,7 @@ void CacheHelper::createPoolWithLocators(const char* name, const char* locators, createPool(name, locators, serverGroup, subscriptionRedundancy, clientNotificationEnabled, subscriptionAckInterval, connections, -1, isMultiuserMode); - ASSERT(poolPtr != NULLPTR, "Failed to create pool."); + ASSERT(poolPtr != nullptr, "Failed to create pool."); logPoolAttributes(poolPtr); LOG("Pool created."); } @@ -612,7 +612,7 @@ RegionPtr CacheHelper::createPooledRegion( } if ((PoolManager::find(poolName)) == - NULLPTR) { // Pool does not exist with the same name. + nullptr) { // Pool does not exist with the same name. PoolPtr pptr = poolFacPtr->create(poolName); } @@ -630,7 +630,7 @@ RegionPtr CacheHelper::createPooledRegion( regionFactoryPtr->setRegionIdleTimeout(action, rit); regionFactoryPtr->setRegionTimeToLive(action, rttl); regionFactoryPtr->setPoolName(poolName); - if (cacheListener != NULLPTR) { + if (cacheListener != nullptr) { regionFactoryPtr->setCacheListener(cacheListener); } return regionFactoryPtr->create(name); @@ -648,7 +648,7 @@ RegionPtr CacheHelper::createPooledRegionConcurrencyCheckDisabled( addServerLocatorEPs(locators, poolFacPtr); if ((PoolManager::find(poolName)) == - NULLPTR) { // Pool does not exist with the same name. + nullptr) { // Pool does not exist with the same name. PoolPtr pptr = poolFacPtr->create(poolName); } @@ -667,7 +667,7 @@ RegionPtr CacheHelper::createPooledRegionConcurrencyCheckDisabled( regionFactoryPtr->setRegionTimeToLive(action, rttl); regionFactoryPtr->setConcurrencyChecksEnabled(concurrencyCheckEnabled); regionFactoryPtr->setPoolName(poolName); - if (cacheListener != NULLPTR) { + if (cacheListener != nullptr) { regionFactoryPtr->setCacheListener(cacheListener); } return regionFactoryPtr->create(name); @@ -697,7 +697,7 @@ RegionPtr CacheHelper::createRegionDiscOverFlow( } RegionAttributesPtr rattrsPtr = af.createRegionAttributes(); - CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cachePtr.ptr()); + CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cachePtr.get()); RegionPtr regionPtr; cacheImpl->createRegion(name, rattrsPtr, regionPtr); return regionPtr; @@ -717,7 +717,7 @@ RegionPtr CacheHelper::createPooledRegionDiscOverFlow( addServerLocatorEPs(locators, poolFacPtr); } if ((PoolManager::find(poolName)) == - NULLPTR) { // Pool does not exist with the same name. + nullptr) { // Pool does not exist with the same name. PoolPtr pptr = poolFacPtr->create(poolName); } @@ -752,7 +752,7 @@ RegionPtr CacheHelper::createPooledRegionDiscOverFlow( regionFactoryPtr->setPersistenceManager( "SqLiteImpl", "createSqLiteInstance", sqLiteProps); } - if (cacheListener != NULLPTR) { + if (cacheListener != nullptr) { regionFactoryPtr->setCacheListener(cacheListener); } return regionFactoryPtr->create(name); @@ -772,7 +772,7 @@ RegionPtr CacheHelper::createPooledRegionSticky( addServerLocatorEPs(locators, poolFacPtr); if ((PoolManager::find(poolName)) == - NULLPTR) { // Pool does not exist with the same name. + nullptr) { // Pool does not exist with the same name. PoolPtr pptr = poolFacPtr->create(poolName); LOG("createPooledRegionSticky logPoolAttributes"); logPoolAttributes(pptr); @@ -792,7 +792,7 @@ RegionPtr CacheHelper::createPooledRegionSticky( regionFactoryPtr->setRegionIdleTimeout(action, rit); regionFactoryPtr->setRegionTimeToLive(action, rttl); regionFactoryPtr->setPoolName(poolName); - if (cacheListener != NULLPTR) { + if (cacheListener != nullptr) { regionFactoryPtr->setCacheListener(cacheListener); } return regionFactoryPtr->create(name); @@ -812,7 +812,7 @@ RegionPtr CacheHelper::createPooledRegionStickySingleHop( addServerLocatorEPs(locators, poolFacPtr); if ((PoolManager::find(poolName)) == - NULLPTR) { // Pool does not exist with the same name. + nullptr) { // Pool does not exist with the same name. PoolPtr pptr = poolFacPtr->create(poolName); LOG("createPooledRegionStickySingleHop logPoolAttributes"); logPoolAttributes(pptr); @@ -832,7 +832,7 @@ RegionPtr CacheHelper::createPooledRegionStickySingleHop( regionFactoryPtr->setRegionIdleTimeout(action, rit); regionFactoryPtr->setRegionTimeToLive(action, rttl); regionFactoryPtr->setPoolName(poolName); - if (cacheListener != NULLPTR) { + if (cacheListener != nullptr) { regionFactoryPtr->setCacheListener(cacheListener); } return regionFactoryPtr->create(name); @@ -843,7 +843,7 @@ RegionPtr CacheHelper::createSubregion(RegionPtr& parent, const char* name, const CacheListenerPtr& listener) { AttributesFactory af; af.setCachingEnabled(caching); - if (listener != NULLPTR) { + if (listener != nullptr) { af.setCacheListener(listener); } RegionAttributesPtr rattrsPtr = af.createRegionAttributes(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/CacheHelper.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/CacheHelper.hpp b/src/cppcache/integration-test/CacheHelper.hpp index 4e85e7c..52de9fe 100644 --- a/src/cppcache/integration-test/CacheHelper.hpp +++ b/src/cppcache/integration-test/CacheHelper.hpp @@ -59,33 +59,33 @@ class CacheHelper { static std::string unitTestOutputFile(); static int getNumLocatorListUpdates(const char* s); - CacheHelper(const char* member_id, const PropertiesPtr& configPtr = NULLPTR, + CacheHelper(const char* member_id, const PropertiesPtr& configPtr = nullptr, const bool noRootRegion = false); /** rootRegionPtr will still be null... */ CacheHelper(const char* member_id, const char* cachexml, - const PropertiesPtr& configPtr = NULLPTR); + const PropertiesPtr& configPtr = nullptr); - CacheHelper(const PropertiesPtr& configPtr = NULLPTR, + CacheHelper(const PropertiesPtr& configPtr = nullptr, const bool noRootRegion = false); - CacheHelper(const bool isThinclient, const PropertiesPtr& configPtr = NULLPTR, + CacheHelper(const bool isThinclient, const PropertiesPtr& configPtr = nullptr, const bool noRootRegion = false); CacheHelper(const bool isThinclient, bool pdxIgnoreUnreadFields, - bool pdxReadSerialized, const PropertiesPtr& configPtr = NULLPTR, + bool pdxReadSerialized, const PropertiesPtr& configPtr = nullptr, const bool noRootRegion = false); CacheHelper(const bool isthinClient, const char* poolName, const char* locators, const char* serverGroup, - const PropertiesPtr& configPtr = NULLPTR, int redundancy = 0, + const PropertiesPtr& configPtr = nullptr, int redundancy = 0, bool clientNotification = false, int subscriptionAckInterval = -1, int connections = -1, int loadConditioningInterval = -1, bool isMultiuserMode = false, bool prSingleHop = false, bool threadLocal = false); CacheHelper(const int redundancyLevel, - const PropertiesPtr& configPtr = NULLPTR); + const PropertiesPtr& configPtr = nullptr); virtual ~CacheHelper(); @@ -153,7 +153,7 @@ class CacheHelper { RegionPtr createRegionAndAttachPool2( const char* name, bool ack, const char* poolName, - const PartitionResolverPtr& aResolver = NULLPTR, bool caching = true, + const PartitionResolverPtr& aResolver = nullptr, bool caching = true, int ettl = 0, int eit = 0, int rttl = 0, int rit = 0, int lel = 0, ExpirationAction::Action action = ExpirationAction::DESTROY); @@ -168,7 +168,7 @@ class CacheHelper { const char* poolName = "__TEST_POOL1__", bool caching = true, bool clientNotificationEnabled = false, int ettl = 0, int eit = 0, int rttl = 0, int rit = 0, int lel = 0, - const CacheListenerPtr& cacheListener = NULLPTR, + const CacheListenerPtr& cacheListener = nullptr, ExpirationAction::Action action = ExpirationAction::DESTROY); RegionPtr createPooledRegionConcurrencyCheckDisabled( @@ -177,7 +177,7 @@ class CacheHelper { bool clientNotificationEnabled = false, bool concurrencyCheckEnabled = true, int ettl = 0, int eit = 0, int rttl = 0, int rit = 0, int lel = 0, - const CacheListenerPtr& cacheListener = NULLPTR, + const CacheListenerPtr& cacheListener = nullptr, ExpirationAction::Action action = ExpirationAction::DESTROY); RegionPtr createRegionDiscOverFlow( @@ -191,7 +191,7 @@ class CacheHelper { const char* poolName = "__TEST_POOL1__", bool caching = true, bool clientNotificationEnabled = false, int ettl = 0, int eit = 0, int rttl = 0, int rit = 0, int lel = 0, - const CacheListenerPtr& cacheListener = NULLPTR, + const CacheListenerPtr& cacheListener = nullptr, ExpirationAction::Action action = ExpirationAction::DESTROY); RegionPtr createPooledRegionSticky( @@ -199,7 +199,7 @@ class CacheHelper { const char* poolName = "__TEST_POOL1__", bool caching = true, bool clientNotificationEnabled = false, int ettl = 0, int eit = 0, int rttl = 0, int rit = 0, int lel = 0, - const CacheListenerPtr& cacheListener = NULLPTR, + const CacheListenerPtr& cacheListener = nullptr, ExpirationAction::Action action = ExpirationAction::DESTROY); RegionPtr createPooledRegionStickySingleHop( @@ -207,7 +207,7 @@ class CacheHelper { const char* poolName = "__TEST_POOL1__", bool caching = true, bool clientNotificationEnabled = false, int ettl = 0, int eit = 0, int rttl = 0, int rit = 0, int lel = 0, - const CacheListenerPtr& cacheListener = NULLPTR, + const CacheListenerPtr& cacheListener = nullptr, ExpirationAction::Action action = ExpirationAction::DESTROY); RegionPtr createSubregion(RegionPtr& parent, const char* name, bool ack, http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/CacheImplHelper.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/CacheImplHelper.hpp b/src/cppcache/integration-test/CacheImplHelper.hpp index 4af1400..68603be 100644 --- a/src/cppcache/integration-test/CacheImplHelper.hpp +++ b/src/cppcache/integration-test/CacheImplHelper.hpp @@ -41,10 +41,10 @@ using namespace unitTests; class CacheImplHelper : public CacheHelper { public: CacheImplHelper(const char* member_id, - const PropertiesPtr& configPtr = NULLPTR) + const PropertiesPtr& configPtr = nullptr) : CacheHelper(member_id, configPtr) {} - CacheImplHelper(const PropertiesPtr& configPtr = NULLPTR) + CacheImplHelper(const PropertiesPtr& configPtr = nullptr) : CacheHelper(configPtr) {} virtual void createRegion(const char* regionName, RegionPtr& regionPtr, @@ -63,7 +63,7 @@ class CacheImplHelper : public CacheHelper { CacheImpl* cimpl = TestUtils::getCacheImpl(cachePtr); ASSERT(cimpl != NULL, "failed to get cacheImpl *."); cimpl->createRegion(regionName, regAttrs, regionPtr); - ASSERT(regionPtr != NULLPTR, "failed to create region."); + ASSERT(regionPtr != nullptr, "failed to create region."); } }; http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/DeltaEx.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/DeltaEx.hpp b/src/cppcache/integration-test/DeltaEx.hpp index e35217f..3937cc2 100644 --- a/src/cppcache/integration-test/DeltaEx.hpp +++ b/src/cppcache/integration-test/DeltaEx.hpp @@ -25,6 +25,11 @@ #include <ace/OS.h> #include "CacheHelper.hpp" class DeltaEx : public Cacheable, public Delta { + private: + std::shared_ptr<DeltaEx> shared_from_this() { + return std::static_pointer_cast<DeltaEx>(Serializable::shared_from_this()); + } + public: int counter; bool isDelta; @@ -74,7 +79,7 @@ class DeltaEx : public Cacheable, public Delta { virtual uint32_t objectSize() const { return 0; } DeltaPtr clone() { cloneCount++; - return DeltaPtr(this); + return shared_from_this(); } virtual ~DeltaEx() {} void setDelta(bool delta) { this->isDelta = delta; } @@ -82,6 +87,12 @@ class DeltaEx : public Cacheable, public Delta { }; class PdxDeltaEx : public PdxSerializable, public Delta { + private: + std::shared_ptr<PdxDeltaEx> shared_from_this() { + return std::static_pointer_cast<PdxDeltaEx>( + Serializable::shared_from_this()); + } + public: int m_counter; bool m_isDelta; @@ -135,7 +146,7 @@ class PdxDeltaEx : public PdxSerializable, public Delta { DeltaPtr clone() { m_cloneCount++; - return DeltaPtr(this); + return shared_from_this(); } virtual ~PdxDeltaEx() {} http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/QueryHelper.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/QueryHelper.hpp b/src/cppcache/integration-test/QueryHelper.hpp index d122f86..0a280b3 100644 --- a/src/cppcache/integration-test/QueryHelper.hpp +++ b/src/cppcache/integration-test/QueryHelper.hpp @@ -70,7 +70,7 @@ class QueryHelper { virtual void populatePortfolioData(RegionPtr& pregion, int setSize, int numSets, int32_t objSize = 1, - CacheableStringArrayPtr nm = NULLPTR); + CacheableStringArrayPtr nm = nullptr); virtual void populatePositionData(RegionPtr& pregion, int setSize, int numSets); virtual void populatePortfolioPdxData(RegionPtr& pregion, int setSize, @@ -161,7 +161,7 @@ void QueryHelper::populatePortfolioData(RegionPtr& rptr, int setSize, for (int set = 1; set <= numSets; set++) { for (int current = 1; current <= setSize; current++) { - CacheablePtr port(new Portfolio(current, objSize, nm)); + auto port = std::make_shared<Portfolio>(current, objSize, nm); char portname[100] = {0}; ACE_OS::sprintf(portname, "port%d-%d", set, current); @@ -187,8 +187,8 @@ void QueryHelper::populatePositionData(RegionPtr& rptr, int setSize, for (int set = 1; set <= numSets; set++) { for (int current = 1; current <= setSize; current++) { - CacheablePtr pos( - new Position(secIds[current % numSecIds], current * 100)); + auto pos = std::make_shared<Position>(secIds[current % numSecIds], + current * 100); char posname[100] = {0}; ACE_OS::sprintf(posname, "pos%d-%d", set, current); @@ -208,7 +208,7 @@ void QueryHelper::populatePortfolioPdxData(RegionPtr& rptr, int setSize, for (int set = 1; set <= numSets; set++) { for (int current = 1; current <= setSize; current++) { - CacheablePtr port(new PortfolioPdx(current, objSize)); + auto port = std::make_shared<PortfolioPdx>(current, objSize); char portname[100] = {0}; ACE_OS::sprintf(portname, "port%d-%d", set, current); @@ -232,8 +232,7 @@ void QueryHelper::populatePositionPdxData(RegionPtr& rptr, int setSize, for (int set = 1; set <= numSets; set++) { for (int current = 1; current <= setSize; current++) { - CacheablePtr pos( - new PositionPdx(secIds[current % numSecIds], current * 100)); + auto pos = std::make_shared<PositionPdx>(secIds[current % numSecIds], current * 100); char posname[100] = {0}; ACE_OS::sprintf(posname, "pos%d-%d", set, current); @@ -251,7 +250,7 @@ void QueryHelper::populatePDXObject(RegionPtr& rptr) { LOG("PdxObject Registered Successfully...."); // Creating object of type PdxObject - CacheablePtr pdxobj(new PdxTests::PdxType()); + auto pdxobj = std::make_shared<PdxTests::PdxType>(); CacheableKeyPtr keyport = CacheableKey::create("ABC"); // PUT Operation @@ -262,8 +261,8 @@ void QueryHelper::populatePDXObject(RegionPtr& rptr) { LOG("localDestroy() operation....Done"); // Remote GET for PdxObject - // PdxObject *obj2 = dynamic_cast<PdxObject *> ((rptr->get(keyport)).ptr()); - PdxTests::PdxTypePtr obj2 = dynCast<PdxTests::PdxTypePtr>(rptr->get(keyport)); + // PdxObject *obj2 = dynamic_cast<PdxObject *> ((rptr->get(keyport)).get()); + auto obj2 = std::dynamic_pointer_cast<PdxTests::PdxType>(rptr->get(keyport)); LOGINFO("get... Result-1: Returned float=%f, String val = %s double=%lf", obj2->getFloat(), obj2->getString(), obj2->getDouble()); @@ -282,11 +281,11 @@ void QueryHelper::populatePDXObject(RegionPtr& rptr) { void QueryHelper::getPDXObject(RegionPtr& rptr) { // Remote GET for PdxObject - // PdxObject *obj2 = dynamic_cast<PdxObject *> ((rptr->get(keyport)).ptr()); + // PdxObject *obj2 = dynamic_cast<PdxObject *> ((rptr->get(keyport)).get()); CacheableKeyPtr keyport = CacheableKey::create("ABC"); LOG("Client-2 PdxObject GET OP Start...."); - PdxTests::PdxTypePtr obj2 = dynCast<PdxTests::PdxTypePtr>(rptr->get(keyport)); + auto obj2 = std::dynamic_pointer_cast<PdxTests::PdxType>(rptr->get(keyport)); LOG("Client-2 PdxObject GET OP Done...."); /* @@ -304,11 +303,11 @@ void QueryHelper::getPDXObject(RegionPtr& rptr) { } bool QueryHelper::verifyRS(SelectResultsPtr& resultSet, int expectedRows) { - if (!instanceOf<ResultSetPtr>(resultSet)) { + if (!std::dynamic_pointer_cast<ResultSet>(resultSet)) { return false; } - ResultSetPtr rsptr = staticCast<ResultSetPtr>(resultSet); + ResultSetPtr rsptr = std::static_pointer_cast<GF_UNWRAP_SP(ResultSetPtr)>(resultSet); int foundRows = 0; @@ -327,7 +326,7 @@ bool QueryHelper::verifyRS(SelectResultsPtr& resultSet, int expectedRows) { bool QueryHelper::verifySS(SelectResultsPtr& structSet, int expectedRows, int expectedFields) { - if (!instanceOf<StructSetPtr>(structSet)) { + if (!std::dynamic_pointer_cast<StructSet>(structSet)) { if (expectedRows == 0 && expectedFields == 0) { return true; // quite possible we got a null set back. } @@ -335,7 +334,7 @@ bool QueryHelper::verifySS(SelectResultsPtr& structSet, int expectedRows, return false; } - StructSetPtr ssptr = staticCast<StructSetPtr>(structSet); + StructSetPtr ssptr = std::static_pointer_cast<GF_UNWRAP_SP(StructSetPtr)>(structSet); int foundRows = 0; @@ -344,7 +343,7 @@ bool QueryHelper::verifySS(SelectResultsPtr& structSet, int expectedRows, SerializablePtr ser = (*iter); foundRows++; - Struct* siptr = dynamic_cast<Struct*>(ser.ptr()); + Struct* siptr = dynamic_cast<Struct*>(ser.get()); if (siptr == NULL) { printf("siptr is NULL \n\n"); http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/TallyListener.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/TallyListener.hpp b/src/cppcache/integration-test/TallyListener.hpp index cdc6a72..d9c5386 100644 --- a/src/cppcache/integration-test/TallyListener.hpp +++ b/src/cppcache/integration-test/TallyListener.hpp @@ -55,7 +55,7 @@ class TallyListener : public CacheListener { isCallbackCalled(false), m_lastKey(), m_lastValue(), - m_callbackArg(NULLPTR), + m_callbackArg(nullptr), m_ignoreTimeout(false), m_quiet(false) { LOG("TallyListener contructor called"); @@ -122,9 +122,9 @@ class TallyListener : public CacheListener { bool isCallBackArgCalled() { return isCallbackCalled; } void checkcallbackArg(const EntryEvent& event) { if (!isListnerInvoked) isListnerInvoked = true; - if (m_callbackArg != NULLPTR) { - CacheableKeyPtr callbkArg = - dynCast<CacheableKeyPtr>(event.getCallbackArgument()); + if (m_callbackArg != nullptr) { + auto callbkArg = + std::dynamic_pointer_cast<CacheableKey>(event.getCallbackArgument()); if (strcmp(m_callbackArg->toString()->asChar(), callbkArg->toString()->asChar()) == 0) { isCallbackCalled = true; @@ -170,7 +170,7 @@ void TallyListener::afterCreate(const EntryEvent& event) { m_lastValue = event.getNewValue(); checkcallbackArg(event); - CacheableStringPtr strPtr = dynCast<CacheableStringPtr>(event.getNewValue()); + auto strPtr = std::dynamic_pointer_cast<CacheableString>(event.getNewValue()); char keytext[100]; m_lastKey->logString(keytext, 100); if (!m_quiet) { @@ -192,7 +192,7 @@ void TallyListener::afterUpdate(const EntryEvent& event) { m_lastKey = event.getKey(); m_lastValue = event.getNewValue(); checkcallbackArg(event); - CacheableStringPtr strPtr = dynCast<CacheableStringPtr>(event.getNewValue()); + auto strPtr = std::dynamic_pointer_cast<CacheableString>(event.getNewValue()); char keytext[100]; m_lastKey->logString(keytext, 100); if (!m_quiet) { http://git-wip-us.apache.org/repos/asf/geode-native/blob/c0098121/src/cppcache/integration-test/TallyWriter.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/TallyWriter.hpp b/src/cppcache/integration-test/TallyWriter.hpp index da3bc7b..e1e49c5 100644 --- a/src/cppcache/integration-test/TallyWriter.hpp +++ b/src/cppcache/integration-test/TallyWriter.hpp @@ -54,7 +54,7 @@ class TallyWriter : virtual public CacheWriter { isWriterfailed(false), m_lastKey(), m_lastValue(), - m_callbackArg(NULLPTR) { + m_callbackArg(nullptr) { LOG("TallyWriter Constructor called"); } @@ -142,9 +142,9 @@ class TallyWriter : virtual public CacheWriter { } void checkcallbackArg(const EntryEvent& event) { if (!isWriterInvoke) isWriterInvoke = true; - if (m_callbackArg != NULLPTR) { - CacheableKeyPtr callbkArg = - dynCast<CacheableKeyPtr>(event.getCallbackArgument()); + if (m_callbackArg != nullptr) { + auto callbkArg = + std::dynamic_pointer_cast<CacheableKey>(event.getCallbackArgument()); if (strcmp(m_callbackArg->toString()->asChar(), callbkArg->toString()->asChar()) == 0) { isCallbackCalled = true;