#include <ident.h>
The resolution of the number is define by the template argument indexMax. By default the number is initialed with a 128 bits resolution.
Robert Gabriel
Nevrax France
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 CIndexVariant & | operator++ (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 | |
T | _Id [indexMax] |
_Id is a table were is store the number. | |
Private Member Functions | |
void | inc (int n) |
throw (NLAIE::CExceptionIndexError) |
|
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 } |
|
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 } |
|
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 } |
|
fill from read stream.
Definition at line 110 of file ident.h. References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::load().
00111 { 00112 load(is); 00113 } |
|
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 } |
|
|
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.
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 } |
|
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().
|
|
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 } |
|
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 } |
|
Definition at line 141 of file ident.h. References sint32.
|
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
Definition at line 150 of file ident.h. References NLAIAGENT::CIndexVariant< T, indexMax, maxT >::_Id, NLAIAGENT::CIndexVariant< T, indexMax, maxT >::getMaxIndex(), and sint32.
|
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|