You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/05/17 17:50:22 UTC
[40/46] geode-native git commit: GEODE-2741: Remove custom shared
pointer from clicache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheTransactionManager.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheTransactionManager.cpp b/src/clicache/src/CacheTransactionManager.cpp
index f8139a1..68c1ddb 100644
--- a/src/clicache/src/CacheTransactionManager.cpp
+++ b/src/clicache/src/CacheTransactionManager.cpp
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-//#include "geode_includes.hpp"
#include "impl/SafeConvert.hpp"
#include "impl/ManagedTransactionListener.hpp"
#include "impl/ManagedTransactionWriter.hpp"
@@ -34,7 +33,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- NativePtr->begin( );
+ try
+ {
+ m_nativeptr->get()->begin( );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -43,7 +49,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- NativePtr->prepare( );
+ try
+ {
+ m_nativeptr->get()->prepare( );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -51,14 +64,28 @@ namespace Apache
void CacheTransactionManager::Commit( )
{
_GF_MG_EXCEPTION_TRY2
- NativePtr->commit( );
+ try
+ {
+ m_nativeptr->get()->commit( );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
void CacheTransactionManager::Rollback( )
{
_GF_MG_EXCEPTION_TRY2
- NativePtr->rollback( );
+ try
+ {
+ m_nativeptr->get()->rollback( );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -66,7 +93,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- return NativePtr->exists( );
+ try
+ {
+ return m_nativeptr->get()->exists( );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -75,7 +109,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- return Apache::Geode::Client::TransactionId::Create( NativePtr->suspend().get() );
+ try
+ {
+ return Apache::Geode::Client::TransactionId::Create( m_nativeptr->get()->suspend() );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -83,7 +124,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- return Apache::Geode::Client::TransactionId::Create( NativePtr->getTransactionId().get() );
+ try
+ {
+ return Apache::Geode::Client::TransactionId::Create( m_nativeptr->get()->getTransactionId() );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -91,7 +139,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- return NativePtr->resume( apache::geode::client::TransactionIdPtr(transactionId->NativePtr()));
+ try
+ {
+ return m_nativeptr->get()->resume(transactionId->GetNative());
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -99,7 +154,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- return NativePtr->isSuspended( apache::geode::client::TransactionIdPtr(transactionId->NativePtr()));
+ try
+ {
+ return m_nativeptr->get()->isSuspended(transactionId->GetNative());
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -107,7 +169,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- return NativePtr->tryResume( apache::geode::client::TransactionIdPtr(transactionId->NativePtr()));
+ try
+ {
+ return m_nativeptr->get()->tryResume(transactionId->GetNative());
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -115,7 +184,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- return NativePtr->tryResume( apache::geode::client::TransactionIdPtr(transactionId->NativePtr()), waitTimeInMilliSec);
+ try
+ {
+ return m_nativeptr->get()->tryResume(transactionId->GetNative(), waitTimeInMilliSec);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -123,7 +199,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2
- return NativePtr->exists( apache::geode::client::TransactionIdPtr(transactionId->NativePtr()));
+ try
+ {
+ return m_nativeptr->get()->exists(transactionId->GetNative());
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -135,9 +218,9 @@ namespace Apache
_GF_MG_EXCEPTION_TRY2
// Conver the unmanaged object to managed generic object
- apache::geode::client::TransactionWriterPtr& writerPtr( NativePtr->getWriter( ) );
+ apache::geode::client::TransactionWriterPtr& writerPtr( m_nativeptr->getGCKeepAlive()->getWriter( ) );
apache::geode::client::ManagedTransactionWriterGeneric* twg =
- dynamic_cast<apache::geode::client::ManagedTransactionWriterGeneric*>( writerPtr.ptr( ) );
+ dynamic_cast<apache::geode::client::ManagedTransactionWriterGeneric*>( writerPtr.get() );
if (twg != nullptr)
{
@@ -163,7 +246,7 @@ namespace Apache
writerPtr = new apache::geode::client::ManagedTransactionWriterGeneric( transactionWriter );
((apache::geode::client::ManagedTransactionWriterGeneric*)writerPtr.get())->setptr(twg);
}
- NativePtr->setWriter( writerPtr );
+ m_nativeptr->getGCKeepAlive()->setWriter( writerPtr );
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -182,7 +265,7 @@ namespace Apache
listenerPtr = new apache::geode::client::ManagedTransactionListenerGeneric( transactionListener );
((apache::geode::client::ManagedTransactionListenerGeneric*)listenerPtr.get())->setptr(twg);
}
- NativePtr->addListener( listenerPtr );
+ m_nativeptr->getGCKeepAlive()->addListener( listenerPtr );
_GF_MG_EXCEPTION_CATCH_ALL2
}
@@ -201,7 +284,7 @@ namespace Apache
listenerPtr = new apache::geode::client::ManagedTransactionListenerGeneric( transactionListener );
((apache::geode::client::ManagedTransactionListenerGeneric*)listenerPtr.get())->setptr(twg);
}
- NativePtr->removeListener( listenerPtr );
+ m_nativeptr->getGCKeepAlive()->removeListener( listenerPtr );
_GF_MG_EXCEPTION_CATCH_ALL2
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheTransactionManager.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheTransactionManager.hpp b/src/clicache/src/CacheTransactionManager.hpp
index 480d95a..07f6954 100644
--- a/src/clicache/src/CacheTransactionManager.hpp
+++ b/src/clicache/src/CacheTransactionManager.hpp
@@ -18,12 +18,12 @@
#pragma once
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CacheTransactionManager.hpp>
#include <geode/InternalCacheTransactionManager2PC.hpp>
+#include "end_native.hpp"
+#include "native_shared_ptr.hpp"
#include "TransactionId.hpp"
-//#include "impl/NativeWrapper.hpp"
-//#include "impl/TransactionWriter.hpp"
-//#include "impl/TransactionListener.hpp"
using namespace System;
namespace Apache
@@ -32,12 +32,11 @@ namespace Apache
{
namespace Client
{
-
+ namespace native = apache::geode::client;
/// <summary>
/// CacheTransactionManager encapsulates the transactions for a cache
/// </summary>
public ref class CacheTransactionManager sealed
- : Internal::SBWrap<apache::geode::client::InternalCacheTransactionManager2PC>
{
public:
/// <summary>
@@ -202,52 +201,9 @@ namespace Apache
Apache::Geode::Client::TransactionId^ get( );
}
-#ifdef CSTX_COMMENTED
-
- /// <summary>
- /// Returns the current transaction writer
- /// </summary>
- /// <returns>current transaction writer(<c>ITransactionWriter</c>)</returns>
- generic<class TKey, class TValue>
- ITransactionWriter<TKey, TValue>^ GetWriter ();
-
- /// <summary>
- /// Set the <c>ITransactionWriter</c> for the cache
- /// <param name="transactionWriter">transaction writer</param>
- generic<class TKey, class TValue>
- void SetWriter (ITransactionWriter<TKey, TValue>^ transactionWriter);
-
- /// <summary>
- /// Adds a transaction listener to the end of the list of transaction listeners
- /// on this cache.
- /// </summary>
- /// <param name="aListener">
- /// the user defined transaction listener to add to the cache
- /// </param>
- /// <exception cref="IllegalArgumentException">
- /// If the parameter is null.
- /// </exception>
- generic<class TKey, class TValue>
- void AddListener(ITransactionListener<TKey, TValue>^ aListener);
-
- /// <summary>
- /// Removes a transaction listener from the list of transaction listeners on this cache.
- /// Does nothing if the specified listener has not been added.
- /// If the specified listener has been added then the close method of the listener will
- /// be called.
- /// </summary>
- /// <param name="aListener">the transaction listener to remove from the cache.</param>
- /// <exception cref="IllegalArgumentException">
- /// if the parameteris null
- /// </exception>
- generic<class TKey, class TValue>
- void RemoveListener(ITransactionListener<TKey, TValue>^ aListener);
-
-#endif
-
internal:
- inline static CacheTransactionManager^ Create( apache::geode::client::InternalCacheTransactionManager2PC* nativeptr )
+ inline static CacheTransactionManager^ Create( native::InternalCacheTransactionManager2PCPtr nativeptr )
{
return ( nativeptr != nullptr ?
gcnew CacheTransactionManager( nativeptr ) : nullptr );
@@ -260,8 +216,12 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CacheTransactionManager( apache::geode::client::InternalCacheTransactionManager2PC* nativeptr )
- : SBWrap( nativeptr ) { }
+ inline CacheTransactionManager( native::InternalCacheTransactionManager2PCPtr nativeptr )
+ {
+ m_nativeptr = gcnew native_shared_ptr<native::InternalCacheTransactionManager2PC>(nativeptr);
+ }
+
+ native_shared_ptr<native::InternalCacheTransactionManager2PC>^ m_nativeptr;
};
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableBuiltins.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableBuiltins.hpp b/src/clicache/src/CacheableBuiltins.hpp
index 3cee562..ce96b61 100644
--- a/src/clicache/src/CacheableBuiltins.hpp
+++ b/src/clicache/src/CacheableBuiltins.hpp
@@ -20,7 +20,10 @@
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CacheableBuiltins.hpp>
+#include "end_native.hpp"
+
#include "CacheableKey.hpp"
#include "Serializable.hpp"
#include "ExceptionTypes.hpp"
@@ -37,7 +40,7 @@ namespace Apache
namespace Client
{
- //namespace Internal
+ namespace native = apache::geode::client;
/// <summary>
@@ -54,9 +57,8 @@ namespace Apache
/// </summary>
CacheableBuiltinKey()
{
- apache::geode::client::SharedPtr<TNative>& nativeptr = TNative::create();
-
- SetSP(nativeptr.get());
+ auto nativeptr = TNative::create();
+ m_nativeptr = gcnew native_shared_ptr<native::Serializable>(nativeptr);
}
/// <summary>
@@ -65,9 +67,8 @@ namespace Apache
/// <param name="value">the value of the new instance</param>
CacheableBuiltinKey(TManaged value)
{
- apache::geode::client::SharedPtr<TNative>& nativeptr = TNative::create(value);
-
- SetSP(nativeptr.get());
+ auto nativeptr = TNative::create(value);
+ m_nativeptr = gcnew native_shared_ptr<native::Serializable>(nativeptr);
}
/// <summary>
@@ -90,7 +91,15 @@ namespace Apache
/// </summary>
virtual String^ ToString() override
{
- return static_cast<TNative*>(NativePtr())->value().ToString();
+ try
+ {
+ return static_cast<TNative*>(m_nativeptr->get())->value().ToString();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
}
/// <summary>
@@ -98,14 +107,23 @@ namespace Apache
/// It invokes the '==' operator of the underlying
/// native object.
/// </summary>
- virtual bool Equals(ICacheableKey^ other) override
+ virtual bool Equals(CacheableBuiltinKey^ other) override
{
- if (other == nullptr || other->ClassId != TYPEID)
+ if (other == nullptr)
{
return false;
}
- return static_cast<TNative*>(NativePtr())->operator==(
- *static_cast<TNative*>(((CacheableKey^)other)->NativePtr()));
+
+ try
+ {
+ return static_cast<TNative*>(m_nativeptr->get())->operator==(
+ *static_cast<TNative*>(other->m_nativeptr->get()));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ GC::KeepAlive(other->m_nativeptr);
+ }
}
/// <summary>
@@ -115,14 +133,7 @@ namespace Apache
/// </summary>
virtual bool Equals(Object^ obj) override
{
- CacheableBuiltinKey^ otherKey =
- dynamic_cast<CacheableBuiltinKey^>(obj);
-
- if (otherKey != nullptr) {
- return static_cast<TNative*>(NativePtr())->operator==(
- *static_cast<TNative*>(otherKey->NativePtr()));
- }
- return false;
+ return Equals(dynamic_cast<CacheableBuiltinKey^>(obj));
}
/// <summary>
@@ -130,7 +141,15 @@ namespace Apache
/// </summary>
bool operator == (TManaged other)
{
- return (static_cast<TNative*>(NativePtr())->value() == other);
+ try
+ {
+ return (static_cast<TNative*>(m_nativeptr->get())->value() == other);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
}
/// <summary>
@@ -140,7 +159,15 @@ namespace Apache
{
inline TManaged get()
{
- return static_cast<TNative*>(NativePtr())->value();
+ try
+ {
+ return static_cast<TNative*>(m_nativeptr->get())->value();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+
}
}
@@ -150,7 +177,7 @@ namespace Apache
/// Protected constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CacheableBuiltinKey(apache::geode::client::Serializable* nativeptr)
+ inline CacheableBuiltinKey(native::SerializablePtr nativeptr)
: CacheableKey(nativeptr) { }
};
@@ -246,7 +273,7 @@ namespace Apache
inline CacheableBuiltinArray()
{
//TODO:
- //apache::geode::client::Serializable* sp = TNative::createDeserializable();
+ //native::Serializable* sp = TNative::createDeserializable();
//SetSP(sp);
}
@@ -254,13 +281,10 @@ namespace Apache
/// Protected constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CacheableBuiltinArray(apache::geode::client::Serializable* nptr)
+ inline CacheableBuiltinArray(native::SerializablePtr nptr)
: Serializable(nptr)
{
- //TODO: ??
- // ManagedPtrWrap< apache::geode::client::Serializable,
- // Internal::SBWrap<apache::geode::client::Serializable> > nptr = nativeptr;
- TNative* nativeptr = static_cast<TNative*>(nptr);
+ auto nativeptr = std::static_pointer_cast<TNative>(nptr);
System::Int32 len = nativeptr->length();
if (len > 0)
{
@@ -364,20 +388,20 @@ namespace Apache
} \
\
internal: \
- static IGeodeSerializable^ Create(apache::geode::client::Serializable* obj) \
+ static IGeodeSerializable^ Create(native::SerializablePtr obj) \
{ \
return (obj != nullptr ? gcnew m(obj) : nullptr); \
} \
\
private: \
- inline m(apache::geode::client::Serializable* nativeptr) \
+ inline m(native::SerializablePtr nativeptr) \
: CacheableBuiltinKey(nativeptr) { } \
};
#define _GFCLI_CACHEABLE_ARRAY_DEF_NEW(m, mt) \
ref class m : public CacheableBuiltinArray< \
- apache::geode::client::m, apache::geode::client::m##Ptr, mt, GeodeClassIds::m> \
+ native::m, native::m##Ptr, mt, GeodeClassIds::m> \
{ \
public: \
/** <summary>
@@ -427,7 +451,7 @@ namespace Apache
} \
\
internal: \
- static IGeodeSerializable^ Create(apache::geode::client::Serializable* obj) \
+ static IGeodeSerializable^ Create(native::SerializablePtr obj) \
{ \
return (obj != nullptr ? gcnew m(obj) : nullptr); \
} \
@@ -460,7 +484,7 @@ namespace Apache
*/ \
inline m(array<mt>^ value, System::Int32 length) \
: CacheableBuiltinArray(value, length) { } \
- inline m(apache::geode::client::Serializable* nativeptr) \
+ inline m(native::SerializablePtr nativeptr) \
: CacheableBuiltinArray(nativeptr) { } \
};
@@ -471,56 +495,56 @@ namespace Apache
/// An immutable wrapper for booleans that can serve
/// as a distributable key object for caching.
/// </summary>
- _GFCLI_CACHEABLE_KEY_DEF_NEW(apache::geode::client::CacheableBoolean,
+ _GFCLI_CACHEABLE_KEY_DEF_NEW(native::CacheableBoolean,
CacheableBoolean, bool);
/// <summary>
/// An immutable wrapper for bytes that can serve
/// as a distributable key object for caching.
/// </summary>
- _GFCLI_CACHEABLE_KEY_DEF_NEW(apache::geode::client::CacheableByte,
+ _GFCLI_CACHEABLE_KEY_DEF_NEW(native::CacheableByte,
CacheableByte, Byte);
/// <summary>
/// An immutable wrapper for 16-bit characters that can serve
/// as a distributable key object for caching.
/// </summary>
- _GFCLI_CACHEABLE_KEY_DEF_NEW(apache::geode::client::CacheableWideChar,
+ _GFCLI_CACHEABLE_KEY_DEF_NEW(native::CacheableWideChar,
CacheableCharacter, Char);
/// <summary>
/// An immutable wrapper for doubles that can serve
/// as a distributable key object for caching.
/// </summary>
- _GFCLI_CACHEABLE_KEY_DEF_NEW(apache::geode::client::CacheableDouble,
+ _GFCLI_CACHEABLE_KEY_DEF_NEW(native::CacheableDouble,
CacheableDouble, Double);
/// <summary>
/// An immutable wrapper for floats that can serve
/// as a distributable key object for caching.
/// </summary>
- _GFCLI_CACHEABLE_KEY_DEF_NEW(apache::geode::client::CacheableFloat,
+ _GFCLI_CACHEABLE_KEY_DEF_NEW(native::CacheableFloat,
CacheableFloat, Single);
/// <summary>
/// An immutable wrapper for 16-bit integers that can serve
/// as a distributable key object for caching.
/// </summary>
- _GFCLI_CACHEABLE_KEY_DEF_NEW(apache::geode::client::CacheableInt16,
+ _GFCLI_CACHEABLE_KEY_DEF_NEW(native::CacheableInt16,
CacheableInt16, System::Int16);
/// <summary>
/// An immutable wrapper for 32-bit integers that can serve
/// as a distributable key object for caching.
/// </summary>
- _GFCLI_CACHEABLE_KEY_DEF_NEW(apache::geode::client::CacheableInt32,
+ _GFCLI_CACHEABLE_KEY_DEF_NEW(native::CacheableInt32,
CacheableInt32, System::Int32);
/// <summary>
/// An immutable wrapper for 64-bit integers that can serve
/// as a distributable key object for caching.
/// </summary>
- _GFCLI_CACHEABLE_KEY_DEF_NEW(apache::geode::client::CacheableInt64,
+ _GFCLI_CACHEABLE_KEY_DEF_NEW(native::CacheableInt64,
CacheableInt64, System::Int64);
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableDate.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableDate.cpp b/src/clicache/src/CacheableDate.cpp
index 79bd75d..824b16c 100644
--- a/src/clicache/src/CacheableDate.cpp
+++ b/src/clicache/src/CacheableDate.cpp
@@ -15,10 +15,6 @@
* limitations under the License.
*/
-
-
-
-//#include "geode_includes.hpp"
#include "CacheableDate.hpp"
#include "DataInput.hpp"
#include "DataOutput.hpp"
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableDate.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableDate.hpp b/src/clicache/src/CacheableDate.hpp
index 9cf2435..9530ef2 100644
--- a/src/clicache/src/CacheableDate.hpp
+++ b/src/clicache/src/CacheableDate.hpp
@@ -17,12 +17,9 @@
#pragma once
-
-
#include "geode_defs.hpp"
#include "ICacheableKey.hpp"
-
using namespace System;
namespace Apache
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableHashSet.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableHashSet.hpp b/src/clicache/src/CacheableHashSet.hpp
index aa6085b..b7fc935 100644
--- a/src/clicache/src/CacheableHashSet.hpp
+++ b/src/clicache/src/CacheableHashSet.hpp
@@ -20,10 +20,15 @@
#pragma once
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CacheableBuiltins.hpp>
+#include "end_native.hpp"
+
#include "Serializable.hpp"
#include "ExceptionTypes.hpp"
#include "impl/PdxInstanceImpl.hpp"
+#include "native_shared_ptr.hpp"
+#include "native_unique_ptr.hpp"
using namespace System;
using namespace System::Collections::Generic;
@@ -52,15 +57,14 @@ namespace Apache
{
output->WriteArrayLen(this->Count);
- Internal::ManagedPtrWrap< apache::geode::client::Serializable,
- Internal::SBWrap<apache::geode::client::Serializable> > nptr = NativePtr;
- HSTYPE* set = static_cast<HSTYPE*>(nptr());
+ auto set = static_cast<HSTYPE*>(m_nativeptr->get());
for (typename HSTYPE::Iterator iter = set->begin();
iter != set->end(); ++iter) {
- //Generic::ICacheableKey^ key = SafeGenericUMKeyConvert<ICacheableKey^>((*iter).get());
- Object^ key = Serializable::GetManagedValueGeneric<Object^>((*iter));
+ auto key = Serializable::GetManagedValueGeneric<Object^>((*iter));
output->WriteObject(key);
}
+
+ GC::KeepAlive(this);
}
virtual IGeodeSerializable^ FromData(DataInput^ input) override
@@ -70,7 +74,6 @@ namespace Apache
{
for (int i = 0; i < len; i++)
{
- //Generic::ICacheableKey^ key = dynamic_cast<Client::ICacheableKey^>(input->ReadObject());
Object^ key = (input->ReadObject());
this->Add(key);
}
@@ -135,8 +138,7 @@ namespace Apache
/// Enumerator for <c>CacheableHashSet</c> class.
/// </summary>
ref class Enumerator sealed
- : public Internal::UMWrap<typename HSTYPE::Iterator>,
- public IEnumerator<Object^>
+ : public IEnumerator<Object^>
{
public:
// Region: IEnumerator<ICacheableKey^> Members
@@ -153,13 +155,14 @@ namespace Apache
{
virtual Object^ get() =
IEnumerator<Object^>::Current::get
- {
- if (!m_started) {
- throw gcnew System::InvalidOperationException(
- "Call MoveNext first.");
- }
- //return SafeGenericUMKeyConvert<Client::ICacheableKey^>((*(*NativePtr())).get());
- return Serializable::GetManagedValueGeneric<Object^>((*(*NativePtr())));
+ {
+ if (!m_started) {
+ throw gcnew System::InvalidOperationException(
+ "Call MoveNext first.");
+ }
+ auto ret = Serializable::GetManagedValueGeneric<Object^>(*(*(m_nativeptr->get())));
+ GC::KeepAlive(this);
+ return ret;
}
}
@@ -177,15 +180,14 @@ namespace Apache
/// </returns>
virtual bool MoveNext()
{
- Internal::ManagedPtrWrap< typename HSTYPE::Iterator,
- Internal::UMWrap<typename HSTYPE::Iterator> > nptr = NativePtr;
+ auto nptr = m_nativeptr->get();
bool isEnd = nptr->isEnd();
if (!m_started) {
m_started = true;
}
else {
if (!isEnd) {
- (*nptr())++;
+ (*nptr)++;
isEnd = nptr->isEnd();
}
}
@@ -199,10 +201,20 @@ namespace Apache
/// </summary>
virtual void Reset()
{
- NativePtr->reset();
+ try
+ {
+ m_nativeptr->get()->reset();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
m_started = false;
}
+ !Enumerator() {}
+ ~Enumerator() {}
+
// End Region: IEnumerator Members
internal:
@@ -210,9 +222,11 @@ namespace Apache
/// Internal constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline Enumerator(typename HSTYPE::Iterator* nativeptr,
+ inline Enumerator(std::unique_ptr<typename HSTYPE::Iterator> nativeptr,
CacheableHashSetType<TYPEID, HSTYPE>^ set)
- : UMWrap(nativeptr, true), m_set(set) { }
+ : m_set(set) {
+ m_nativeptr = gcnew native_unique_ptr<typename HSTYPE::Iterator>(std::move(nativeptr));
+ }
private:
// Region: IEnumerator Members
@@ -241,6 +255,8 @@ namespace Apache
bool m_started;
CacheableHashSetType<TYPEID, HSTYPE>^ m_set;
+
+ native_unique_ptr<typename HSTYPE::Iterator>^ m_nativeptr;
};
/// <summary>
@@ -253,7 +269,6 @@ namespace Apache
{
virtual System::UInt32 get() override
{
- //return static_cast<HSTYPE*>(NativePtr())->classId() + 0x80000000;
return TYPEID;
}
}
@@ -265,7 +280,14 @@ namespace Apache
{
inline System::Int32 get()
{
- return static_cast<HSTYPE*>(NativePtr())->max_size();
+ try
+ {
+ return static_cast<HSTYPE*>(m_nativeptr->get())->max_size();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
}
@@ -276,7 +298,14 @@ namespace Apache
{
inline bool get()
{
- return static_cast<HSTYPE*>(NativePtr())->empty();
+ try
+ {
+ return static_cast<HSTYPE*>(m_nativeptr->get())->empty();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
}
@@ -287,7 +316,14 @@ namespace Apache
{
inline System::Int32 get()
{
- return static_cast<HSTYPE*>(NativePtr())->bucket_count();
+ try
+ {
+ return static_cast<HSTYPE*>(m_nativeptr->get())->bucket_count();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
}
@@ -297,7 +333,14 @@ namespace Apache
/// <param name="size">The new size of the HashSet.</param>
virtual void Resize(System::Int32 size) sealed
{
- static_cast<HSTYPE*>(NativePtr())->resize(size);
+ try
+ {
+ static_cast<HSTYPE*>(m_nativeptr->get())->resize(size);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
/// <summary>
@@ -309,9 +352,17 @@ namespace Apache
/// </param>
virtual void Swap(CacheableHashSetType<TYPEID, HSTYPE>^ other) sealed
{
- if (other != nullptr) {
- static_cast<HSTYPE*>(NativePtr())->swap(
- *static_cast<HSTYPE*>(other->NativePtr()));
+ try
+ {
+ if (other != nullptr) {
+ static_cast<HSTYPE*>(m_nativeptr->get())->swap(
+ *static_cast<HSTYPE*>(other->m_nativeptr->get()));
+ }
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ GC::KeepAlive(other->m_nativeptr);
}
}
@@ -327,8 +378,14 @@ namespace Apache
{
_GF_MG_EXCEPTION_TRY2/* due to auto replace */
- apache::geode::client::CacheableKeyPtr nativeptr(Serializable::GetUnmanagedValueGeneric(item));
- static_cast<HSTYPE*>(NativePtr())->insert(nativeptr);
+ try
+ {
+ static_cast<HSTYPE*>(m_nativeptr->get())->insert(Serializable::GetUnmanagedValueGeneric(item));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
_GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
}
@@ -338,7 +395,14 @@ namespace Apache
/// </summary>
virtual void Clear()
{
- static_cast<HSTYPE*>(NativePtr())->clear();
+ try
+ {
+ static_cast<HSTYPE*>(m_nativeptr->get())->clear();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
/// <summary>
@@ -354,8 +418,14 @@ namespace Apache
/// </returns>
virtual bool Contains(Object^ item)
{
- return static_cast<HSTYPE*>(NativePtr())->contains(
- apache::geode::client::CacheableKeyPtr(Serializable::GetUnmanagedValueGeneric(item)));
+ try
+ {
+ return static_cast<HSTYPE*>(m_nativeptr->get())->contains(Serializable::GetUnmanagedValueGeneric(item));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
/// <summary>
@@ -386,9 +456,8 @@ namespace Apache
throw gcnew IllegalArgumentException("CacheableHashSet.CopyTo():"
" array is null or array index is less than zero");
}
- Internal::ManagedPtrWrap< apache::geode::client::Serializable,
- Internal::SBWrap<apache::geode::client::Serializable> > nptr = NativePtr;
- HSTYPE* set = static_cast<HSTYPE*>(nptr());
+
+ auto set = static_cast<HSTYPE*>(m_nativeptr->get());
System::Int32 index = arrayIndex;
if (arrayIndex >= array->Length ||
@@ -402,7 +471,8 @@ namespace Apache
iter != set->end(); ++iter, ++index) {
array[index] = Serializable::GetManagedValueGeneric<Object^>((*iter));
}
- GC::KeepAlive(this);
+
+ GC::KeepAlive(m_nativeptr);
}
/// <summary>
@@ -413,7 +483,14 @@ namespace Apache
{
virtual System::Int32 get()
{
- return static_cast<HSTYPE*>(NativePtr())->size();
+ try
+ {
+ return static_cast<HSTYPE*>(m_nativeptr->get())->size();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
}
@@ -432,8 +509,14 @@ namespace Apache
/// </returns>
virtual bool Remove(Object^ item)
{
- return (static_cast<HSTYPE*>(NativePtr())->erase(
- apache::geode::client::CacheableKeyPtr(Serializable::GetUnmanagedValueGeneric(item))) > 0);
+ try
+ {
+ return (static_cast<HSTYPE*>(m_nativeptr->get())->erase(Serializable::GetUnmanagedValueGeneric(item)) > 0);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
/// <summary>
@@ -464,10 +547,16 @@ namespace Apache
/// </returns>
virtual IEnumerator<Object^>^ GetEnumerator()
{
- typename HSTYPE::Iterator* iter = new typename HSTYPE::Iterator(
- static_cast<HSTYPE*>(NativePtr())->begin());
-
- return gcnew Enumerator(iter, this);
+ try
+ {
+ auto iter = std::make_unique<typename HSTYPE::Iterator>(
+ static_cast<HSTYPE*>(m_nativeptr->get())->begin());
+ return gcnew Enumerator(std::move(iter), this);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
// End Region: IEnumerable<ICacheableKey^> Members
@@ -505,14 +594,14 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CacheableHashSetType<TYPEID, HSTYPE>(apache::geode::client::Serializable* nativeptr)
+ inline CacheableHashSetType<TYPEID, HSTYPE>(apache::geode::client::SerializablePtr nativeptr)
: Serializable(nativeptr) { }
/// <summary>
/// Allocates a new empty instance.
/// </summary>
inline CacheableHashSetType<TYPEID, HSTYPE>()
- : Serializable(HSTYPE::createDeserializable())
+ : Serializable(std::shared_ptr<HSTYPE>(static_cast<HSTYPE*>(HSTYPE::createDeserializable())))
{ }
/// <summary>
@@ -520,7 +609,7 @@ namespace Apache
/// </summary>
/// <param name="size">The initial size of the HashSet.</param>
inline CacheableHashSetType<TYPEID, HSTYPE>(System::Int32 size)
- : Serializable(HSTYPE::create(size).get())
+ : Serializable(HSTYPE::create(size))
{ }
};
}
@@ -572,13 +661,13 @@ namespace Apache
} \
\
internal: \
- static IGeodeSerializable^ Create(apache::geode::client::Serializable* obj) \
+ static IGeodeSerializable^ Create(apache::geode::client::SerializablePtr obj) \
{ \
return gcnew m(obj); \
} \
\
private: \
- inline m(apache::geode::client::Serializable* nativeptr) \
+ inline m(apache::geode::client::SerializablePtr nativeptr) \
: Internal::CacheableHashSetType<Apache::Geode::Client::GeodeClassIds::m, HSTYPE>(nativeptr) { } \
};
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableKey.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableKey.cpp b/src/clicache/src/CacheableKey.cpp
index 4526b78..5fc03fa 100644
--- a/src/clicache/src/CacheableKey.cpp
+++ b/src/clicache/src/CacheableKey.cpp
@@ -29,10 +29,19 @@ namespace Apache
namespace Client
{
+ namespace native = apache::geode::client;
+
// generic<class TKey>
System::Int32 CacheableKey::GetHashCode()
{
- return static_cast<apache::geode::client::CacheableKey*>(NativePtr())->hashcode();
+ try
+ {
+ return static_cast<native::CacheableKey*>(m_nativeptr->get())->hashcode();
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
// generic<class TKey>
@@ -41,22 +50,23 @@ namespace Apache
if (other == nullptr || other->ClassId != ClassId) {
return false;
}
- return static_cast<apache::geode::client::CacheableKey*>(NativePtr())->operator==(
- *static_cast<apache::geode::client::CacheableKey*>(
- ((Client::CacheableKey^)other)->NativePtr()));
+ try
+ {
+ return static_cast<native::CacheableKey*>(m_nativeptr->get())->operator==(
+ *static_cast<native::CacheableKey*>(
+ ((Client::CacheableKey^)other)->m_nativeptr->get()));
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ GC::KeepAlive(((Client::CacheableKey^)other)->m_nativeptr);
+ }
}
//generic<class TKey>
bool CacheableKey::Equals(Object^ obj)
{
- CacheableKey^ otherKey =
- dynamic_cast<CacheableKey^>(obj);
-
- if (otherKey != nullptr) {
- return static_cast<apache::geode::client::CacheableKey*>(NativePtr())->operator==(
- *static_cast<apache::geode::client::CacheableKey*>(otherKey->NativePtr()));
- }
- return false;
+ return Equals(dynamic_cast<CacheableKey^>(obj));
}
//generic<class TKey>
@@ -108,11 +118,10 @@ namespace Apache
}
//generic<class TKey>
- CacheableKey::operator CacheableKey^ (String^ value)
+ CacheableKey::operator CacheableKey ^ (String^ value)
{
return dynamic_cast<CacheableKey^>(CacheableString::Create(value));
+ }
} // namespace Client
} // namespace Geode
} // namespace Apache
-
-} //namespace
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableKey.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableKey.hpp b/src/clicache/src/CacheableKey.hpp
index f36f3ae..39bf3e5 100644
--- a/src/clicache/src/CacheableKey.hpp
+++ b/src/clicache/src/CacheableKey.hpp
@@ -18,8 +18,10 @@
#pragma once
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CacheableKey.hpp>
-//#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
#include "Serializable.hpp"
#include "ICacheableKey.hpp"
@@ -129,7 +131,7 @@ namespace Apache
/// Internal constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CacheableKey(apache::geode::client::Serializable* nativeptr)
+ inline CacheableKey(apache::geode::client::SerializablePtr nativeptr)
: Client::Serializable(nativeptr) { }
};
} // namespace Client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableObjectArray.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableObjectArray.cpp b/src/clicache/src/CacheableObjectArray.cpp
index c4caa7d..ac615fd 100644
--- a/src/clicache/src/CacheableObjectArray.cpp
+++ b/src/clicache/src/CacheableObjectArray.cpp
@@ -16,9 +16,9 @@
*/
-
-//#include "geode_includes.hpp"
+#include "begin_native.hpp"
#include <GeodeTypeIdsImpl.hpp>
+#include "end_native.hpp"
#include "CacheableObjectArray.hpp"
#include "DataOutput.hpp"
#include "DataInput.hpp"
@@ -50,20 +50,6 @@ namespace Apache
//TODO::split
output->WriteObject(obj);
}
-
- /*_GF_MG_EXCEPTION_TRY
-
- apache::geode::client::DataOutput& nativeOutput = *(output->_NativePtr);
- nativeOutput.writeArrayLen((System::Int32)Count);
- nativeOutput.write((int8_t)apache::geode::client::GeodeTypeIdsImpl::Class);
- nativeOutput.write((int8_t)apache::geode::client::GeodeTypeIds::CacheableASCIIString);
- nativeOutput.writeASCII("java.lang.Object");
- for each (IGeodeSerializable^ obj in this) {
- apache::geode::client::SerializablePtr objPtr(SafeMSerializableConvert(obj));
- nativeOutput.writeObject(objPtr);
- }
-
- _GF_MG_EXCEPTION_CATCH_ALL*/
}
IGeodeSerializable^ CacheableObjectArray::FromData(DataInput^ input)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableStack.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableStack.cpp b/src/clicache/src/CacheableStack.cpp
index 96839e6..6b5d1c8 100644
--- a/src/clicache/src/CacheableStack.cpp
+++ b/src/clicache/src/CacheableStack.cpp
@@ -17,11 +17,12 @@
-//#include "geode_includes.hpp"
#include "CacheableStack.hpp"
#include "DataOutput.hpp"
#include "DataInput.hpp"
+#include "begin_native.hpp"
#include <GeodeTypeIdsImpl.hpp>
+#include "end_native.hpp"
#include "impl/SafeConvert.hpp"
#include "GeodeClassIds.hpp"
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableString.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableString.cpp b/src/clicache/src/CacheableString.cpp
index 36d7b09..ceea6d6 100644
--- a/src/clicache/src/CacheableString.cpp
+++ b/src/clicache/src/CacheableString.cpp
@@ -79,8 +79,8 @@ namespace Apache
cStr = apache::geode::client::CacheableString::create(pin_value, (System::Int32)len);
}
else {
- cStr = (apache::geode::client::CacheableString*)
- apache::geode::client::CacheableString::createDeserializable();
+ cStr.reset(
+ static_cast<apache::geode::client::CacheableString*>(apache::geode::client::CacheableString::createDeserializable()));
}
}
@@ -94,8 +94,8 @@ namespace Apache
(const wchar_t*)pin_value, (System::Int32)len);
}
else {
- cStr = (apache::geode::client::CacheableString*)
- apache::geode::client::CacheableString::createDeserializable();
+ cStr.reset(
+ static_cast<apache::geode::client::CacheableString*>(apache::geode::client::CacheableString::createDeserializable()));
}
}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableString.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableString.hpp b/src/clicache/src/CacheableString.hpp
index 633cae9..d24adc5 100644
--- a/src/clicache/src/CacheableString.hpp
+++ b/src/clicache/src/CacheableString.hpp
@@ -20,7 +20,10 @@
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CacheableString.hpp>
+#include "end_native.hpp"
+
#include "impl/ManagedString.hpp"
#include "CacheableKey.hpp"
#include "GeodeClassIds.hpp"
@@ -239,7 +242,7 @@ namespace Apache
/// <summary>
/// Factory function to register wrapper
/// </summary>
- static IGeodeSerializable^ Create(apache::geode::client::Serializable* obj)
+ static IGeodeSerializable^ Create(apache::geode::client::SerializablePtr obj)
{
return (obj != nullptr ?
gcnew CacheableString(obj) : nullptr);
@@ -313,7 +316,7 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CacheableString(apache::geode::client::Serializable* nativeptr)
+ inline CacheableString(apache::geode::client::SerializablePtr nativeptr)
: CacheableKey(nativeptr) { }
};
} // namespace Client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheableStringArray.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableStringArray.hpp b/src/clicache/src/CacheableStringArray.hpp
index fca0be6..e8c66f6 100644
--- a/src/clicache/src/CacheableStringArray.hpp
+++ b/src/clicache/src/CacheableStringArray.hpp
@@ -20,7 +20,10 @@
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CacheableBuiltins.hpp>
+#include "end_native.hpp"
+
#include "Serializable.hpp"
#include "GeodeClassIds.hpp"
#include "CacheableString.hpp"
@@ -152,7 +155,7 @@ namespace Apache
/// <summary>
/// Factory function to register wrapper
/// </summary>
- static IGeodeSerializable^ Create(apache::geode::client::Serializable* obj)
+ static IGeodeSerializable^ Create(apache::geode::client::SerializablePtr obj)
{
return (obj != nullptr ?
gcnew CacheableStringArray(obj) : nullptr);
@@ -180,7 +183,7 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CacheableStringArray(apache::geode::client::Serializable* nativeptr)
+ inline CacheableStringArray(apache::geode::client::SerializablePtr nativeptr)
: Serializable(nativeptr) { }
};
} // namespace Client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqAttributes.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributes.cpp b/src/clicache/src/CqAttributes.cpp
index 7025eb6..ef10045 100644
--- a/src/clicache/src/CqAttributes.cpp
+++ b/src/clicache/src/CqAttributes.cpp
@@ -23,7 +23,9 @@
#include "impl/ManagedCqStatusListener.hpp"
#include "ICqStatusListener.hpp"
-using namespace System;
+#include "begin_native.hpp"
+#include <geode/CqAttributes.hpp>
+#include "end_native.hpp"
namespace Apache
{
@@ -31,37 +33,42 @@ namespace Apache
{
namespace Client
{
+ using namespace System;
+
+ namespace native = apache::geode::client;
generic<class TKey, class TResult>
array<ICqListener<TKey, TResult>^>^ CqAttributes<TKey, TResult>::getCqListeners( )
{
- apache::geode::client::VectorOfCqListener vrr;
- NativePtr->getCqListeners( vrr );
- array<ICqListener<TKey, TResult>^>^ listners = gcnew array<ICqListener<TKey, TResult>^>( vrr.size( ) );
+ native::CqAttributes::listener_container_type vrr;
+ try
+ {
+ m_nativeptr->get()->getCqListeners(vrr);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ auto listners = gcnew array<ICqListener<TKey, TResult>^>(vrr.size());
- for( System::Int32 index = 0; index < vrr.size( ); index++ )
+ for (System::Int32 index = 0; index < vrr.size(); index++)
{
- apache::geode::client::CqListenerPtr& nativeptr( vrr[ index ] );
- apache::geode::client::ManagedCqListenerGeneric* mg_listener =
- dynamic_cast<apache::geode::client::ManagedCqListenerGeneric*>( nativeptr.ptr( ) );
- if (mg_listener != nullptr)
+ auto nativeptr = vrr[index];
+ if (auto mg_listener = std::dynamic_pointer_cast<native::ManagedCqListenerGeneric>(nativeptr))
{
- listners[ index ] = (ICqListener<TKey, TResult>^) mg_listener->userptr( );
- }else
+ listners[index] = (ICqListener<TKey, TResult>^) mg_listener->userptr();
+ }
+ else if (auto mg_statuslistener = std::dynamic_pointer_cast<native::ManagedCqStatusListenerGeneric>(nativeptr))
+ {
+ listners[index] = (ICqStatusListener<TKey, TResult>^) mg_statuslistener->userptr();
+ }
+ else
{
- apache::geode::client::ManagedCqStatusListenerGeneric* mg_statuslistener =
- dynamic_cast<apache::geode::client::ManagedCqStatusListenerGeneric*>( nativeptr.ptr( ) );
- if (mg_statuslistener != nullptr) {
- listners[ index ] = (ICqStatusListener<TKey, TResult>^) mg_statuslistener->userptr( );
- }
- else {
- listners[ index ] = nullptr;
- }
+ listners[index] = nullptr;
}
}
return listners;
+ }
} // namespace Client
} // namespace Geode
} // namespace Apache
-
-} //namespace
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqAttributes.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributes.hpp b/src/clicache/src/CqAttributes.hpp
index 756bc85..cf3fb56 100644
--- a/src/clicache/src/CqAttributes.hpp
+++ b/src/clicache/src/CqAttributes.hpp
@@ -18,8 +18,11 @@
#pragma once
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CqAttributes.hpp>
-#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
using namespace System;
@@ -30,6 +33,7 @@ namespace Apache
{
namespace Client
{
+ namespace native = apache::geode::client;
generic<class TKey, class TResult>
interface class ICqListener;
@@ -39,7 +43,6 @@ namespace Apache
/// </summary>
generic<class TKey, class TResult>
public ref class CqAttributes sealed
- : public Internal::SBWrap<apache::geode::client::CqAttributes>
{
public:
@@ -58,15 +61,16 @@ namespace Apache
/// <returns>
/// The managed wrapper object; null if the native pointer is null.
/// </returns>
- inline static CqAttributes<TKey, TResult>^ Create( apache::geode::client::CqAttributes* nativeptr )
+ inline static CqAttributes<TKey, TResult>^ Create( native::CqAttributesPtr nativeptr )
{
- if (nativeptr == nullptr)
- {
- return nullptr;
- }
- return gcnew CqAttributes( nativeptr );
+ return __nullptr == nativeptr ? nullptr :
+ gcnew CqAttributes( nativeptr );
}
+ std::shared_ptr<native::CqAttributes> GetNative()
+ {
+ return m_nativeptr->get_shared_ptr();
+ }
private:
@@ -74,8 +78,12 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CqAttributes( apache::geode::client::CqAttributes* nativeptr )
- : SBWrap( nativeptr ) { }
+ inline CqAttributes( native::CqAttributesPtr nativeptr )
+ {
+ m_nativeptr = gcnew native_shared_ptr<native::CqAttributes>(nativeptr);
+ }
+
+ native_shared_ptr<native::CqAttributes>^ m_nativeptr;
};
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqAttributesFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributesFactory.cpp b/src/clicache/src/CqAttributesFactory.cpp
index 9903d0f..d504335 100644
--- a/src/clicache/src/CqAttributesFactory.cpp
+++ b/src/clicache/src/CqAttributesFactory.cpp
@@ -15,6 +15,9 @@
* limitations under the License.
*/
+#include "begin_native.hpp"
+#include <geode/QueryService.hpp>
+#include "end_native.hpp"
//#include "geode_includes.hpp"
#include "CqAttributesFactory.hpp"
@@ -32,18 +35,18 @@ namespace Apache
{
namespace Client
{
+ namespace native = apache::geode::client;
generic<class TKey, class TResult>
void CqAttributesFactory<TKey, TResult>::AddCqListener(Client::ICqListener<TKey, TResult>^ cqListener )
{
- apache::geode::client::CqListenerPtr listenerptr;
+ native::CqListenerPtr listenerptr;
if ( cqListener != nullptr ) {
- ICqStatusListener<TKey, TResult>^ cqStatusListener =
- dynamic_cast<ICqStatusListener<TKey, TResult>^>(cqListener);
+ auto cqStatusListener = dynamic_cast<ICqStatusListener<TKey, TResult>^>(cqListener);
if (cqStatusListener != nullptr) {
- CqStatusListenerGeneric<TKey, TResult>^ sLstr = gcnew CqStatusListenerGeneric<TKey, TResult>();
+ auto sLstr = gcnew CqStatusListenerGeneric<TKey, TResult>();
sLstr->AddCqListener(cqListener);
- listenerptr = new apache::geode::client::ManagedCqStatusListenerGeneric(cqListener);
+ listenerptr = std::shared_ptr<native::ManagedCqStatusListenerGeneric>(new native::ManagedCqStatusListenerGeneric(cqListener));
try {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->ContainsKey( cqListener) ) {
@@ -55,14 +58,13 @@ namespace Apache
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
- ((apache::geode::client::ManagedCqStatusListenerGeneric*)listenerptr.get())->setptr(sLstr);
+ ((native::ManagedCqStatusListenerGeneric*)listenerptr.get())->setptr(sLstr);
}
else {
//TODO::split
- CqListenerGeneric<TKey, TResult>^ cqlg = gcnew CqListenerGeneric<TKey, TResult>();
+ auto cqlg = gcnew CqListenerGeneric<TKey, TResult>();
cqlg->AddCqListener(cqListener);
- //listenerptr = new apache::geode::client::ManagedCqListenerGeneric((ICqListener<Object^, Object^>^)cqListener );
- listenerptr = new apache::geode::client::ManagedCqListenerGeneric( /*clg,*/ cqListener );
+ listenerptr = std::shared_ptr<native::ManagedCqListenerGeneric>(new native::ManagedCqListenerGeneric(cqListener));
try {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->ContainsKey( cqListener) ) {
@@ -74,25 +76,31 @@ namespace Apache
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
- ((apache::geode::client::ManagedCqListenerGeneric*)listenerptr.get())->setptr(cqlg);
+ ((native::ManagedCqListenerGeneric*)listenerptr.get())->setptr(cqlg);
}
}
- NativePtr->addCqListener( listenerptr );
+ try
+ {
+ m_nativeptr->get()->addCqListener( listenerptr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
generic<class TKey, class TResult>
void CqAttributesFactory<TKey, TResult>::InitCqListeners(array<Client::ICqListener<TKey, TResult>^>^ cqListeners)
{
- apache::geode::client::VectorOfCqListener vrr;
+ native::CqAttributes::listener_container_type vrr;
for( int i = 0; i < cqListeners->Length; i++ )
{
- ICqStatusListener<TKey, TResult>^ lister = dynamic_cast<ICqStatusListener<TKey, TResult>^>(cqListeners[i]);
+ auto lister = dynamic_cast<ICqStatusListener<TKey, TResult>^>(cqListeners[i]);
if (lister != nullptr) {
- apache::geode::client::CqStatusListenerPtr cptr(new apache::geode::client::ManagedCqStatusListenerGeneric(
- (ICqStatusListener<TKey, TResult>^)lister ));
- vrr.push_back(cptr);
- CqStatusListenerGeneric<TKey, TResult>^ cqlg = gcnew CqStatusListenerGeneric<TKey, TResult>();
+ auto cptr = std::shared_ptr<native::ManagedCqStatusListenerGeneric>(new native::ManagedCqStatusListenerGeneric(lister));
+ vrr.push_back(std::static_pointer_cast<native::CqListener>(cptr));
+ auto cqlg = gcnew CqStatusListenerGeneric<TKey, TResult>();
cqlg->AddCqListener(cqListeners[i]);
try {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
@@ -105,12 +113,11 @@ namespace Apache
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
- ((apache::geode::client::ManagedCqStatusListenerGeneric*)vrr[i].get())->setptr(cqlg);
+ ((native::ManagedCqStatusListenerGeneric*)vrr[i].get())->setptr(cqlg);
}
else {
- ICqListener<TKey, TResult>^ lister = cqListeners[i];
- apache::geode::client::CqListenerPtr cptr(new apache::geode::client::ManagedCqListenerGeneric(
- (ICqListener<TKey, TResult>^)lister ));
+ auto lister = cqListeners[i];
+ auto cptr = std::shared_ptr<native::ManagedCqListenerGeneric>(new native::ManagedCqListenerGeneric(lister));
vrr.push_back(cptr);
CqListenerGeneric<TKey, TResult>^ cqlg = gcnew CqListenerGeneric<TKey, TResult>();
cqlg->AddCqListener(cqListeners[i]);
@@ -125,19 +132,32 @@ namespace Apache
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
- ((apache::geode::client::ManagedCqListenerGeneric*)vrr[i].get())->setptr(cqlg);
+ ((native::ManagedCqListenerGeneric*)vrr[i].get())->setptr(cqlg);
}
}
- NativePtr->initCqListeners( vrr );
+ try
+ {
+ m_nativeptr->get()->initCqListeners( vrr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
generic<class TKey, class TResult>
Client::CqAttributes<TKey, TResult>^ CqAttributesFactory<TKey, TResult>::Create( )
{
- return Client::CqAttributes<TKey, TResult>::Create(NativePtr->create().get());
+ try
+ {
+ return Client::CqAttributes<TKey, TResult>::Create(m_nativeptr->get()->create());
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
} // namespace Client
} // namespace Geode
} // namespace Apache
-
-} //namespace
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqAttributesFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributesFactory.hpp b/src/clicache/src/CqAttributesFactory.hpp
index d421caa..6fa5ab0 100644
--- a/src/clicache/src/CqAttributesFactory.hpp
+++ b/src/clicache/src/CqAttributesFactory.hpp
@@ -18,11 +18,13 @@
#pragma once
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CqAttributesFactory.hpp>
-//#include "impl/NativeWrapper.hpp"
-#include "impl/SafeConvert.hpp"
+#include "end_native.hpp"
+#include "impl/SafeConvert.hpp"
#include "CqAttributes.hpp"
+#include "native_unique_ptr.hpp"
using namespace System;
using namespace System::Collections::Generic;
@@ -33,11 +35,8 @@ namespace Apache
{
namespace Client
{
+ namespace native = apache::geode::client;
- /*
- generic<class TKey, class TValue>
- ref class CqAttributes;
- */
generic<class TKey, class TResult>
interface class ICqListener;
@@ -47,7 +46,6 @@ namespace Apache
/// <seealso cref="CqAttributes" />
generic<class TKey, class TResult>
public ref class CqAttributesFactory sealed
- : public Internal::UMWrap<apache::geode::client::CqAttributesFactory>
{
public:
@@ -56,12 +54,14 @@ namespace Apache
/// to create a <c>CqAttributes</c> with default settings.
/// </summary>
inline CqAttributesFactory( )
- : UMWrap( new apache::geode::client::CqAttributesFactory( ), true )
- { }
+ {
+ m_nativeptr = gcnew native_unique_ptr<native::CqAttributesFactory>(std::make_unique<native::CqAttributesFactory>());
+ }
inline CqAttributesFactory(Client::CqAttributes<TKey, TResult>^ cqAttributes )
- : UMWrap( new apache::geode::client::CqAttributesFactory(apache::geode::client::CqAttributesPtr(GetNativePtrFromSBWrapGeneric<apache::geode::client::CqAttributes>(cqAttributes ))), true )
- { }
+ {
+ m_nativeptr = gcnew native_unique_ptr<native::CqAttributesFactory>(std::make_unique<native::CqAttributesFactory>(cqAttributes->GetNative()));
+ }
// ATTRIBUTES
@@ -81,6 +81,10 @@ namespace Apache
/// Creates a <c>CqAttributes</c> with the current settings.
/// </summary>
Client::CqAttributes<TKey, TResult>^ Create( );
+
+ private:
+
+ native_unique_ptr<native::CqAttributesFactory>^ m_nativeptr;
};
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqAttributesMutator.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributesMutator.cpp b/src/clicache/src/CqAttributesMutator.cpp
index c6950b4..5184903 100644
--- a/src/clicache/src/CqAttributesMutator.cpp
+++ b/src/clicache/src/CqAttributesMutator.cpp
@@ -15,8 +15,12 @@
* limitations under the License.
*/
+#include <memory>
+
+#include "begin_native.hpp"
+#include <geode/QueryService.hpp>
+#include "end_native.hpp"
-//#include "geode_includes.hpp"
#include "CqAttributesMutator.hpp"
#include "impl/ManagedCqListener.hpp"
#include "impl/ManagedCqStatusListener.hpp"
@@ -30,18 +34,18 @@ namespace Apache
{
namespace Client
{
+ namespace native = apache::geode::client;
generic<class TKey, class TResult>
void CqAttributesMutator<TKey, TResult>::AddCqListener( Client::ICqListener<TKey, TResult>^ cqListener )
{
- apache::geode::client::CqListenerPtr listenerptr;
+ native::CqListenerPtr listenerptr;
if ( cqListener != nullptr ) {
- ICqStatusListener<TKey, TResult>^ cqStatusListener =
- dynamic_cast<ICqStatusListener<TKey, TResult>^>(cqListener);
+ auto cqStatusListener = dynamic_cast<ICqStatusListener<TKey, TResult>^>(cqListener);
if (cqStatusListener != nullptr) {
- CqStatusListenerGeneric<TKey, TResult>^ sLstr = gcnew CqStatusListenerGeneric<TKey, TResult>();
+ auto sLstr = gcnew CqStatusListenerGeneric<TKey, TResult>();
sLstr->AddCqListener(cqListener);
- listenerptr = new apache::geode::client::ManagedCqStatusListenerGeneric(cqListener);
+ listenerptr = std::shared_ptr<native::ManagedCqStatusListenerGeneric>(new native::ManagedCqStatusListenerGeneric(cqListener));
try {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->ContainsKey(cqListener) ) {
@@ -54,14 +58,13 @@ namespace Apache
finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
- ((apache::geode::client::ManagedCqStatusListenerGeneric*)listenerptr.get())->setptr(sLstr);
+ ((native::ManagedCqStatusListenerGeneric*)listenerptr.get())->setptr(sLstr);
}
else {
//TODO::split
- CqListenerGeneric<TKey, TResult>^ cqlg = gcnew CqListenerGeneric<TKey, TResult>();
+ auto cqlg = gcnew CqListenerGeneric<TKey, TResult>();
cqlg->AddCqListener(cqListener);
- //listenerptr = new apache::geode::client::ManagedCqListenerGeneric((ICqListener<Object^, Object^>^)cqListener );
- listenerptr = new apache::geode::client::ManagedCqListenerGeneric( /*clg,*/ cqListener );
+ listenerptr = std::shared_ptr<native::ManagedCqListenerGeneric>(new native::ManagedCqListenerGeneric(cqListener));
try {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->ContainsKey(cqListener) ) {
@@ -73,45 +76,68 @@ namespace Apache
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
- ((apache::geode::client::ManagedCqListenerGeneric*)listenerptr.get())->setptr(cqlg);
+ ((native::ManagedCqListenerGeneric*)listenerptr.get())->setptr(cqlg);
}
}
- NativePtr->addCqListener( listenerptr );
+ try
+ {
+ m_nativeptr->get()->addCqListener( listenerptr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
generic<class TKey, class TResult>
void CqAttributesMutator<TKey, TResult>::RemoveCqListener( Client::ICqListener<TKey, TResult>^ cqListener )
{
- Client::ICqStatusListener<TKey, TResult>^ lister = dynamic_cast<Client::ICqStatusListener<TKey, TResult>^>(cqListener);
+ auto lister = dynamic_cast<Client::ICqStatusListener<TKey, TResult>^>(cqListener);
if (lister != nullptr) {
- CqStatusListenerGeneric<TKey, TResult>^ cqlg = gcnew CqStatusListenerGeneric<TKey, TResult>();
+ auto cqlg = gcnew CqStatusListenerGeneric<TKey, TResult>();
cqlg->AddCqListener(cqListener);
- apache::geode::client::CqStatusListenerPtr lptr(new apache::geode::client::ManagedCqStatusListenerGeneric(
- (Client::ICqStatusListener<TKey, TResult>^) lister ));
- ((apache::geode::client::ManagedCqStatusListenerGeneric*)lptr.get())->setptr(cqlg);
+ native::CqStatusListenerPtr lptr = std::shared_ptr<native::ManagedCqStatusListenerGeneric>(
+ new native::ManagedCqStatusListenerGeneric(lister));
+ ((native::ManagedCqStatusListenerGeneric*)lptr.get())->setptr(cqlg);
try {
IntPtr value;
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->TryGetValue(cqListener, value) ) {
- apache::geode::client::CqStatusListenerPtr lptr((apache::geode::client::CqStatusListener*)value.ToPointer());
- NativePtr->removeCqListener(lptr);
+ // TODO shared_ptr this will break, need to keep shared_ptr
+ native::CqStatusListenerPtr lptr((native::CqStatusListener*)value.ToPointer());
+ try
+ {
+ m_nativeptr->get()->removeCqListener(lptr);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
}
else {
- CqListenerGeneric<TKey, TResult>^ cqlg = gcnew CqListenerGeneric<TKey, TResult>();
+ auto cqlg = gcnew CqListenerGeneric<TKey, TResult>();
cqlg->AddCqListener(cqListener);
- apache::geode::client::CqListenerPtr lptr(new apache::geode::client::ManagedCqListenerGeneric(
- (Client::ICqListener<TKey, TResult>^) cqListener ));
- ((apache::geode::client::ManagedCqListenerGeneric*)lptr.get())->setptr(cqlg);
+ native::CqListenerPtr lptr = std::shared_ptr<native::ManagedCqListenerGeneric>(
+ new native::ManagedCqListenerGeneric(cqListener));
+ ((native::ManagedCqListenerGeneric*)lptr.get())->setptr(cqlg);
try {
IntPtr value;
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->TryGetValue(cqListener, value) ) {
- apache::geode::client::CqListenerPtr lptr((apache::geode::client::CqListener*)value.ToPointer());
- NativePtr->removeCqListener(lptr);
+ // TODO shared_ptr this will break, need to keep shared_ptr
+ native::CqListenerPtr lptr((native::CqListener*)value.ToPointer());
+ try
+ {
+ m_nativeptr->get()->removeCqListener(lptr);
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
}
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
@@ -122,15 +148,14 @@ namespace Apache
generic<class TKey, class TResult>
void CqAttributesMutator<TKey, TResult>::SetCqListeners(array<Client::ICqListener<TKey, TResult>^>^ newListeners)
{
- apache::geode::client::VectorOfCqListener vrr;
+ native::CqAttributes::listener_container_type vrr;
for( int i = 0; i < newListeners->Length; i++ )
{
- Client::ICqStatusListener<TKey, TResult>^ lister = dynamic_cast<Client::ICqStatusListener<TKey, TResult>^>(newListeners[i]);
+ auto lister = dynamic_cast<Client::ICqStatusListener<TKey, TResult>^>(newListeners[i]);
if (lister != nullptr) {
- apache::geode::client::CqStatusListenerPtr cptr(new apache::geode::client::ManagedCqStatusListenerGeneric(
- (ICqStatusListener<TKey, TResult>^)lister ));
+ auto cptr = std::shared_ptr<native::ManagedCqStatusListenerGeneric>(new native::ManagedCqStatusListenerGeneric(lister));
vrr.push_back(cptr);
- CqStatusListenerGeneric<TKey, TResult>^ cqlg = gcnew CqStatusListenerGeneric<TKey, TResult>();
+ auto cqlg = gcnew CqStatusListenerGeneric<TKey, TResult>();
cqlg->AddCqListener(newListeners[i]);
try {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
@@ -143,14 +168,13 @@ namespace Apache
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
- ((apache::geode::client::ManagedCqStatusListenerGeneric*)vrr[i].get())->setptr(cqlg);
+ ((native::ManagedCqStatusListenerGeneric*)vrr[i].get())->setptr(cqlg);
}
else {
- Client::ICqListener<TKey, TResult>^ lister = newListeners[i];
- apache::geode::client::CqListenerPtr cptr(new apache::geode::client::ManagedCqListenerGeneric(
- (ICqListener<TKey, TResult>^)lister ));
+ auto lister = newListeners[i];
+ auto cptr = std::shared_ptr<native::ManagedCqListenerGeneric>(new native::ManagedCqListenerGeneric(lister));
vrr.push_back(cptr);
- CqListenerGeneric<TKey, TResult>^ cqlg = gcnew CqListenerGeneric<TKey, TResult>();
+ auto cqlg = gcnew CqListenerGeneric<TKey, TResult>();
cqlg->AddCqListener(newListeners[i]);
try {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
@@ -163,13 +187,19 @@ namespace Apache
} finally {
CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
}
- ((apache::geode::client::ManagedCqListenerGeneric*)vrr[i].get())->setptr(cqlg);
+ ((native::ManagedCqListenerGeneric*)vrr[i].get())->setptr(cqlg);
}
}
- NativePtr->setCqListeners( vrr );
+ try
+ {
+ m_nativeptr->get()->setCqListeners( vrr );
+ }
+ finally
+ {
+ GC::KeepAlive(m_nativeptr);
+ }
+ }
} // namespace Client
} // namespace Geode
} // namespace Apache
-
-} //namespace
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqAttributesMutator.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributesMutator.hpp b/src/clicache/src/CqAttributesMutator.hpp
index 2aafb5c..498de30 100644
--- a/src/clicache/src/CqAttributesMutator.hpp
+++ b/src/clicache/src/CqAttributesMutator.hpp
@@ -18,8 +18,12 @@
#pragma once
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CqAttributesMutator.hpp>
-#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
+
+#include "native_shared_ptr.hpp"
using namespace System;
@@ -32,6 +36,7 @@ namespace Apache
{
namespace Client
{
+ namespace native = apache::geode::client;
generic<class TKey, class TResult>
interface class ICqListener;
@@ -52,7 +57,6 @@ namespace Apache
/// </summary>
generic<class TKey, class TResult>
public ref class CqAttributesMutator sealed
- : public Internal::SBWrap<apache::geode::client::CqAttributesMutator>
{
public:
@@ -87,13 +91,10 @@ namespace Apache
/// <returns>
/// The managed wrapper object; null if the native pointer is null.
/// </returns>
- inline static Client::CqAttributesMutator<TKey, TResult>^ Create( apache::geode::client::CqAttributesMutator* nativeptr )
+ inline static Client::CqAttributesMutator<TKey, TResult>^ Create( native::CqAttributesMutatorPtr nativeptr )
{
- if (nativeptr == nullptr)
- {
- return nullptr;
- }
- return gcnew Client::CqAttributesMutator<TKey, TResult>( nativeptr );
+ return __nullptr == nativeptr ? nullptr :
+ gcnew Client::CqAttributesMutator<TKey, TResult>( nativeptr );
}
@@ -103,8 +104,12 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CqAttributesMutator<TKey, TResult>( apache::geode::client::CqAttributesMutator* nativeptr )
- : SBWrap( nativeptr ) { }
+ inline CqAttributesMutator<TKey, TResult>( native::CqAttributesMutatorPtr nativeptr )
+ {
+ m_nativeptr = gcnew native_shared_ptr<native::CqAttributesMutator>(nativeptr);
+ }
+
+ native_shared_ptr<native::CqAttributesMutator>^ m_nativeptr;
};
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqEvent.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqEvent.cpp b/src/clicache/src/CqEvent.cpp
index a8d4109..ae1c668 100644
--- a/src/clicache/src/CqEvent.cpp
+++ b/src/clicache/src/CqEvent.cpp
@@ -28,45 +28,46 @@ namespace Apache
{
namespace Client
{
+ namespace native = apache::geode::client;
generic<class TKey, class TResult>
CqQuery<TKey, TResult>^ CqEvent<TKey, TResult>::getCq( )
{
- apache::geode::client::CqQueryPtr& cQueryptr( NativePtr->getCq( ) );
- return CqQuery<TKey, TResult>::Create( cQueryptr.ptr( ) );
+ native::CqQueryPtr& cQueryptr( m_nativeptr->getCq( ) );
+ return CqQuery<TKey, TResult>::Create( cQueryptr);
}
generic<class TKey, class TResult>
CqOperationType CqEvent<TKey, TResult>::getBaseOperation( )
{
- return CqOperation::ConvertFromNative(NativePtr->getBaseOperation());
+ return CqOperation::ConvertFromNative(m_nativeptr->getBaseOperation());
}
generic<class TKey, class TResult>
CqOperationType CqEvent<TKey, TResult>::getQueryOperation( )
{
- return CqOperation::ConvertFromNative(NativePtr->getQueryOperation());
+ return CqOperation::ConvertFromNative(m_nativeptr->getQueryOperation());
}
generic<class TKey, class TResult>
TKey CqEvent<TKey, TResult>::getKey( )
{
- apache::geode::client::CacheableKeyPtr& keyptr( NativePtr->getKey( ) );
+ native::CacheableKeyPtr& keyptr( m_nativeptr->getKey( ) );
return Serializable::GetManagedValueGeneric<TKey>(keyptr);
}
generic<class TKey, class TResult>
TResult CqEvent<TKey, TResult>::getNewValue( )
{
- apache::geode::client::CacheablePtr& valptr( NativePtr->getNewValue( ) );
+ native::CacheablePtr& valptr( m_nativeptr->getNewValue( ) );
return Serializable::GetManagedValueGeneric<TResult>(valptr);
}
generic<class TKey, class TResult>
array< Byte >^ CqEvent<TKey, TResult>::getDeltaValue( )
{
- apache::geode::client::CacheableBytesPtr deltaBytes = NativePtr->getDeltaValue( );
- CacheableBytes^ managedDeltaBytes = ( CacheableBytes^ ) CacheableBytes::Create( deltaBytes.ptr( ) );
+ auto deltaBytes = m_nativeptr->getDeltaValue( );
+ auto managedDeltaBytes = ( CacheableBytes^ ) CacheableBytes::Create( deltaBytes );
return ( array< Byte >^ ) managedDeltaBytes;
}
} // namespace Client
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqEvent.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqEvent.hpp b/src/clicache/src/CqEvent.hpp
index 5e12595..d0ddcc1 100644
--- a/src/clicache/src/CqEvent.hpp
+++ b/src/clicache/src/CqEvent.hpp
@@ -17,11 +17,14 @@
#pragma once
+#include "native_shared_ptr.hpp"
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CqEvent.hpp>
+#include "end_native.hpp"
+
#include "CqQuery.hpp"
#include "CqOperation.hpp"
-//#include "impl/NativeWrapper.hpp"
#include "ICqEvent.hpp"
#include "ICacheableKey.hpp"
@@ -34,17 +37,15 @@ namespace Apache
{
namespace Client
{
+ namespace native = apache::geode::client;
interface class IGeodeSerializable;
- //interface class ICqEvent;
- //interface class ICacheableKey;
-
+
/// <summary>
/// This class encapsulates events that occur for cq.
/// </summary>
generic<class TKey, class TResult>
public ref class CqEvent sealed
- : public Internal::UMWrap<apache::geode::client::CqEvent>
{
public:
@@ -85,8 +86,18 @@ namespace Apache
/// Private constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CqEvent( const apache::geode::client::CqEvent* nativeptr )
- : UMWrap( const_cast<apache::geode::client::CqEvent*>( nativeptr ), false ) { }
+ inline CqEvent( const native::CqEvent* nativeptr )
+ : m_nativeptr(nativeptr)
+ {
+ }
+
+ const native::CqEvent* GetNative()
+ {
+ return m_nativeptr;
+ }
+
+ private:
+ const native::CqEvent* m_nativeptr;
};
} // namespace Client
} // namespace Geode
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqListener.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqListener.hpp b/src/clicache/src/CqListener.hpp
deleted file mode 100644
index 977447f..0000000
--- a/src/clicache/src/CqListener.hpp
+++ /dev/null
@@ -1,112 +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.
- */
-
-#pragma once
-
-#include "geode_defs.hpp"
-#include "ICqListener.hpp"
-//#include "impl/NativeWrapper.hpp"
-
-
-using namespace System;
-using namespace System::Collections::Generic;
-
-namespace Apache
-{
- namespace Geode
- {
- namespace Client
- {
-
- generic<class TKey, class TResult>
- ref class CqEvent;
- //interface class ICqListener;
-
- /// <summary>
- /// This class wraps the native C++ <c>apache::geode::client::Serializable</c> objects
- /// as managed <see cref="../../IGeodeSerializable" /> objects.
- /// </summary>
- generic<class TKey, class TResult>
- public ref class CqListener
- : public Internal::SBWrap<apache::geode::client::CqListener>, public ICqListener<TKey, TResult>
- {
- public:
-
- /// <summary>
- /// Invoke on an event
- /// </summary>
- virtual void OnEvent( CqEvent<TKey, TResult>^ ev)
- {
- }
-
- /// <summary>
- /// Invoke on an error
- /// </summary>
- virtual void OnError( CqEvent<TKey, TResult>^ ev)
- {
- }
-
- /// <summary>
- /// Invoke on close
- /// </summary>
- virtual void Close()
- {
- }
-
- internal:
-
- /// <summary>
- /// Default constructor.
- /// </summary>
- inline CqListener<TKey, TResult>( )
- : SBWrap( ) { }
-
- /// <summary>
- /// Internal constructor to wrap a native object pointer
- /// </summary>
- /// <param name="nativeptr">The native object pointer</param>
- inline CqListener<TKey, TResult>( apache::geode::client::CqListener* nativeptr )
- : SBWrap( nativeptr ) { }
-
- /// <summary>
- /// Used to assign the native Serializable pointer to a new object.
- /// </summary>
- /// <remarks>
- /// Note the order of preserveSB() and releaseSB(). This handles the
- /// corner case when <c>m_nativeptr</c> is same as <c>nativeptr</c>.
- /// </remarks>
- inline void AssignSP( apache::geode::client::CqListener* nativeptr )
- {
- AssignPtr( nativeptr );
- }
-
- /// <summary>
- /// Used to assign the native CqListener pointer to a new object.
- /// </summary>
- inline void SetSP( apache::geode::client::CqListener* nativeptr )
- {
- if ( nativeptr != nullptr ) {
- nativeptr->preserveSB( );
- }
- _SetNativePtr( nativeptr );
- }
-
- };
- } // namespace Client
- } // namespace Geode
-} // namespace Apache
-
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CqOperation.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqOperation.hpp b/src/clicache/src/CqOperation.hpp
index c092008..e6292c9 100644
--- a/src/clicache/src/CqOperation.hpp
+++ b/src/clicache/src/CqOperation.hpp
@@ -20,7 +20,10 @@
#pragma once
#include "geode_defs.hpp"
+#include "begin_native.hpp"
#include <geode/CqOperation.hpp>
+#include "end_native.hpp"
+
using namespace System;
@@ -31,6 +34,7 @@ namespace Apache
{
namespace Client
{
+ namespace native = apache::geode::client;
/// <summary>
/// Enumerated type for CqOperationType
@@ -45,29 +49,29 @@ namespace Apache
OP_TYPE_DESTROY = 16,
OP_TYPE_MARKER = 32
};
+
public ref class CqOperation sealed
- : public Internal::UMWrap<apache::geode::client::CqOperation>
{
public:
/// <summary>
/// conenience function for convertin from c++
- /// apache::geode::client::CqOperation::CqOperationType to
+ /// native::CqOperation::CqOperationType to
/// CqOperationType here.
/// </summary>
- inline static CqOperationType ConvertFromNative(apache::geode::client::CqOperation::CqOperationType tp)
+ inline static CqOperationType ConvertFromNative(native::CqOperation::CqOperationType tp)
{
- if(tp==apache::geode::client::CqOperation::OP_TYPE_CREATE)
+ if(tp==native::CqOperation::OP_TYPE_CREATE)
return CqOperationType::OP_TYPE_CREATE;
- if(tp==apache::geode::client::CqOperation::OP_TYPE_UPDATE)
+ if(tp==native::CqOperation::OP_TYPE_UPDATE)
return CqOperationType::OP_TYPE_UPDATE;
- if(tp==apache::geode::client::CqOperation::OP_TYPE_INVALIDATE)
+ if(tp==native::CqOperation::OP_TYPE_INVALIDATE)
return CqOperationType::OP_TYPE_INVALIDATE;
- if(tp==apache::geode::client::CqOperation::OP_TYPE_REGION_CLEAR)
+ if(tp==native::CqOperation::OP_TYPE_REGION_CLEAR)
return CqOperationType::OP_TYPE_REGION_CLEAR;
- if(tp==apache::geode::client::CqOperation::OP_TYPE_DESTROY)
+ if(tp==native::CqOperation::OP_TYPE_DESTROY)
return CqOperationType::OP_TYPE_DESTROY;
- if(tp==apache::geode::client::CqOperation::OP_TYPE_MARKER)
+ if(tp==native::CqOperation::OP_TYPE_MARKER)
return CqOperationType::OP_TYPE_MARKER;
return CqOperationType::OP_TYPE_INVALID;
}
@@ -77,8 +81,13 @@ namespace Apache
/// Internal constructor to wrap a native object pointer
/// </summary>
/// <param name="nativeptr">The native object pointer</param>
- inline CqOperation( apache::geode::client::CqOperation* nativeptr )
- : UMWrap( nativeptr, false ) { }
+ inline CqOperation( native::CqOperation* nativeptr )
+ : m_nativeptr(nativeptr)
+ {
+ }
+
+ private:
+ const native::CqOperation* m_nativeptr;
};
} // namespace Client
} // namespace Geode