mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 17:07:41 +00:00
more classes added
This commit is contained in:
40
Runtime/rstl.hpp
Normal file
40
Runtime/rstl.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef __RSTL_HPP__
|
||||
#define __RSTL_HPP__
|
||||
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace rstl
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Vector reserved on construction
|
||||
*/
|
||||
template <class T, size_t N>
|
||||
class reserved_vector : public std::vector<T>
|
||||
{
|
||||
public:
|
||||
reserved_vector() {this->reserve(N);}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Simple data/refcount pair
|
||||
*/
|
||||
class CRefData
|
||||
{
|
||||
void* m_ptr;
|
||||
int m_refCount;
|
||||
public:
|
||||
CRefData() : m_ptr(nullptr), m_refCount(0xffffff) {}
|
||||
CRefData(void* ptr) : m_ptr(ptr), m_refCount(0) {}
|
||||
|
||||
void* GetPtr() const {return m_ptr;}
|
||||
int AddRef() {return ++m_refCount;}
|
||||
int DelRef() {return --m_refCount;}
|
||||
|
||||
static CRefData sNull;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __RSTL_HPP__
|
||||
Reference in New Issue
Block a user