# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

type_def.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_TYPE_DEF_H
00027 #define NL_TYPE_DEF_H
00028 #include "nel/ai/script/constraint.h"
00029 
00030 namespace NLAISCRIPT
00031 {       
00032         struct CFactorType;
00033 
00043         class IOpType: public IConstraint
00044         {               
00045 
00046         public:
00047                 IOpType()
00048                 {
00049                 }
00050 
00052 
00053                 virtual void run(IConstraint *){}
00054                 virtual void run(CCompilateur &){}
00055                 virtual void addIndex(int i,CCodeBrancheRun *){}
00056                 virtual void getError(char *) const{}
00057                 virtual int getLine() const{ return 0;}
00058                 virtual int getColone() const{return 0;}
00059                 double evalParam(IOpType *);
00060                 virtual double eval (IOpType *);
00062 
00063                 virtual ~IOpType();
00064 
00065         public:
00066                 static const IOpType*loadIOpType(NLMISC::IStream &f);           
00067         };
00068 
00078         class COperandVoid: public IOpType
00079         {
00080         
00081         public:
00082                 COperandVoid()
00083                 {                                               
00084                 }
00085 
00086                 const char *getInfo()
00087                 {
00088                         return "constraint<COperandVoid>";
00089                 }
00090 
00091                 const NLAIC::CIdentType *getConstraintTypeOf()
00092                 {
00093                         return &NLAIC::CIdentType::VoidType;
00094                 }
00095 
00096                 virtual void serial(NLMISC::IStream     &f) throw(NLMISC::EStream)
00097                 {
00098                         if ( f.isReading() )
00099                         {
00100                                 throw NLMISC::EStream();
00101                         }
00102                         else
00103                         {
00104                                 sint32 n =  (sint32)getTypeOfClass();
00105                                 f.serial(n);
00106                         }
00107                 }
00108 
00109                 virtual ConstraintTypeEnum getTypeOfClass() const
00110                 {
00111                         return operandVoid;
00112                 }
00113 
00114                 bool operator == (const IConstraint &c) const
00115                 {
00116                         if(getTypeOfClass() == c.getTypeOfClass())
00117                         {
00118                                 return true;
00119                         }
00120                         return false;
00121                 }
00122 
00123                 bool dependOn(const IConstraint *) const
00124                 {
00125                         return false;
00126                 }
00127 
00128                 const IConstraint *clone() const
00129                 {
00130                         IConstraint *x = new COperandVoid();
00131                         return x;
00132                 }               
00133 
00134                 bool satisfied()
00135                 {
00136                         return true;
00137                 }               
00138 
00139                 virtual ~COperandVoid()
00140                 {                                               
00141                 }
00142         };
00143 
00153         class COperandAnyObject: public IOpType
00154         {
00155         
00156         public:
00157                 COperandAnyObject()
00158                 {                                               
00159                 }
00160 
00161                 const char *getInfo()
00162                 {
00163                         return "constraint<COperandAnyObject>";
00164                 }
00165 
00166                 const NLAIC::CIdentType *getConstraintTypeOf()
00167                 {
00168                         return &NLAIC::CIdentType::VoidType;
00169                 }
00170 
00171                 virtual void serial(NLMISC::IStream     &f) throw(NLMISC::EStream)
00172                 {
00173                         if ( f.isReading() )
00174                         {
00175                                 throw NLMISC::EStream();
00176                         }
00177                         else
00178                         {
00179                                 sint32 n =  (sint32)getTypeOfClass();
00180                                 f.serial(n);
00181                         }
00182                 }
00183 
00184                 virtual ConstraintTypeEnum getTypeOfClass() const
00185                 {
00186                         return operandAnyObject;
00187                 }
00188 
00189                 bool operator == (const IConstraint &c) const
00190                 {                       
00191                         return true;
00192                 }
00193 
00194                 bool dependOn(const IConstraint *) const
00195                 {
00196                         return false;
00197                 }
00198 
00199                 const IConstraint *clone() const
00200                 {
00201                         IConstraint *x = new COperandAnyObject();
00202                         return x;
00203                 }               
00204 
00205                 bool satisfied()
00206                 {
00207                         return true;
00208                 }               
00209 
00210                 virtual ~COperandAnyObject()
00211                 {                                               
00212                 }
00213         };
00214 
00224         class COperandSimple: public IOpType
00225         {
00226         private:
00227                 NLAIC::CIdentType *_Ident;
00228                 std::string _TxtInfo;
00229 
00230         public:
00231                 COperandSimple(NLMISC::IStream  &f)
00232                 {
00233                         _Ident = new NLAIC::CIdentType(f);                      
00234                 }
00235                 COperandSimple(NLAIC::CIdentType *i) : _Ident(i)
00236                 {                       
00237                 }
00238 
00239                 const char *getInfo()
00240                 {
00241                         if(_TxtInfo.begin() == _TxtInfo.end())
00242                         {
00243                                 _TxtInfo = NLAIC::stringGetBuild("constraint<COperandSimple> for %s",(const char *)*_Ident);                            
00244                         }
00245                         return _TxtInfo.c_str();
00246                 }
00247 
00248                 const NLAIC::CIdentType *getConstraintTypeOf()
00249                 {
00250                         return _Ident;
00251                 }
00252 
00253                 virtual ConstraintTypeEnum getTypeOfClass() const
00254                 {
00255                         return operandSimple;
00256                 }
00257 
00258                 bool operator == (const IConstraint &c) const
00259                 {
00260                         if(getTypeOfClass() == c.getTypeOfClass() && *((const COperandSimple &)c)._Ident == *_Ident)
00261                         {
00262                                 return true;
00263                         }
00264                         return false;
00265                 }
00266 
00267                 bool dependOn(const IConstraint *) const
00268                 {
00269                         return false;
00270                 }
00271 
00272                 const IConstraint *clone() const
00273                 {
00274                         IConstraint *x = new COperandSimple(new NLAIC::CIdentType(*_Ident));
00275                         return x;
00276                 }               
00277 
00278                 bool satisfied()
00279                 {
00280                         return true;
00281                 }
00282 
00283                 virtual void serial(NLMISC::IStream     &f) throw(NLMISC::EStream)
00284                 {
00285                         if ( f.isReading() )
00286                         {
00287                                 if(_Ident) _Ident->release();
00288                                 _Ident = new NLAIC::CIdentType(f);
00289                                 _TxtInfo.clear();
00290                                 
00291                         }
00292                         else
00293                         {
00294                                 sint32 n =  (sint32)getTypeOfClass();
00295                                 f.serial(n);
00296                                 _Ident->serial(f);
00297                         }
00298                 }
00299 
00300                 virtual ~COperandSimple()
00301                 {
00302                         _Ident->release();                      
00303                 }
00304         };
00305 
00306 
00316         class COperandSimpleListOr: public IOpType
00317         {
00318         private:
00319                 std::list<NLAIC::CIdentType *> _TypeListe;
00320                 //NLAIC::CIdentType *_Ident;
00321                 char *_TxtInfo;
00322 
00323         public:
00324                 COperandSimpleListOr(NLMISC::IStream &f)
00325                 {
00326                         serial(f);
00327                 }               
00328 
00329                 COperandSimpleListOr(const std::list<NLAIC::CIdentType *> &l)
00330                 {
00331                         char txt[1028*8];               
00332                         sprintf(txt,"constraint<COperandSimpleListOr> for ...");
00333                         _TxtInfo = new char [strlen(txt) + 1];
00334                         strcpy(_TxtInfo,txt);
00335 
00336                         std::list<NLAIC::CIdentType *>::const_iterator i = l.begin();
00337                         while(i != l.end())
00338                         {
00339                                 _TypeListe.push_back(new NLAIC::CIdentType(*(*i++)));
00340                         }
00341                 }
00342 
00343 
00344                 COperandSimpleListOr(int count, ...);
00345 
00346                 const std::list<NLAIC::CIdentType *> &getList() const
00347                 {
00348                         return _TypeListe;
00349                 }
00350 
00351                 const char *getInfo()
00352                 {
00353                         return _TxtInfo;
00354                 }
00355 
00356                 const NLAIC::CIdentType *getConstraintTypeOf()
00357                 {
00358                         return _TypeListe.back();
00359                 }
00360 
00361                 virtual ConstraintTypeEnum getTypeOfClass() const
00362                 {
00363                         return operandSimpleListOr;
00364                 }
00365 
00366                 bool operator == (const IConstraint &c) const
00367                 {
00368                         if(getTypeOfClass() == c.getTypeOfClass())
00369                         {               
00370                                 const COperandSimpleListOr &l = (const COperandSimpleListOr &)c;
00371                                 if(l._TypeListe.size() != _TypeListe.size()) return false;
00372 
00373                                 std::list<NLAIC::CIdentType *>::const_iterator i = _TypeListe.begin();
00374                                 std::list<NLAIC::CIdentType *>::const_iterator j = l._TypeListe.begin();
00375                                 while(i != _TypeListe.end())
00376                                 {
00377                                         if(!((*i++) == (*j++))) return false;
00378                                 }
00379                                 return true;
00380                         }
00381                         return false;
00382                 }
00383 
00384                 bool dependOn(const IConstraint *) const
00385                 {
00386                         return false;
00387                 }
00388 
00389                 const IConstraint *clone() const
00390                 {
00391                         IConstraint *x = new COperandSimpleListOr(_TypeListe);
00392                         return x;
00393                 }               
00394 
00395                 bool satisfied()
00396                 {
00397                         return true;
00398                 }
00399 
00400                 virtual void serial(NLMISC::IStream     &f) throw(NLMISC::EStream)
00401                 {
00402                         if ( f.isReading() )
00403                         {
00404                                 while(_TypeListe.size())
00405                                 {
00406                                         delete _TypeListe.back();
00407                                         _TypeListe.pop_back();
00408                                 }
00409                                 
00410                         
00411                                 sint32 i;
00412                                 f.serial(i);                            
00413                                 while(i --)
00414                                 {
00415                                         NLAIC::CIdentType *ident = new NLAIC::CIdentType(f);
00416                                         _TypeListe.push_back(ident);
00417                                 }                               
00418                                 delete _TxtInfo;
00419                                 char txt[1028*8];               
00420                                 sprintf(txt,"constraint<COperandSimpleListOr> for ...");
00421                                 _TxtInfo = new char [strlen(txt) + 1];
00422                                 strcpy(_TxtInfo,txt);
00423                         }
00424                         else
00425                         {
00426                                 sint32 n =  (sint32)getTypeOfClass();
00427                                 f.serial(n);
00428                                 n = _TypeListe.size();
00429                                 f.serial(n);
00430                                 std::list<NLAIC::CIdentType *>::iterator i = _TypeListe.begin();
00431                                 while(i != _TypeListe.end())
00432                                 {
00433                                         (*i++)->serial(f);
00434                                 }                                                               
00435                         }
00436                 }
00437 
00438                 virtual double eval (IOpType *);
00439 
00440                 virtual ~COperandSimpleListOr()
00441                 {
00442                         while(_TypeListe.size())
00443                         {
00444                                 delete _TypeListe.back();
00445                                 _TypeListe.pop_back();
00446                         }
00447                         delete _TxtInfo;
00448                 }
00449         };
00450 
00451 
00461         class COperandUnknown: public IOpType
00462         {
00463         private:                
00464                  IConstraint *_Constraint;               
00465                  NLAIC::CIdentType *_Id;
00466                  char *_TxtInfo;
00467                  bool _RunIsDone;
00468                 
00469         public:
00470                 COperandUnknown(IConstraint *constraint):_Constraint(constraint),_Id(NULL)
00471                 {               
00472                         char txt[1028*8];               
00473                         sprintf(txt,"constraint<COperandUnknown> for %s",_Constraint->getInfo());
00474                         _TxtInfo = new char [strlen(txt) + 1];
00475                         strcpy(_TxtInfo,txt);
00476                         _Constraint->addConstraint(this);
00477                         _RunIsDone = false;
00478                 }
00479 
00480                 virtual void serial(NLMISC::IStream     &f) throw(NLMISC::EStream)
00481                 {
00482                         if(_Id != NULL)
00483                         {
00484                                 COperandSimple n(new NLAIC::CIdentType (*_Id));
00485                                 n.serial(f);
00486                         }
00487                         else throw NLMISC::EStream();
00488                 }
00489 
00490                 const char *getInfo()
00491                 {
00492                         return _TxtInfo;
00493                 }
00494                 
00495                 const NLAIC::CIdentType *getConstraintTypeOf() 
00496                 {
00497                         if(_Id == NULL)
00498                         {
00499                                 _Id = (NLAIC::CIdentType *)_Constraint->getConstraintTypeOf();
00500                         }
00501                         return _Id;
00502                 }
00503 
00504                 const IConstraint *clone() const
00505                 {
00506                         IConstraint *x = new COperandUnknown((IConstraint *)_Constraint->clone());              
00507                         return x;
00508                 }               
00509 
00510                 void run(CCompilateur &c)
00511                 {
00512                         if(_Id == NULL)
00513                         {
00514                                 _Constraint->run(c);
00515                                 run(_Constraint);
00516                         }
00517                 }
00518                 
00519                 void run(IConstraint *c)
00520                 {                       
00521                         if(c == _Constraint) 
00522                         {
00523                                 _Id = (NLAIC::CIdentType *)_Constraint->getConstraintTypeOf();
00524                                 if(satisfied())
00525                                 {
00526                                         _RunIsDone = true;                                      
00527                                 }
00528                         }
00529                 }
00530                 
00531                 bool operator == (const IConstraint &c) const
00532                 {
00533                         if(getTypeOfClass() == c.getTypeOfClass() && *((const COperandUnknown &)c)._Constraint == *_Constraint)
00534                         {
00535                                 return true;
00536                         }
00537                         return false;
00538                 }
00539 
00540                 bool dependOn(const IConstraint *c) const
00541                 {
00542                         return _Constraint == c || _Constraint->dependOn(c);
00543                 }
00544                 virtual ConstraintTypeEnum getTypeOfClass() const
00545                 {
00546                         return operandUnknown;
00547                 }
00548 
00549                 bool satisfied()
00550                 {
00551                         return getConstraintTypeOf()  != NULL;
00552                 }
00553                 
00554                 virtual ~COperandUnknown()                      
00555                 {                       
00556                         if (_Constraint != NULL)
00557                         {                       
00558                                 if(!_RunIsDone) _Constraint->popConstraint(this);                               
00559                                 
00560                                 _Constraint->release();
00561                                 _Constraint = NULL;
00562 
00563                         }
00564                         delete _TxtInfo;
00565                 }               
00566         };
00567 
00577         class COperationType: public IOpType
00578         {
00579         private:
00581                 IOpType *_Operand;
00583                 NLAIC::CTypeOfOperator::TTypeOp _Op;
00584                 char *_TxtInfo;
00585                 NLAIC::CIdentType *_Id;
00586         public:
00587                 COperationType(const IOpType &operand,NLAIC::CTypeOfOperator::TTypeOp op):
00588                         _Operand((IOpType *)operand.clone()),_Op(op)
00589                 {
00590 
00591                         char txt[1028*8];               
00592                         sprintf(txt,"constraint<COperationType> for %s",_Operand->getInfo());
00593                         _TxtInfo = new char [strlen(txt) + 1];
00594                         strcpy(_TxtInfo,txt);
00595                         _Id = NULL;
00596                 }
00597 
00598 
00599                 COperationType():_Operand(NULL),_Op((NLAIC::CTypeOfOperator::TTypeOp)0)
00600                 {
00601                         _Id = NULL;
00602                 }
00603 
00604                 virtual void serial(NLMISC::IStream     &f) throw(NLMISC::EStream)
00605                 {
00606                         if(_Id != NULL)
00607                         {
00608                                 COperandSimple n(new NLAIC::CIdentType (*_Id));
00609                                 n.serial(f);
00610                         }
00611                         else throw NLMISC::EStream();
00612                 }
00613 
00614                 const char *getInfo()
00615                 {
00616                         return _TxtInfo;
00617                 }
00618 
00619                 void setOp(NLAIC::CTypeOfOperator::TTypeOp op)
00620                 {
00621                         _Op = op;
00622                 }
00623 
00624                 void setOperand(IOpType *operand)
00625                 {
00626                         _Operand = operand;
00627                         char txt[1028*8];               
00628                         sprintf(txt,"constraint<COperationType> for %s",operand->getInfo());
00629                         _TxtInfo = new char [strlen(txt) + 1];
00630                         strcpy(_TxtInfo,txt);
00631                 }
00632 
00633                 bool dependOn(const IConstraint *c) const
00634                 {
00635                         return _Operand->dependOn(c);
00636                 }
00637 
00638                 virtual void run(CCompilateur &c)
00639                 {
00640                         _Operand->run(c);
00641                         _Id = (NLAIC::CIdentType *)getConstraintTypeOf();                       
00642                 }
00643                 
00644 
00645                 void run(IConstraint *c)
00646                 {
00647                 }
00648 
00649                 const NLAIC::CIdentType *getConstraintTypeOf() 
00650                 {                                                       
00651                         if(_Id) return _Id;
00652                         else return (_Id = (NLAIC::CIdentType *)_Operand->getConstraintTypeOf());
00653                 }
00654                 
00655                 bool satisfied()
00656                 {                       
00657                         return getConstraintTypeOf() != NULL;
00658                 }
00659 
00660                 const IConstraint *clone() const
00661                 {
00662                         IConstraint *x = new COperationType((const COperationType &)*_Operand,_Op);
00663                         return x;                               
00664                 }
00665                 
00666 
00667                 bool operator == (const IConstraint &c) const
00668                 {
00669                         if(getTypeOfClass() == c.getTypeOfClass() && *((const COperationType &)c)._Operand == *_Operand && ((const COperationType &)c)._Op == _Op)
00670                         {
00671                                 return true;
00672                         }
00673                         return false;
00674                 }               
00675 
00676                 virtual ConstraintTypeEnum getTypeOfClass() const
00677                 {
00678                         return operationType;
00679                 }
00680 
00681                 virtual ~COperationType()
00682                 {
00683                         _Operand->release();
00684                         delete _TxtInfo;
00685                 }
00686         };
00687 
00697         class COperationTypeGD: public IOpType
00698         {
00699         private:
00701                 IOpType *_OpG;
00702                 //Left operand.
00703                 IOpType *_OpD;
00705                 NLAIC::CTypeOfOperator::TTypeOp _Op;
00706                 char *_TxtInfo;
00707                 NLAIC::CIdentType *_Id;
00708         public:
00709                 COperationTypeGD(const COperationType &opG,const COperationType &opD,NLAIC::CTypeOfOperator::TTypeOp op):
00710                                 _OpG((IOpType   *)opG.clone()),_OpD((IOpType *)opD.clone()),_Op(op)
00711                 {
00712                         char txt[1028*8];               
00713                         sprintf(txt,"constraint<COperationType> for <%s> <%s>",_OpG->getInfo(),_OpD->getInfo());
00714                         _TxtInfo = new char [strlen(txt) + 1];
00715                         strcpy(_TxtInfo,txt);
00716                         _Id = NULL;
00717                         _TxtInfo = NULL;
00718                                         
00719                 }
00720                 
00721                 COperationTypeGD()
00722                 {
00723                         _OpG = _OpD = NULL;
00724                         _Op = (NLAIC::CTypeOfOperator::TTypeOp)0;
00725                         _Id = NULL;
00726                         _TxtInfo = NULL;
00727                 }
00728 
00729                 virtual void serial(NLMISC::IStream     &f) throw(NLMISC::EStream)
00730                 {
00731                         if(_Id != NULL)
00732                         {
00733                                 COperandSimple n(new NLAIC::CIdentType (*_Id));
00734                                 n.serial(f);
00735                         }
00736                         else throw NLMISC::EStream();
00737                 }
00738 
00739                 const char *getInfo()
00740                 {
00741                         if(_TxtInfo == NULL)
00742                         {
00743                                 char txt[1028*8];               
00744                                 sprintf(txt,"constraint<COperationTypeGD> for <%s> <%s>",_OpG->getInfo(),_OpD->getInfo());
00745                                 _TxtInfo = new char [strlen(txt) + 1];
00746                                 strcpy(_TxtInfo,txt);
00747                         }
00748                         return _TxtInfo;
00749                 }
00750 
00751                 bool dependOn(const IConstraint *c) const
00752                 {
00753                         return _OpG->dependOn(c) || c == _OpG || _OpD->dependOn(c) || c == _OpD;
00754                 }
00755                 
00756                 void setOp(NLAIC::CTypeOfOperator::TTypeOp op)
00757                 {
00758                         _Op = op;
00759                 }
00760 
00761                 void setOperationG(IOpType *opG)
00762                 {
00763                         _OpG = opG;                     
00764                         
00765                 }
00766 
00767                 void setOperationD(IOpType *opD)
00768                 {
00769                         _OpD = opD;
00770                 }
00771 
00772                 const IConstraint *clone() const
00773                 {
00774                         IConstraint *x = new COperationTypeGD ((const COperationType &)*_OpG,(const COperationType &)*_OpD,_Op);
00775                         return x;
00776                 }
00777 
00778                 virtual void run(CCompilateur &c)
00779                 {
00780                         _OpG->run(c);
00781                         _OpD->run(c);
00782                         
00783                         _Id = (NLAIC::CIdentType *)getConstraintTypeOf();
00784                 }
00785                 
00786 
00787                 void run(IConstraint *c)
00788                 {
00789                 }
00790 
00791                 const NLAIC::CIdentType *getConstraintTypeOf()
00792                 {                       
00793                         if(satisfied()) return (_Id = (NLAIC::CIdentType *)_OpG->getConstraintTypeOf());
00794                         return NULL;
00795                 }
00796                 
00797                 bool satisfied();
00798                 
00799 
00800                 bool operator == (const IConstraint &c) const
00801                 {
00802                         if(getTypeOfClass() == c.getTypeOfClass() && *((const COperationTypeGD &)c)._OpG == *_OpG && *((const COperationTypeGD &)c)._OpD == *_OpD)
00803                         {
00804                                 return true;
00805                         }
00806                         return false;
00807                 }
00808                 
00809 
00810                 virtual ConstraintTypeEnum getTypeOfClass() const
00811                 {
00812                         return operationTypeGD;
00813                 }
00814 
00815                 virtual ~COperationTypeGD()
00816                 {
00817                         if(_OpG) _OpG->release();
00818                         if(_OpD) _OpD->release();
00819                         delete _TxtInfo;
00820                 }
00821         };
00822 
00833         class COperandListType: public IOpType
00834         {
00835         private:
00836                 std::list<IOpType *> _List;
00837                 NLAIC::CIdentType *_Id;
00838                 bool _S;
00839                 char *_TxtInfo;
00840         public:
00841 
00842                 COperandListType(const COperandListType &c)                     
00843                 {
00844                         std::list<IOpType *>::const_iterator i = c._List.begin();
00845                         _S = c._S;
00846                         while(i != c._List.end())
00847                         {
00848                                 _List.push_back(*i);
00849                                 (*i)->incRef();
00850                                 i ++;
00851                         }                       
00852                         _TxtInfo = new char [strlen(c._TxtInfo) + 1];
00853                         strcpy(_TxtInfo,c._TxtInfo);
00854                         if(c._Id) _Id = new NLAIC::CIdentType (*c._Id);
00855                 }
00856 
00857                 COperandListType()
00858                 {
00859                         _Id = NULL;
00860                         _S = false;
00861                         char txt[1028*8];               
00862                         sprintf(txt,"constraint<COperandListType>");
00863                         _TxtInfo = new char [strlen(txt) + 1];
00864                         strcpy(_TxtInfo,txt);
00865                 }
00866 
00867                 virtual void serial(NLMISC::IStream     &f) throw(NLMISC::EStream)
00868                 {
00869                         if(_Id != NULL)
00870                         {
00871                                 COperandSimple n(new NLAIC::CIdentType (*_Id));
00872                                 n.serial(f);
00873                         }
00874                         else throw NLMISC::EStream();
00875                 }
00876 
00877                 virtual ConstraintTypeEnum getTypeOfClass() const
00878                 {
00879                         return operandListType;
00880                 }
00881 
00882                 const IConstraint *clone() const
00883                 {
00884                         IConstraint *x = new COperandListType (*this);
00885                         return x;
00886                 }
00887 
00888                 const NLAIC::CIdentType *getConstraintTypeOf()
00889                 {
00890                         return _Id;
00891                 }
00892 
00893                 bool operator == (const IConstraint &c) const
00894                 {
00895                         if(getTypeOfClass() == c.getTypeOfClass())
00896                         {
00897                                 const COperandListType &o = (const COperandListType &)c;
00898 
00899                                 if(o._List.size() != _List.size()) return false;
00900 
00901                                 std::list<IOpType *>::const_iterator i = o._List.begin();                               
00902                                 std::list<IOpType *>::const_iterator j = _List.begin();                         
00903                                 while(j != _List.end())
00904                                 {
00905                                         if(!(*(*i) == *(*j))) return false;
00906                                         i ++;
00907                                         j ++;
00908                                 }                                                       
00909                                 return true;
00910                         }
00911                         else
00912                         {
00913                                 std::list<IOpType *>::const_iterator j = _List.begin();
00914                                 while(j != _List.end())
00915                                 {
00916                                         if( c == *(*j)) return true;
00917                                         j ++;
00918                                 }                                                       
00919                                 return false;
00920                         }
00921                         return false;
00922                 }
00923 
00924                 const char *getInfo()
00925                 {
00926                         return _TxtInfo;
00927                 }
00928 
00929                 bool satisfied()
00930                 {
00931                         return _S;
00932                 }
00933 
00934                 void run(CCompilateur &c)
00935                 {
00936                         std::list<IOpType *>::iterator i = _List.begin();
00937                         _S = true;
00938                         while(i != _List.end())
00939                         {
00940                                 IOpType *o = *i++;
00941                                 o->run(c);
00942                                 if(o->satisfied())
00943                                 {
00944                                         if(_Id == NULL) 
00945                                         {
00946                                                 _Id = new NLAIC::CIdentType(*o->getConstraintTypeOf());
00947                                         }
00948                                         else if(!(*_Id == *o->getConstraintTypeOf())) _S = false;
00949                                 }
00950                         }
00951                 }
00952 
00953                 bool dependOn(const IConstraint *a) const
00954                 {
00955                         std::list<IOpType *>::const_iterator i = _List.begin();                 
00956                         while(i != _List.end())
00957                         {
00958                                 const IConstraint *o = *i++;
00959                                 if(a == o || o->dependOn(a)) return true;
00960                         }
00961                         return false;
00962                 }
00963 
00964                 void add(IOpType *o)
00965                 {
00966                         _List.push_back(o);
00967                 }
00968 
00969                 virtual ~COperandListType()
00970                 {
00971                         while(_List.size())
00972                         {
00973                                 _List.back()->release();
00974                                 _List.pop_back();
00975                         }
00976                         if(_Id) delete _Id;
00977                         delete _TxtInfo;
00978                 }
00979 
00980 
00981         };
00982 
00984         inline const IOpType *IOpType::loadIOpType(NLMISC::IStream &f)
00985         {
00986                 IConstraint::ConstraintTypeEnum k = constraintMethode;
00987                 IOpType *x;
00988 
00989                 f.serial((sint32 &)k);
00990         
00991                 switch(k)
00992                 {
00993                 case operandAnyObject:
00994                         x = new  COperandAnyObject();
00995                         return x;
00996 
00997                 case operandVoid:
00998                         x = new COperandVoid();
00999                         return x;
01000 
01001                 case operandSimple:
01002                         x = new COperandSimple(f);
01003                         return x;
01004 
01005                 case operandSimpleListOr:
01006                         x = new COperandSimpleListOr(f);
01007                         return x;
01008                 default: break;
01009                 }
01010                 return NULL;
01011         }
01012 }
01013 #endif