VMware Tanzu GemFire Native C++ Reference 10.3.0
apache::geode::client::PdxInstanceFactory Class Reference

PdxInstanceFactory gives you a way to create PdxInstances. More...

#include <PdxInstanceFactory.hpp>

Public Member Functions

std::shared_ptr< PdxInstancecreate ()
 Create a PdxInstance. More...
 
PdxInstanceFactorymarkIdentityField (const std::string &fieldName)
 Indicate that the named field should be included in hashCode and equals (operator==()) checks of this object on a server that is accessing PdxInstance or when a client executes a query on a server. More...
 
PdxInstanceFactorywriteArrayOfByteArrays (const std::string &fieldName, int8_t **value, int32_t arrayLength, int32_t *elementLength)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteBoolean (const std::string &fieldName, bool value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteBooleanArray (const std::string &fieldName, const std::vector< bool > &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteByte (const std::string &fieldName, int8_t value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteByteArray (const std::string &fieldName, const std::vector< int8_t > &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteChar (const std::string &fieldName, char value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteChar (const std::string &fieldName, char16_t value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteCharArray (const std::string &fieldName, const std::vector< char16_t > &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteDate (const std::string &fieldName, std::shared_ptr< CacheableDate > value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteDouble (const std::string &fieldName, double value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteDoubleArray (const std::string &fieldName, const std::vector< double > &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteFloat (const std::string &fieldName, float value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteFloatArray (const std::string &fieldName, const std::vector< float > &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteInt (const std::string &fieldName, int32_t value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteIntArray (const std::string &fieldName, const std::vector< int32_t > &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteLong (const std::string &fieldName, int64_t value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteLongArray (const std::string &fieldName, const std::vector< int64_t > &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteObject (const std::string &fieldName, std::shared_ptr< Cacheable > value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteObjectArray (const std::string &fieldName, std::shared_ptr< CacheableObjectArray > value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteShort (const std::string &fieldName, int16_t value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteShortArray (const std::string &fieldName, const std::vector< int16_t > &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteString (const std::string &fieldName, const std::string &value)
 Writes the named field with the given value to the serialized form. More...
 
PdxInstanceFactorywriteStringArray (const std::string &fieldName, const std::vector< std::string > &value)
 Writes the named field with the given value to the serialized form. More...
 

Detailed Description

PdxInstanceFactory gives you a way to create PdxInstances.

Call the write methods to populate the field data and then call create to produce an actual instance that contains the data. To create a factory call Cache#createPdxInstanceFactory. A factory can only create a single instance. To create multiple instances create multiple factories or use PdxInstance#createWriter to create subsequent instances.

Member Function Documentation

◆ create()

std::shared_ptr< PdxInstance > apache::geode::client::PdxInstanceFactory::create ( )

Create a PdxInstance.

The instance will contain any data written to this factory using the write methods.

Returns
the created Pdxinstance
Exceptions
IllegalStateExceptionif called more than once

◆ markIdentityField()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::markIdentityField ( const std::string &  fieldName)

Indicate that the named field should be included in hashCode and equals (operator==()) checks of this object on a server that is accessing 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 (operator==()) methods of PdxInstance. Because of this, the identity fields should themselves either be primitives, or implement hashCode and equals (operator==()).

If no fields are set as identity fields, then all fields will be used in hashCode and equals (operator==()) checks.

The identity fields should make marked after they are written using a write* method.

Parameters
fieldNamethe name of the field to mark as an identity field.
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field does not exist.

◆ writeArrayOfByteArrays()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeArrayOfByteArrays ( const std::string &  fieldName,
int8_t **  value,
int32_t  arrayLength,
int32_t *  elementLength 
)

Writes the named field with the given value to the serialized form.

The fields type is int8_t**.

Java byte[][] is mapped to C++ int8_t**.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
arrayLengththe length of the actual byte array field holding individual byte arrays to write
elementLengththe length of the individual byte arrays to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeBoolean()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeBoolean ( const std::string &  fieldName,
bool  value 
)

Writes the named field with the given value to the serialized form.

The fields type is bool.

Java boolean is mapped to C++ bool.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeBooleanArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeBooleanArray ( const std::string &  fieldName,
const std::vector< bool > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is bool*.

Java boolean[] is mapped to C++ bool*.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeByte()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeByte ( const std::string &  fieldName,
int8_t  value 
)

Writes the named field with the given value to the serialized form.

The fields type is int8_t.

Java byte is mapped to C++ int8_t

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeByteArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeByteArray ( const std::string &  fieldName,
const std::vector< int8_t > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is int8_t*.

Java byte[] is mapped to C++ int8_t*.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeChar() [1/2]

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeChar ( const std::string &  fieldName,
char  value 
)

Writes the named field with the given value to the serialized form.

The fields type is char.

Java char is mapped to C++ char.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeChar() [2/2]

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeChar ( const std::string &  fieldName,
char16_t  value 
)

Writes the named field with the given value to the serialized form.

The fields type is char16_t.

Java char is mapped to C++ char16_t.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeCharArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeCharArray ( const std::string &  fieldName,
const std::vector< char16_t > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is char16_t*.

Java char[] is mapped to C++ char16_t*.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeDate()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeDate ( const std::string &  fieldName,
std::shared_ptr< CacheableDate value 
)

Writes the named field with the given value to the serialized form.

The fields type is CacheableDatePtr.

Java Date is mapped to C++ std::shared_ptr<CacheableDate>.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeDouble()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeDouble ( const std::string &  fieldName,
double  value 
)

Writes the named field with the given value to the serialized form.

The fields type is double.

Java double is mapped to C++ double.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeDoubleArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeDoubleArray ( const std::string &  fieldName,
const std::vector< double > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is double*.

Java double[] is mapped to C++ double*.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeFloat()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeFloat ( const std::string &  fieldName,
float  value 
)

Writes the named field with the given value to the serialized form.

The fields type is float.

Java float is mapped to C++ float.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeFloatArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeFloatArray ( const std::string &  fieldName,
const std::vector< float > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is float*.

Java float[] is mapped to C++ float*.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeInt()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeInt ( const std::string &  fieldName,
int32_t  value 
)

Writes the named field with the given value to the serialized form.

The fields type is int32_t.

Java int is mapped to C++ int32_t.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeIntArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeIntArray ( const std::string &  fieldName,
const std::vector< int32_t > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is int32_t*.

Java int[] is mapped to C++ int32_t*.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeLong()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeLong ( const std::string &  fieldName,
int64_t  value 
)

Writes the named field with the given value to the serialized form.

The fields type is int64_t.

Java long is mapped to C++ int64_t.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeLongArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeLongArray ( const std::string &  fieldName,
const std::vector< int64_t > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is int64_t*.

Java long[] is mapped to C++ int64_t*.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeObject()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeObject ( const std::string &  fieldName,
std::shared_ptr< Cacheable value 
)

Writes the named field with the given value to the serialized form.

The fields type is CacheablePtr.

Java object is mapped to C++ std::shared_ptr<Cacheable>.

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.

Note that some Java objects serialized with this method may not be compatible with non-java languages.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeObjectArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeObjectArray ( const std::string &  fieldName,
std::shared_ptr< CacheableObjectArray value 
)

Writes the named field with the given value to the serialized form.

The fields type is CacheableObjectArrayPtr. Java Object[] is mapped to C++ std::shared_ptr<CacheableObjectArray>. For how each element of the array is a mapped to C++ see writeObject. Note that this call may serialize elements that are not compatible with non-java languages.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeShort()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeShort ( const std::string &  fieldName,
int16_t  value 
)

Writes the named field with the given value to the serialized form.

The fields type is int16_t.

Java short is mapped to C++ int16_t.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeShortArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeShortArray ( const std::string &  fieldName,
const std::vector< int16_t > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is int16_t*.

Java short[] is mapped to C++ int16_t*.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeString()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeString ( const std::string &  fieldName,
const std::string &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is std::string.

Java String is mapped to C++ std::string.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

◆ writeStringArray()

PdxInstanceFactory & apache::geode::client::PdxInstanceFactory::writeStringArray ( const std::string &  fieldName,
const std::vector< std::string > &  value 
)

Writes the named field with the given value to the serialized form.

The fields type is char**.

Java String[] is mapped to C++ char**.

Parameters
fieldNamethe name of the field to write
valuethe value of the field to write
Returns
this PdxInstanceFactory
Exceptions
IllegalStateExceptionif the named field has already been written or fieldName is nullptr or empty.

Apache Geode C++ Cache API Documentation