00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef NL_REGISTER_TYPE_H
00026 #define NL_REGISTER_TYPE_H
00027
00028 #include <iostream>
00029 #include "nel/misc/types_nl.h"
00030
00031 namespace NLAIC
00032 {
00041 class CBinaryType: public NLAIC::IBasicInterface
00042 {
00043 private:
00045 uint32 _Bites;
00046
00047 public:
00049 CBinaryType(uint32 bites):_Bites(bites)
00050 {
00051 }
00052
00054 CBinaryType(const CBinaryType &bites):_Bites(bites._Bites)
00055 {
00056 }
00057
00059 CBinaryType(NLMISC::IStream &is)
00060 {
00061 load(is);
00062 }
00063
00065 CBinaryType():_Bites(0)
00066 {
00067 }
00068
00069
00071
00072 CBinaryType &operator = (sint32 bites)
00073 {
00074 _Bites = bites;
00075 return *this;
00076 }
00078
00080
00081 CBinaryType &operator |= (sint32 bites)
00082 {
00083 _Bites |= bites;
00084 return *this;
00085 }
00086 CBinaryType &operator |= (const CBinaryType &bites)
00087 {
00088 _Bites |= bites._Bites;
00089 return *this;
00090 }
00091 CBinaryType operator | (sint32 bites)
00092 {
00093 return CBinaryType(_Bites | bites);
00094 }
00095
00096
00097 CBinaryType operator | (const CBinaryType &bites)
00098 {
00099
00100 return CBinaryType(_Bites | bites._Bites);
00101 }
00103
00105
00106 CBinaryType &operator &= (sint32 bites)
00107 {
00108 _Bites &= bites;
00109 return *this;
00110 }
00111 CBinaryType &operator &= (const CBinaryType &bites)
00112 {
00113 _Bites &= bites._Bites;
00114 return *this;
00115 }
00116 CBinaryType operator & (sint32 bites)
00117 {
00118 return CBinaryType(_Bites & bites);
00119 }
00120 CBinaryType operator & (const CBinaryType &bites)
00121 {
00122 return CBinaryType(_Bites & bites._Bites);
00123 }
00125
00127
00128 CBinaryType &operator ^= (sint32 bites)
00129 {
00130 _Bites ^= bites;
00131 return *this;
00132 }
00133
00134 CBinaryType &operator ^= (const CBinaryType &bites)
00135 {
00136 _Bites ^= bites._Bites;
00137 return *this;
00138 }
00139 CBinaryType operator ^ (sint32 bites)
00140 {
00141 return CBinaryType(_Bites ^ bites);
00142 }
00143 CBinaryType operator ^ (const CBinaryType &bites)
00144 {
00145 return CBinaryType(_Bites ^ bites._Bites);
00146 }
00148
00150
00151 CBinaryType &operator <<= (sint32 bites)
00152 {
00153 _Bites <<= bites;
00154 return *this;
00155 }
00156 CBinaryType operator << (sint32 bites)
00157 {
00158 return CBinaryType(_Bites << bites);
00159 }
00161
00163
00164 CBinaryType &operator >>= (sint32 bites)
00165 {
00166 _Bites >>= bites;
00167 return *this;
00168 }
00169 CBinaryType operator >> (sint32 bites)
00170 {
00171 return CBinaryType(_Bites >> bites);
00172 }
00173
00175 bool operator !()
00176 {
00177 return !_Bites;
00178 }
00180
00182 operator uint () const
00183 {
00184 return _Bites;
00185 }
00186
00187 uint getValue() const
00188 {
00189 return _Bites;
00190 }
00191
00192 public:
00194
00195 virtual const NLAIC::CIdentType &getType() const
00196 {
00197
00198 throw NLAIE::CExceptionUnReference(std::string("const CIdentType & CBinaryType::getType()"));
00199 return NLAIC::CIdentType::VoidType;
00200 }
00201
00202 virtual const NLAIC::IBasicType *clone() const
00203 {
00204 return new CBinaryType(*this);
00205 }
00206 virtual const NLAIC::IBasicType *newInstance() const
00207 {
00208 return new CBinaryType();
00209 }
00210 virtual void save(NLMISC::IStream &os)
00211 {
00212 uint32 bytes = (uint32) _Bites;
00213 os.serial( bytes );
00214 }
00215
00216 virtual void getDebugString(std::string &t) const
00217 {
00218 t = stringGetBuild("CBinaryType <%d>",_Bites);
00219 }
00220
00221 virtual void load(NLMISC::IStream &is)
00222 {
00223 uint32 bytes;
00224 is.serial( bytes );
00225 _Bites = (uint32) bytes;
00226 }
00228
00229 void addType(sint32 b)
00230 {
00231 _Bites = _Bites | b;
00232 }
00233 };
00234
00235
00243 class CTypeOfObject: public CBinaryType
00244 {
00245 public:
00246 static NLAIC::CIdentType IdTypeOfObject;
00247
00248 public:
00250 enum TTypeBite{
00252 tNombre = 1,
00254 tString = 2,
00256 tLogic = 4,
00258 tList = 8,
00259
00261
00262
00264
00266
00268
00270
00271 tMessage = 2048,
00273 tLast = tMessage,
00275 tUndef = 0xFFFFFFFF - tLast*2
00276
00277 };
00278
00279 CTypeOfObject()
00280 {
00281 }
00282
00283 CTypeOfObject(uint32 bites):CBinaryType(bites)
00284 {
00285 }
00286
00287 CTypeOfObject(const CTypeOfObject &bites):CBinaryType(bites)
00288 {
00289 }
00290
00291 CTypeOfObject(NLMISC::IStream &is):CBinaryType(is)
00292 {
00293 }
00294
00295 virtual ~CTypeOfObject()
00296 {
00297 }
00298 public:
00300
00301 virtual const NLAIC::IBasicType *clone() const
00302 {
00303 NLAIC::IBasicType *x = new CTypeOfObject(*this);
00304 return x;
00305 }
00306
00307 virtual const NLAIC::IBasicType *newInstance() const
00308 {
00309 NLAIC::IBasicType *x = new CTypeOfObject();
00310 return x;
00311 }
00312
00313 virtual const NLAIC::CIdentType &getType() const;
00314 virtual void getDebugString(char *txt) const;
00316 };
00317
00325 class CTypeOfOperator: public CBinaryType
00326 {
00327 public:
00328 static NLAIC::CIdentType IdTypeOfOperator;
00329
00330 public:
00332 enum TTypeOp{
00334 opNone = 0,
00336 opAdd = 1,
00338 opSub = 2,
00340 opMul = 4,
00342 opDiv = 8,
00344 opEq = 16,
00346 opInf = 32,
00348 opSup = 64,
00350 opInfEq = 128,
00352 opSupEq = 256,
00354 opNot = 512,
00356 opDiff = 1024,
00358 opNeg = 2048,
00360 opAff = 4096,
00362 tUndef = 0xFFFFFFFF - opAff*2 + 1
00363 };
00364
00365 CTypeOfOperator()
00366 {
00367 }
00368
00369 CTypeOfOperator(uint32 bites):CBinaryType(bites)
00370 {
00371 }
00372
00373
00374 CTypeOfOperator(const CTypeOfOperator &bites):CBinaryType(bites)
00375 {
00376 }
00377
00378 CTypeOfOperator(NLMISC::IStream &is):CBinaryType(is)
00379 {
00380 }
00381
00382
00383 virtual ~CTypeOfOperator()
00384 {
00385 }
00386 public:
00388
00389
00390 virtual const NLAIC::IBasicType *clone() const
00391 {
00392 NLAIC::IBasicType *x = new CTypeOfOperator(*this);
00393 return x;
00394 }
00395
00396 virtual const NLAIC::IBasicType *newInstance() const
00397 {
00398 NLAIC::IBasicType *x = new CTypeOfOperator();
00399 return x;
00400 }
00401
00402 virtual const NLAIC::CIdentType &getType() const;
00403 virtual void getDebugString(char *txt) const;
00405 };
00406 }
00407
00408 #endif