- don't build ghost's event printer unless ghost debug is enabled.
[blender.git] / intern / ghost / intern / GHOST_ISystem.cpp
1 /*
2  * $Id$
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Contributor(s): none yet.
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 /** \file ghost/intern/GHOST_ISystem.cpp
30  *  \ingroup GHOST
31  */
32
33
34 /**
35
36  * $Id$
37  * Copyright (C) 2001 NaN Technologies B.V.
38  * @author      Maarten Gribnau
39  * @date        May 7, 2001
40  */
41
42 #include "GHOST_ISystem.h"
43
44 #ifdef WITH_HEADLESS
45 #       include "GHOST_SystemNULL.h"
46 #elif defined(WITH_GHOST_SDL)
47 #       include "GHOST_SystemSDL.h"
48 #elif defined(WIN32)
49 #       include "GHOST_SystemWin32.h"
50 #else
51 #       ifdef __APPLE__
52 #               ifdef GHOST_COCOA
53 #                       include "GHOST_SystemCocoa.h"
54 #               else
55 #                       include "GHOST_SystemCarbon.h"
56 #               endif
57 #       else
58 #               include "GHOST_SystemX11.h"
59 #       endif
60 #endif
61
62
63 GHOST_ISystem* GHOST_ISystem::m_system = 0;
64
65
66 GHOST_TSuccess GHOST_ISystem::createSystem()
67 {
68         GHOST_TSuccess success;
69         if (!m_system) {
70 #ifdef WITH_HEADLESS
71                 m_system = new GHOST_SystemNULL();
72 #elif defined(WITH_GHOST_SDL)
73                 m_system = new GHOST_SystemSDL();
74 #elif defined(WIN32)
75                 m_system = new GHOST_SystemWin32 ();
76 #else
77 #       ifdef __APPLE__
78 #               ifdef GHOST_COCOA
79                         m_system = new GHOST_SystemCocoa ();
80 #               else
81                         m_system = new GHOST_SystemCarbon ();
82 #               endif
83 #       else 
84                 m_system = new GHOST_SystemX11 ();
85 #       endif
86 #endif 
87                 success = m_system != 0 ? GHOST_kSuccess : GHOST_kFailure;
88         }
89         else {
90                 success = GHOST_kFailure;
91         }
92         if (success) {
93                 success = m_system->init();
94         }
95         return success;
96 }
97
98 GHOST_TSuccess GHOST_ISystem::disposeSystem()
99 {
100         GHOST_TSuccess success = GHOST_kSuccess;
101         if (m_system) {
102                 delete m_system;
103                 m_system = 0;
104         }
105         else {
106                 success = GHOST_kFailure;
107         }
108         return success;
109 }
110
111
112 GHOST_ISystem* GHOST_ISystem::getSystem()
113 {
114         return m_system;
115 }
116