Added an abstract base class for NativeAsset to prepare to support serialization of Assets for scripts

This commit is contained in:
Kah Wei 2022-11-22 00:39:53 +08:00
parent af2ad6cc80
commit 07efa1ab51
3 changed files with 46 additions and 21 deletions

View File

@ -21,6 +21,17 @@ of DigiPen Institute of Technology is prohibited.
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
/* Explicit Tempalte Instantiations */
/* Properties */
/*---------------------------------------------------------------------------------*/
GenericHandle Asset::NativeObjectHandle::get()
{
return nativeObjHandle;
}
/*---------------------------------------------------------------------------------*/
/* Constructors */
/*---------------------------------------------------------------------------------*/
Asset::Asset(Handle<void> nativeHandle)
: nativeObjHandle { Convert::ToCLI(Handle<void>(nativeHandle)) }
{}
}

View File

@ -24,11 +24,6 @@ namespace SHADE
/* Properties */
/*---------------------------------------------------------------------------------*/
template <typename NativeAssetType>
GenericHandle NativeAsset<NativeAssetType>::NativeObjectHandle::get()
{
return nativeObjHandle;
}
template <typename NativeAssetType>
Handle<NativeAssetType> NativeAsset<NativeAssetType>::NativeObject::get()
try
{
@ -44,7 +39,6 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
template <typename NativeAssetType>
NativeAsset<NativeAssetType>::NativeAsset(Handle<NativeAssetType> nativeObj)
: nativeObjHandle{ Convert::ToCLI(Handle<void>(nativeObj)) }
: Asset { Handle<void>(nativeObj) }
{}
}

View File

@ -19,13 +19,9 @@ of DigiPen Institute of Technology is prohibited.
namespace SHADE
{
/// <summary>
/// Generalised template class for a managed representation of a native asset
/// Abstract base class that all Native Assets will inherit from.
/// </summary>
/// <typeparam name="NativeAssetType">
/// The type of the asset's native representation.
/// </typeparam>
template<typename NativeAssetType>
public ref class NativeAsset
public ref class Asset abstract
{
internal:
/*-----------------------------------------------------------------------------*/
@ -38,6 +34,36 @@ namespace SHADE
{
GenericHandle get();
}
/*-----------------------------------------------------------------------------*/
/* Constructors/Destructor */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Constructor for the asset.
/// </summary>
/// <param name="ptr">Native asset object handle.</param>
Asset(Handle<void> nativeHandle);
protected:
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
GenericHandle nativeObjHandle;
};
/// <summary>
/// Generalised template class for a managed representation of a native asset
/// </summary>
/// <typeparam name="NativeAssetType">
/// The type of the asset's native representation.
/// </typeparam>
template<typename NativeAssetType>
public ref class NativeAsset abstract : Asset
{
internal:
/*-----------------------------------------------------------------------------*/
/* Properties */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Copy of the Handle to the native object.
/// </summary>
@ -52,14 +78,8 @@ namespace SHADE
/// <summary>
/// Constructor for the native asset
/// </summary>
/// <param name="ptr">Native asset object.</param>
/// <param name="ptr">Native asset object handle.</param>
NativeAsset(Handle<NativeAssetType> ptr);
protected:
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
GenericHandle nativeObjHandle;
};
}