목차

include/AK/Plugin/PluginServices/AkFXParameterChangeHandler.h

Go to the documentation of this file.
00001 
00002 //
00003 // Copyright (c) 2006 Audiokinetic Inc. / All Rights Reserved
00004 //
00006 
00007 #ifndef _AKFXPARAMETERCHANGEHANDLER_H_
00008 #define _AKFXPARAMETERCHANGEHANDLER_H_
00009 
00010 #include <AK/SoundEngine/Common/AkTypes.h>
00011 #include <AK/Tools/Common/AkAssert.h>
00012 #include <AK/Tools/Common/AkPlatformFuncs.h>
00013 
00016 namespace AK
00017 {
00018 
00019     template <AkUInt32 T_MAXNUMPARAMS> 
00020     class AkFXParameterChangeHandler
00021     {
00022     public:
00023 
00024         inline AkFXParameterChangeHandler()
00025         {
00026             ResetAllParamChanges( );
00027         }
00028 
00029         inline void SetParamChange( AkPluginParamID in_ID )
00030         {
00031             AKASSERT( in_ID <= T_MAXNUMPARAMS );
00032             const AkUInt32 uByteIndex = in_ID/8;
00033             const AkUInt32 uBitMask = 1<<(in_ID-uByteIndex*8);
00034             m_uParamBitArray[uByteIndex] |= uBitMask;
00035         }
00036 
00037         inline bool HasChanged( AkPluginParamID in_ID )
00038         {
00039             AKASSERT( in_ID <= T_MAXNUMPARAMS );
00040             const AkUInt32 uByteIndex = in_ID/8;
00041             const AkUInt32 uBitMask = 1<<(in_ID-uByteIndex*8);
00042             return (m_uParamBitArray[uByteIndex] & uBitMask) > 0;
00043         }
00044 
00045         inline bool HasAnyChanged()
00046         {
00047             AkUInt32 uByteIndex = 0;
00048             do
00049             {
00050                 if ( m_uParamBitArray[uByteIndex] > 0 )
00051                     return true;
00052                 ++uByteIndex;
00053             } while (uByteIndex < (((T_MAXNUMPARAMS) + ((8)-1)) & ~((8)-1))/8 );
00054             return false;
00055         }
00056 
00057         inline void ResetParamChange( AkPluginParamID in_ID )
00058         {
00059             AKASSERT( in_ID <= T_MAXNUMPARAMS );
00060             const AkUInt32 uByteIndex = in_ID/8;
00061             const AkUInt32 uBitMask = 1<<(in_ID-uByteIndex*8);
00062             m_uParamBitArray[uByteIndex] &= ~uBitMask;
00063         }
00064 
00065         inline void ResetAllParamChanges( )
00066         {
00067             AkZeroMemSmall( m_uParamBitArray, sizeof(m_uParamBitArray) );
00068         }
00069 
00070         inline void SetAllParamChanges( )
00071         {
00072             AKPLATFORM::AkMemSet( m_uParamBitArray, 0xFF, sizeof(m_uParamBitArray) );
00073         }   
00074 
00075     protected:
00076 
00077         // Minimum storage in bits aligned to next byte boundary
00078         AkUInt8 m_uParamBitArray[(((T_MAXNUMPARAMS) + ((8)-1)) & ~((8)-1))/8]; 
00079 
00080     };
00081 
00082 } // namespace AK
00083 
00084 #endif // _AKFXPARAMETERCHANGEHANDLER_H_