Refactor the way resources are loaded (#191)
* WIP * WIP * Font works * WIP: Only Music remains * Looks like it's working * Fix oopsie * Core/ObjectRef: Add cast functions * Update ChangeLog.md * Audio/SoundStream: Make sound stream thread-safe
This commit is contained in:
@@ -480,6 +480,60 @@ namespace Nz
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Casts an ObjectRef from one type to another using static_cast
|
||||
* \return Reference to the casted object
|
||||
*
|
||||
* \param ref The reference to convert
|
||||
*
|
||||
* \remark It is an undefined behavior to cast between incompatible types
|
||||
*/
|
||||
template<typename T, typename U>
|
||||
ObjectRef<T> ConstRefCast(const ObjectRef<U>& ref)
|
||||
{
|
||||
return ObjectRef<T>(const_cast<T*>(ref.Get()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Casts an ObjectRef from one type to another using static_cast
|
||||
* \return Reference to the casted object
|
||||
*
|
||||
* \param ref The reference to convert
|
||||
*/
|
||||
template<typename T, typename U>
|
||||
ObjectRef<T> DynamicRefCast(const ObjectRef<U>& ref)
|
||||
{
|
||||
return ObjectRef<T>(dynamic_cast<T*>(ref.Get()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Casts an ObjectRef from one type to another using static_cast
|
||||
* \return Reference to the casted object
|
||||
*
|
||||
* \param ref The reference to convert
|
||||
*
|
||||
* \remark It is an undefined behavior to cast between incompatible types
|
||||
*/
|
||||
template<typename T, typename U>
|
||||
ObjectRef<T> ReinterpretRefCast(const ObjectRef<U>& ref)
|
||||
{
|
||||
return ObjectRef<T>(static_cast<T*>(ref.Get()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Casts an ObjectRef from one type to another using static_cast
|
||||
* \return Reference to the casted object
|
||||
*
|
||||
* \param ref The reference to convert
|
||||
*
|
||||
* \remark It is an undefined behavior to cast between incompatible types
|
||||
*/
|
||||
template<typename T, typename U>
|
||||
ObjectRef<T> StaticRefCast(const ObjectRef<U>& ref)
|
||||
{
|
||||
return ObjectRef<T>(static_cast<T*>(ref.Get()));
|
||||
}
|
||||
}
|
||||
|
||||
namespace std
|
||||
@@ -504,3 +558,4 @@ namespace std
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
#include "ObjectRef.hpp"
|
||||
|
||||
Reference in New Issue
Block a user