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 iObjectRegistry; 00051 struct iEvent; 00052 struct iEventHandler; 00053 struct iEventQueue; 00054 struct iPluginManager; 00055 struct iVirtualClock; 00056 struct iCommandLineParser; 00057 struct iConfigManager; 00058 struct iVerbosityManager; 00059 00063 00064 #define CS_REQUEST_PLUGIN(Name,Interface) \ 00065 Name, scfInterfaceTraits<Interface>::GetName(), \ 00066 scfInterfaceTraits<Interface>::GetID(), \ 00067 scfInterfaceTraits<Interface>::GetVersion() 00069 #define CS_REQUEST_PLUGIN_TAG(Name,Interface,Tag) \ 00070 Name ":" Tag , scfInterfaceTraits<Interface>::GetName(), \ 00071 scfInterfaceTraits<Interface>::GetID(), \ 00072 scfInterfaceTraits<Interface>::GetVersion() 00073 00074 // !!! NOTE !!! 00075 // When editing this list, you *must* ensure that initapp.h #include the 00076 // appropriate header for each SCF interface mentioned by a CS_REQUEST_PLUGIN() 00077 // invocation. This is necessary to guarantee that the interface-specialized 00078 // version of scfInterfaceTraits<> is seen by clients rather than the non-specialized 00079 // template. 00080 00082 #define CS_REQUEST_END \ 00083 (const char*)0 00085 #define CS_REQUEST_VFS \ 00086 CS_REQUEST_PLUGIN("crystalspace.kernel.vfs", iVFS) 00088 #define CS_REQUEST_FONTSERVER \ 00089 CS_REQUEST_PLUGIN("crystalspace.font.server.default", iFontServer) 00091 #define CS_REQUEST_IMAGELOADER \ 00092 CS_REQUEST_PLUGIN("crystalspace.graphic.image.io.multiplexer", iImageIO) 00094 #define CS_REQUEST_NULL3D \ 00095 CS_REQUEST_PLUGIN("crystalspace.graphics3d.null",iGraphics3D) 00097 #define CS_REQUEST_SOFTWARE3D \ 00098 CS_REQUEST_PLUGIN("crystalspace.graphics3d.software",iGraphics3D) 00100 #define CS_REQUEST_OPENGL3D \ 00101 CS_REQUEST_PLUGIN("crystalspace.graphics3d.opengl", iGraphics3D) 00103 #define CS_REQUEST_ENGINE \ 00104 CS_REQUEST_PLUGIN("crystalspace.engine.3d", iEngine) 00106 #define CS_REQUEST_LEVELLOADER \ 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) 00120 00125 typedef bool (*csEventHandlerFunc) (iEvent&); 00126 00137 class CS_CRYSTALSPACE_EXPORT csPluginRequest 00138 { 00139 private: 00140 csString class_name; 00141 csString interface_name; 00142 scfInterfaceID interface_id; 00143 int interface_version; 00144 void set(csPluginRequest const&); 00145 public: 00146 csPluginRequest(csString class_name, csString interface_name, 00147 scfInterfaceID interface_id, int interface_version); 00148 csPluginRequest(csPluginRequest const& r) { set(r); } 00149 csPluginRequest& operator=(csPluginRequest const& r) {set(r); return *this;} 00150 bool operator==(csPluginRequest const&) const; 00151 bool operator!=(csPluginRequest const& r) const { return !operator==(r); } 00152 csString GetClassName() const { return class_name; } 00153 csString GetInterfaceName() const { return interface_name; } 00154 scfInterfaceID GetInterfaceID() const { return interface_id; } 00155 int GetInterfaceVersion() const { return interface_version; } 00156 }; 00157 00158 00164 class CS_CRYSTALSPACE_EXPORT csInitializer 00165 { 00166 public: 00195 static iObjectRegistry* CreateEnvironment(int argc, char const* const argv[]); 00196 00201 static bool InitializeSCF (int argc, char const* const argv[]); 00202 00208 static iObjectRegistry* CreateObjectRegistry (); 00209 00216 static iPluginManager* CreatePluginManager (iObjectRegistry*); 00217 00224 static iEventQueue* CreateEventQueue (iObjectRegistry*); 00225 00232 static iVirtualClock* CreateVirtualClock (iObjectRegistry*); 00233 00239 static iCommandLineParser* CreateCommandLineParser ( 00240 iObjectRegistry*, int argc, char const* const argv[]); 00241 00246 static iVerbosityManager* CreateVerbosityManager (iObjectRegistry*); 00247 00253 static iConfigManager* CreateConfigManager (iObjectRegistry*); 00254 00261 static bool CreateInputDrivers (iObjectRegistry*); 00262 00272 static bool CreateStringSet (iObjectRegistry*); 00273 00286 static bool SetupConfigManager (iObjectRegistry*, const char* configName, 00287 const char *ApplicationID = 0); 00288 00300 static iVFS* SetupVFS(iObjectRegistry* objectReg, 00301 const char* pluginID = "crystalspace.kernel.vfs"); 00302 00314 static bool RequestPlugins (iObjectRegistry*, ...); 00315 00321 static bool RequestPluginsV (iObjectRegistry*, va_list); 00322 00342 static bool RequestPlugins(iObjectRegistry*,csArray<csPluginRequest> const&); 00343 00348 static bool OpenApplication (iObjectRegistry*); 00349 00353 static void CloseApplication (iObjectRegistry*); 00354 00363 static bool SetupEventHandler (iObjectRegistry*, iEventHandler*, const csEventID[]); 00364 00371 static bool SetupEventHandler (iObjectRegistry*, csEventHandlerFunc, const csEventID events[]); 00372 00380 static bool SetupEventHandler (iObjectRegistry*, csEventHandlerFunc); 00381 00410 static void DestroyApplication (iObjectRegistry*); 00411 00417 static const char* GetDefaultAppID(); 00418 protected: 00419 }; 00420 00423 #endif // __CS_INITAPP_H__
Generated for Crystal Space by doxygen 1.4.7