NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift > Struct Template Reference

#include <context_sound.h>

template<uint NbJoker, bool UseRandom, uint Shift = 5>
struct NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >


Public Types

enum  { JOKER_ARRAY_SIZE = (NbJoker == 0 ? 1 : NbJoker) }

Public Member Functions

 CContextMatcher (uint32 *jokersValues, uint32 randomValue)
size_t getHashValue () const
bool operator== (const CContextMatcher &other) const

Data Fields

uint32 HashValue
uint32 JokersValues [JOKER_ARRAY_SIZE]
uint32 RandomValue

Member Enumeration Documentation

template<uint NbJoker, bool UseRandom, uint Shift = 5>
anonymous enum
 

Enumeration values:
JOKER_ARRAY_SIZE 

Definition at line 43 of file context_sound.h.

00044         {
00045                 // Size of array : special case for 0 joker because we can't declare array of 0 elements
00046                 JOKER_ARRAY_SIZE = (NbJoker == 0 ? 1 : NbJoker)
00047         };


Constructor & Destructor Documentation

template<uint NbJoker, bool UseRandom, uint Shift = 5>
NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::CContextMatcher uint32 jokersValues,
uint32  randomValue
[inline]
 

Definition at line 49 of file context_sound.h.

References NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::HashValue, NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::JokersValues, NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::RandomValue, uint, and uint32.

00050                 : HashValue(0)
00051         {
00052                 uint i;
00053                 for (i=0; i<NbJoker; ++i)
00054                 {
00055                         JokersValues[i] = jokersValues[i];
00056                         
00057                         uint leftShift = (5*i)&0x1f;
00058                         HashValue ^= JokersValues[i] << leftShift;
00059                         HashValue ^= JokersValues[i] >> (32-leftShift);
00060                 }
00061                 if (UseRandom)
00062                 {
00063                         RandomValue = randomValue;
00064                         uint leftShift = (5*i)&0x1f;
00065                         HashValue ^= randomValue << leftShift;
00066                         HashValue ^= randomValue >> (32-leftShift);
00067                 }
00068                 else
00069                         RandomValue = 0;
00070         }


Member Function Documentation

template<uint NbJoker, bool UseRandom, uint Shift = 5>
size_t NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::getHashValue  )  const [inline]
 

Definition at line 82 of file context_sound.h.

References NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::HashValue.

Referenced by NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::CHash::operator()().

00083         {
00084                 return size_t(HashValue);
00085         }

template<uint NbJoker, bool UseRandom, uint Shift = 5>
bool NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::operator== const CContextMatcher< NbJoker, UseRandom, Shift > &  other  )  const [inline]
 

Definition at line 72 of file context_sound.h.

References NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::HashValue, NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::JokersValues, NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::RandomValue, and uint32.

00073         {
00074                 if (HashValue != other.HashValue)
00075                         return false;
00076                 else if (UseRandom)
00077                         return RandomValue == other.RandomValue && memcmp(JokersValues, other.JokersValues, sizeof(uint32)*NbJoker) == 0;
00078                 else
00079                         return memcmp(JokersValues, other.JokersValues, sizeof(uint32)*NbJoker) == 0;
00080         }


Field Documentation

template<uint NbJoker, bool UseRandom, uint Shift = 5>
uint32 NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::HashValue
 

Definition at line 87 of file context_sound.h.

Referenced by NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::CContextMatcher(), NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::getHashValue(), and NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::operator==().

template<uint NbJoker, bool UseRandom, uint Shift = 5>
uint32 NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::JokersValues[JOKER_ARRAY_SIZE]
 

Definition at line 88 of file context_sound.h.

Referenced by NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::CContextMatcher(), and NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::operator==().

template<uint NbJoker, bool UseRandom, uint Shift = 5>
uint32 NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::RandomValue
 

Definition at line 89 of file context_sound.h.

Referenced by NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::CContextMatcher(), and NLSOUND::CContextMatcher< NbJoker, UseRandom, Shift >::operator==().


The documentation for this struct was generated from the following file:
Generated on Tue Mar 16 14:37:18 2004 for NeL by doxygen 1.3.6