sfxProvider.h
Engine/source/sfx/sfxProvider.h
Classes:
class
class
Public Typedefs
Vector< SFXDeviceInfo * >
SFXDeviceInfoVector
Detailed Description
Public Typedefs
typedef Vector< SFXDeviceInfo * > SFXDeviceInfoVector
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _SFXPROVIDER_H_ 25#define _SFXPROVIDER_H_ 26 27#ifndef _TVECTOR_H_ 28 #include "core/util/tVector.h" 29#endif 30 31 32class SFXDevice; 33 34 35 36struct SFXDeviceInfo 37{ 38 String driver; 39 String name; 40 bool hasHardware; 41 S32 maxBuffers; 42 43 virtual ~SFXDeviceInfo() {} 44}; 45 46typedef Vector<SFXDeviceInfo*> SFXDeviceInfoVector; 47 48class SFXProvider 49{ 50 friend class SFXSystem; 51 52 private: 53 54 /// The head of the linked list of avalible providers. 55 static SFXProvider* smProviders; 56 57 /// The next provider in the linked list of available providers. 58 SFXProvider* mNextProvider; 59 60 /// The provider name which is passed by the concrete provider 61 /// class to the SFXProvider constructor. 62 String mName; 63 64 static Vector<SFXProvider*> sAllProviders; 65 66 protected: 67 68 /// The array of avaIlable devices from this provider. The 69 /// concrete provider class will fill this on construction. 70 SFXDeviceInfoVector mDeviceInfo; 71 72 /// This registers the provider to the available provider list. It should be called 73 /// for providers that are properly initialized and available for device enumeration and creation. 74 /// the add and registration process is 2 steps to avoid issues when TGEA is used as a shared library (specifically on Windows) 75 static void regProvider( SFXProvider* provider ); 76 77 virtual void init() = 0; 78 79 SFXProvider( const String& name ); 80 ~SFXProvider(); 81 82 /// Look up the SFXDeviceInfo for the given device in mDeviceInfo. 83 /// Return default device (first in list) if no other device matches (or null if device list is empty). 84 SFXDeviceInfo* _findDeviceInfo( const String& deviceName ); 85 86 /// This is called from SFXSystem to create a new device. Must be implemented 87 /// by all contrete provider classes. 88 /// 89 /// @param deviceName The case sensitive name of the device or NULL to create the 90 // default device. 91 /// @param useHardware Toggles the use of hardware processing when available. 92 /// @param maxBuffers The maximum buffers for this device to use or -1 93 /// for the device to pick a reasonable default for that device. 94 /// 95 /// @return Returns the created device or NULL for failure. 96 /// 97 virtual SFXDevice* createDevice( const String& deviceName, bool useHardware, S32 maxBuffers ) = 0; 98 99 public: 100 101 /// Returns a specific provider by searching the provider list 102 /// for the first provider with the case sensitive name. 103 static SFXProvider* findProvider( String providerName ); 104 105 /// Returns the first provider in the provider list. Use 106 /// getNextProvider() to iterate over list. 107 static SFXProvider* getFirstProvider() { return smProviders; } 108 109 /// Returns the next provider in the provider list or NULL 110 /// when the end of the list is reached. 111 SFXProvider* getNextProvider() const { return mNextProvider; } 112 113 /// The case sensitive name of this provider. 114 const String& getName() const { return mName; } 115 116 /// Returns a read only vector with device information for 117 /// all creatable devices available from this provider. 118 const SFXDeviceInfoVector& getDeviceInfo() const { return mDeviceInfo; } 119 120 static void initializeAllProviders(); 121 122}; 123 124 125#endif // _SFXPROVIDER_H_ 126