21 #ifndef __EDELIB_EDELIB_GLOBAL_H__
22 #define __EDELIB_EDELIB_GLOBAL_H__
27 # define NULL ((void*)0)
39 # define EDELIB_NS edelib
43 # define EDELIB_NS_BEGIN namespace EDELIB_NS {
44 # define EDELIB_NS_END }
46 # define EDELIB_NS_BEGIN
47 # define EDELIB_NS_END
66 # define EDELIB_NS_USE using namespace EDELIB_NS;
68 # define EDELIB_NS_USE
79 # define EDELIB_NS_USING(n) using EDELIB_NS::n;
81 # define EDELIB_NS_USING(n)
92 # define EDELIB_NS_USING_AS(old_name, new_name) typedef EDELIB_NS::old_name new_name;
94 # define EDELIB_NS_USING_AS(old_name, new_name) typedef old_name new_name;
103 # define EDELIB_NS_PREPEND(n) EDELIB_NS::n
105 # define EDELIB_NS_PREPEND(n) n
118 #include "for-each-macro.h"
120 #ifdef EDELIB_FOR_EACH_FUNC
121 # define EDELIB_FOR_EACH_FUNC_OLD__ EDELIB_FOR_EACH_FUNC
124 #define EDELIB_FOR_EACH_FUNC EDELIB_NS_USING
125 #define EDELIB_NS_USING_LIST(n, list) EDELIB_FOR_EACH(n, list)
127 #ifdef EDELIB_FOR_EACH_FUNC_OLD__
128 # define EDELIB_FOR_EACH_FUNC EDELIB_FOR_EACH_FUNC_OLD__
129 # undef EDELIB_FOR_EACH_FUNC_OLD__
144 # define E_EXPORT __attribute__ ((visibility("default")))
145 # define E_NO_EXPORT __attribute__ ((visibility("hidden")))
151 #define EDELIB_API E_EXPORT
152 #define EDELIB_NO_API E_NO_EXPORT
161 #define E_DISABLE_CLASS_COPY(klass) \
162 klass(const klass&); \
163 klass& operator=(klass&);
176 #define E_CLASS_GLOBAL_DECLARE(klass) \
177 static klass* global(void);
186 #define E_CLASS_GLOBAL_IMPLEMENT(klass) \
187 klass* klass::global(void) { \
203 #define E_CLASS_GLOBAL_EXPLICIT_DECLARE(klass) \
204 static void init(void); \
205 static void shutdown(void); \
206 static bool inited(void); \
207 static klass* global(void);
215 #define E_CLASS_GLOBAL_EXPLICIT_IMPLEMENT(klass) \
216 klass* klass##_instance = NULL; \
218 void klass::init(void) { \
219 if(!klass##_instance) \
220 klass##_instance = new klass(); \
223 void klass::shutdown(void) { \
224 delete klass##_instance; \
225 klass##_instance = NULL; \
228 bool klass::inited(void) { \
229 return (klass##_instance != NULL); \
232 klass* klass::global(void) { \
233 E_ASSERT(klass##_instance != NULL && "Did you run init() first?"); \
234 return klass##_instance; \
239 # define EDELIB_DEPRECATED __attribute__ ((deprecated))
241 # define EDELIB_DEPRECATED
244 #include "edelib-config.h"