OgreHapticsForceEffectManager.h

Go to the documentation of this file.
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 // -- Template system based on Ogre::ParticleSystemManager, original copyright follows --
00025 // 
00026 // This source file is part of OGRE
00027 //    (Object-oriented Graphics Rendering Engine)
00028 // For the latest info, see http://www.ogre3d.org/
00029 //
00030 // Copyright (c) 2000-2006 Torus Knot Software Ltd
00031 // Also see acknowledgements in Readme.html
00032 //
00033 // This program is free software; you can redistribute it and/or modify it under
00034 // the terms of the GNU Lesser General Public License as published by the Free Software
00035 // Foundation; either version 2 of the License, or (at your option) any later
00036 // version.
00037 //
00038 // This program is distributed in the hope that it will be useful, but WITHOUT
00039 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00040 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00041 //
00042 // You should have received a copy of the GNU Lesser General Public License along with
00043 // this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00044 // Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00045 // http://www.gnu.org/copyleft/lesser.txt.
00046 //
00047 // You may alternatively use this source under the terms of a specific version of
00048 // the OGRE Unrestricted License provided you have obtained such a license from
00049 // Torus Knot Software Ltd.
00050 #ifndef _OgreHapticsForceEffectManager_H__
00051 #define _OgreHapticsForceEffectManager_H__
00052 
00053 #include "OgreHapticsPrerequisites.h"
00054 
00055 namespace OgreHaptics {
00056 
00079     class _OgreHapticsExport ForceEffectManager : public Singleton<ForceEffectManager>,
00080         public ScriptLoader
00081     {
00082     protected:
00083         typedef std::map<String, ForceEffect*> ForceEffectMap;
00084         typedef std::map<String, ForceEffectAlgorithmFactory*> ForceEffectAlgorithmFactoryMap;
00085     public:
00087         ForceEffectManager();
00089         virtual ~ForceEffectManager();
00106         static ForceEffectManager& getSingleton(void);
00123         static ForceEffectManager* getSingletonPtr(void);
00124 
00126         const StringVector& getScriptPatterns(void) const;
00128         void parseScript(DataStreamPtr& stream, const String& groupName);
00130         Real getLoadingOrder(void) const;
00131 
00143         ForceEffect* createTemplate(const String& name);
00163         void addTemplate(const String& name, ForceEffect* effect);
00171         ForceEffect* getTemplate(const String& name);
00172 
00173         typedef ConstMapIterator<ForceEffectMap> ForceEffectIterator;
00178         ForceEffectIterator getTemplateIterator(void);
00190         void removeTemplate(const String& name, bool deleteTemplate = true);
00200         void removeAllTemplates(bool deleteTemplates = true);
00201 
00221         ForceEffect* createEffect(const String& name, const String& templateName);
00238         ForceEffect* createEffect(const String& name);
00244         ForceEffect* getEffect(const String& name) const;
00246         bool hasEffect(const String& name) const;
00251         void destroyEffect(const String& name);
00256         void destroyEffect(ForceEffect* effect);
00258         void destroyAllEffects(void);
00259 
00282         void addAlgorithmFactory(ForceEffectAlgorithmFactory* factory);
00283 
00284         typedef ConstMapIterator<ForceEffectAlgorithmFactoryMap>
00285             ForceEffectAlgorithmFactoryIterator;
00290         ForceEffectAlgorithmFactoryIterator getAlgorithmFactoryIterator(void);
00291 
00304         ForceEffectAlgorithm* _createAlgorithm(const String& algorithmType);
00316         void _destroyAlgorithm(ForceEffectAlgorithm* algorithm);
00317     protected:
00318         OGREHAPTICS_AUTO_MUTEX
00320         ForceEffectMap mEffectTemplates;
00322         ForceEffectMap mEffects;
00324         ForceEffectAlgorithmFactoryMap mAlgorithmFactories;
00326         StringVector mScriptPatterns;
00327 
00329         void parseNewAlgorithm(const String& type, DataStreamPtr& stream, ForceEffect* effect);
00331         void parseAttrib(const String& line, ForceEffect* effect);
00333         void parseAlgorithmAttrib(const String& line, ForceEffectAlgorithm* algorithm);
00335         void skipToNextCloseBrace(DataStreamPtr& stream);
00337         void skipToNextOpenBrace(DataStreamPtr& stream);
00338     };
00339 
00340 }
00341 
00342 #endif

Last modified Tue Jan 6 22:31:25 2009