Photon C++ Client API: ValueObject< Etype > Class Template Reference

Photon C++ Client API

Photon C++ Client API  4.1.12.2
ValueObject< Etype > Class Template Reference
Inheritance diagram for ValueObject< Etype >:
Collaboration diagram for ValueObject< Etype >:

Public Member Functions

 ValueObject (const ValueObject< Etype > &toCopy)
 
 ValueObject (const Object &obj)
 
 ValueObject (const Object *obj)
 
 ValueObject (const typename Helpers::ConfirmAllowed< Etype >::type &data)
 
 ValueObject (const typename Helpers::ConfirmAllowed< Etype >::type pData, typename Helpers::ArrayLengthType< Etype >::type size)
 
 ValueObject (const typename Helpers::ConfirmAllowed< Etype >::type pData, const short *sizes)
 
virtual ~ValueObject (void)
 
virtual ValueObject< Etype > & operator= (const ValueObject< Etype > &toCopy)
 
virtual ValueObject< Etype > & operator= (const Object &toCopy)
 
const Helpers::ArrayLengthType< Etype >::type * getSizes (void) const
 
Etype getDataCopy (void) const
 
Etype * getDataAddress (void) const
 
- Public Member Functions inherited from Object
 Object (void)
 
virtual ~Object (void)
 
 Object (const Object &toCopy)
 
bool operator== (const Object &toCompare) const
 
bool operator!= (const Object &toCompare) const
 
nByte getType (void) const
 
nByte getCustomType (void) const
 
const short * getSizes (void) const
 
unsigned int getDimensions (void) const
 
JStringtoString (JString &retStr, bool withTypes=false) const
 
- Public Member Functions inherited from Base
virtual ~Base (void)
 
- Public Member Functions inherited from ToString
virtual ~ToString (void)
 
virtual JString typeToString (void) const
 
JString toString (bool withTypes=false) const
 

Additional Inherited Members

- Static Public Member Functions inherited from Base
static void setListener (const BaseListener *baseListener)
 
static int getDebugOutputLevel (void)
 
static bool setDebugOutputLevel (int debugLevel)
 
static const LogFormatOptionsgetLogFormatOptions (void)
 
static void setLogFormatOptions (const LogFormatOptions &options)
 

Detailed Description

template<typename Etype>
class ExitGames::Common::ValueObject< Etype >

Container class template for objects to be stored as values in a Hashtable or Dictionary.

Remarks
In most cases the library will do the work of storing a value in a ValueObject for you, so for example you don't have to explicitly create an instance of this class, when storing a key-value pair in a Dictionary or Hashtable instance. However there are some situations, where you will receive instances of class Object or want to create them (for example Hashtable::getValue() will return an Object) and in that case casting those instances into ValueObject-instances can be a convenient way of assuring a type-safe access to their payloads.

Constructor & Destructor Documentation

§ ValueObject() [1/6]

ValueObject ( const ValueObject< Etype > &  toCopy)

Copy-Constructor.

Creates an object out of a deep copy of its parameter.

The parameter has to be of the same template overload as the object, you want to create.

Parameters
toCopyThe object to copy.

§ ValueObject() [2/6]

ValueObject ( const Object obj)

Constructor.

Creates an object out of a deep copy of the passed Object&.

If the type of the content of the passed object does not match the template overload of the object to create, an empty object is created instead of a copy of the passed object, which leads to getDataCopy() and getDataAddress() returning 0.

Parameters
objThe Object& to copy.

§ ValueObject() [3/6]

ValueObject ( const Object obj)

Constructor.

Creates an object out of a deep copy of the passed Object*.

If the type of the content of the passed object does not match the template overload of the object to create, an empty object is created instead of a copy of the passed object, which leads to getDataCopy() and getDataAddress() return 0.

Parameters
objThe Object* to copy.

§ ValueObject() [4/6]

ValueObject ( const typename Helpers::ConfirmAllowed< Etype >::type &  data)

Constructor.

Creates an object out of a deep copy of the passed single-value Etype.

Parameters
dataThe value to copy. Has to be of a supported type.

§ ValueObject() [5/6]

ValueObject ( const typename Helpers::ConfirmAllowed< Etype >::type  pData,
typename Helpers::ArrayLengthType< Etype >::type  size 
)

Constructor.

Creates an object out of a deep copy of the passed single-dimensional Etype-array.

Parameters
pDataThe array to copy.
sizeThe element count of data.

§ ValueObject() [6/6]

ValueObject ( const typename Helpers::ConfirmAllowed< Etype >::type  pData,
const short *  sizes 
)

Constructor.

Creates an object out of a deep copy of the passed multi-dimensional Etype-array.

Parameters
pDataThe array to copy.
sizesThe array of element counts for the different dimensions of data.

§ ~ValueObject()

~ValueObject ( void  )
virtual

Destructor.

Member Function Documentation

§ operator=() [1/2]

ValueObject< Etype > & operator= ( const ValueObject< Etype > &  toCopy)
virtual

operator= : Makes a deep copy of its right operand into its left operand. This overwrites old data in the left operand.

§ operator=() [2/2]

ValueObject< Etype > & operator= ( const Object toCopy)
virtual

operator= : Makes a deep copy of its right operand into its left operand. This overwrites old data in the left operand.

If the type of the content of the right operand does not match the template overload of the left operand, then the left operand stays unchanged.

Reimplemented from Object.

§ getDataCopy()

Etype getDataCopy ( void  ) const

Returns a deep copy of the content of the object. If you only need access to the content, while the object still exists, you can use getDataAddress() instead to avoid the deep copy. That is especially interesting for large content, of course.

If successful, the template overloads for array types of this function allocate the data for the copy by calling allocateArray<Etype>(), so you have to call deallocateArray() on it, as soon, as you do not need the array anymore. All non-array copies free their memory automatically, as soon as they leave their scope, same as the single indices of the array, as soon, as the array is freed.

In case of an error this function returns 0 for primitive return types and for arrays and an empty object for classes.

Returns
a deep copy of the content of the object if successful, 0 or an empty object otherwise.

§ getDataAddress()

Etype * getDataAddress ( void  ) const

Returns the address of the original content of the object. If you need access to the data beyond the lifetime of the object, call getDataCopy() instead of this function.

The return type is a pointer to the data, so it is a double-pointer for template overloads, for which the data itself already is a pointer.

In case of an error, this function returns NULL.

Returns
the address of the original content of the object, if successful, NULL otherwise.