CrystalSpace

Public API Reference

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()
00070 
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
00086 
00087 #define CS_REQUEST_VFS \
00088   CS_REQUEST_PLUGIN("crystalspace.kernel.vfs", iVFS)
00089 
00090 #define CS_REQUEST_FONTSERVER \
00091   CS_REQUEST_PLUGIN("crystalspace.font.server.multiplexer", iFontServer)
00092 
00093 #define CS_REQUEST_IMAGELOADER \
00094   CS_REQUEST_PLUGIN("crystalspace.graphic.image.io.multiplexer", iImageIO)
00095 
00096 #define CS_REQUEST_NULL3D \
00097   CS_REQUEST_PLUGIN("crystalspace.graphics3d.null",iGraphics3D)
00098 
00099 #define CS_REQUEST_SOFTWARE3D \
00100   CS_REQUEST_PLUGIN("crystalspace.graphics3d.software",iGraphics3D)
00101 
00102 #define CS_REQUEST_OPENGL3D \
00103   CS_REQUEST_PLUGIN("crystalspace.graphics3d.opengl", iGraphics3D)
00104 
00105 #define CS_REQUEST_ENGINE \
00106   CS_REQUEST_PLUGIN("crystalspace.engine.3d", iEngine)
00107 
00108 #define CS_REQUEST_LEVELLOADER \
00109   CS_REQUEST_PLUGIN("crystalspace.level.threadedloader", iThreadedLoader), \
00110   CS_REQUEST_PLUGIN("crystalspace.level.loader", iLoader)
00111 
00112 #define CS_REQUEST_LEVELSAVER \
00113   CS_REQUEST_PLUGIN("crystalspace.level.saver", iSaver)
00114 
00115 #define CS_REQUEST_REPORTER \
00116   CS_REQUEST_PLUGIN("crystalspace.utilities.reporter", iReporter)
00117 
00118 #define CS_REQUEST_REPORTERLISTENER \
00119   CS_REQUEST_PLUGIN("crystalspace.utilities.stdrep", iStandardReporterListener)
00120 
00121 #define CS_REQUEST_CONSOLEOUT \
00122   CS_REQUEST_PLUGIN("crystalspace.console.output.standard", iConsoleOutput)
00123 
00124 #define CS_REQUEST_JOYSTICK \
00125   CS_REQUEST_PLUGIN("crystalspace.device.joystick", iEventPlug)
00126 
00131 typedef bool (*csEventHandlerFunc) (iEvent&);
00132 
00143 class CS_CRYSTALSPACE_EXPORT csPluginRequest
00144 {
00145 private:
00146   csString class_name;
00147   csString interface_name;
00148   scfInterfaceID interface_id;
00149   int interface_version;
00150   void set(csPluginRequest const&);
00151 public:
00152   csPluginRequest(csString class_name, csString interface_name,
00153     scfInterfaceID interface_id, int interface_version);
00154   csPluginRequest(csPluginRequest const& r) { set(r); }
00155   csPluginRequest& operator=(csPluginRequest const& r) {set(r); return *this;}
00156   bool operator==(csPluginRequest const&) const;
00157   bool operator!=(csPluginRequest const& r) const { return !operator==(r); }
00158   csString GetClassName() const { return class_name; }
00159   csString GetInterfaceName() const { return interface_name; }
00160   scfInterfaceID GetInterfaceID() const { return interface_id; }
00161   int GetInterfaceVersion() const { return interface_version; }
00162 };
00163 
00164 
00170 class CS_CRYSTALSPACE_EXPORT csInitializer
00171 {
00172 public:
00204   static iObjectRegistry* CreateEnvironment(int argc, char const* const argv[],
00205     bool scanDefaultPluginPaths = true);
00206 
00217   static bool InitializeSCF (int argc, char const* const argv[],
00218     bool scanDefaultPluginPaths = true);
00219 
00225   static iObjectRegistry* CreateObjectRegistry ();
00226 
00233   static iPluginManager* CreatePluginManager (iObjectRegistry*);
00234 
00241   static iEventQueue* CreateEventQueue (iObjectRegistry*);
00242 
00247   static iThreadManager* CreateThreadManager (iObjectRegistry*);
00248 
00255   static iVirtualClock* CreateVirtualClock (iObjectRegistry*);
00256 
00262   static iCommandLineParser* CreateCommandLineParser (
00263     iObjectRegistry*, int argc, char const* const argv[]);
00264 
00269   static iVerbosityManager* CreateVerbosityManager (iObjectRegistry*);
00270 
00276   static iConfigManager* CreateConfigManager (iObjectRegistry*);
00277 
00284   static bool CreateInputDrivers (iObjectRegistry*);
00285 
00303   static bool CreateStringSet (iObjectRegistry*);
00304 
00310   static iSystemOpenManager* CreateSystemOpenManager (iObjectRegistry*);
00311 
00324   static bool SetupConfigManager (iObjectRegistry*, const char* configName,
00325     const char *ApplicationID = 0);
00326 
00338   static iVFS* SetupVFS(iObjectRegistry* objectReg, 
00339           const char* pluginID = "crystalspace.kernel.vfs");
00340 
00352   static bool RequestPlugins (iObjectRegistry*, ...);
00353 
00359   static bool RequestPluginsV (iObjectRegistry*, va_list);
00360 
00380   static bool RequestPlugins(iObjectRegistry*,csArray<csPluginRequest> const&);
00381 
00386   static bool OpenApplication (iObjectRegistry*);
00387 
00391   static void CloseApplication (iObjectRegistry*);
00392 
00401   static bool SetupEventHandler (iObjectRegistry*, iEventHandler*, const csEventID[]);
00402 
00409   static bool SetupEventHandler (iObjectRegistry*, csEventHandlerFunc, const csEventID events[]);
00410 
00418   static bool SetupEventHandler (iObjectRegistry*, csEventHandlerFunc);
00419 
00448   static void DestroyApplication (iObjectRegistry*);
00449   
00455   static const char* GetDefaultAppID();
00456 protected:
00457 };
00458 
00461 #endif // __CS_INITAPP_H__

Generated for Crystal Space 2.0 by doxygen 1.7.6.1