00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __EDELIB_EDELIB_GLOBAL_H__
00022 #define __EDELIB_EDELIB_GLOBAL_H__
00023
00024
00025 #ifndef NULL
00026 # ifndef __cplusplus
00027 # define NULL ((void*)0)
00028 # else
00029 # define NULL 0
00030 # endif
00031 #endif
00032
00038 #ifndef EDELIB_NS
00039 # define EDELIB_NS edelib
00040 #endif
00041
00042 #ifdef EDELIB_NS
00043 # define EDELIB_NS_BEGIN namespace EDELIB_NS {
00044 # define EDELIB_NS_END }
00045 #else
00046 # define EDELIB_NS_BEGIN
00047 # define EDELIB_NS_END
00048 #endif
00049
00065 #ifdef EDELIB_NS
00066 # define EDELIB_NS_USE using namespace EDELIB_NS;
00067 #else
00068 # define EDELIB_NS_USE
00069 #endif
00070
00078 #ifdef EDELIB_NS
00079 # define EDELIB_NS_USING(n) using EDELIB_NS::n;
00080 #else
00081 # define EDELIB_NS_USING(n)
00082 #endif
00083
00091 #ifdef EDELIB_NS
00092 # define EDELIB_NS_USING_AS(old_name, new_name) typedef EDELIB_NS::old_name new_name;
00093 #else
00094 # define EDELIB_NS_USING_AS(old_name, new_name) typedef old_name new_name;
00095 #endif
00096
00102 #ifdef EDELIB_NS
00103 # define EDELIB_NS_PREPEND(n) EDELIB_NS::n
00104 #else
00105 # define EDELIB_NS_PREPEND(n) n
00106 #endif
00107
00118 #include "for-each-macro.h"
00119
00120 #ifdef EDELIB_FOR_EACH_FUNC
00121 # define EDELIB_FOR_EACH_FUNC_OLD__ EDELIB_FOR_EACH_FUNC
00122 #endif
00123
00124 #define EDELIB_FOR_EACH_FUNC EDELIB_NS_USING
00125 #define EDELIB_NS_USING_LIST(n, list) EDELIB_FOR_EACH(n, list)
00126
00127 #ifdef EDELIB_FOR_EACH_FUNC_OLD__
00128 # define EDELIB_FOR_EACH_FUNC EDELIB_FOR_EACH_FUNC_OLD__
00129 # undef EDELIB_FOR_EACH_FUNC_OLD__
00130 #endif
00131
00143 #if __GNUC__ >= 4
00144 # define E_EXPORT __attribute__ ((visibility("default")))
00145 # define E_NO_EXPORT __attribute__ ((visibility("hidden")))
00146 #else
00147 # define E_EXPORT
00148 # define E_NO_EXPORT
00149 #endif
00150
00151 #define EDELIB_API E_EXPORT
00152 #define EDELIB_NO_API E_NO_EXPORT
00153
00161 #define E_DISABLE_CLASS_COPY(klass) \
00162 klass(const klass&); \
00163 klass& operator=(klass&);
00164
00176 #define E_CLASS_GLOBAL_DECLARE(klass) \
00177 static klass* global(void);
00178
00186 #define E_CLASS_GLOBAL_IMPLEMENT(klass) \
00187 klass* klass::global(void) { \
00188 static klass obj; \
00189 return &obj; \
00190 }
00191
00203 #define E_CLASS_GLOBAL_EXPLICIT_DECLARE(klass) \
00204 static void init(void); \
00205 static void shutdown(void); \
00206 static bool inited(void); \
00207 static klass* global(void);
00208
00215 #define E_CLASS_GLOBAL_EXPLICIT_IMPLEMENT(klass) \
00216 klass* klass##_instance = NULL; \
00217 \
00218 void klass::init(void) { \
00219 if(!klass##_instance) \
00220 klass##_instance = new klass(); \
00221 } \
00222 \
00223 void klass::shutdown(void) { \
00224 delete klass##_instance; \
00225 klass##_instance = NULL; \
00226 } \
00227 \
00228 bool klass::inited(void) { \
00229 return (klass##_instance != NULL); \
00230 } \
00231 \
00232 klass* klass::global(void) { \
00233 E_ASSERT(klass##_instance != NULL && "Did you run init() first?"); \
00234 return klass##_instance; \
00235 }
00236
00237
00238 #ifdef __GNUC__
00239 # define EDELIB_DEPRECATED __attribute__ ((deprecated))
00240 #else
00241 # define EDELIB_DEPRECATED
00242 #endif
00243
00244 #ifdef HAVE_EDELIB_BASE_CONFIG_H
00245 # include "_conf.h"
00246 #endif
00247
00248 #include "edelib-config.h"
00249
00250 #endif