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/08/11 23:52:18 UTC
[02/52] [partial] geode-native git commit: GEODE-3165: Reogranized
sources relative to the root for better CMake IDE integration.
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/PdxHelper.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/PdxHelper.cpp b/clicache/src/impl/PdxHelper.cpp
new file mode 100644
index 0000000..f611146
--- /dev/null
+++ b/clicache/src/impl/PdxHelper.cpp
@@ -0,0 +1,451 @@
+/*
+ * 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 "begin_native.hpp"
+#include <CacheImpl.hpp>
+#include <CacheRegionHelper.hpp>
+#include <geode/Cache.hpp>
+#include "end_native.hpp"
+
+#include "PdxHelper.hpp"
+#include "PdxTypeRegistry.hpp"
+#include "PdxWriterWithTypeCollector.hpp"
+#include "PdxReaderWithTypeCollector.hpp"
+#include "PdxRemoteReader.hpp"
+#include "PdxRemoteWriter.hpp"
+#include "../Serializable.hpp"
+#include "PdxWrapper.hpp"
+#include "../Log.hpp"
+#include "PdxInstanceImpl.hpp"
+
+using namespace System;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+
+ namespace Internal
+ {
+
+ void PdxHelper::SerializePdx(DataOutput^ dataOutput, IPdxSerializable^ pdxObject)
+ {
+ dataOutput->setPdxSerialization(true);
+ String^ pdxClassname = nullptr;
+ bool isPdxWrapper = false;
+ //String^ className = nullptr;
+ Type^ pdxType = nullptr;
+
+ PdxWrapper^ pdxWrapper = dynamic_cast<PdxWrapper^>(pdxObject);
+
+ if(pdxWrapper != nullptr)
+ {
+ //className = pdxWrapper->GetObject()->GetType()->FullName;
+ isPdxWrapper = true;
+ pdxType = pdxWrapper->GetObject()->GetType();
+ }
+ else
+ {
+ PdxInstanceImpl^ pdxII = dynamic_cast<PdxInstanceImpl^>(pdxObject);
+ if(pdxII != nullptr)
+ {
+ PdxType^ piPt = pdxII->getPdxType();
+ if(piPt != nullptr && piPt->TypeId == 0)//from pdxInstance factory need to get typeid from server
+ {
+ int typeId = PdxTypeRegistry::GetPDXIdForType(piPt, dataOutput->GetPoolName(), dataOutput->GetNative()->getCache());
+ pdxII->setPdxId(typeId);
+ }
+ PdxLocalWriter^ plw = gcnew PdxLocalWriter(dataOutput, piPt);
+ pdxII->ToData(plw);
+
+ plw->EndObjectWriting();//now write typeid
+
+ int len = 0;
+ System::Byte* pdxStream = plw->GetPdxStream(len);
+ pdxII->updatePdxStream( pdxStream, len);
+
+
+ return;
+ }
+ //className = pdxObject->GetType()->FullName;
+ pdxType = pdxObject->GetType();
+ }
+
+ pdxClassname = Serializable::GetPdxTypeName(pdxType->FullName);
+ PdxType^ localPdxType = PdxTypeRegistry::GetLocalPdxType(pdxClassname);
+
+ if(localPdxType == nullptr)
+ {
+ //need to grab type info, as fromdata is not called yet
+ PdxWriterWithTypeCollector^ ptc = gcnew PdxWriterWithTypeCollector(dataOutput, pdxClassname);
+ pdxObject->ToData(ptc);
+
+ PdxType^ nType = ptc->PdxLocalType;//local type
+ nType->InitializeType();//initialize it
+
+ //get type id from server and then set it
+ int nTypeId = PdxTypeRegistry::GetPDXIdForType(pdxType,
+ dataOutput->GetPoolName(), nType, true, dataOutput->GetNative()->getCache());
+ nType->TypeId = nTypeId;
+
+ ptc->EndObjectWriting();//now write typeid
+
+ PdxTypeRegistry::AddLocalPdxType(pdxClassname, nType);//add classname VS pdxType
+ PdxTypeRegistry::AddPdxType(nTypeId, nType);//add typeid vs pdxtype
+
+ //This is for pdx Statistics
+ System::Byte* stPos = dataOutput->GetStartBufferPosition() + ptc->getStartPositionOffset();
+ int pdxLen = PdxHelper::ReadInt32(stPos);
+ // TODO global - Figure out why dataInput cache is nullptr
+ // CacheRegionHelper::getCacheImpl(dataOutput->GetNative()->getCache())->getCachePerfStats().incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID
+ // GC::KeepAlive(dataOutput);
+ }
+ else//we know locasl type, need to see preerved data
+ {
+ //if object got from server than create instance of RemoteWriter otherwise local writer.
+ PdxRemotePreservedData^ pd = PdxTypeRegistry::GetPreserveData(pdxObject);
+
+ //now always remotewriter as we have API Read/WriteUnreadFields
+ //so we don't know whether user has used those or not;; Can we do some trick here?
+ PdxRemoteWriter^ prw = nullptr;
+ if(pd != nullptr)
+ {
+ PdxType^ mergedPdxType = PdxTypeRegistry::GetPdxType(pd->MergedTypeId);
+
+ prw = gcnew PdxRemoteWriter(dataOutput, mergedPdxType, pd);
+ }
+ else
+ {
+ prw = gcnew PdxRemoteWriter(dataOutput, pdxClassname);
+ }
+
+ pdxObject->ToData(prw);
+
+ prw->EndObjectWriting();
+
+ //This is for pdx Statistics
+ System::Byte* stPos = dataOutput->GetStartBufferPosition() + prw->getStartPositionOffset();
+ int pdxLen = PdxHelper::ReadInt32(stPos);
+ // TODO global - Figure out why dataInput cache is nullptr
+ // CacheRegionHelper::getCacheImpl(dataOutput->GetNative()->getCache())->getCachePerfStats().incPdxSerialization(pdxLen + 1 + 2*4); //pdxLen + 93 DSID + len + typeID
+ // GC::KeepAlive(dataOutput);
+ }
+ }
+
+
+ IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int len, const native::SerializationRegistry* serializationRegistry)
+ {
+ dataInput->setPdxdeserialization(true);
+ String^ pdxClassname = nullptr;
+ String^ pdxDomainClassname = nullptr;
+ IPdxSerializable^ pdxObject = nullptr;
+ dataInput->AdvanceUMCursor();//it will increase the cursor in c++ layer
+ dataInput->SetBuffer();//it will c++ buffer in cli layer
+
+ PdxType^ pType = PdxTypeRegistry::GetPdxType(typeId);
+ PdxType^ pdxLocalType = nullptr;
+
+ if(pType != nullptr)//this may happen with PdxInstanceFactory
+ pdxLocalType = PdxTypeRegistry::GetLocalPdxType(pType->PdxClassName);//this should be fine for IPdxTypeMapper
+
+ if(pType != nullptr && pdxLocalType != nullptr)//type found
+ {
+ pdxClassname = pType->PdxClassName;
+ pdxDomainClassname = Serializable::GetLocalTypeName(pdxClassname);
+ //Log::Debug("found type " + typeId + " " + pType->IsLocal);
+ pdxObject = Serializable::GetPdxType(pdxDomainClassname);
+ if(pType->IsLocal)//local type no need to read Unread data
+ {
+ PdxLocalReader^ plr = gcnew PdxLocalReader(dataInput, pType, len);
+ pdxObject->FromData(plr);
+ plr->MoveStream();//it will set stream
+ }
+ else
+ {
+ PdxRemoteReader^ prr = gcnew PdxRemoteReader(dataInput, pType, len);
+ pdxObject->FromData(prr);
+
+ PdxType^ mergedVersion = PdxTypeRegistry::GetMergedType(pType->TypeId);
+ PdxRemotePreservedData^ preserveData = prr->GetPreservedData(mergedVersion, pdxObject);
+ if(preserveData != nullptr)
+ PdxTypeRegistry::SetPreserveData(pdxObject, preserveData);//it will set data in weakhashmap
+ prr->MoveStream();
+ }
+ }
+ else//type not found; need to get from server
+ {
+ if(pType == nullptr)
+ {
+ pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId, dataInput->GetNative()->getCache()));
+ pdxLocalType = PdxTypeRegistry::GetLocalPdxType(pType->PdxClassName);//this should be fine for IPdxTypeMappers
+ }
+
+ pdxClassname = pType->PdxClassName;
+ pdxDomainClassname = Serializable::GetLocalTypeName(pdxClassname);
+
+ pdxObject = Serializable::GetPdxType(pdxDomainClassname);
+
+ Object^ pdxRealObject = pdxObject;
+ bool isPdxWrapper = false;
+
+ PdxWrapper^ pdxWrapper = dynamic_cast<PdxWrapper^>(pdxObject);
+
+ if(pdxWrapper != nullptr)
+ {
+ //pdxDomainType = pdxWrapper->GetObject()->GetType();
+ isPdxWrapper = true;
+ }
+ else
+ {
+ //pdxDomainType = pdxObject->GetType();
+ }
+
+ if(pdxLocalType == nullptr)//need to know local type
+ {
+ PdxReaderWithTypeCollector^ prtc = gcnew PdxReaderWithTypeCollector(dataInput,pType,len);
+ pdxObject->FromData(prtc);
+
+ if(isPdxWrapper)
+ pdxRealObject = pdxWrapper->GetObject();
+
+ pdxLocalType = prtc->LocalType;
+
+ if(pType->Equals(pdxLocalType))//same
+ {
+ PdxTypeRegistry::AddLocalPdxType(pdxClassname, pType);
+ PdxTypeRegistry::AddPdxType(pType->TypeId, pType);
+ pType->IsLocal = true;
+ }
+ else
+ {
+ //need to know local type and then merge type
+ pdxLocalType->InitializeType();
+ pdxLocalType->TypeId = PdxTypeRegistry::GetPDXIdForType(pdxObject->GetType(),
+ dataInput->GetPoolName(),
+ pdxLocalType, true, dataInput->GetNative()->getCache());
+ pdxLocalType->IsLocal = true;
+ PdxTypeRegistry::AddLocalPdxType(pdxClassname, pdxLocalType);//added local type
+ PdxTypeRegistry::AddPdxType(pdxLocalType->TypeId, pdxLocalType);
+
+ pType->InitializeType();
+ PdxTypeRegistry::AddPdxType(pType->TypeId, pType); //adding remote type
+ //pdxLocalType->AddOtherVersion(pType);
+ //pdxLocalType->AddOtherVersion(pdxLocalType);//no need to add local type
+
+ //need to create merge type
+ CreateMergedType(pdxLocalType, pType, dataInput, serializationRegistry);
+
+ PdxType^ mergedVersion = PdxTypeRegistry::GetMergedType(pType->TypeId);
+ PdxRemotePreservedData^ preserveData = prtc->GetPreservedData(mergedVersion, pdxObject);
+ if(preserveData != nullptr)
+ PdxTypeRegistry::SetPreserveData(pdxObject, preserveData);
+ }
+ prtc->MoveStream();
+ }
+ else//remote reader will come here as local type is there
+ {
+ pType->InitializeType();
+ //Log::Debug("Adding type " + pType->TypeId);
+ PdxTypeRegistry::AddPdxType(pType->TypeId, pType); //adding remote type
+ //pdxLocalType->AddOtherVersion(pType);
+
+ PdxRemoteReader^ prr = gcnew PdxRemoteReader(dataInput, pType, len);
+
+ pdxObject->FromData(prr);
+
+ if(isPdxWrapper)
+ pdxRealObject = pdxWrapper->GetObject();
+
+ //need to create merge type
+ CreateMergedType(pdxLocalType, pType, dataInput, serializationRegistry);
+
+ PdxType^ mergedVersion = PdxTypeRegistry::GetMergedType(pType->TypeId);
+ PdxRemotePreservedData^ preserveData = prr->GetPreservedData(mergedVersion, pdxObject);
+ if(preserveData != nullptr)
+ PdxTypeRegistry::SetPreserveData(pdxObject, preserveData);
+ prr->MoveStream();
+ }
+ }//end type not found
+ return pdxObject;
+ }
+
+ IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, const native::SerializationRegistry* serializationRegistry)
+ {
+ try
+ {
+ dataInput->setPdxdeserialization(true);
+ if(PdxTypeRegistry::PdxReadSerialized == false || forceDeserialize ||dataInput->isRootObjectPdx())
+ {
+
+ //here we are reading length and typeId..Note; our internal typeid already read in c++ layer
+ int len = dataInput->ReadInt32();
+ int typeId= dataInput->ReadInt32();
+
+ //This is for pdx Statistics
+ CacheRegionHelper::getCacheImpl(dataInput->GetNative()->getCache())->getCachePerfStats().incPdxDeSerialization(len + 9);//pdxLen + 1 + 2*4
+
+ return DeserializePdx(dataInput, forceDeserialize, typeId, len, serializationRegistry);
+ }//create PdxInstance
+ else
+ {
+ IPdxSerializable^ pdxObject = nullptr;
+ //here we are reading length and typeId..Note; our internal typeid already read in c++ layer
+ int len = dataInput->ReadInt32();
+ int typeId= dataInput->ReadInt32();
+
+// Log::Debug(" len " + len + " " + typeId + " readbytes " + dataInput->BytesReadInternally);
+
+ PdxType^ pType = PdxTypeRegistry::GetPdxType(typeId);
+
+ if(pType == nullptr)
+ {
+ PdxType^ pType = (PdxType^)(Serializable::GetPDXTypeById(dataInput->GetPoolName(), typeId, dataInput->GetNative()->getCache()));
+ //this should be fine for IPdxTypeMapper
+ PdxTypeRegistry::AddLocalPdxType(pType->PdxClassName, pType);
+ PdxTypeRegistry::AddPdxType(pType->TypeId, pType);
+ //pType->IsLocal = true; ?????
+ }
+
+ // pdxObject = gcnew PdxInstanceImpl(gcnew DataInput(dataInput->GetBytes(dataInput->GetCursor(), len + 8 ), len + 8));
+ pdxObject = gcnew PdxInstanceImpl(dataInput->GetBytes(dataInput->GetCursor(), len ), len, typeId, true, dataInput->GetNative()->getCache());
+
+ dataInput->AdvanceCursorPdx(len );
+
+ dataInput->AdvanceUMCursor();
+
+ dataInput->SetBuffer();
+
+ //This is for pdxinstance Statistics
+ CacheRegionHelper::getCacheImpl(dataInput->GetNative()->getCache())->getCachePerfStats().incPdxInstanceCreations();
+ return pdxObject;
+ }
+ }finally
+ {
+ dataInput->setPdxdeserialization(false);
+ }
+ }
+
+ Int32 PdxHelper::GetEnumValue(String^ enumClassName, String^ enumName, int hashcode, const native::Cache* cache)
+ {
+ //in case app want different name
+ enumClassName = Serializable::GetPdxTypeName(enumClassName);
+ EnumInfo^ ei = gcnew EnumInfo(enumClassName, enumName, hashcode);
+ return PdxTypeRegistry::GetEnumValue(ei, cache);
+ }
+
+ Object^ PdxHelper::GetEnum(int enumId, const native::Cache* cache)
+ {
+ EnumInfo^ ei = PdxTypeRegistry::GetEnum(enumId, cache);
+ return ei->GetEnum();
+ }
+
+ void PdxHelper::CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput, const native::SerializationRegistry* serializationRegistry)
+ {
+ PdxType^ mergedVersion = localType->MergeVersion(remoteType);
+
+ if(mergedVersion->Equals(localType))
+ {
+ PdxTypeRegistry::SetMergedType(remoteType->TypeId, localType);
+ }
+ else if(mergedVersion->Equals(remoteType))
+ {
+ PdxTypeRegistry::SetMergedType(remoteType->TypeId, remoteType);
+ }
+ else
+ {//need to create new version
+ mergedVersion->InitializeType();
+ if(mergedVersion->TypeId == 0)
+ mergedVersion->TypeId = Serializable::GetPDXIdForType(dataInput->GetPoolName(), mergedVersion, dataInput->GetNative()->getCache());
+
+ // PdxTypeRegistry::AddPdxType(remoteType->TypeId, mergedVersion);
+ PdxTypeRegistry::AddPdxType(mergedVersion->TypeId, mergedVersion);
+ PdxTypeRegistry::SetMergedType(remoteType->TypeId, mergedVersion);
+ PdxTypeRegistry::SetMergedType(mergedVersion->TypeId, mergedVersion);
+ }
+ }
+
+ Int32 PdxHelper::ReadInt32(System::Byte* offsetPosition)
+ {
+ Int32 data = offsetPosition[0];
+ data = (data << 8) | offsetPosition[1];
+ data = (data << 8) | offsetPosition[2];
+ data = (data << 8) | offsetPosition[3];
+
+ return data;
+ }
+
+ Int32 PdxHelper::ReadInt16(System::Byte* offsetPosition)
+ {
+ System::Int16 data = offsetPosition[0];
+ data = (data << 8) | offsetPosition[1];
+ return (Int32)data;
+ }
+
+ Int32 PdxHelper::ReadUInt16(System::Byte* offsetPosition)
+ {
+ UInt16 data = offsetPosition[0];
+ data = (data << 8) | offsetPosition[1];
+ return (Int32)data;
+ }
+
+ Int32 PdxHelper::ReadByte(System::Byte* offsetPosition)
+ {
+ return (Int32)offsetPosition[0];
+ }
+
+ void PdxHelper::WriteInt32(System::Byte* offsetPosition, Int32 value)
+ {
+ offsetPosition[0] = (System::Byte)(value >> 24);
+ offsetPosition[1] = (System::Byte)(value >> 16);
+ offsetPosition[2] = (System::Byte)(value >> 8);
+ offsetPosition[3] = (System::Byte)value;
+ }
+
+ void PdxHelper::WriteInt16(System::Byte* offsetPosition, Int32 value)
+ {
+ Int16 val = (Int16)value;
+ offsetPosition[0] = (System::Byte)(val >> 8);
+ offsetPosition[1] = (System::Byte)val;
+ }
+
+ void PdxHelper::WriteByte(System::Byte* offsetPosition, Int32 value)
+ {
+ offsetPosition[0] = (Byte)value;
+ }
+
+ Int32 PdxHelper::ReadInt(System::Byte* offsetPosition, int size)
+ {
+ switch(size)
+ {
+ case 1:
+ return ReadByte(offsetPosition);
+ case 2:
+ return ReadUInt16(offsetPosition);
+ case 4:
+ return ReadInt32(offsetPosition);
+ }
+ throw gcnew System::ArgumentException("Size should be 1,2 or 4 in PdxHelper::ReadInt.");
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/PdxHelper.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/PdxHelper.hpp b/clicache/src/impl/PdxHelper.hpp
new file mode 100644
index 0000000..7cc9c82
--- /dev/null
+++ b/clicache/src/impl/PdxHelper.hpp
@@ -0,0 +1,79 @@
+/*
+ * 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 "../DataOutput.hpp"
+#include "begin_native.hpp"
+#include <geode/DataOutput.hpp>
+#include "SerializationRegistry.hpp"
+#include "end_native.hpp"
+
+#include "../IPdxSerializable.hpp"
+using namespace System;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+ namespace native = apache::geode::client;
+ ref class DataOutput;
+ ref class DataInput;
+ namespace Internal
+ {
+ ref class PdxType;
+ public ref class PdxHelper
+ {
+ public:
+
+ static void SerializePdx(DataOutput^ dataOutput, IPdxSerializable^ pdxObject);
+
+ static IPdxSerializable^ DeserializePdx(DataInput^ dataOutput, bool forceDeserialize, const native::SerializationRegistry* serializationRegistry);
+
+ static IPdxSerializable^ PdxHelper::DeserializePdx(DataInput^ dataInput, bool forceDeserialize, int typeId, int length, const native::SerializationRegistry* serializationRegistry);
+
+ literal Byte PdxHeader = 8;
+
+ static Int32 ReadInt32(System::Byte* offsetPosition);
+
+ static Int32 ReadInt16(System::Byte* offsetPosition);
+
+ static Int32 PdxHelper::ReadUInt16(System::Byte* offsetPosition);
+
+ static Int32 ReadByte(System::Byte* offsetPosition);
+
+ static void WriteInt32(System::Byte* offsetPosition, Int32 value);
+
+ static void WriteInt16(System::Byte* offsetPosition, Int32 value);
+
+ static void WriteByte(System::Byte* offsetPosition, Int32 value);
+
+ static Int32 ReadInt(System::Byte* offsetPosition, int size);
+
+ static Int32 GetEnumValue(String^ enumClassName, String^ enumName, int hashcode, const native::Cache* cache);
+
+ static Object^ GetEnum(int enumId, const native::Cache* cache);
+
+ private:
+ static void CreateMergedType(PdxType^ localType, PdxType^ remoteType, DataInput^ dataInput, const native::SerializationRegistry* serializationRegistry);
+ };
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/PdxInstanceFactoryImpl.cpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/PdxInstanceFactoryImpl.cpp b/clicache/src/impl/PdxInstanceFactoryImpl.cpp
new file mode 100644
index 0000000..230972a
--- /dev/null
+++ b/clicache/src/impl/PdxInstanceFactoryImpl.cpp
@@ -0,0 +1,359 @@
+/*
+ * 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 "begin_native.hpp"
+#include "CacheRegionHelper.hpp"
+#include "CacheImpl.hpp"
+#include "end_native.hpp"
+#include "PdxInstanceFactoryImpl.hpp"
+#include "PdxInstanceImpl.hpp"
+#include "DotNetTypes.hpp"
+using namespace System::Text;
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+
+ namespace Internal
+ {
+ PdxInstanceFactoryImpl::PdxInstanceFactoryImpl(String^ className, native::Cache* cache)
+ {
+ if (className == nullptr)
+ throw gcnew IllegalStateException(
+ "Classname should not be null.");
+ m_pdxType = gcnew PdxType(className, false);
+ m_FieldVsValues = gcnew Dictionary<String^, Object^>();
+ m_created = false;
+ m_cache = cache;
+ }
+
+ IPdxInstance^ PdxInstanceFactoryImpl::Create()
+ {
+ if (m_created)
+ {
+ throw gcnew IllegalStateException(
+ "The IPdxInstanceFactory.Create() method can only be called once.");
+ }
+ //need to get typeid;
+ IPdxInstance^ pi = gcnew PdxInstanceImpl(m_FieldVsValues, m_pdxType, &CacheRegionHelper::getCacheImpl(m_cache)->getCachePerfStats(), m_cache);
+ m_created = true;
+ return pi;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteChar(String^ fieldName, Char value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "char", PdxTypes::CHAR, GeodeClassIds::CHAR_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteBoolean(String^ fieldName, Boolean value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "boolean", PdxTypes::BOOLEAN, GeodeClassIds::BOOLEAN_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteByte(String^ fieldName, SByte value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "byte", PdxTypes::BYTE, GeodeClassIds::BYTE_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteShort(String^ fieldName, Int16 value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "short", PdxTypes::SHORT, GeodeClassIds::SHORT_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteInt(String^ fieldName, Int32 value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "int", PdxTypes::INT, GeodeClassIds::INTEGER_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteLong(String^ fieldName, Int64 value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "long", PdxTypes::LONG, GeodeClassIds::LONG_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteFloat(String^ fieldName, float value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "float", PdxTypes::FLOAT, GeodeClassIds::FLOAT_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteDouble(String^ fieldName, double value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "double", PdxTypes::DOUBLE, GeodeClassIds::DOUBLE_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteDate(String^ fieldName, System::DateTime value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddFixedLengthTypeField(fieldName, "Date", PdxTypes::DATE, GeodeClassIds::DATE_SIZE);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteString(String^ fieldName, String^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "String", PdxTypes::STRING);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteObject(String^ fieldName, Object^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, /*obj->GetType()->FullName*/"Object", PdxTypes::OBJECT);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteBooleanArray(String^ fieldName, array<Boolean>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "bool[]", PdxTypes::BOOLEAN_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteCharArray(String^ fieldName, array<Char>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "char[]", PdxTypes::CHAR_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteByteArray(String^ fieldName, array<Byte>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "byte[]", PdxTypes::BYTE_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteShortArray(String^ fieldName, array<Int16>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "short[]", PdxTypes::SHORT_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteIntArray(String^ fieldName, array<Int32>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "int[]", PdxTypes::INT_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteLongArray(String^ fieldName, array<Int64>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "long[]", PdxTypes::LONG_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteFloatArray(String^ fieldName, array<float>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "float[]", PdxTypes::FLOAT_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteDoubleArray(String^ fieldName, array<double>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "double[]", PdxTypes::DOUBLE_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteStringArray(String^ fieldName, array<String^>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "String[]", PdxTypes::STRING_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteObjectArray(String^ fieldName, System::Collections::Generic::List<Object^>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "Object[]", PdxTypes::OBJECT_ARRAY);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteArrayOfByteArrays(String^ fieldName, array<array<Byte>^>^ value)
+ {
+ isFieldAdded(fieldName);
+ m_pdxType->AddVariableLengthTypeField(fieldName, "byte[][]", PdxTypes::ARRAY_OF_BYTE_ARRAYS);
+ m_FieldVsValues->Add(fieldName, value);
+ return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::WriteField(String^ fieldName, Object^ fieldValue, Type^ type)
+ {
+ isFieldAdded(fieldName);
+ if (type->Equals(DotNetTypes::IntType))
+ {
+ return this->WriteInt(fieldName, (int)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::StringType))
+ {
+ return this->WriteString(fieldName, (String^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::BooleanType))
+ {
+ return this->WriteBoolean(fieldName, (bool)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::FloatType))
+ {
+ return this->WriteFloat(fieldName, (float)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::DoubleType))
+ {
+ return this->WriteDouble(fieldName, (double)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::CharType))
+ {
+ return this->WriteChar(fieldName, (Char)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::SByteType))
+ {
+ return this->WriteByte(fieldName, (SByte)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::ShortType))
+ {
+ return this->WriteShort(fieldName, (short)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::LongType))
+ {
+ return this->WriteLong(fieldName, (Int64)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::ByteArrayType))
+ {
+ return this->WriteByteArray(fieldName, (array<Byte>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::DoubleArrayType))
+ {
+ return this->WriteDoubleArray(fieldName, (array<double>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::FloatArrayType))
+ {
+ return this->WriteFloatArray(fieldName, (array<float>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::ShortArrayType))
+ {
+ return this->WriteShortArray(fieldName, (array<Int16>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::IntArrayType))
+ {
+ return this->WriteIntArray(fieldName, (array<System::Int32>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::LongArrayType))
+ {
+ return this->WriteLongArray(fieldName, (array<Int64>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::BoolArrayType))
+ {
+ return this->WriteBooleanArray(fieldName, (array<bool>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::CharArrayType))
+ {
+ return this->WriteCharArray(fieldName, (array<Char>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::StringArrayType))
+ {
+ return this->WriteStringArray(fieldName, (array<String^>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::DateType))
+ {
+ return this->WriteDate(fieldName, (DateTime)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::ByteArrayOfArrayType))
+ {
+ return this->WriteArrayOfByteArrays(fieldName, (array<array<Byte>^>^)fieldValue);
+ }
+ else if (type->Equals(DotNetTypes::ObjectArrayType))
+ {
+ return this->WriteObjectArray(fieldName, safe_cast<System::Collections::Generic::List<Object^>^>(fieldValue));
+ }
+ else
+ {
+ return this->WriteObject(fieldName, fieldValue);
+ //throw gcnew IllegalStateException("WriteField unable to serialize "
+ // + fieldName + " of " + type);
+ }
+ // return this;
+ }
+
+ IPdxInstanceFactory^ PdxInstanceFactoryImpl::MarkIdentityField(String^ fieldName)
+ {
+ PdxFieldType^ pft = m_pdxType->GetPdxField(fieldName);
+
+ if (pft == nullptr)
+ {
+ throw gcnew IllegalStateException(
+ "Field must be added before calling MarkIdentityField ");
+ }
+
+ pft->IdentityField = true;
+ return this;
+ }
+
+ void PdxInstanceFactoryImpl::isFieldAdded(String^ fieldName)
+ {
+ if (fieldName == nullptr || fieldName->Length == 0 || m_FieldVsValues->ContainsKey(fieldName))
+ {
+ throw gcnew IllegalStateException(
+ "Field: " + fieldName + " either already added into PdxInstanceFactory or it is null");
+ } // namespace Client
+ } // namespace Geode
+ } // namespace Apache
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6cbd424f/clicache/src/impl/PdxInstanceFactoryImpl.hpp
----------------------------------------------------------------------
diff --git a/clicache/src/impl/PdxInstanceFactoryImpl.hpp b/clicache/src/impl/PdxInstanceFactoryImpl.hpp
new file mode 100644
index 0000000..cce22e4
--- /dev/null
+++ b/clicache/src/impl/PdxInstanceFactoryImpl.hpp
@@ -0,0 +1,402 @@
+/*
+ * 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 "begin_native.hpp"
+#include <geode/Cache.hpp>
+#include "end_native.hpp"
+
+#include "../IPdxInstanceFactory.hpp"
+#include "../IPdxSerializable.hpp"
+#include "../DataInput.hpp"
+#include "PdxLocalWriter.hpp"
+
+namespace Apache
+{
+ namespace Geode
+ {
+ namespace Client
+ {
+
+ namespace Internal
+ {
+
+ namespace native = apache::geode::client;
+
+ ref class PdxInstanceFactoryImpl : IPdxInstanceFactory
+ {
+ private:
+ bool m_created;
+ PdxType^ m_pdxType;
+ Dictionary<String^, Object^>^ m_FieldVsValues;
+ native::Cache* m_cache;
+ internal:
+ PdxInstanceFactoryImpl(String^ className, native::Cache* cache);
+ void isFieldAdded(String^ fieldName);
+
+
+ public:
+ /// <summary>
+ /// Create a {@link PdxInstance}. The instance
+ /// will contain any data written to this factory
+ /// using the write methods.
+ /// @return the created instance
+ /// @throws IllegalStateException if called more than once
+ /// </summary>
+ virtual IPdxInstance^ Create();
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>char</code>.
+ /// <p>Java char is mapped to .NET System.Char.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteChar(String^ fieldName, Char value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>boolean</code>.
+ /// <p>Java boolean is mapped to .NET System.Boolean.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteBoolean(String^ fieldName, Boolean value);
+
+ /// </summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>byte</code>.
+ /// <p>Java byte is mapped to .NET System.SByte.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteByte(String^ fieldName, SByte value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>short</code>.
+ /// <p>Java short is mapped to .NET System.Int16.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteShort(String^ fieldName, Int16 value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>int</code>.
+ /// <p>Java int is mapped to .NET System.Int32.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteInt(String^ fieldName, Int32 value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>long</code>.
+ /// <p>Java long is mapped to .NET System.Int64.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteLong(String^ fieldName, Int64 value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>float</code>.
+ /// <p>Java float is mapped to .NET System.Float.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteFloat(String^ fieldName, float value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>double</code>.
+ /// <p>Java double is mapped to .NET System.Double.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteDouble(String^ fieldName, double value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>Date</code>.
+ /// <p>Java Date is mapped to .NET System.DateTime.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteDate(String^ fieldName, System::DateTime value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>String</code>.
+ /// <p>Java String is mapped to .NET System.String.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteString(String^ fieldName, String^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>Object</code>.
+ /// <p>
+ /// It is best to use one of the other writeXXX methods if your field type
+ /// will always be XXX. This method allows the field value to be anything
+ /// that is an instance of Object. This gives you more flexibility but more
+ /// space is used to store the serialized field.
+ /// <p>
+ /// Note that some Java objects serialized with this method may not be compatible with non-java languages.
+ /// To ensure that only portable objects are serialized use {@link #writeObject(String, Object, boolean)}.
+ ///
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteObject(String^ fieldName, Object^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>boolean[]</code>.
+ /// <p>Java boolean[] is mapped to .NET System.Boolean[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteBooleanArray(String^ fieldName, array<Boolean>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>char[]</code>.
+ /// <p>Java char[] is mapped to .NET System.Char[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteCharArray(String^ fieldName, array<Char>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>byte[]</code>.
+ /// <p>Java byte[] is mapped to .NET System.Byte[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteByteArray(String^ fieldName, array<Byte>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>short[]</code>.
+ /// <p>Java short[] is mapped to .NET System.Int16[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteShortArray(String^ fieldName, array<Int16>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>int[]</code>.
+ /// <p>Java int[] is mapped to .NET System.Int32[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteIntArray(String^ fieldName, array<Int32>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>long[]</code>.
+ /// <p>Java long[] is mapped to .NET System.Int64[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteLongArray(String^ fieldName, array<Int64>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>float[]</code>.
+ /// <p>Java float[] is mapped to .NET System.Float[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteFloatArray(String^ fieldName, array<float>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>double[]</code>.
+ /// <p>Java double[] is mapped to .NET System.Double[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteDoubleArray(String^ fieldName, array<double>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>String[]</code>.
+ /// <p>Java String[] is mapped to .NET System.String[].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteStringArray(String^ fieldName, array<String^>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>Object[]</code>.
+ /// <p>Java Object[] is mapped to .NET System.Collections.Generic.List<Object>.
+ /// For how each element of the array is a mapped to .NET see {@link #writeObject(String, Object, boolean) writeObject}.
+ /// Note that this call may serialize elements that are not compatible with non-java languages.
+ /// To ensure that only portable objects are serialized use {@link #writeObjectArray(String, Object[], boolean)}.
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteObjectArray(String^ fieldName, System::Collections::Generic::List<Object^>^ value);
+ /// <summary>
+ /// Writes the named field with the given value to the serialized form.
+ /// The fields type is <code>byte[][]</code>.
+ /// <p>Java byte[][] is mapped to .NET System.Byte[][].
+ /// @param fieldName the name of the field to write
+ /// @param value the value of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// </summary>
+ virtual IPdxInstanceFactory^ WriteArrayOfByteArrays(String^ fieldName, array<array<Byte>^>^ value);
+
+ /// <summary>
+ /// Writes the named field with the given value and type to the serialized form.
+ /// This method uses the <code>fieldType</code> to determine which writeXXX method it should call.
+ /// If it can not find a specific match to a writeXXX method it will call {@link #writeObject(String, Object) writeObject}.
+ /// This method may serialize objects that are not portable to non-java languages.
+ /// To ensure that only objects that are portable to non-java languages are serialized use {@link #writeField(String, Object, Class, boolean)} instead.
+ /// <p>The fieldTypes that map to a specific method are:
+ /// <ul>
+ /// <li>boolean.class: {@link #writeBoolean}
+ /// <li>byte.class: {@link #writeByte}
+ /// <li>char.class: {@link #writeChar}
+ /// <li>short.class: {@link #writeShort}
+ /// <li>int.class: {@link #writeInt}
+ /// <li>long.class: {@link #writeLong}
+ /// <li>float.class: {@link #writeFloat}
+ /// <li>double.class: {@link #writeDouble}
+ /// <li>String.class: {@link #writeString}
+ /// <li>Date.class: {@link #writeDate}
+ /// <li>boolean[].class: {@link #writeBooleanArray}
+ /// <li>byte[].class: {@link #writeByteArray}
+ /// <li>char[].class: {@link #writeCharArray}
+ /// <li>short[].class: {@link #writeShortArray}
+ /// <li>int[].class: {@link #writeIntArray}
+ /// <li>long[].class: {@link #writeLongArray}
+ /// <li>float[].class: {@link #writeFloatArray}
+ /// <li>double[].class: {@link #writeDoubleArray}
+ /// <li>String[].class: {@link #writeStringArray}
+ /// <li>byte[][].class: {@link #writeArrayOfByteArrays}
+ /// <li>any other array class: {@link #writeObjectArray}
+ /// </ul>
+ /// Note that the object form of primitives, for example Integer.class and Long.class, map to {@link #writeObject(String, Object) writeObject}.
+ /// @param fieldName the name of the field to write
+ /// @param fieldValue the value of the field to write; this parameter's class must extend the <code>fieldType</code>
+ /// @param fieldType the type of the field to write
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldAlreadyExistsException if the named field has already been written
+ /// @throws PdxSerializationException if serialization of the field fails.
+ /// <summary>
+ virtual IPdxInstanceFactory^ WriteField(String^ fieldName, Object^ fieldValue, Type^ fieldType);
+
+ /// <summary>
+ /// Indicate that the named field should be included in hashCode and equals checks
+ /// of this object on a server that is accessing {@link PdxInstance}
+ /// or when a client executes a query on a server.
+ ///
+ /// The fields that are marked as identity fields are used to generate the hashCode and
+ /// equals methods of {@link PdxInstance}. Because of this, the identity fields should themselves
+ /// either be primitives, or implement hashCode and equals.
+ ///
+ /// If no fields are set as identity fields, then all fields will be used in hashCode and equals
+ /// checks.
+ ///
+ /// The identity fields should make marked after they are written using a write/// method.
+ ///
+ /// @param fieldName the name of the field to mark as an identity field.
+ /// @return this PdxInstanceFactory
+ /// @throws PdxFieldDoesNotExistException if the named field has not already been written.
+ /// </summary>
+ virtual IPdxInstanceFactory^ MarkIdentityField(String^ fieldName);
+
+
+ };
+ } // namespace Client
+ } // namespace Geode
+} // namespace Apache
+
+}