NLAIAGENT::CIndexVariant< T, indexMax, maxT > Class Template Reference

#include <ident.h>


Detailed Description

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
class NLAIAGENT::CIndexVariant< T, indexMax, maxT >

This class is a basic hi nomber manipulation. An index variant is an maxIndex*64 bit number.

The resolution of the number is define by the template argument indexMax. By default the number is initialed with a 128 bits resolution.

Author:
Chafik sameh

Robert Gabriel

Nevrax France

Date:
2000

Definition at line 51 of file ident.h.

Public Member Functions

 CIndexVariant (NLMISC::IStream &is)
 fill from read stream.

 CIndexVariant (T n)
 Initializ by an value.

 CIndexVariant (const T *id)
 fill with a table.

 CIndexVariant (const CIndexVariant< T, indexMax, maxT > &a)
 Copy contructor.

void getDebugString (std::string &str) const
 Have a debug string.

sint32 getMaxIndex () const
void load (NLMISC::IStream &is)
 loading the nomber from an input stream.

const CIndexVariantoperator++ (int)
 throw (NLAIE::CExceptionIndexError)

void save (NLMISC::IStream &os)
 saving the nomber in an output stream.

Binary method.
const CIndexVariant< T, indexMax,
maxT > & 
operator &= (const CIndexVariant< T, indexMax, maxT > &a)
const CIndexVariant< T, indexMax,
maxT > & 
operator^= (const CIndexVariant< T, indexMax, maxT > &a)
const CIndexVariant< T, indexMax,
maxT > & 
operator|= (const CIndexVariant< T, indexMax, maxT > &a)
comparison of two CIndexVariant.
bool operator< (const CIndexVariant< T, indexMax, maxT > &a) const
bool operator== (const CIndexVariant< T, indexMax, maxT > &a) const
bool operator> (const CIndexVariant< T, indexMax, maxT > &a) const
Assignment method.
const CIndexVariant< T, indexMax,
maxT > & 
operator<<= (sint a)
const CIndexVariant< T, indexMax,
maxT > & 
operator= (T a)
const CIndexVariant< T, indexMax,
maxT > & 
operator= (const CIndexVariant< T, indexMax, maxT > &a)
const CIndexVariant< T, indexMax,
maxT > & 
operator>>= (sint a)

Protected Attributes

_Id [indexMax]
 _Id is a table were is store the number.


Private Member Functions

void inc (int n)
 throw (NLAIE::CExceptionIndexError)


Constructor & Destructor Documentation

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
NLAIAGENT::CIndexVariant< T, indexMax, maxT >::CIndexVariant const CIndexVariant< T, indexMax, maxT > &  a  )  [inline]
 

Copy contructor.

Definition at line 84 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id, and NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex().

00085                 {
00086                         memcpy(_Id,a._Id,getMaxIndex()*sizeof(T));
00087                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
NLAIAGENT::CIndexVariant< T, indexMax, maxT >::CIndexVariant const T *  id  )  [inline]
 

fill with a table.

Definition at line 90 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), and sint32.

00091                 {
00092                         for(sint32 i = 0; i < getMaxIndex(); i ++) 
00093                         {
00094                                 _Id[i] = id[i];
00095                         }
00096                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
NLAIAGENT::CIndexVariant< T, indexMax, maxT >::CIndexVariant n  )  [inline]
 

Initializ by an value.

Definition at line 99 of file ident.h.

00100                 {
00101                         /*for(sint32 i = 0; i < getMaxIndex(); i ++) 
00102                         {
00103                                 _Id[i] = n;
00104                         }*/
00105                         *this = n;
00106                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
NLAIAGENT::CIndexVariant< T, indexMax, maxT >::CIndexVariant NLMISC::IStream is  )  [inline]
 

fill from read stream.

Definition at line 110 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::load().

00111                 {
00112                         load(is);
00113                 }


Member Function Documentation

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
void NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getDebugString std::string &  str  )  const [inline]
 

Have a debug string.

Definition at line 288 of file ident.h.

References count, NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), s, and sint.

00289                 {                                                                                               
00290                         char b[sizeof(T)*8 + 1];
00291                         b[sizeof(T)*8] = 0;
00292                         sint i;
00293                         for(i = getMaxIndex() - 1 ; i >= 0; i --)
00294                         {
00295                                 memset(b,'0',sizeof(T)*8);
00296                                 T s = _Id[i];
00297                                 sint base = 0;
00298                                 sint count = 0;
00299                                 for(base = 0; base < sizeof(T)*8; base ++)
00300                                 {
00301                                         if(s & 1)
00302                                         {
00303                                                 b[sizeof(T)*8 - base - 1] = '1'; 
00304                                         }
00305                                         s >>= 1;
00306                                 }                                                       
00307                                 str += std::string(b);
00308                         }
00309                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
sint32 NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex  )  const [inline]
 

Definition at line 312 of file ident.h.

References sint32.

Referenced by NLAIAGENT::CIndexVariant< T, indexMax, maxT >::CIndexVariant(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getDebugString(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::inc(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::load(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator &=(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator<<=(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator=(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator==(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator>(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator>>=(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator^=(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator|=(), and NLAIAGENT::CIndexVariant< T, indexMax, maxT >::save().

00313                 {
00314                         return indexMax;
00315                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
void NLAIAGENT::CIndexVariant< T, indexMax, maxT >::inc int  n  )  [inline, private]
 

throw (NLAIE::CExceptionIndexError)

This fonction increment the _Id number by one. It's call from the ++ operator. If the number id overflow the NLAIE::CExceptionIndexError is emited.

Parameters:
n The first index to increment.

Definition at line 64 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex().

Referenced by NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator++().

00065                 {
00066                         if (n == getMaxIndex())
00067                         {
00068                                 // The highest Number as been reach.
00069                                 throw NLAIE::CExceptionIndexError();
00070                         }
00071 
00072                         if (_Id[n] == maxT)
00073                         {
00074                                 // If an index is max, we increment the next index.
00075                                 inc(n+1);
00076                                 _Id[n] = 0;
00077                         }
00078                         else _Id[n]++;
00079                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
void NLAIAGENT::CIndexVariant< T, indexMax, maxT >::load NLMISC::IStream is  )  [inline]
 

loading the nomber from an input stream.

Definition at line 267 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), num, NLMISC::IStream::serial(), and sint32.

Referenced by NLAIAGENT::CIndexVariant< T, indexMax, maxT >::CIndexVariant().

00268                 {
00269                         sint32 max,i;
00270 
00271                         is.serial(max);
00272                         /*if(max != getMaxIndex()) 
00273                         {
00274                                 throw(NLAIE::CExceptionIndexError());
00275                         }*/
00276 
00277                         for(i = 0; i < getMaxIndex(); i ++)
00278                         {               
00279                                 T num;
00280                                 is.serial(num);
00281                                 _Id[i] = num;
00282                         }
00283 
00284                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
const CIndexVariant<T,indexMax,maxT>& NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator &= const CIndexVariant< T, indexMax, maxT > &  a  )  [inline]
 

Definition at line 171 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id, NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), and sint32.

00172                 {
00173                         for(sint32 i = 0; i < getMaxIndex(); i ++)
00174                         {
00175                                 _Id[i] &= a._Id[i];
00176                         }               
00177                         return *this;
00178                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
const CIndexVariant& NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator++ int   )  [inline]
 

throw (NLAIE::CExceptionIndexError)

Definition at line 116 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::inc().

00117                 {
00118                         try
00119                         {
00120                                 inc(0);
00121                         }
00122                         catch(NLAIE::IException &e)
00123                         {
00124                                 throw e;
00125                         }
00126                         return *this;
00127                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
bool NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator< const CIndexVariant< T, indexMax, maxT > &  a  )  const [inline]
 

Definition at line 141 of file ident.h.

References sint32.

00142                 {                       
00143                         for(sint32 i = a.getMaxIndex()-1; i >= 0; i --)
00144                         {
00145                                 if(_Id[i] < a._Id[i]) return true;
00146                         }                       
00147                         return false;
00148                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
const CIndexVariant<T,indexMax,maxT>& NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator<<= sint  a  )  [inline]
 

Definition at line 229 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), r, and sint.

00230                 {
00231                         T bits = (1 << a) - 1;
00232                         T r;
00233                         T bitlen = 8*sizeof(T) - a;
00234                         sint i;
00235 
00236                         bits <<= (bitlen);
00237 
00238                         _Id[getMaxIndex() - 1] <<= a;
00239                         for(i = getMaxIndex() - 2 ; i >= 0; i --)
00240                         {                       
00241                                 r = _Id[i] & bits;
00242                                 r >>= bitlen;
00243                                 _Id[i] <<= a;
00244                                 _Id[i+1] |= r;
00245                         }               
00246 
00247                         return *this;
00248                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
const CIndexVariant<T,indexMax,maxT>& NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator= a  )  [inline]
 

Definition at line 201 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex().

00202                 {
00203                         memset(_Id,0,getMaxIndex()*sizeof(T));
00204                         _Id[0] = a;
00205                         return *this;
00206                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
const CIndexVariant<T,indexMax,maxT>& NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator= const CIndexVariant< T, indexMax, maxT > &  a  )  [inline]
 

Definition at line 192 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id, NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), and sint32.

00193                 {
00194                         for(sint32 i = 0; i < getMaxIndex(); i ++)
00195                         {
00196                                 _Id[i] = a._Id[i];
00197                         }               
00198                         return *this;
00199                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
bool NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator== const CIndexVariant< T, indexMax, maxT > &  a  )  const [inline]
 

Definition at line 131 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id, NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), and sint32.

00132                 {                       
00133                         for(sint32 i = 0; i < getMaxIndex(); i ++)
00134                         {
00135                                 if(_Id[i] != a._Id[i]) return false;
00136                         }
00137                         
00138                         return true;
00139                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
bool NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator> const CIndexVariant< T, indexMax, maxT > &  a  )  const [inline]
 

Definition at line 150 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id, NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), and sint32.

00151                 {                       
00152                         for(sint32 i = a.getMaxIndex()-1; i >= 0; i --)
00153                         {
00154                                 if(_Id[i] > a._Id[i]) return true;
00155                         }
00156                         
00157                         return false;
00158                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
const CIndexVariant<T,indexMax,maxT>& NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator>>= sint  a  )  [inline]
 

Definition at line 208 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), r, and sint.

00209                 {
00210                         T bits = 1;
00211                         T r;
00212                         T bitlen = 8*sizeof(T) - a;
00213                         sint i;                 
00214 
00215                         bits <<= a;
00216                         bits -= 1;
00217                         _Id[0] >>= a;
00218                         for(i = 1; i < getMaxIndex(); i ++)
00219                         {                       
00220                                 r = _Id[i] & bits;
00221                                 _Id[i] >>= a;
00222                                 r <<= bitlen;
00223                                 _Id[i - 1] |= r;
00224                         }               
00225 
00226                         return *this;
00227                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
const CIndexVariant<T,indexMax,maxT>& NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator^= const CIndexVariant< T, indexMax, maxT > &  a  )  [inline]
 

Definition at line 180 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id, NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), and sint32.

00181                 {
00182                         for(sint32 i = 0; i < getMaxIndex(); i ++)
00183                         {
00184                                 _Id[i] ^= a._Id[i];
00185                         }               
00186                         return *this;
00187                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
const CIndexVariant<T,indexMax,maxT>& NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator|= const CIndexVariant< T, indexMax, maxT > &  a  )  [inline]
 

Definition at line 163 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id, NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), and sint32.

00164                 {
00165                         for(sint32 i = 0; i < getMaxIndex(); i ++)
00166                         {
00167                                 _Id[i] |= a._Id[i];
00168                         }               
00169                         return *this;
00170                 }

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
void NLAIAGENT::CIndexVariant< T, indexMax, maxT >::save NLMISC::IStream os  )  [inline]
 

saving the nomber in an output stream.

Definition at line 254 of file ident.h.

References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), NLMISC::IStream::serial(), and sint32.

00255                 {                       
00256                         sint32 i;
00257                         i = getMaxIndex();
00258                         os.serial(i);
00259                         for(i = 0; i < getMaxIndex(); i ++)
00260                         {
00261                                 T n = _Id[i];                           
00262                                 os.serial(n);                           
00263                         }
00264                 }


Field Documentation

template<class T = sint64, sint32 indexMax = maxIndex, T maxT = (T)-1>
T NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id[indexMax] [protected]
 

_Id is a table were is store the number.

Definition at line 55 of file ident.h.

Referenced by NLAIAGENT::CIndexVariant< T, indexMax, maxT >::CIndexVariant(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator &=(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator=(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator==(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator>(), NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator^=(), and NLAIAGENT::CIndexVariant< T, indexMax, maxT >::operator|=().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 09:16:44 2004 for NeL by doxygen 1.3.6