If the code hasn't been touched in this long, its probably release-worthy.
This commit is contained in:
18
src/Static.h
18
src/Static.h
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "Platform.h"
|
||||
|
||||
// Utility class mostly for when certain inputs need singleton callback handlers
|
||||
template<typename T> class Static {
|
||||
@@ -10,7 +11,24 @@ private:
|
||||
static T* s_instance;
|
||||
};
|
||||
|
||||
template<typename T> struct StaticTaskRegistration : public Platform::TaskRegistration {
|
||||
StaticTaskRegistration() : Platform::TaskRegistration(Static<T>::instance()) {
|
||||
Platform::registerTask(this);
|
||||
}
|
||||
};
|
||||
|
||||
struct AutoTaskRegistration : public Platform::TaskRegistration {
|
||||
explicit AutoTaskRegistration(Task* task) : Platform::TaskRegistration(task) {
|
||||
Platform::registerTask(this);
|
||||
}
|
||||
};
|
||||
|
||||
#define NAMED_STATIC_ALLOC(Cls, StaticName) static Cls _staticAlloc__ ## StaticName;\
|
||||
template<> Cls* Static<Cls>::s_instance=&_staticAlloc__ ## StaticName;
|
||||
|
||||
#define STATIC_ALLOC(Cls) NAMED_STATIC_ALLOC(Cls, Cls)
|
||||
|
||||
#define NAMED_STATIC_TASK(Cls, StaticName) static StaticTaskRegistration<Cls> _staticTask_ ## StaticName;
|
||||
#define STATIC_TASK(Cls) NAMED_STATIC_TASK(Cls, Cls)
|
||||
|
||||
#define REGISTER_TASK(TaskName) static AutoTaskRegistration _autoTask__ ## TaskName(&TaskName);
|
||||
|
Reference in New Issue
Block a user