NXEngine v1.0.0.2
[NXEngine.git] / common / InitList.h
blob5b2c34ce587c9aafbc8a506f5983533ce395f5f9
2 #ifndef _INITLIST_H
3 #define _INITLIST_H
5 #include "BList.h"
6 #define MAX_INIT_RECORDS 10000
8 struct InitRecord
10 void *func;
11 bool returns_value;
14 class InitList
16 public:
17 virtual ~InitList();
19 void AddFunction(void (*func)(void));
20 void AddFunction(bool (*func)(void));
21 void AddFunction(void *func);
22 bool CallFunctions();
24 private:
25 InitRecord *fFunctions[MAX_INIT_RECORDS];
26 int fCount; // counting on behavior of auto-initilization to 0
29 class InitAdder
31 public:
32 InitAdder(InitList *initlist, void (*func)(void));
33 InitAdder(InitList *initlist, bool (*func)(void));
34 InitAdder(InitList &initlist, void (*func)(void));
35 InitAdder(InitList &initlist, bool (*func)(void));
38 #define INITFUNC(TARGET) \
39 static void __InitFunc(void); \
40 static InitAdder _ia(TARGET, __InitFunc); \
41 static void __InitFunc(void) \
43 #endif