00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "IEventQueue.h"
00020 #include "CLog.h"
00021
00022 #if WINAPI_CARBON
00023 #include <execinfo.h>
00024 #include <stdio.h>
00025 #endif
00026
00027
00028
00029
00030
00031
00032 static int g_systemTarget = 0;
00033 IEventQueue* IEventQueue::s_instance = NULL;
00034
00035 void*
00036 IEventQueue::getSystemTarget()
00037 {
00038
00039 return &g_systemTarget;
00040 }
00041
00042 IEventQueue*
00043 IEventQueue::getInstance()
00044 {
00045 if (s_instance == NULL) {
00046 LOG((CLOG_ERR "null event queue"));
00047 #if WINAPI_CARBON
00048 void* callstack[128];
00049 int i, frames = backtrace(callstack, 128);
00050 char** strs = backtrace_symbols(callstack, frames);
00051 for (i = 0; i < frames; ++i) {
00052 printf("%s\n", strs[i]);
00053 }
00054 free(strs);
00055 #endif
00056 }
00057 assert(s_instance != NULL);
00058 return s_instance;
00059 }
00060
00061 void
00062 IEventQueue::setInstance(IEventQueue* instance)
00063 {
00064 assert(s_instance == NULL || instance == NULL);
00065 s_instance = instance;
00066 }