cstool/initapp.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 1998-2001 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_INITAPP_H__ 00020 #define __CS_INITAPP_H__ 00021 00030 #include "csextern.h" 00031 00032 #include "csutil/array.h" 00033 #include "csutil/eventnames.h" 00034 #include "csutil/csstring.h" 00035 #include "csutil/scf.h" 00036 #include "iengine/engine.h" 00037 #include "igraphic/imageio.h" 00038 #include "imap/loader.h" 00039 #include "imap/saver.h" 00040 #include "iutil/evdefs.h" 00041 #include "iutil/vfs.h" 00042 #include "iutil/objreg.h" 00043 #include "iutil/plugin.h" 00044 #include "ivaria/conout.h" 00045 #include "ivaria/reporter.h" 00046 #include "ivaria/stdrep.h" 00047 #include "ivideo/graph3d.h" 00048 #include "ivideo/fontserv.h" 00049 00050 struct iCommandLineParser; 00051 struct iConfigManager; 00052 struct iEvent; 00053 struct iEventHandler; 00054 struct iEventQueue; 00055 struct iObjectRegistry; 00056 struct iPluginManager; 00057 struct iThreadManager; 00058 struct iVirtualClock; 00059 struct iSystemOpenManager; 00060 struct iVerbosityManager; 00061 00065 00066 #define CS_REQUEST_PLUGIN(Name,Interface) \ 00067 Name, scfInterfaceTraits<Interface>::GetName(), \ 00068 scfInterfaceTraits<Interface>::GetID(), \ 00069 scfInterfaceTraits<Interface>::GetVersion() 00071 #define CS_REQUEST_PLUGIN_TAG(Name,Interface,Tag) \ 00072 Name ":" Tag , scfInterfaceTraits<Interface>::GetName(), \ 00073 scfInterfaceTraits<Interface>::GetID(), \ 00074 scfInterfaceTraits<Interface>::GetVersion() 00075 00076 // !!! NOTE !!! 00077 // When editing this list, you *must* ensure that initapp.h #include the 00078 // appropriate header for each SCF interface mentioned by a CS_REQUEST_PLUGIN() 00079 // invocation. This is necessary to guarantee that the interface-specialized 00080 // version of scfInterfaceTraits<> is seen by clients rather than the non-specialized 00081 // template. 00082 00084 #define CS_REQUEST_END \ 00085 (const char*)0 00087 #define CS_REQUEST_VFS \ 00088 CS_REQUEST_PLUGIN("crystalspace.kernel.vfs", iVFS) 00090 #define CS_REQUEST_FONTSERVER \ 00091 CS_REQUEST_PLUGIN("crystalspace.font.server.multiplexer", iFontServer) 00093 #define CS_REQUEST_IMAGELOADER \ 00094 CS_REQUEST_PLUGIN("crystalspace.graphic.image.io.multiplexer", iImageIO) 00096 #define CS_REQUEST_NULL3D \ 00097 CS_REQUEST_PLUGIN("crystalspace.graphics3d.null",iGraphics3D) 00099 #define CS_REQUEST_OPENGL3D \ 00100 CS_REQUEST_PLUGIN("crystalspace.graphics3d.opengl", iGraphics3D) 00102 #define CS_REQUEST_ENGINE \ 00103 CS_REQUEST_PLUGIN("crystalspace.engine.3d", iEngine) 00105 #define CS_REQUEST_LEVELLOADER \ 00106 CS_REQUEST_PLUGIN("crystalspace.level.threadedloader", iThreadedLoader), \ 00107 CS_REQUEST_PLUGIN("crystalspace.level.loader", iLoader) 00109 #define CS_REQUEST_LEVELSAVER \ 00110 CS_REQUEST_PLUGIN("crystalspace.level.saver", iSaver) 00112 #define CS_REQUEST_REPORTER \ 00113 CS_REQUEST_PLUGIN("crystalspace.utilities.reporter", iReporter) 00115 #define CS_REQUEST_REPORTERLISTENER \ 00116 CS_REQUEST_PLUGIN("crystalspace.utilities.stdrep", iStandardReporterListener) 00118 #define CS_REQUEST_CONSOLEOUT \ 00119 CS_REQUEST_PLUGIN("crystalspace.console.output.standard", iConsoleOutput) 00121 #define CS_REQUEST_JOYSTICK \ 00122 CS_REQUEST_PLUGIN("crystalspace.device.joystick", iEventPlug) 00123 00128 typedef bool (*csEventHandlerFunc) (iEvent&); 00129 00140 class CS_CRYSTALSPACE_EXPORT csPluginRequest 00141 { 00142 private: 00143 csString class_name; 00144 csString interface_name; 00145 scfInterfaceID interface_id; 00146 int interface_version; 00147 void set(csPluginRequest const&); 00148 public: 00149 csPluginRequest(csString class_name, csString interface_name, 00150 scfInterfaceID interface_id, int interface_version); 00151 csPluginRequest(csPluginRequest const& r) { set(r); } 00152 csPluginRequest& operator=(csPluginRequest const& r) {set(r); return *this;} 00153 bool operator==(csPluginRequest const&) const; 00154 bool operator!=(csPluginRequest const& r) const { return !operator==(r); } 00155 csString GetClassName() const { return class_name; } 00156 csString GetInterfaceName() const { return interface_name; } 00157 scfInterfaceID GetInterfaceID() const { return interface_id; } 00158 int GetInterfaceVersion() const { return interface_version; } 00159 }; 00160 00161 00167 class CS_CRYSTALSPACE_EXPORT csInitializer 00168 { 00169 public: 00201 static iObjectRegistry* CreateEnvironment(int argc, char const* const argv[], 00202 bool scanDefaultPluginPaths = true); 00203 00214 static bool InitializeSCF (int argc, char const* const argv[], 00215 bool scanDefaultPluginPaths = true); 00216 00222 static iObjectRegistry* CreateObjectRegistry (); 00223 00230 static iPluginManager* CreatePluginManager (iObjectRegistry*); 00231 00238 static iEventQueue* CreateEventQueue (iObjectRegistry*); 00239 00244 static iThreadManager* CreateThreadManager (iObjectRegistry*); 00245 00252 static iVirtualClock* CreateVirtualClock (iObjectRegistry*); 00253 00259 static iCommandLineParser* CreateCommandLineParser ( 00260 iObjectRegistry*, int argc, char const* const argv[]); 00261 00266 static iVerbosityManager* CreateVerbosityManager (iObjectRegistry*); 00267 00273 static iConfigManager* CreateConfigManager (iObjectRegistry*); 00274 00281 static bool CreateInputDrivers (iObjectRegistry*); 00282 00300 static bool CreateStringSet (iObjectRegistry*); 00301 00307 static iSystemOpenManager* CreateSystemOpenManager (iObjectRegistry*); 00308 00321 static bool SetupConfigManager (iObjectRegistry*, const char* configName, 00322 const char *ApplicationID = 0); 00323 00335 static iVFS* SetupVFS(iObjectRegistry* objectReg, 00336 const char* pluginID = "crystalspace.kernel.vfs"); 00337 00349 static bool RequestPlugins (iObjectRegistry*, ...); 00350 00356 static bool RequestPluginsV (iObjectRegistry*, va_list); 00357 00377 static bool RequestPlugins(iObjectRegistry*,csArray<csPluginRequest> const&); 00378 00383 static bool OpenApplication (iObjectRegistry*); 00384 00388 static void CloseApplication (iObjectRegistry*); 00389 00398 static bool SetupEventHandler (iObjectRegistry*, iEventHandler*, const csEventID[]); 00399 00406 static bool SetupEventHandler (iObjectRegistry*, csEventHandlerFunc, const csEventID events[]); 00407 00415 static bool SetupEventHandler (iObjectRegistry*, csEventHandlerFunc); 00416 00445 static void DestroyApplication (iObjectRegistry*); 00446 00452 static const char* GetDefaultAppID(); 00453 protected: 00454 }; 00455 00458 #endif // __CS_INITAPP_H__
Generated for Crystal Space 2.1 by doxygen 1.6.1
