• Main Page
  • Classes
  • Files
  • File List

IEventQueue.cpp

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2004 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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 // IEventQueue
00030 //
00031 
00032 static int              g_systemTarget = 0;
00033 IEventQueue*            IEventQueue::s_instance = NULL;
00034 
00035 void*
00036 IEventQueue::getSystemTarget()
00037 {
00038     // any unique arbitrary pointer will do
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 }

Generated on Sun May 19 2013 00:00:05 for Synergy by  doxygen 1.7.1