class ManagedSerializableArray

Inherits: IReflectable

Allows access to an underlying managed array, or a cached version of that array that can be serialized/deserialized.

You can transfer an object in linked state to serialized state by calling serialize(). If an object is in serialized state you can call deserialize() to populated a managed object from the cached data.

Public

Constructors

ManagedSerializableArray

ManagedSerializableArray(const ConstructPrivately &dummy, const SPtr<ManagedTypeInfoArray> &typeInfo, MonoObject *managedInstance)

ManagedSerializableArray

ManagedSerializableArray(const ConstructPrivately &dummy)

Methods

~ManagedSerializableArray

~ManagedSerializableArray() noexcept

GetManagedInstance

MonoObject *GetManagedInstance() const

Returns the internal managed instance of the array.

This will return null if the object is in serialized mode.

GetTypeInfo

SPtr<ManagedTypeInfoArray> GetTypeInfo() const

Returns the type information for the internal array.

Resize

void Resize(const Vector<u32> &newSizes)

Changes the size of the array.

Operates on managed object if in linked state, or on cached data otherwise. If in linked state the new instance of the managed object will be created and must be retrieved by GetManagedInstance().

newSizes
Array of sizes, one per array dimension. Number of sizes must match number of array dimensions as specified by its type.

GetLength

u32 GetLength(u32 dimension) const

Returns the size of a specific dimension of the array.

Operates on managed object if in linked state, or on cached data otherwise.

GetLengths

Vector<u32> GetLengths() const

Returns the sizes of a all dimensions of the array.

Operates on managed object if in linked state, or on cached data otherwise.

GetTotalLength

u32 GetTotalLength() const

Returns the total of all sizes of all dimensions of the array.

Operates on managed object if in linked state, or on cached data otherwise.

SetFieldData

void SetFieldData(u32 arrayIdx, const SPtr<ManagedSerializableFieldData> &val)

Sets a new element value at the specified array index.

Operates on managed object if in linked state, or on cached data otherwise.

arrayIdx
Index at which to set the value.
val
Wrapper around the value to store in the array. Must be of the array element type.

GetFieldData

SPtr<ManagedSerializableFieldData> GetFieldData(u32 arrayIdx)

Returns the element value at the specified array index.

Operates on managed object if in linked state, or on cached data otherwise.

arrayIdx
Index at which to retrieve the value.

Returns: A wrapper around the element value in the array.

Serialize

void Serialize()

Serializes the internal managed object into a set of cached data that can be saved in memory/disk and can be deserialized later.

The internal managed object will be freed (if no other references to it). Calling serialize() again will have no result.

Deserialize

MonoObject *Deserialize()

Deserializes a set of cached data into a managed object.

This action may fail in case the cached data contains a type that no longer exists in which case null is returned.

Returns: Newly created object initialized with the cached data.

staticCreateFromExisting

static SPtr<ManagedSerializableArray> CreateFromExisting(MonoObject *managedInstance, const SPtr<ManagedTypeInfoArray> &typeInfo)

Creates a managed serializable array that references an existing managed array.

Created object will be in linked mode.

managedInstance
Constructed managed instance of the array to link with. Its type must correspond with the provided type info.
typeInfo
Type information for the array and its elements.

staticCreateNew

static SPtr<ManagedSerializableArray> CreateNew(const SPtr<ManagedTypeInfoArray> &typeInfo, const Vector<u32> &sizes)

Creates a managed serializable array that creates and references a brand new managed array instance.

typeInfo
Type of the array to create.
sizes
Array of sizes, one per array dimension. Number of sizes must match number of array dimensions as specified by its type.

staticCreateManagedInstance

static MonoObject *CreateManagedInstance(const SPtr<ManagedTypeInfoArray> &typeInfo, const Vector<u32> &sizes)

Creates a managed array instance.

typeInfo
Type of the array to create.
sizes
Array of sizes, one per array dimension. Number of sizes must match number of array dimensions as specified by its type.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const

Returns an interface you can use to access class' Run Time Type Information.

Protected

Methods

InitMonoObjects

void InitMonoObjects()

Retrieves needed Mono types and methods.

Should be called before performing any operations with the managed object.

GetLengthInternal

u32 GetLengthInternal(u32 dimension) const

Returns the size of the specified dimension of the array.

Operates on the internal managed object.

SetFieldData

void SetFieldData(MonoArray *obj, u32 arrayIdx, const SPtr<ManagedSerializableFieldData> &val)

Sets a new element value at the specified array index.

Operates on the provided managed instance.

obj
Managed instance in which to set the data in.
arrayIdx
Index at which to set the value.
val
Wrapper around the value to store in the array. Must be of the array element type.

SetValueInternal

void SetValueInternal(MonoArray *obj, u32 arrayIdx, void *val)

Sets a value at the specified index in the array.

Operates on the provided managed object.

ToSequentialIdx

u32 ToSequentialIdx(const Vector<u32> &idx) const

Converts a multi-dimensional array index into a sequential one-dimensional index.

staticCreateNew

static SPtr<ManagedSerializableArray> CreateNew()

Creates an empty and uninitialized object used for serialization purposes.

Fields

mGCHandle

uint32_t mGCHandle

mElementMonoClass

::MonoClass * mElementMonoClass

mCopyMethod

MonoMethod * mCopyMethod

mArrayTypeInfo

SPtr<ManagedTypeInfoArray> mArrayTypeInfo

mCachedEntries

Vector<SPtr<ManagedSerializableFieldData>> mCachedEntries

mNumElements

Vector<u32> mNumElements

mElemSize

u32 mElemSize