root/juggler/tags/1.0.7/Sound/vjSoundFactory.h
| Revision 8789, 3.8 kB (checked in by patrickh, 7 years ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /*************** <auto-copyright.pl BEGIN do not edit this line> ************** |
| 2 | * |
| 3 | * VR Juggler is (C) Copyright 1998, 1999, 2000, 2001, 2002 |
| 4 | * by Iowa State University |
| 5 | * |
| 6 | * Original Authors: |
| 7 | * Allen Bierbaum, Christopher Just, |
| 8 | * Patrick Hartling, Kevin Meinert, |
| 9 | * Carolina Cruz-Neira, Albert Baker |
| 10 | * |
| 11 | * This library is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU Library General Public |
| 13 | * License as published by the Free Software Foundation; either |
| 14 | * version 2 of the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This library is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * Library General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU Library General Public |
| 22 | * License along with this library; if not, write to the |
| 23 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 24 | * Boston, MA 02111-1307, USA. |
| 25 | * |
| 26 | * ----------------------------------------------------------------- |
| 27 | * File: $RCSfile$ |
| 28 | * Date modified: $Date$ |
| 29 | * Version: $Revision$ |
| 30 | * ----------------------------------------------------------------- |
| 31 | * |
| 32 | *************** <auto-copyright.pl END do not edit this line> ***************/ |
| 33 | |
| 34 | #ifndef VJ_SOUND_FACTORY |
| 35 | #define VJ_SOUND_FACTORY |
| 36 | |
| 37 | #include <Sound/vjSoundEngine.h> |
| 38 | #include <Sound/vjSound.h> |
| 39 | #include <Kernel/vjDebug.h> |
| 40 | #include <vector> |
| 41 | #include <typeinfo> |
| 42 | #include <Utils/vjSingleton.h> |
| 43 | |
| 44 | //: soundengines use the SEC to register themselves with the sound factory |
| 45 | class vjSoundEngineConstructorBase; |
| 46 | |
| 47 | |
| 48 | //: use the vjSoundFactory factory to create a new sound engine. |
| 49 | // do not create an engine directly. |
| 50 | //!PUBLIC_API: |
| 51 | class vjSoundFactory |
| 52 | { |
| 53 | public: |
| 54 | // pass in a description of the sound engine (like sl, aw, nosound) |
| 55 | // pass in a config file name to go with that sound engine. |
| 56 | // returns a non-NULL pointer on success, NULL on failure. |
| 57 | //static SoundEngine* newEngine( const std::string& description, const char* const setupFile = NULL ); |
| 58 | |
| 59 | //: Query if the factory knows about the given sound engine |
| 60 | //!PRE: chunk != NULL, chunk is a valid chunk |
| 61 | //!ARGS: chunk - chunk we are requesting about knowledge to create |
| 62 | //!RETURNS: true - factory knows how to create the engine |
| 63 | //+ false - factory does not know how to create the engine |
| 64 | bool recognizeEngine(vjConfigChunk* chunk); |
| 65 | |
| 66 | //: Load the specified device |
| 67 | //!PRE: recognizeDevice(chunk) == true |
| 68 | //!ARGS: chunk - specification of the device to load |
| 69 | //!RETURNS: null - Device failed to load |
| 70 | //+ other - Pointer to the loaded device |
| 71 | vjSoundEngine* loadEngine(vjConfigChunk* chunk); |
| 72 | |
| 73 | |
| 74 | public: |
| 75 | // register a creator to the factory. |
| 76 | // this is intended to be used by each api's registration method |
| 77 | void registerConstructor( vjSoundEngineConstructorBase* constructor ); |
| 78 | |
| 79 | // TODO: add a removeCreator function. |
| 80 | protected: |
| 81 | /* |
| 82 | // returns a creator mased on some description |
| 83 | // pointer to the found creator is returned |
| 84 | // success value is also returned, true if one is found. |
| 85 | bool lookupCreator( const std::string& description, SoundEngineCreator* &sec ); |
| 86 | */ |
| 87 | |
| 88 | //: Find a constructor for the given device type |
| 89 | //!RETURNS: -1 - Not found |
| 90 | //+ - Index of the constructorck |
| 91 | int findConstructor(vjConfigChunk* chunk); |
| 92 | |
| 93 | protected: |
| 94 | // regged soundengines... |
| 95 | std::vector< vjSoundEngineConstructorBase* > mConstructors; |
| 96 | |
| 97 | protected: |
| 98 | //: Constructor. |
| 99 | vjSoundFactory(); |
| 100 | |
| 101 | vjSingletonHeader(vjSoundFactory); |
| 102 | /* |
| 103 | public: |
| 104 | //: Get instance of singleton object |
| 105 | static vjSoundFactory* instance() |
| 106 | { |
| 107 | if (_instance == NULL) |
| 108 | _instance = new vjSoundFactory; |
| 109 | return _instance; |
| 110 | } |
| 111 | |
| 112 | private: |
| 113 | static vjSoundFactory* _instance; //: The instance |
| 114 | */ |
| 115 | }; |
| 116 | |
| 117 | #endif |
Note: See TracBrowser for help on using the browser.
