Core Module refactored.

This commit is contained in:
Martín Lucas Golini
2014-06-14 03:24:12 -03:00
parent 810b4568aa
commit e4d342d8d0
6 changed files with 1042 additions and 1042 deletions

View File

@@ -7,7 +7,7 @@
namespace EE {
template<typename T>
class eeAllocator {
class Allocator {
public:
typedef T value_type;
typedef T * pointer;
@@ -17,13 +17,13 @@ class eeAllocator {
typedef ptrdiff_t difference_type;
typedef size_t size_type;
eeAllocator() {
Allocator() {
}
eeAllocator( const eeAllocator& ) {
Allocator( const Allocator& ) {
}
virtual ~eeAllocator() {
virtual ~Allocator() {
}
T * allocate( size_t cnt, typename std::allocator<void>::const_pointer ptr = 0 ) {
@@ -59,18 +59,18 @@ class eeAllocator {
return &x;
}
eeAllocator<T>& operator=(const eeAllocator&) { return *this; }
Allocator<T>& operator=(const Allocator&) { return *this; }
template <class U>
struct rebind {
typedef eeAllocator<U> other;
typedef Allocator<U> other;
};
template <class U>
eeAllocator( const eeAllocator<U>& ) {}
Allocator( const Allocator<U>& ) {}
template <class U>
eeAllocator& operator=(const eeAllocator<U>&) { return *this; }
Allocator& operator=(const Allocator<U>&) { return *this; }
protected:
};

View File

@@ -10,9 +10,9 @@
namespace EE {
class EE_API cAllocatedPointer {
class EE_API AllocatedPointer {
public:
cAllocatedPointer( void * Data, const std::string& File, int Line, size_t Memory );
AllocatedPointer( void * Data, const std::string& File, int Line, size_t Memory );
std::string mFile;
int mLine;
@@ -20,14 +20,14 @@ class EE_API cAllocatedPointer {
void * mData;
};
typedef std::map<void*, cAllocatedPointer> tAllocatedPointerMap;
typedef tAllocatedPointerMap::iterator tAllocatedPointerMapIt;
typedef std::map<void*, AllocatedPointer> AllocatedPointerMap;
typedef AllocatedPointerMap::iterator AllocatedPointerMapIt;
class EE_API MemoryManager {
public:
static void * AddPointer( const cAllocatedPointer& aAllocatedPointer );
static void * AddPointer( const AllocatedPointer& aAllocatedPointer );
static void * AddPointerInPlace( void * Place, const cAllocatedPointer& aAllocatedPointer );
static void * AddPointerInPlace( void * Place, const AllocatedPointer& aAllocatedPointer );
static bool RemovePointer( void * Data );
@@ -59,21 +59,21 @@ class EE_API MemoryManager {
static size_t GetTotalMemoryUsage();
static const cAllocatedPointer& GetBiggestAllocation();
static const AllocatedPointer& GetBiggestAllocation();
};
#ifdef EE_MEMORY_MANAGER
#define eeNew( classType, constructor ) \
( classType *)EE::MemoryManager::AddPointer( EE::cAllocatedPointer( new classType constructor ,__FILE__,__LINE__, sizeof(classType) ) )
( classType *)EE::MemoryManager::AddPointer( EE::AllocatedPointer( new classType constructor ,__FILE__,__LINE__, sizeof(classType) ) )
#define eeNewInPlace( place, classType, constructor ) \
( classType *)EE::MemoryManager::AddPointerInPlace( place, EE::cAllocatedPointer( new place classType constructor ,__FILE__,__LINE__, sizeof(classType) ) )
( classType *)EE::MemoryManager::AddPointerInPlace( place, EE::AllocatedPointer( new place classType constructor ,__FILE__,__LINE__, sizeof(classType) ) )
#define eeNewArray( classType, amount ) \
( classType *) EE::MemoryManager::AddPointer( EE::cAllocatedPointer( new classType [ amount ], __FILE__, __LINE__, amount * sizeof( classType ) ) )
( classType *) EE::MemoryManager::AddPointer( EE::AllocatedPointer( new classType [ amount ], __FILE__, __LINE__, amount * sizeof( classType ) ) )
#define eeMalloc(amount) \
EE::MemoryManager::AddPointer( EE::cAllocatedPointer( EE::MemoryManager::Allocate( amount ), __FILE__, __LINE__, amount ) )
EE::MemoryManager::AddPointer( EE::AllocatedPointer( EE::MemoryManager::Allocate( amount ), __FILE__, __LINE__, amount ) )
#define eeDelete( data ){ \
if( EE::MemoryManager::RemovePointer( EE::MemoryManager::Delete( data ) ) == false ) printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \

View File

@@ -8,7 +8,7 @@
namespace EE {
template <typename T, typename A = eeAllocator<T> >
struct eeStack {
struct Stack {
#ifdef EE_MEMORY_MANAGER
typedef typename std::stack<T, A> type;
#else
@@ -17,7 +17,7 @@ namespace EE {
};
template <typename T, typename A = eeAllocator<T> >
struct eeDeque {
struct Deque {
#ifdef EE_MEMORY_MANAGER
typedef typename std::deque<T, A> type;
#else
@@ -26,7 +26,7 @@ namespace EE {
};
template <typename T, typename A = eeAllocator<T> >
struct eeVector {
struct Vector {
#ifdef EE_MEMORY_MANAGER
typedef typename std::vector<T, A> type;
#else
@@ -35,7 +35,7 @@ namespace EE {
};
template <typename T, typename A = eeAllocator<T> >
struct eeList {
struct List {
#ifdef EE_MEMORY_MANAGER
typedef typename std::list<T, A> type;
#else
@@ -44,7 +44,7 @@ namespace EE {
};
template <typename T, typename P = std::less<T>, typename A = eeAllocator<T> >
struct eeSet {
struct Set {
#ifdef EE_MEMORY_MANAGER
typedef typename std::set<T, P, A> type;
#else
@@ -53,7 +53,7 @@ namespace EE {
};
template <typename K, typename V, typename P = std::less<K>, typename A = eeAllocator< std::pair<const K, V> > >
struct eeMap {
struct Map {
#ifdef EE_MEMORY_MANAGER
typedef typename std::map<K, V, P, A> type;
#else
@@ -62,7 +62,7 @@ namespace EE {
};
template <typename K, typename V, typename P = std::less<K>, typename A = eeAllocator< std::pair<const K, V> > >
struct eeMultimap {
struct Multimap {
#ifdef EE_MEMORY_MANAGER
typedef typename std::multimap<K, V, P, A> type;
#else

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff