00001 /* 00002 This source file is part of OgreHaptics 00003 (a library for wrapping haptics devices for use with the open-source 00004 graphics engine OGRE, http://www.ogre3d.org) 00005 00006 Copyright (c) 2006 - 2008 Jorrit de Vries 00007 Also see acknowledgements in Readme.html 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public License 00011 as published by the Free Software Foundation; either version 2.1 00012 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the 00021 Free Software Foundation, Inc., 00022 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 // -- Plugin management and configuration based on, and uses, Ogre::Root, 00025 // original copyright follows -- 00026 // 00027 // This source file is part of OGRE 00028 // (Object-oriented Graphics Rendering Engine) 00029 // For the latest info, see http://www.ogre3d.org/ 00030 // 00031 // Copyright (c) 2000-2006 Torus Knot Software Ltd 00032 // Also see acknowledgements in Readme.html 00033 // 00034 // This program is free software; you can redistribute it and/or modify it under 00035 // the terms of the GNU Lesser General Public License as published by the Free Software 00036 // Foundation; either version 2 of the License, or (at your option) any later 00037 // version. 00038 // 00039 // This program is distributed in the hope that it will be useful, but WITHOUT 00040 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00041 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00042 // 00043 // You should have received a copy of the GNU Lesser General Public License along with 00044 // this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00045 // Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00046 // http://www.gnu.org/copyleft/lesser.txt. 00047 // 00048 // You may alternatively use this source under the terms of a specific version of 00049 // the OGRE Unrestricted License provided you have obtained such a license from 00050 // Torus Knot Software Ltd. 00051 #ifndef _OgreHapticsSystem_H__ 00052 #define _OgreHapticsSystem_H__ 00053 00054 #include "OgreHapticsPrerequisites.h" 00055 #include "OgreHapticsCommon.h" 00056 00057 namespace OgreHaptics { 00058 00060 typedef std::vector<RenderSystem*> RenderSystemList; 00061 00080 class _OgreHapticsExport System : public Singleton<System> 00081 { 00082 public: 00093 System(const String& pluginsFileName = "HapticsPlugins.cfg", 00094 const String& configFileName = "OgreHaptics.cfg", 00095 const String& logFileName = "OgreHaptics.log"); 00097 virtual ~System(); 00098 00115 static System& getSingleton(void); 00132 static System* getSingletonPtr(void); 00133 00143 Device* initialise(bool autoCreateDevice); 00150 void shutdown(void); 00152 bool isInitialised(void) const { return mIsInitialised; } 00153 00160 void saveConfig(void); 00171 bool restoreConfig(void); 00177 bool showConfigDialog(void); 00188 void setConfigSettings(const DeviceInitInfo& configSettings); 00193 const DeviceInitInfo& getConfigSettings(void) const { return mConfigSettings; } 00194 00232 bool setOption(const String& key, const void* value); 00248 bool getOption(const String& key, void* value); 00249 00251 Log* getLog(void) { return mLog; } 00253 void logMessage(const String& message, LogMessageLevel lml = LML_NORMAL, 00254 bool maskDebug = false); 00256 Log::Stream logStream(LogMessageLevel lml = LML_NORMAL, bool maskDebug = false); 00257 00271 void loadPlugin(const String& pluginName); 00281 void unloadPlugin(const String& pluginName); 00288 void installPlugin(Plugin* plugin); 00298 void uninstallPlugin(Plugin* plugin); 00299 00300 typedef std::vector<DynLib*> PluginLibList; 00301 typedef std::vector<Plugin*> PluginInstanceList; 00302 00304 const PluginInstanceList& getInstalledPlugins() const { return mPlugins; } 00305 00318 void addRenderSystem(RenderSystem* newRend); 00325 RenderSystem* getRenderSystemByName(const String& name); 00327 RenderSystemList* getAvailableRenderSystems(void); 00328 00337 const DeviceInfoList& getAvailableNamedDevices(void) const; 00342 unsigned int getNumConnectedDevices(void); 00343 00367 Device* createDevice(const String& name, const DeviceInitInfo& initInfo); 00392 Device* createDevice(const String& name, unsigned int index, DeviceInitInfo& initInfo); 00399 Device* getDevice(const String& name); 00404 void destroyDevice(const String& name); 00405 00407 void destroyDevice(Device* device); 00414 void destroyAllDevices(void); 00419 ConstDeviceIterator getDeviceIterator(void) const; 00420 00449 void startSchedulers(unsigned long rate = 1000, bool autoEnableDevices = true); 00454 void stopSchedulers(void); 00455 00460 void update(void); 00461 00468 void _oneTimePostDeviceCreate(void); 00469 protected: 00471 OGREHAPTICS_AUTO_MUTEX 00473 bool mIsInitialised; 00476 bool mFirstTimePostDeviceCreate; 00478 String mConfigFileName; 00480 DeviceInitInfo mConfigSettings; 00482 PluginLibList mPluginLibs; 00484 PluginInstanceList mPlugins; 00485 00491 void loadPlugins(const String& pluginsFileName = "HapticsPlugins.cfg"); 00496 void initialisePlugins(void); 00501 void shutdownPlugins(void); 00503 void unloadPlugins(void); 00504 private: 00505 // Pointer to automatically created device, if any. 00506 Device* mAutoDevice; 00507 // Singletons 00508 ForceEffectManager* mForceEffectManager; 00509 // List of available render systems. 00510 RenderSystemList mRenderSystems; 00511 // List of available devices through all registered render systems. 00512 // Used for iterator. 00513 mutable DeviceInfoList mAvailableDevices; 00514 // List of managed devices. 00515 DeviceMap mDevices; 00516 00517 String mVersion; 00518 Log* mLog; 00519 00520 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 00521 // The thread affinity mask used for all OgreHaptics threads. 00522 DWORD mThreadAffinityMask; 00523 #endif 00524 }; 00525 00526 } 00527 00528 #endif
Last modified Tue Jan 6 22:31:25 2009