Blender  V2.59
GHOST_ISystem.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: GHOST_ISystem.cpp 38351 2011-07-13 06:04:54Z campbellbarton $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program 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, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00020  * All rights reserved.
00021  *
00022  * The Original Code is: all of this file.
00023  *
00024  * Contributor(s): none yet.
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00042 #include "GHOST_ISystem.h"
00043 
00044 #ifdef WITH_HEADLESS
00045 #       include "GHOST_SystemNULL.h"
00046 #elif defined(WITH_GHOST_SDL)
00047 #       include "GHOST_SystemSDL.h"
00048 #elif defined(WIN32)
00049 #       include "GHOST_SystemWin32.h"
00050 #else
00051 #       ifdef __APPLE__
00052 #               ifdef GHOST_COCOA
00053 #                       include "GHOST_SystemCocoa.h"
00054 #               else
00055 #                       include "GHOST_SystemCarbon.h"
00056 #               endif
00057 #       else
00058 #               include "GHOST_SystemX11.h"
00059 #       endif
00060 #endif
00061 
00062 
00063 GHOST_ISystem* GHOST_ISystem::m_system = 0;
00064 
00065 
00066 GHOST_TSuccess GHOST_ISystem::createSystem()
00067 {
00068         GHOST_TSuccess success;
00069         if (!m_system) {
00070 #ifdef WITH_HEADLESS
00071                 m_system = new GHOST_SystemNULL();
00072 #elif defined(WITH_GHOST_SDL)
00073                 m_system = new GHOST_SystemSDL();
00074 #elif defined(WIN32)
00075                 m_system = new GHOST_SystemWin32 ();
00076 #else
00077 #       ifdef __APPLE__
00078 #               ifdef GHOST_COCOA
00079                         m_system = new GHOST_SystemCocoa ();
00080 #               else
00081                         m_system = new GHOST_SystemCarbon ();
00082 #               endif
00083 #       else 
00084                 m_system = new GHOST_SystemX11 ();
00085 #       endif
00086 #endif 
00087                 success = m_system != 0 ? GHOST_kSuccess : GHOST_kFailure;
00088         }
00089         else {
00090                 success = GHOST_kFailure;
00091         }
00092         if (success) {
00093                 success = m_system->init();
00094         }
00095         return success;
00096 }
00097 
00098 GHOST_TSuccess GHOST_ISystem::disposeSystem()
00099 {
00100         GHOST_TSuccess success = GHOST_kSuccess;
00101         if (m_system) {
00102                 delete m_system;
00103                 m_system = 0;
00104         }
00105         else {
00106                 success = GHOST_kFailure;
00107         }
00108         return success;
00109 }
00110 
00111 
00112 GHOST_ISystem* GHOST_ISystem::getSystem()
00113 {
00114         return m_system;
00115 }
00116