http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableLinkedList.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableLinkedList.hpp b/src/clicache/src/CacheableLinkedList.hpp
new file mode 100644
index 0000000..041a6e1
--- /dev/null
+++ b/src/clicache/src/CacheableLinkedList.hpp
@@ -0,0 +1,142 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "CacheableVector.hpp"
+
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ /// <summary>
+ /// A mutable <c>IGFSerializable</c> vector wrapper that can serve as
+ /// a distributable object for caching. This class extends .NET generic
+ /// <c>List</c> class.
+ /// </summary>
+ ref class CacheableLinkedList
+ : public IGFSerializable
+ {
+ System::Collections::Generic::LinkedList<Object^>^ m_linkedList;
+ public:
+ /// <summary>
+ /// Allocates a new empty instance.
+ /// </summary>
+ inline CacheableLinkedList(System::Collections::Generic::LinkedList<Object^>^ list)
+ {
+ m_linkedList = list;
+ }
+
+
+ /// <summary>
+ /// Static function to create a new empty instance.
+ /// </summary>
+ inline static CacheableLinkedList^ Create()
+ {
+ return gcnew CacheableLinkedList(gcnew System::Collections::Generic::LinkedList<Object^>());
+ }
+
+ /// <summary>
+ /// Static function to create a new empty instance.
+ /// </summary>
+ inline static CacheableLinkedList^ Create(System::Collections::Generic::LinkedList<Object^>^ list)
+ {
+ return gcnew CacheableLinkedList(list);
+ }
+
+
+ // Region: IGFSerializable Members
+
+ /// <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ virtual uint32_t get()
+ {
+ return GemFireClassIds::CacheableLinkedList;
+ }
+ }
+
+ // Region: IGFSerializable Members
+
+ virtual void ToData(DataOutput^ output)
+ {
+ if(m_linkedList != nullptr)
+ {
+ output->WriteArrayLen(m_linkedList->Count);
+ for each (Object^ obj in m_linkedList) {
+ //TODO::split
+ output->WriteObject(obj);
+ }
+ }
+ else
+ output->WriteByte(0xFF);
+ }
+
+ virtual IGFSerializable^ FromData(DataInput^ input)
+ {
+ int len = input->ReadArrayLen();
+ for( int i = 0; i < len; i++)
+ {
+ m_linkedList->AddLast(input->ReadObject());
+ }
+ return this;
+ }
+
+ /*uint32_t ObjectSize::get()
+ {
+ //TODO::
+ uint32_t size = static_cast<uint32_t> (sizeof(CacheableVector^));
+ for each (IGFSerializable^ val in this) {
+ if (val != nullptr) {
+ size += val->ObjectSize;
+ }
+ }
+ return m_linkedList->Count;
+ }*/
+
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get()
+ {
+ return m_linkedList->Count;
+ }
+ }
+
+ virtual property System::Collections::Generic::LinkedList<Object^>^ Value
+ {
+ virtual System::Collections::Generic::LinkedList<Object^>^ get()
+ {
+ return m_linkedList;
+ }
+ }
+ // End Region: IGFSerializable Members
+
+ /// <summary>
+ /// Factory function to register this class.
+ /// </summary>
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableLinkedList(gcnew System::Collections::Generic::LinkedList<Object^>());
+ }
+ };
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableObject.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableObject.cpp b/src/clicache/src/CacheableObject.cpp
new file mode 100644
index 0000000..17df515
--- /dev/null
+++ b/src/clicache/src/CacheableObject.cpp
@@ -0,0 +1,72 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+
+//#include "gf_includes.hpp"
+#include "CacheableObject.hpp"
+#include "DataInput.hpp"
+#include "DataOutput.hpp"
+#include "impl/GFNullStream.hpp"
+#include "impl/GFDataInputStream.hpp"
+#include "impl/GFDataOutputStream.hpp"
+
+using namespace System;
+using namespace System::IO;
+using namespace System::Runtime::Serialization::Formatters::Binary;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ void CacheableObject::ToData(DataOutput^ output)
+ {
+ if(m_obj != nullptr)
+ {
+ output->AdvanceCursor(4); // placeholder for object size bytes needed while reading back.
+
+ GFDataOutputStream dos(output);
+ BinaryFormatter bf;
+ int64_t checkpoint = dos.Length;
+ bf.Serialize(%dos, m_obj);
+ m_objectSize = (uint32_t) (dos.Length - checkpoint);
+
+ output->RewindCursor(m_objectSize + 4);
+ output->WriteInt32(m_objectSize);
+ output->AdvanceCursor(m_objectSize);
+ }
+ }
+
+ IGFSerializable^ CacheableObject::FromData(DataInput^ input)
+ {
+ int maxSize = input->ReadInt32();
+ GFDataInputStream dis(input, maxSize);
+ uint32_t checkpoint = dis.BytesRead;
+ BinaryFormatter bf;
+ m_obj = bf.Deserialize(%dis);
+ m_objectSize = dis.BytesRead - checkpoint;
+ return this;
+ }
+
+ uint32_t CacheableObject::ObjectSize::get()
+ {
+ if (m_objectSize == 0) {
+ GFNullStream ns;
+ BinaryFormatter bf;
+ bf.Serialize(%ns, m_obj);
+
+ m_objectSize = (uint32_t)sizeof(CacheableObject^) + (uint32_t)ns.Length;
+ }
+ return m_objectSize;
+ }
+ }
+ }
+}
+ } //namespace
+
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableObject.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableObject.hpp b/src/clicache/src/CacheableObject.hpp
new file mode 100644
index 0000000..d1037ae
--- /dev/null
+++ b/src/clicache/src/CacheableObject.hpp
@@ -0,0 +1,146 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "IGFSerializable.hpp"
+#include "GemFireClassIds.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ /// <summary>
+ /// An mutable generic <see cref="System.Object" /> wrapper that can
+ /// serve as a distributable value for caching.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class can serialize any class which has either the
+ /// [Serializable] attribute set or implements
+ /// <see cref="System.Runtime.Serialization.ISerializable" /> interface.
+ /// However, for better efficiency the latter should be avoided and the
+ /// user should implement <see cref="../../IGFSerializable" /> instead.
+ /// </para><para>
+ /// The user must keep in mind that the rules that apply to runtime
+ /// serialization would be the rules that apply to this class. For
+ /// the serialization will be carried out by serializing all the
+ /// members (public/private/protected) of the class. Each of the
+ /// contained classes should also have either the [Serializable]
+ /// attribute set or implement <c>ISerializable</c> interface.
+ /// </para>
+ /// </remarks>
+ public ref class CacheableObject
+ : public IGFSerializable
+ {
+ public:
+ /// <summary>
+ /// Static function to create a new instance from the given object.
+ /// </summary>
+ /// <remarks>
+ /// If the given object is null then this method returns null.
+ /// </remarks>
+ inline static CacheableObject^ Create(Object^ value)
+ {
+ return (value != nullptr ? gcnew CacheableObject(value) :
+ nullptr);
+ }
+
+ /// <summary>
+ /// Serializes this <see cref="System.Object" /> using
+ /// <see cref="System.Runtime.Serialization.Formatters.Binary.BinaryFormatter" /> class.
+ /// </summary>
+ /// <param name="output">
+ /// the DataOutput object to use for serializing the object
+ /// </param>
+ virtual void ToData(DataOutput^ output);
+
+ /// <summary>
+ /// Deserializes the <see cref="System.Object" /> using
+ /// <see cref="System.Runtime.Serialization.Formatters.Binary.BinaryFormatter" /> class.
+ /// </summary>
+ /// <param name="input">
+ /// the DataInput stream to use for reading the object data
+ /// </param>
+ /// <returns>the deserialized object</returns>
+ virtual IGFSerializable^ FromData(DataInput^ input);
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get();
+ }
+
+ /// <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ inline virtual uint32_t get()
+ {
+ return GemFireClassIds::CacheableManagedObject;
+ }
+ }
+
+ /// <summary>
+ /// Gets the object value.
+ /// </summary>
+ /// <remarks>
+ /// The user can modify the object and the changes shall be reflected
+ /// immediately in the local cache. For this change to be propagate to
+ /// other members of the distributed system, the object needs to be
+ /// put into the cache.
+ /// </remarks>
+ property Object^ Value
+ {
+ inline Object^ get()
+ {
+ return m_obj;
+ }
+ }
+
+ virtual String^ ToString() override
+ {
+ return (m_obj == nullptr ? nullptr : m_obj->ToString());
+ }
+
+ /// <summary>
+ /// Factory function to register this class.
+ /// </summary>
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableObject(nullptr);
+ }
+
+ internal:
+ /// <summary>
+ /// Allocates a new instance from the given object.
+ /// </summary>
+ inline CacheableObject(Object^ value)
+ : m_obj(value), m_objectSize(0) { }
+
+
+
+ private:
+ Object^ m_obj;
+ uint32_t m_objectSize;
+ };
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableObjectArray.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableObjectArray.cpp b/src/clicache/src/CacheableObjectArray.cpp
new file mode 100644
index 0000000..a0aa643
--- /dev/null
+++ b/src/clicache/src/CacheableObjectArray.cpp
@@ -0,0 +1,113 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+
+
+//#include "gf_includes.hpp"
+#include <GemfireTypeIdsImpl.hpp>
+#include "CacheableObjectArray.hpp"
+#include "DataOutput.hpp"
+#include "DataInput.hpp"
+#include "ExceptionTypes.hpp"
+#include "impl/SafeConvert.hpp"
+#include "impl/PdxTypeRegistry.hpp"
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ // Region: IGFSerializable Members
+
+ void CacheableObjectArray::ToData(DataOutput^ output)
+ {
+ output->WriteArrayLen((int32_t)Count);
+ output->WriteByte((int8_t)gemfire::GemfireTypeIdsImpl::Class);
+ output->WriteByte((int8_t)gemfire::GemfireTypeIds::CacheableASCIIString);
+ output->WriteUTF("java.lang.Object");
+
+ for each (Object^ obj in this) {
+ //TODO::split
+ output->WriteObject(obj);
+ }
+
+ /*_GF_MG_EXCEPTION_TRY
+
+ gemfire::DataOutput& nativeOutput = *(output->_NativePtr);
+ nativeOutput.writeArrayLen((int32_t)Count);
+ nativeOutput.write((int8_t)gemfire::GemfireTypeIdsImpl::Class);
+ nativeOutput.write((int8_t)gemfire::GemfireTypeIds::CacheableASCIIString);
+ nativeOutput.writeASCII("java.lang.Object");
+ for each (IGFSerializable^ obj in this) {
+ gemfire::SerializablePtr objPtr(SafeMSerializableConvert(obj));
+ nativeOutput.writeObject(objPtr);
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL*/
+ }
+
+ IGFSerializable^ CacheableObjectArray::FromData(DataInput^ input)
+ {
+ int len = input->ReadArrayLen();
+ if (len >= 0) {
+ //int8_t typeCode;
+ input->ReadByte(); // ignore CLASS typeid
+ input->ReadByte(); // ignore string typeid
+ unsigned short classLen;
+ classLen = input->ReadInt16();
+ input->AdvanceCursor(classLen);
+ //nativeInput.readInt(&classLen);
+ //nativeInput.advanceCursor(classLen);
+ }
+ for (int32_t index = 0; index < len; ++index) {
+ Add(input->ReadObject());
+ }
+ return this;
+ /*_GF_MG_EXCEPTION_TRY
+
+ gemfire::DataInput& nativeInput = *(input->_NativePtr);
+ int32_t len;
+ nativeInput.readArrayLen(&len);
+ if (len >= 0) {
+ int8_t typeCode;
+ nativeInput.read(&typeCode); // ignore CLASS typeid
+ nativeInput.read(&typeCode); // ignore string typeid
+ uint16_t classLen;
+ nativeInput.readInt(&classLen);
+ nativeInput.advanceCursor(classLen);
+ }
+ gemfire::CacheablePtr value;
+ for (int32_t index = 0; index < len; ++index) {
+ nativeInput.readObject(value);
+ Add(SafeUMSerializableConvert(value.ptr()));
+ }
+
+ _GF_MG_EXCEPTION_CATCH_ALL
+ return this;*/
+ }
+
+ uint32_t CacheableObjectArray::ObjectSize::get()
+ {
+ /* uint32_t size = static_cast<uint32_t> (sizeof(CacheableObjectArray^));
+ for each (IGFSerializable^ val in this) {
+ if (val != nullptr) {
+ size += val->ObjectSize;
+ }
+ }*/
+ return Count;
+ }
+ // End Region: IGFSerializable Members
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableObjectArray.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableObjectArray.hpp b/src/clicache/src/CacheableObjectArray.hpp
new file mode 100644
index 0000000..cf8b178
--- /dev/null
+++ b/src/clicache/src/CacheableObjectArray.hpp
@@ -0,0 +1,145 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "IGFSerializable.hpp"
+#include "GemFireClassIds.hpp"
+
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+
+ /// <summary>
+ /// A mutable <c>IGFSerializable</c> object array wrapper that can serve
+ /// as a distributable object for caching. Though this class provides
+ /// compatibility with java Object[] serialization, it provides the
+ /// semantics of .NET generic <c>List</c> class.
+ /// </summary>
+ public ref class CacheableObjectArray
+ : public List<Object^>, public IGFSerializable
+ {
+ public:
+ /// <summary>
+ /// Allocates a new empty instance.
+ /// </summary>
+ inline CacheableObjectArray()
+ : List<Object^>()
+ { }
+
+ /// <summary>
+ /// Allocates a new instance copying from the given collection.
+ /// </summary>
+ /// <param name="collection">
+ /// The collection whose elements are copied to this list.
+ /// </param>
+ inline CacheableObjectArray(IEnumerable<Object^>^ collection)
+ : List<Object^>(collection)
+ { }
+
+ /// <summary>
+ /// Allocates a new empty instance with given initial size.
+ /// </summary>
+ /// <param name="capacity">
+ /// The initial capacity of the vector.
+ /// </param>
+ inline CacheableObjectArray(int32_t capacity)
+ : List<Object^>(capacity)
+ { }
+
+ /// <summary>
+ /// Static function to create a new empty instance.
+ /// </summary>
+ inline static CacheableObjectArray^ Create()
+ {
+ return gcnew CacheableObjectArray();
+ }
+
+ /// <summary>
+ /// Static function to create a new instance copying from the
+ /// given collection.
+ /// </summary>
+ inline static CacheableObjectArray^ Create(
+ IEnumerable<Object^>^ collection)
+ {
+ return gcnew CacheableObjectArray(collection);
+ }
+
+ /// <summary>
+ /// Static function to create a new instance with given initial size.
+ /// </summary>
+ inline static CacheableObjectArray^ Create(int32_t capacity)
+ {
+ return gcnew CacheableObjectArray(capacity);
+ }
+
+ // Region: IGFSerializable Members
+
+ /// <summary>
+ /// Serializes this object.
+ /// </summary>
+ /// <param name="output">
+ /// the DataOutput object to use for serializing the object
+ /// </param>
+ virtual void ToData(DataOutput^ output);
+
+ /// <summary>
+ /// Deserialize this object, typical implementation should return
+ /// the 'this' pointer.
+ /// </summary>
+ /// <param name="input">
+ /// the DataInput stream to use for reading the object data
+ /// </param>
+ /// <returns>the deserialized object</returns>
+ virtual IGFSerializable^ FromData(DataInput^ input);
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get();
+ }
+
+ /// <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ virtual uint32_t get()
+ {
+ return GemFireClassIds::CacheableObjectArray;
+ }
+ }
+
+ // End Region: IGFSerializable Members
+
+ /// <summary>
+ /// Factory function to register this class.
+ /// </summary>
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableObjectArray();
+ }
+ };
+
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableObjectXml.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableObjectXml.cpp b/src/clicache/src/CacheableObjectXml.cpp
new file mode 100644
index 0000000..b2e4073
--- /dev/null
+++ b/src/clicache/src/CacheableObjectXml.cpp
@@ -0,0 +1,101 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+
+
+//#include "gf_includes.hpp"
+#include "CacheableObjectXml.hpp"
+#include "DataInput.hpp"
+#include "DataOutput.hpp"
+#include "Log.hpp"
+#include "impl/GFNullStream.hpp"
+#include "impl/GFDataInputStream.hpp"
+#include "impl/GFDataOutputStream.hpp"
+
+using namespace System;
+using namespace System::IO;
+using namespace System::Xml::Serialization;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ void CacheableObjectXml::ToData(DataOutput^ output)
+ {
+ if (m_obj == nullptr) {
+ output->WriteByte((Byte)1);
+ }
+ else
+ {
+ output->WriteByte((Byte)0);
+ Type^ objType = m_obj->GetType();
+
+ output->WriteUTF(objType->AssemblyQualifiedName);
+
+ output->AdvanceCursor(4); // placeholder for object size bytes needed while reading back.
+
+ XmlSerializer xs(objType);
+ GFDataOutputStream dos(output);
+ int64_t checkpoint = dos.Length;
+ xs.Serialize(%dos, m_obj);
+ m_objectSize = (uint32_t) (dos.Length - checkpoint);
+
+ output->RewindCursor(m_objectSize + 4);
+ output->WriteInt32(m_objectSize);
+ output->AdvanceCursor(m_objectSize);
+ }
+ }
+
+ IGFSerializable^ CacheableObjectXml::FromData(DataInput^ input)
+ {
+ Byte isNull = input->ReadByte();
+ if (isNull) {
+ m_obj = nullptr;
+ }
+ else {
+ String^ typeName = input->ReadUTF();
+ Type^ objType = Type::GetType(typeName);
+ if (objType == nullptr)
+ {
+ Log::Error("CacheableObjectXml.FromData(): Cannot find type '" +
+ typeName + "'.");
+ m_obj = nullptr;
+ }
+ else {
+ int maxSize = input->ReadInt32();
+ GFDataInputStream dis(input, maxSize);
+ XmlSerializer xs(objType);
+ uint32_t checkpoint = dis.BytesRead;
+ m_obj = xs.Deserialize(%dis);
+ m_objectSize = dis.BytesRead - checkpoint;
+ }
+ }
+ return this;
+ }
+
+ uint32_t CacheableObjectXml::ObjectSize::get()
+ {
+ if (m_objectSize == 0) {
+ if (m_obj != nullptr) {
+ Type^ objType = m_obj->GetType();
+ XmlSerializer xs(objType);
+ GFNullStream ns;
+ xs.Serialize(%ns, m_obj);
+
+ m_objectSize = (uint32_t)sizeof(CacheableObjectXml^) + (uint32_t)ns.Length;
+ }
+ }
+ return m_objectSize;
+ }
+ }
+ }
+}
+ } //namespace
+
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableObjectXml.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableObjectXml.hpp b/src/clicache/src/CacheableObjectXml.hpp
new file mode 100644
index 0000000..10a6bc6
--- /dev/null
+++ b/src/clicache/src/CacheableObjectXml.hpp
@@ -0,0 +1,147 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "IGFSerializable.hpp"
+#include "GemFireClassIds.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ /// <summary>
+ /// A mutable generic <see cref="System.Object" /> wrapper that can
+ /// serve as a distributable value for caching.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class can contain any object and uses the
+ /// <see cref="System.Xml.Serialization.XmlSerializer" /> to
+ /// serialize and deserialize the object. So the user must use the
+ /// <c>XmlSerializer</c> attributes to control the serialization/deserialization
+ /// of the object (or implement the <see cref="System.Xml.Serialization.IXmlSerializable" />)
+ /// to change the serialization/deserialization. However, the latter should
+ /// be avoided for efficiency reasons and the user should implement
+ /// <see cref="../../IGFSerializable" /> instead.
+ /// </para><para>
+ /// The user must keep in mind that the rules that apply to <c>XmlSerializer</c>
+ /// would be the rules that apply to this class. For instance the user
+ /// cannot pass objects of class implementing or containing
+ /// <see cref="System.Collections.IDictionary" /> class, must use
+ /// <see cref="System.Xml.Serialization.XmlIncludeAttribute" /> to
+ /// mark user-defined types etc.
+ /// </para>
+ /// </remarks>
+ public ref class CacheableObjectXml
+ : public IGFSerializable
+ {
+ public:
+ /// <summary>
+ /// Static function to create a new instance from the given object.
+ /// </summary>
+ /// <remarks>
+ /// If the given object is null then this method returns null.
+ /// </remarks>
+ inline static CacheableObjectXml^ Create(Object^ value)
+ {
+ return (value != nullptr ? gcnew CacheableObjectXml(value) :
+ nullptr);
+ }
+
+ /// <summary>
+ /// Serializes this <see cref="System.Object" /> using
+ /// <see cref="System.Xml.Serialization.XmlSerializer" /> class.
+ /// </summary>
+ /// <param name="output">
+ /// the DataOutput object to use for serializing the object
+ /// </param>
+ virtual void ToData(DataOutput^ output);
+
+ /// <summary>
+ /// Deserializes the <see cref="System.Object" /> using
+ /// <see cref="System.Xml.Serialization.XmlSerializer" /> class.
+ /// </summary>
+ /// <param name="input">
+ /// the DataInput stream to use for reading the object data
+ /// </param>
+ /// <returns>the deserialized object</returns>
+ virtual IGFSerializable^ FromData(DataInput^ input);
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get();
+ }
+
+ /// <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ inline virtual uint32_t get()
+ {
+ return GemFireClassIds::CacheableManagedObjectXml;
+ }
+ }
+
+ /// <summary>
+ /// Gets the object value.
+ /// </summary>
+ /// <remarks>
+ /// The user can modify the object and the changes shall be reflected
+ /// immediately in the local cache. For this change to be propagate to
+ /// other members of the distributed system, the object needs to be
+ /// put into the cache.
+ /// </remarks>
+ property Object^ Value
+ {
+ inline Object^ get()
+ {
+ return m_obj;
+ }
+ }
+
+ virtual String^ ToString() override
+ {
+ return (m_obj == nullptr ? nullptr : m_obj->ToString());
+ }
+
+ /// <summary>
+ /// Factory function to register this class.
+ /// </summary>
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableObjectXml(nullptr);
+ }
+
+ internal:
+ /// <summary>
+ /// Allocates a new instance from the given object.
+ /// </summary>
+ inline CacheableObjectXml(Object^ value)
+ : m_obj(value), m_objectSize(0) { }
+
+ private:
+ Object^ m_obj;
+ uint32_t m_objectSize;
+ };
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableStack.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableStack.cpp b/src/clicache/src/CacheableStack.cpp
new file mode 100644
index 0000000..386a794
--- /dev/null
+++ b/src/clicache/src/CacheableStack.cpp
@@ -0,0 +1,82 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+
+
+//#include "gf_includes.hpp"
+#include "CacheableStack.hpp"
+#include "DataOutput.hpp"
+#include "DataInput.hpp"
+#include <GemfireTypeIdsImpl.hpp>
+#include "impl/SafeConvert.hpp"
+#include "GemFireClassIds.hpp"
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ // Region: IGFSerializable Members
+
+ void CacheableStack::ToData(DataOutput^ output)
+ {
+ if(m_stack != nullptr)
+ {
+ output->WriteArrayLen((int32_t)m_stack->Count);
+ for each (Object^ obj in m_stack) {
+ output->WriteObject(obj);
+ }
+ }
+ else
+ {
+ output->WriteByte(0xFF);
+ }
+ }
+
+ IGFSerializable^ CacheableStack::FromData(DataInput^ input)
+ {
+ int len = input->ReadArrayLen();
+ if (len > 0)
+ {
+ System::Collections::Generic::Stack<Object^>^ stack = safe_cast<System::Collections::Generic::Stack<Object^>^>(m_stack);
+ for( int i = 0; i < len; i++)
+ {
+ (stack)->Push(input->ReadObject());
+// Push(input->ReadObject());
+ }
+ }
+ return this;
+ }
+
+ uint32_t CacheableStack::ClassId::get()
+ {
+ return GemFireClassIds::CacheableStack;
+ }
+
+ uint32_t CacheableStack::ObjectSize::get()
+ {
+ //TODO:
+ /*uint32_t size = static_cast<uint32_t> (sizeof(CacheableStack^));
+ for each (IGFSerializable^ val in this) {
+ if (val != nullptr) {
+ size += val->ObjectSize;
+ }
+ }*/
+ return m_stack->Count;
+ }
+
+ // End Region: IGFSerializable Members
+ }
+ }
+}
+ } //namespace
+
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableStack.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableStack.hpp b/src/clicache/src/CacheableStack.hpp
new file mode 100644
index 0000000..82e8c22
--- /dev/null
+++ b/src/clicache/src/CacheableStack.hpp
@@ -0,0 +1,120 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "IGFSerializable.hpp"
+
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ /// <summary>
+ /// A mutable <c>IGFSerializable</c> vector wrapper that can serve as
+ /// a distributable object for caching.
+ /// </summary>
+ ref class CacheableStack
+ : public IGFSerializable
+ {
+ public:
+ /// <summary>
+ /// Allocates a new empty instance.
+ /// </summary>
+ inline CacheableStack(System::Collections::ICollection^ stack)
+ {
+ m_stack = stack;
+ }
+
+ /// <summary>
+ /// Static function to create a new empty instance.
+ /// </summary>
+ inline static CacheableStack^ Create()
+ {
+ return gcnew CacheableStack(gcnew System::Collections::Generic::Stack<Object^>());
+ }
+
+ /// <summary>
+ /// Static function to create a new empty instance.
+ /// </summary>
+ inline static CacheableStack^ Create(System::Collections::ICollection^ stack)
+ {
+ return gcnew CacheableStack(stack);
+ }
+
+
+
+ // Region: IGFSerializable Members
+
+ /// <summary>
+ /// Serializes this object.
+ /// </summary>
+ /// <param name="output">
+ /// the DataOutput object to use for serializing the object
+ /// </param>
+ virtual void ToData(DataOutput^ output);
+
+ /// <summary>
+ /// Deserialize this object, typical implementation should return
+ /// the 'this' pointer.
+ /// </summary>
+ /// <param name="input">
+ /// the DataInput stream to use for reading the object data
+ /// </param>
+ /// <returns>the deserialized object</returns>
+ virtual IGFSerializable^ FromData(DataInput^ input);
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get();
+ }
+
+ /// <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ virtual uint32_t get();
+ }
+
+ virtual property System::Collections::ICollection^ Value
+ {
+ virtual System::Collections::ICollection^ get()
+ {
+ return m_stack;
+ }
+ }
+ // End Region: IGFSerializable Members
+
+ /// <summary>
+ /// Factory function to register this class.
+ /// </summary>
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableStack(gcnew System::Collections::Generic::Stack<Object^>());
+ }
+
+ private:
+ System::Collections::ICollection^ m_stack;
+ };
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableString.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableString.cpp b/src/clicache/src/CacheableString.cpp
new file mode 100644
index 0000000..b1a29a8
--- /dev/null
+++ b/src/clicache/src/CacheableString.cpp
@@ -0,0 +1,202 @@
+/*=========================================================================
+* Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+*=========================================================================
+*/
+
+
+#include "DataOutput.hpp"
+#include "DataInput.hpp"
+
+//#include "gf_includes.hpp"
+#include "CacheableString.hpp"
+#include "ExceptionTypes.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+
+ void CacheableString::ToData(DataOutput^ output)
+ {
+ if (m_type == GemFireClassIds::CacheableASCIIString ||
+ m_type == GemFireClassIds::CacheableString)
+ {
+ output->WriteUTF(m_value);
+ }
+ else if (m_type == GemFireClassIds::CacheableASCIIStringHuge)
+ {
+ output->WriteASCIIHuge(m_value);
+ }
+ else
+ {
+ output->WriteUTFHuge(m_value);
+ }
+ }
+
+ IGFSerializable^ CacheableString::FromData(DataInput^ input)
+ {
+ if (m_type == GemFireClassIds::CacheableASCIIString ||
+ m_type == GemFireClassIds::CacheableString)
+ {
+ m_value = input->ReadUTF();
+ }
+ else if (m_type == GemFireClassIds::CacheableASCIIStringHuge)
+ {
+ m_value = input->ReadASCIIHuge();
+ }
+ else
+ {
+ m_value = input->ReadUTFHuge();
+ }
+
+ return this;
+ }
+
+
+ inline void CacheableString::GetCacheableString(String^ value,
+ gemfire::CacheableStringPtr& cStr)
+ {
+ size_t len;
+ if (value != nullptr && (len = value->Length) > 0) {
+ pin_ptr<const wchar_t> pin_value = PtrToStringChars(value);
+ cStr = gemfire::CacheableString::create(pin_value, (int32_t)len);
+ }
+ else {
+ cStr = (gemfire::CacheableString*)
+ gemfire::CacheableString::createDeserializable();
+ }
+ }
+
+ inline void CacheableString::GetCacheableString(array<Char>^ value,
+ gemfire::CacheableStringPtr& cStr)
+ {
+ size_t len;
+ if (value != nullptr && (len = value->Length) > 0) {
+ pin_ptr<const Char> pin_value = &value[0];
+ cStr = gemfire::CacheableString::create(
+ (const wchar_t*)pin_value, (int32_t)len);
+ }
+ else {
+ cStr = (gemfire::CacheableString*)
+ gemfire::CacheableString::createDeserializable();
+ }
+ }
+
+ CacheableString::CacheableString(String^ value)
+ : CacheableKey()
+ {
+ if (value == nullptr ) {
+ throw gcnew IllegalArgumentException("CacheableString: null or " +
+ "zero-length string provided to the constructor.");
+ }
+ m_value = value;
+
+ this->SetStringType();
+ }
+
+ CacheableString::CacheableString(array<Char>^ value)
+ : CacheableKey()
+ {
+ if (value == nullptr ) {
+ throw gcnew IllegalArgumentException("CacheableString: null or " +
+ "zero-length character array provided to the constructor.");
+ }
+ m_value = gcnew String(value);
+
+ this->SetStringType();
+ }
+
+ CacheableString::CacheableString(String^ value, bool noParamCheck)
+ : CacheableKey()
+ {
+ m_value = value;
+ this->SetStringType();
+ }
+
+ CacheableString::CacheableString(array<Char>^ value, bool noParamCheck)
+ : CacheableKey()
+ {
+ m_value = gcnew String(value);
+ this->SetStringType();
+ }
+
+ uint32_t CacheableString::ObjectSize::get()
+ {
+ return (m_value->Length * sizeof(char));
+ }
+
+ bool CacheableString::Equals(GemStone::GemFire::Cache::Generic::ICacheableKey^ other)
+ {
+ if (other == nullptr || other->ClassId != ClassId) {
+ return false;
+ }
+
+ CacheableString^ otherStr =
+ dynamic_cast<CacheableString^>(other);
+
+ if (otherStr == nullptr)
+ return false;
+
+ return m_value->Equals(otherStr->Value);//TODO::
+ }
+
+ bool CacheableString::Equals(Object^ obj)
+ {
+ CacheableString^ otherStr =
+ dynamic_cast<CacheableString^>(obj);
+
+ if (otherStr != nullptr) {
+ return m_value->Equals(otherStr->Value);
+ }
+ return false;
+ }
+
+ int32_t CacheableString::GetHashCode()
+ {
+ if (String::IsNullOrEmpty(m_value)) {
+ return 0;
+ }
+ //TODO: need to need java hashcode
+ //return m_value->GetHashCode();
+ if(m_hashcode == 0)
+ {
+ int32_t prime = 31;
+ int32_t localHash = 0;
+ for (int32_t i = 0; i < m_value->Length; i++)
+ localHash = prime*localHash + m_value[i];
+ m_hashcode = localHash;
+ }
+ return m_hashcode;
+ }
+
+ void CacheableString::SetStringType()
+ {
+ int len = DataOutput::getEncodedLength(m_value);
+
+ if (len == m_value->Length)//ASCII string
+ {
+ if (len > 0xFFFF)
+ m_type = GemFireClassIds::CacheableASCIIStringHuge;
+ else
+ m_type = GemFireClassIds::CacheableASCIIString;
+ }
+ else
+ {
+ if (len > 0xFFFF)
+ m_type = GemFireClassIds::CacheableStringHuge;
+ else
+ m_type = GemFireClassIds::CacheableString;
+ }
+ }
+ }
+ }
+}
+ } //namespace
+
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableString.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableString.hpp b/src/clicache/src/CacheableString.hpp
new file mode 100644
index 0000000..146bd7c
--- /dev/null
+++ b/src/clicache/src/CacheableString.hpp
@@ -0,0 +1,313 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+
+
+#include "gf_defs.hpp"
+#include <gfcpp/CacheableString.hpp>
+#include "impl/ManagedString.hpp"
+#include "CacheableKey.hpp"
+#include "GemFireClassIds.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ /// <summary>
+ /// An immutable string wrapper that can serve as a distributable
+ /// key object for caching as well as being a string value.
+ /// </summary>
+ ref class CacheableString
+ : public CacheableKey
+ {
+ public:
+ /// <summary>
+ /// Allocates a new instance copying from the given string.
+ /// </summary>
+ /// <param name="value">the string value of the new instance</param>
+ /// <exception cref="IllegalArgumentException">
+ /// if the provided string is null or has zero length
+ /// </exception>
+ CacheableString(String^ value);
+
+ /// <summary>
+ /// Allocates a new instance copying from the given character array.
+ /// </summary>
+ /// <param name="value">
+ /// the character array value of the new instance
+ /// </param>
+ /// <exception cref="IllegalArgumentException">
+ /// if the provided array is null or has zero length
+ /// </exception>
+ CacheableString(array<Char>^ value);
+
+ /// <summary>
+ /// Static function to create a new instance copying from
+ /// the given string.
+ /// </summary>
+ /// <remarks>
+ /// Providing a null or zero size string will return a null
+ /// <c>CacheableString</c> object.
+ /// </remarks>
+ /// <param name="value">the string value of the new instance</param>
+ inline static CacheableString^ Create(String^ value)
+ {
+ return (value != nullptr ?
+ gcnew CacheableString(value, true) : nullptr);
+ }
+
+ /// <summary>
+ /// Serializes this managed object.
+ /// </summary>
+ /// <param name="output">
+ /// the DataOutput object to use for serializing the object
+ /// </param>
+ virtual void ToData(DataOutput^ output) override;
+
+ /// <summary>
+ /// Deserializes the managed object -- returns an instance of the
+ /// <c>IGFSerializable</c> class.
+ /// </summary>
+ /// <param name="input">
+ /// the DataInput stream to use for reading the object data
+ /// </param>
+ /// <returns>the deserialized object</returns>
+ virtual IGFSerializable^ FromData(DataInput^ input) override;
+
+ // <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ virtual uint32_t get() override
+ {
+ return m_type;
+ }
+ }
+
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get() override;
+ }
+
+ /// <summary>
+ /// Static function to create a new instance copying from
+ /// the given character array.
+ /// </summary>
+ /// <remarks>
+ /// Providing a null or zero size character array will return a null
+ /// <c>CacheableString</c> object.
+ /// </remarks>
+ /// <param name="value">
+ /// the character array value of the new instance
+ /// </param>
+ inline static CacheableString^ Create(array<Char>^ value)
+ {
+ return (value != nullptr && value->Length > 0 ?
+ gcnew CacheableString(value, true) : nullptr);
+ }
+
+ /// <summary>
+ /// Return a string representation of the object.
+ /// This returns the same string as <c>Value</c> property.
+ /// </summary>
+ virtual String^ ToString() override
+ {
+ return m_value;
+ }
+
+ /// <summary>
+ /// Return true if this key matches other object.
+ /// It invokes the '==' operator of the underlying
+ /// <c>gemfire::CacheableString</c> object.
+ /// </summary>
+ virtual bool Equals(GemStone::GemFire::Cache::Generic::ICacheableKey^ other) override;
+
+ /// <summary>
+ /// Return true if this key matches other object.
+ /// It invokes the '==' operator of the underlying
+ /// <c>gemfire::CacheableString</c> object.
+ /// </summary>
+ virtual bool Equals(Object^ obj) override;
+
+ /// <summary>
+ /// Return the hashcode for this key.
+ /// </summary>
+ virtual int32_t GetHashCode() override;
+
+ /// <summary>
+ /// Gets the string value.
+ /// </summary>
+ property String^ Value
+ {
+ inline String^ get()
+ {
+ return m_value;
+ }
+ }
+
+ /// <summary>
+ /// Static function to check whether IsNullOrEmpty.
+ /// </summary>
+ /// <remarks>
+ /// This is similar to the C# string.IsNullOrEmpty method.
+ /// </remarks>
+ /// <param name="value">the CacheableString value to check</param>
+ inline static bool IsNullOrEmpty(CacheableString^ value)
+ {
+ return (value == nullptr || value->Length == 0);
+ }
+
+ /// <summary>
+ /// Implicit conversion operator to underlying <c>System.String</c>.
+ /// </summary>
+ inline static operator String^ (CacheableString^ str)
+ {
+ return (str != nullptr ? CacheableString::GetString(str) : nullptr);
+ }
+
+ /// <summary>
+ /// Gets the length of the underlying C string.
+ /// </summary>
+ property uint32_t Length
+ {
+ inline uint32_t get()
+ {
+ return m_value->Length;
+ }
+ }
+
+ /// <summary>
+ /// True when the underlying C string is a wide-character string.
+ /// </summary>
+ property bool IsWideString
+ {
+ inline bool get()
+ {
+ return true;//TODO:
+ }
+ }
+
+ internal:
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableString(GemFireClassIds::CacheableASCIIString);
+ }
+
+ static IGFSerializable^ createDeserializableHuge()
+ {
+ return gcnew CacheableString(GemFireClassIds::CacheableASCIIStringHuge);
+ }
+
+ static IGFSerializable^ createUTFDeserializable()
+ {
+ return gcnew CacheableString(GemFireClassIds::CacheableString);
+ }
+
+ static IGFSerializable^ createUTFDeserializableHuge()
+ {
+ return gcnew CacheableString(GemFireClassIds::CacheableStringHuge);
+ }
+ /// <summary>
+ /// Factory function to register wrapper
+ /// </summary>
+ static IGFSerializable^ Create(gemfire::Serializable* obj)
+ {
+ return (obj != nullptr ?
+ gcnew CacheableString(obj) : nullptr);
+ }
+
+ /// <summary>
+ /// Internal function to create a <c>gemfire::CacheableString</c>
+ /// from the given managed string.
+ /// </summary>
+ static void GetCacheableString(String^ value,
+ gemfire::CacheableStringPtr& cStr);
+
+ /// <summary>
+ /// Internal function to create a <c>gemfire::CacheableString</c>
+ /// from the given managed array of characters.
+ /// </summary>
+ static void GetCacheableString(array<Char>^ value,
+ gemfire::CacheableStringPtr& cStr);
+
+ /// <summary>
+ /// Get the <c>System.String</c> from the given
+ /// <c>gemfire::CacheableString</c>
+ /// </summary>
+ inline static String^ GetString(gemfire::CacheableString * cStr)
+ {
+ if (cStr == NULL) {
+ return nullptr;
+ }
+ else if (cStr->isWideString()) {
+ return ManagedString::Get(cStr->asWChar());
+ }
+ else {
+ return ManagedString::Get(cStr->asChar());
+ }
+ }
+
+ inline static String^ GetString(CacheableString^ cStr)
+ {
+ return cStr->Value;
+ }
+
+ CacheableString(uint32_t type): CacheableKey()
+ {
+ m_type = type;
+ }
+
+ private:
+ String^ m_value;
+ uint32_t m_type;
+ int m_hashcode;
+
+ CacheableString(): CacheableKey()
+ {
+ m_type = GemFireClassIds::CacheableASCIIString;
+ }
+
+ void SetStringType();
+ /// <summary>
+ /// Private constructor to create a CacheableString without checking
+ /// for arguments.
+ /// </summary>
+ CacheableString(String^ value, bool noParamCheck);
+
+ /// <summary>
+ /// Private constructor to create a CacheableString without checking
+ /// for arguments.
+ /// </summary>
+ CacheableString(array<Char>^ value, bool noParamCheck);
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline CacheableString(gemfire::Serializable* nativeptr)
+ : CacheableKey(nativeptr) { }
+ };
+ }
+ }
+}
+ } //namespace
+
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableStringArray.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableStringArray.cpp b/src/clicache/src/CacheableStringArray.cpp
new file mode 100644
index 0000000..84f2468
--- /dev/null
+++ b/src/clicache/src/CacheableStringArray.cpp
@@ -0,0 +1,88 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+
+#include "CacheableStringArray.hpp"
+#include "CacheableString.hpp"
+#include "DataInput.hpp"
+#include "DataOutput.hpp"
+#include "ExceptionTypes.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+
+ CacheableStringArray::CacheableStringArray(array<String^>^ strings)
+ : Serializable()
+ {
+ m_value = strings;
+ }
+
+
+ array<String^>^ CacheableStringArray::GetValues()
+ {
+ return m_value;
+ }
+
+ String^ CacheableStringArray::default::get(int32_t index)
+ {
+ return m_value[index];
+ }
+
+ void CacheableStringArray::ToData(DataOutput^ output)
+ {
+ if (m_value == nullptr)
+ {
+ output->WriteArrayLen(-1);
+ }
+ else
+ {
+ output->WriteArrayLen(m_value->Length);
+ if (m_value->Length > 0)
+ {
+ for(int i = 0; i < m_value->Length; i++)
+ {
+ output->WriteObject(m_value[i]);
+ }
+ GC::KeepAlive(this);
+ }
+ }
+ }
+
+
+ IGFSerializable^ CacheableStringArray::FromData(DataInput^ input)
+ {
+ int len = input->ReadArrayLen();
+ if ( len == -1)
+ {
+ m_value = nullptr;
+ return nullptr;
+ }
+ else
+ {
+ m_value = gcnew array<String^>(len);
+ if (len > 0)
+ {
+ for( int i = 0; i < len; i++)
+ {
+ m_value[i] = dynamic_cast<String^>(input->ReadObject());
+ }
+ }
+ return this;
+ }
+ }
+
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableStringArray.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableStringArray.hpp b/src/clicache/src/CacheableStringArray.hpp
new file mode 100644
index 0000000..006f402
--- /dev/null
+++ b/src/clicache/src/CacheableStringArray.hpp
@@ -0,0 +1,180 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+
+
+#include "gf_defs.hpp"
+#include <gfcpp/CacheableBuiltins.hpp>
+#include "Serializable.hpp"
+#include "GemFireClassIds.hpp"
+#include "CacheableString.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ ref class CacheableString;
+
+ /// <summary>
+ /// An immutable wrapper for array of strings that can serve as
+ /// a distributable object for caching.
+ /// </summary>
+ ref class CacheableStringArray
+ : public Serializable
+ {
+ public:
+ /// <summary>
+ /// Static function to create a new instance copying from the given
+ /// string array.
+ /// </summary>
+ /// <remarks>
+ /// If the given array of strings is null or of zero-length then
+ /// this method returns null.
+ /// </remarks>
+ /// <exception cref="IllegalArgumentException">
+ /// If the array contains a string greater than or equal 64K in length.
+ /// </exception>
+ inline static CacheableStringArray^ Create(array<String^>^ strings)
+ {
+ return (strings != nullptr && strings->Length > 0 ?
+ gcnew CacheableStringArray(strings) : nullptr);
+ }
+
+ /// <summary>
+ /// Serializes this managed object.
+ /// </summary>
+ /// <param name="output">
+ /// the DataOutput object to use for serializing the object
+ /// </param>
+ virtual void ToData(DataOutput^ output) override;
+
+ /// <summary>
+ /// Deserializes the managed object -- returns an instance of the
+ /// <c>IGFSerializable</c> class.
+ /// </summary>
+ /// <param name="input">
+ /// the DataInput stream to use for reading the object data
+ /// </param>
+ /// <returns>the deserialized object</returns>
+ virtual IGFSerializable^ FromData(DataInput^ input) override;
+
+
+ /// <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ virtual uint32_t get() override
+ {
+ return GemFireClassIds::CacheableStringArray;
+ }
+ }
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get() override
+ {
+ int size = 0;
+ for( int i = 0; i < m_value->Length; i++ )
+ {
+ size += m_value[i]->Length;
+ }
+ return (uint32_t) (size + sizeof(this));
+ }
+
+ }
+
+ /// <summary>
+ /// Returns a copy of the underlying array of strings.
+ /// </summary>
+ array<String^>^ GetValues();
+
+ /// <summary>
+ /// Returns a copy of the underlying string at the given index.
+ /// </summary>
+ property String^ GFINDEXER(int32_t)
+ {
+ String^ get(int32_t index);
+ }
+
+ /// <summary>
+ /// Gets the length of the array.
+ /// </summary>
+ property int32_t Length
+ {
+ inline int32_t get()
+ {
+ return m_value->Length;
+ }
+ }
+
+ virtual String^ ToString() override
+ {
+ return m_value->ToString();
+ }
+
+ /// <summary>
+ /// Factory function to register this class.
+ /// </summary>
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableStringArray();
+ }
+
+ internal:
+ /// <summary>
+ /// Factory function to register wrapper
+ /// </summary>
+ static IGFSerializable^ Create(gemfire::Serializable* obj)
+ {
+ return (obj != nullptr ?
+ gcnew CacheableStringArray(obj) : nullptr);
+ }
+
+ private:
+ array<String^>^ m_value;
+ /// <summary>
+ /// Allocates a new instance copying from the given string array.
+ /// </summary>
+ /// <exception cref="IllegalArgumentException">
+ /// If the array contains a string greater than or equal 64K in length.
+ /// </exception>
+ CacheableStringArray(array<String^>^ strings);
+
+
+ inline CacheableStringArray()
+ : Serializable()
+ {
+ //gemfire::Serializable* sp = gemfire::CacheableStringArray::createDeserializable();
+ //SetSP(sp);
+ }
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline CacheableStringArray(gemfire::Serializable* nativeptr)
+ : Serializable(nativeptr) { }
+ };
+ }
+ }
+}
+ } //namespace
+
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableUndefined.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableUndefined.cpp b/src/clicache/src/CacheableUndefined.cpp
new file mode 100644
index 0000000..bc86844
--- /dev/null
+++ b/src/clicache/src/CacheableUndefined.cpp
@@ -0,0 +1,45 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+
+
+//#include "gf_includes.hpp"
+#include "CacheableUndefined.hpp"
+#include "DataOutput.hpp"
+#include "DataInput.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ // Region: IGFSerializable Members
+
+ void CacheableUndefined::ToData(DataOutput^ output)
+ {
+ }
+
+ IGFSerializable^ CacheableUndefined::FromData(DataInput^ input)
+ {
+ return this;
+ }
+
+ uint32_t CacheableUndefined::ObjectSize::get()
+ {
+ return static_cast<uint32_t> (sizeof(CacheableUndefined^));
+ }
+
+ // End Region: IGFSerializable Members
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableUndefined.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableUndefined.hpp b/src/clicache/src/CacheableUndefined.hpp
new file mode 100644
index 0000000..4a6d7c0
--- /dev/null
+++ b/src/clicache/src/CacheableUndefined.hpp
@@ -0,0 +1,99 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "IGFSerializable.hpp"
+#include "GemFireClassIds.hpp"
+#include "Log.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ /// <summary>
+ /// Encapsulate an undefined result.
+ /// </summary>
+ public ref class CacheableUndefined
+ : public IGFSerializable
+ {
+ public:
+ /// <summary>
+ /// Allocates a new empty instance.
+ /// </summary>
+ inline CacheableUndefined() { }
+
+ /// <summary>
+ /// Static function to create a new empty instance.
+ /// </summary>
+ inline static CacheableUndefined^ Create()
+ {
+ return gcnew CacheableUndefined();
+ }
+
+ // Region: IGFSerializable Members
+
+ /// <summary>
+ /// Serializes this object.
+ /// </summary>
+ /// <param name="output">
+ /// the DataOutput object to use for serializing the object
+ /// </param>
+ virtual void ToData(DataOutput^ output);
+
+ /// <summary>
+ /// Deserialize this object, typical implementation should return
+ /// the 'this' pointer.
+ /// </summary>
+ /// <param name="input">
+ /// the DataInput stream to use for reading the object data
+ /// </param>
+ /// <returns>the deserialized object</returns>
+ virtual IGFSerializable^ FromData(DataInput^ input);
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get();
+ }
+
+ /// <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ inline virtual uint32_t get()
+ {
+ return GemFireClassIds::CacheableUndefined;
+ }
+ }
+
+ // End Region: IGFSerializable Members
+
+ /// <summary>
+ /// Factory function to register this class.
+ /// </summary>
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableUndefined();
+ }
+ };
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableVector.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableVector.cpp b/src/clicache/src/CacheableVector.cpp
new file mode 100644
index 0000000..ca5998d
--- /dev/null
+++ b/src/clicache/src/CacheableVector.cpp
@@ -0,0 +1,70 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+
+
+//#include "gf_includes.hpp"
+#include "CacheableVector.hpp"
+#include "DataOutput.hpp"
+#include "DataInput.hpp"
+#include "ExceptionTypes.hpp"
+#include "impl/SafeConvert.hpp"
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ // Region: IGFSerializable Members
+
+ void CacheableVector::ToData(DataOutput^ output)
+ {
+ if(m_arrayList != nullptr)
+ {
+ output->WriteArrayLen(m_arrayList->Count);
+ for each (Object^ obj in m_arrayList) {
+ //TODO::split
+ output->WriteObject(obj);
+ }
+ }
+ else
+ output->WriteByte(0xFF);
+ }
+
+ IGFSerializable^ CacheableVector::FromData(DataInput^ input)
+ {
+ int len = input->ReadArrayLen();
+ for( int i = 0; i < len; i++)
+ {
+ m_arrayList->Add(input->ReadObject());
+ }
+ return this;
+ }
+
+ uint32_t CacheableVector::ObjectSize::get()
+ {
+ //TODO::
+ /*uint32_t size = static_cast<uint32_t> (sizeof(CacheableVector^));
+ for each (IGFSerializable^ val in this) {
+ if (val != nullptr) {
+ size += val->ObjectSize;
+ }
+ }*/
+ return m_arrayList->Count;
+ }
+
+ // End Region: IGFSerializable Members
+ }
+ }
+}
+ } //namespace
+
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CacheableVector.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheableVector.hpp b/src/clicache/src/CacheableVector.hpp
new file mode 100644
index 0000000..969d4ec
--- /dev/null
+++ b/src/clicache/src/CacheableVector.hpp
@@ -0,0 +1,126 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include "IGFSerializable.hpp"
+#include "GemFireClassIds.hpp"
+
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ /// <summary>
+ /// A mutable <c>IGFSerializable</c> vector wrapper that can serve as
+ /// a distributable object for caching. This class extends .NET generic
+ /// <c>List</c> class.
+ /// </summary>
+ ref class CacheableVector
+ : public IGFSerializable
+ {
+ public:
+ /// <summary>
+ /// Allocates a new empty instance.
+ /// </summary>
+ inline CacheableVector(System::Collections::IList^ arrayList)
+ {
+ m_arrayList = arrayList;
+ }
+
+
+ /// <summary>
+ /// Static function to create a new empty instance.
+ /// </summary>
+ inline static CacheableVector^ Create()
+ {
+ return gcnew CacheableVector(gcnew System::Collections::ArrayList());
+ }
+
+ /// <summary>
+ /// Static function to create a new empty instance.
+ /// </summary>
+ inline static CacheableVector^ Create(System::Collections::IList^ list)
+ {
+ return gcnew CacheableVector(list);
+ }
+
+
+ // Region: IGFSerializable Members
+
+ /// <summary>
+ /// Serializes this object.
+ /// </summary>
+ /// <param name="output">
+ /// the DataOutput object to use for serializing the object
+ /// </param>
+ virtual void ToData(DataOutput^ output);
+
+ /// <summary>
+ /// Deserialize this object, typical implementation should return
+ /// the 'this' pointer.
+ /// </summary>
+ /// <param name="input">
+ /// the DataInput stream to use for reading the object data
+ /// </param>
+ /// <returns>the deserialized object</returns>
+ virtual IGFSerializable^ FromData(DataInput^ input);
+
+ /// <summary>
+ /// return the size of this object in bytes
+ /// </summary>
+ virtual property uint32_t ObjectSize
+ {
+ virtual uint32_t get();
+ }
+
+ /// <summary>
+ /// Returns the classId of the instance being serialized.
+ /// This is used by deserialization to determine what instance
+ /// type to create and deserialize into.
+ /// </summary>
+ /// <returns>the classId</returns>
+ virtual property uint32_t ClassId
+ {
+ virtual uint32_t get()
+ {
+ return GemFireClassIds::CacheableVector;
+ }
+ }
+
+ virtual property System::Collections::IList^ Value
+ {
+ virtual System::Collections::IList^ get()
+ {
+ return m_arrayList;
+ }
+ }
+
+ // End Region: IGFSerializable Members
+
+ /// <summary>
+ /// Factory function to register this class.
+ /// </summary>
+ static IGFSerializable^ CreateDeserializable()
+ {
+ return gcnew CacheableVector(gcnew System::Collections::ArrayList());
+ }
+
+ private:
+ System::Collections::IList^ m_arrayList;
+ };
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CqAttributes.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributes.cpp b/src/clicache/src/CqAttributes.cpp
new file mode 100644
index 0000000..0faaa8c
--- /dev/null
+++ b/src/clicache/src/CqAttributes.cpp
@@ -0,0 +1,57 @@
+/*=========================================================================
+* Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+*=========================================================================
+*/
+
+//#include "gf_includes.hpp"
+#include "CqAttributes.hpp"
+#include "impl/ManagedCqListener.hpp"
+#include "ICqListener.hpp"
+#include "impl/ManagedCqStatusListener.hpp"
+#include "ICqStatusListener.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ generic<class TKey, class TResult>
+ array<ICqListener<TKey, TResult>^>^ CqAttributes<TKey, TResult>::getCqListeners( )
+ {
+ gemfire::VectorOfCqListener vrr;
+ NativePtr->getCqListeners( vrr );
+ array<ICqListener<TKey, TResult>^>^ listners = gcnew array<ICqListener<TKey, TResult>^>( vrr.size( ) );
+
+ for( int32_t index = 0; index < vrr.size( ); index++ )
+ {
+ gemfire::CqListenerPtr& nativeptr( vrr[ index ] );
+ gemfire::ManagedCqListenerGeneric* mg_listener =
+ dynamic_cast<gemfire::ManagedCqListenerGeneric*>( nativeptr.ptr( ) );
+ if (mg_listener != nullptr)
+ {
+ listners[ index ] = (ICqListener<TKey, TResult>^) mg_listener->userptr( );
+ }else
+ {
+ gemfire::ManagedCqStatusListenerGeneric* mg_statuslistener =
+ dynamic_cast<gemfire::ManagedCqStatusListenerGeneric*>( nativeptr.ptr( ) );
+ if (mg_statuslistener != nullptr) {
+ listners[ index ] = (ICqStatusListener<TKey, TResult>^) mg_statuslistener->userptr( );
+ }
+ else {
+ listners[ index ] = nullptr;
+ }
+ }
+ }
+ return listners;
+ }
+
+ }
+ }
+ }
+} //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CqAttributes.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributes.hpp b/src/clicache/src/CqAttributes.hpp
new file mode 100644
index 0000000..7e99472
--- /dev/null
+++ b/src/clicache/src/CqAttributes.hpp
@@ -0,0 +1,74 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include <gfcpp/CqAttributes.hpp>
+#include "impl/NativeWrapper.hpp"
+
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ generic<class TKey, class TResult>
+ interface class ICqListener;
+
+ /// <summary>
+ /// Defines attributes for configuring a cq.
+ /// </summary>
+ generic<class TKey, class TResult>
+ public ref class CqAttributes sealed
+ : public Internal::SBWrap<gemfire::CqAttributes>
+ {
+ public:
+
+ /// <summary>
+ /// get all listeners in this attributes
+ /// </summary>
+ virtual array<Generic::ICqListener<TKey, TResult>^>^ getCqListeners();
+
+ internal:
+
+ /// <summary>
+ /// Internal factory function to wrap a native object pointer inside
+ /// this managed class with null pointer check.
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ /// <returns>
+ /// The managed wrapper object; null if the native pointer is null.
+ /// </returns>
+ inline static CqAttributes<TKey, TResult>^ Create( gemfire::CqAttributes* nativeptr )
+ {
+ if (nativeptr == nullptr)
+ {
+ return nullptr;
+ }
+ return gcnew CqAttributes( nativeptr );
+ }
+
+
+ private:
+
+ /// <summary>
+ /// Private constructor to wrap a native object pointer
+ /// </summary>
+ /// <param name="nativeptr">The native object pointer</param>
+ inline CqAttributes( gemfire::CqAttributes* nativeptr )
+ : SBWrap( nativeptr ) { }
+ };
+
+ }
+ }
+}
+ } //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CqAttributesFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributesFactory.cpp b/src/clicache/src/CqAttributesFactory.cpp
new file mode 100644
index 0000000..d43ccd9
--- /dev/null
+++ b/src/clicache/src/CqAttributesFactory.cpp
@@ -0,0 +1,133 @@
+/*=========================================================================
+* Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+*=========================================================================
+*/
+
+//#include "gf_includes.hpp"
+#include "CqAttributesFactory.hpp"
+#include "impl/ManagedCqListener.hpp"
+#include "ICqListener.hpp"
+#include "impl/ManagedCqStatusListener.hpp"
+#include "ICqStatusListener.hpp"
+#include "CqAttributesMutator.hpp"
+
+using namespace System;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+ generic<class TKey, class TResult>
+ void CqAttributesFactory<TKey, TResult>::AddCqListener(Generic::ICqListener<TKey, TResult>^ cqListener )
+ {
+ gemfire::CqListenerPtr listenerptr;
+ if ( cqListener != nullptr ) {
+ ICqStatusListener<TKey, TResult>^ cqStatusListener =
+ dynamic_cast<ICqStatusListener<TKey, TResult>^>(cqListener);
+ if (cqStatusListener != nullptr) {
+ CqStatusListenerGeneric<TKey, TResult>^ sLstr = gcnew CqStatusListenerGeneric<TKey, TResult>();
+ sLstr->AddCqListener(cqListener);
+ listenerptr = new gemfire::ManagedCqStatusListenerGeneric(cqListener);
+ try {
+ CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
+ if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->ContainsKey( cqListener) ) {
+ CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict[cqListener] = (IntPtr)listenerptr.ptr();
+ }
+ else {
+ CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->Add(cqListener, (IntPtr)listenerptr.ptr());
+ }
+ } finally {
+ CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
+ }
+ ((gemfire::ManagedCqStatusListenerGeneric*)listenerptr.ptr())->setptr(sLstr);
+ }
+ else {
+ //TODO::split
+ CqListenerGeneric<TKey, TResult>^ cqlg = gcnew CqListenerGeneric<TKey, TResult>();
+ cqlg->AddCqListener(cqListener);
+ //listenerptr = new gemfire::ManagedCqListenerGeneric((ICqListener<Object^, Object^>^)cqListener );
+ listenerptr = new gemfire::ManagedCqListenerGeneric( /*clg,*/ cqListener );
+ try {
+ CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
+ if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->ContainsKey( cqListener) ) {
+ CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict[cqListener] = (IntPtr)listenerptr.ptr();
+ }
+ else {
+ CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->Add(cqListener, (IntPtr)listenerptr.ptr());
+ }
+ } finally {
+ CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
+ }
+ ((gemfire::ManagedCqListenerGeneric*)listenerptr.ptr())->setptr(cqlg);
+ }
+ }
+
+ NativePtr->addCqListener( listenerptr );
+ }
+
+ generic<class TKey, class TResult>
+ void CqAttributesFactory<TKey, TResult>::InitCqListeners(array<Generic::ICqListener<TKey, TResult>^>^ cqListeners)
+ {
+ gemfire::VectorOfCqListener vrr;
+ for( int i = 0; i < cqListeners->Length; i++ )
+ {
+ ICqStatusListener<TKey, TResult>^ lister = dynamic_cast<ICqStatusListener<TKey, TResult>^>(cqListeners[i]);
+ if (lister != nullptr) {
+ gemfire::CqStatusListenerPtr cptr(new gemfire::ManagedCqStatusListenerGeneric(
+ (ICqStatusListener<TKey, TResult>^)lister ));
+ vrr.push_back(cptr);
+ CqStatusListenerGeneric<TKey, TResult>^ cqlg = gcnew CqStatusListenerGeneric<TKey, TResult>();
+ cqlg->AddCqListener(cqListeners[i]);
+ try {
+ CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
+ if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->ContainsKey( cqListeners[i]) ) {
+ CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict[cqListeners[i]] = (IntPtr)cptr.ptr();
+ }
+ else {
+ CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->Add(cqListeners[i], (IntPtr)cptr.ptr());
+ }
+ } finally {
+ CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
+ }
+ ((gemfire::ManagedCqStatusListenerGeneric*)vrr[i].ptr())->setptr(cqlg);
+ }
+ else {
+ ICqListener<TKey, TResult>^ lister = cqListeners[i];
+ gemfire::CqListenerPtr cptr(new gemfire::ManagedCqListenerGeneric(
+ (ICqListener<TKey, TResult>^)lister ));
+ vrr.push_back(cptr);
+ CqListenerGeneric<TKey, TResult>^ cqlg = gcnew CqListenerGeneric<TKey, TResult>();
+ cqlg->AddCqListener(cqListeners[i]);
+ try {
+ CqListenerHelper<TKey, TResult>::g_readerWriterLock->AcquireWriterLock(-1);
+ if ( CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->ContainsKey( cqListeners[i]) ) {
+ CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict[cqListeners[i]] = (IntPtr)cptr.ptr();
+ }
+ else {
+ CqListenerHelper<TKey, TResult>::m_ManagedVsUnManagedCqLstrDict->Add(cqListeners[i], (IntPtr)cptr.ptr());
+ }
+ } finally {
+ CqListenerHelper<TKey, TResult>::g_readerWriterLock->ReleaseWriterLock();
+ }
+ ((gemfire::ManagedCqListenerGeneric*)vrr[i].ptr())->setptr(cqlg);
+ }
+ }
+
+ NativePtr->initCqListeners( vrr );
+ }
+
+ generic<class TKey, class TResult>
+ Generic::CqAttributes<TKey, TResult>^ CqAttributesFactory<TKey, TResult>::Create( )
+ {
+ return Generic::CqAttributes<TKey, TResult>::Create(NativePtr->create().ptr());
+ }
+
+ }
+ }
+ }
+} //namespace
http://git-wip-us.apache.org/repos/asf/geode/blob/2d4a7ecd/src/clicache/src/CqAttributesFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CqAttributesFactory.hpp b/src/clicache/src/CqAttributesFactory.hpp
new file mode 100644
index 0000000..afb07af
--- /dev/null
+++ b/src/clicache/src/CqAttributesFactory.hpp
@@ -0,0 +1,80 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+
+#pragma once
+
+#include "gf_defs.hpp"
+#include <gfcpp/CqAttributesFactory.hpp>
+//#include "impl/NativeWrapper.hpp"
+#include "impl/SafeConvert.hpp"
+
+#include "CqAttributes.hpp"
+
+using namespace System;
+using namespace System::Collections::Generic;
+
+namespace GemStone
+{
+ namespace GemFire
+ {
+ namespace Cache { namespace Generic
+ {
+
+ /*
+ generic<class TKey, class TValue>
+ ref class CqAttributes;
+ */
+ generic<class TKey, class TResult>
+ interface class ICqListener;
+
+ /// <summary>
+ /// Creates instances of <c>CqAttributes</c>.
+ /// </summary>
+ /// <seealso cref="CqAttributes" />
+ generic<class TKey, class TResult>
+ public ref class CqAttributesFactory sealed
+ : public Internal::UMWrap<gemfire::CqAttributesFactory>
+ {
+ public:
+
+ /// <summary>
+ /// Creates a new instance of <c>CqAttributesFactory</c> ready
+ /// to create a <c>CqAttributes</c> with default settings.
+ /// </summary>
+ inline CqAttributesFactory( )
+ : UMWrap( new gemfire::CqAttributesFactory( ), true )
+ { }
+
+ inline CqAttributesFactory(Generic::CqAttributes<TKey, TResult>^ cqAttributes )
+ : UMWrap( new gemfire::CqAttributesFactory(gemfire::CqAttributesPtr(GetNativePtrFromSBWrapGeneric<gemfire::CqAttributes>(cqAttributes ))), true )
+ { }
+
+ // ATTRIBUTES
+
+ /// <summary>
+ /// add a cqListener
+ /// </summary>
+ void AddCqListener(Generic::ICqListener<TKey, TResult>^ cqListener);
+
+ /// <summary>
+ /// Initialize with an array of listeners
+ /// </summary>
+ void InitCqListeners( array<Generic::ICqListener<TKey, TResult>^>^ cqListeners );
+
+ // FACTORY METHOD
+
+ /// <summary>
+ /// Creates a <c>CqAttributes</c> with the current settings.
+ /// </summary>
+ Generic::CqAttributes<TKey, TResult>^ Create( );
+ };
+
+ }
+ }
+}
+ } //namespace
|