2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 17:04:55 +00:00

Various CStateManager additions and camera stubs

This commit is contained in:
Jack Andersen
2016-04-16 11:49:47 -10:00
parent e51a657ec1
commit 042030934b
44 changed files with 778 additions and 124 deletions

View File

@@ -31,44 +31,9 @@ struct SObjectTag
}
};
/**
* @brief singleton static-allocator
*/
template<class T>
class TOneStatic
{
static u8 m_allocspace[sizeof(T)];
static u32 m_refCount;
public:
static T* GetAllocSpace() {return (T*)m_allocspace;}
static u32& ReferenceCount() {return m_refCount;}
T* operator->() const {return (T*)m_allocspace;}
T& operator*() const {return *(T*)m_allocspace;}
void* operator new(size_t) = delete;
void operator delete(void*) = delete;
template<typename U = T>
TOneStatic(typename std::enable_if<!std::is_default_constructible<U>::value>::type* = 0)
{++m_refCount;}
template<typename U = T>
TOneStatic(typename std::enable_if<std::is_default_constructible<U>::value>::type* = 0)
{++m_refCount; new (m_allocspace) T();}
template<typename... Args> TOneStatic(Args&&... args)
{++m_refCount; new (m_allocspace) T(std::forward<Args>(args)...);}
~TOneStatic() {--m_refCount;}
template<typename... Args> void reset(Args&&... args)
{new (m_allocspace) T(std::forward<Args>(args)...);}
};
template<class T> u8 TOneStatic<T>::m_allocspace[sizeof(T)];
template<class T> u32 TOneStatic<T>::m_refCount;
using TUniqueId = u16;
using TEditorId = u32;
using TAreaId = u32;
using TUniqueId = s16;
using TEditorId = s32;
using TAreaId = s32;
#define kInvalidEditorId TEditorId(-1)
#define kInvalidUniqueId TUniqueId(-1)