# 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  

constraint_type.cpp

Go to the documentation of this file.
00001 
00006 /* Copyright, 2000 Nevrax Ltd.
00007  *
00008  * This file is part of NEVRAX NEL.
00009  * NEVRAX NEL is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2, or (at your option)
00012  * any later version.
00013 
00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * General Public License for more details.
00018 
00019  * You should have received a copy of the GNU General Public License
00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00022  * MA 02111-1307, USA.
00023  */
00024 #include "nel/ai/script/compilateur.h"
00025 #include "nel/ai/script/constraint.h"
00026 
00027 namespace NLAISCRIPT
00028 {
00029         CConstraintChkMethodeType::CConstraintChkMethodeType(IConstraint *constraint,int lin,int col):
00030                                         _Constraint(constraint),_Satisfied(false),_Lin(lin),_Col(col)
00031         {
00032                 _Ident = NULL;
00033                 ((CConstraintMethode *)constraint)->addConstraint(this);
00034                 std::string text;
00035                 text = NLAIC::stringGetBuild("constraint<CConstraintChkMethodeType> for %s",((IConstraint *)_Constraint)->getInfo());
00036                 _TxtInfo = new char [strlen(text.c_str()) + 1];
00037                 strcpy(_TxtInfo,text.c_str());
00038                 _RunIsDone = false;
00039         }
00040 
00041         const IConstraint *CConstraintChkMethodeType::clone() const
00042         {
00043                 IConstraint *x = new CConstraintChkMethodeType(_Constraint,_Lin,_Col);
00044                 return x;
00045         }
00046 
00047         void CConstraintChkMethodeType::run(CCompilateur &c)
00048         {
00049                 if(_Ident == NULL)
00050                 {
00051                         _Constraint->run(c);
00052                         _Ident = (NLAIC::CIdentType *)((CConstraintMethode *)_Constraint)->getConstraintTypeOf();
00053                 }
00054                 runConnexcion();
00055         }
00056 
00057         void CConstraintChkMethodeType::run(IConstraint *c)
00058         {
00059                 if(c == _Constraint)
00060                 {
00061                         //_Constraint = NULL;
00062                         _RunIsDone = true;
00063                         _Ident = (NLAIC::CIdentType *)((CConstraintMethode *)c)->getConstraintTypeOf();
00064                 }                               
00065         }
00066 
00067         bool CConstraintChkMethodeType::operator == (const IConstraint &c) const
00068         {
00069                 if(getTypeOfClass() == c.getTypeOfClass() && *((const CConstraintChkMethodeType &)c)._Constraint == *_Constraint)
00070                 {
00071                         return true;
00072                 }
00073                 return false;
00074         }
00075 
00076         void CConstraintChkMethodeType::addIndex(int i,CCodeBrancheRun *c)
00077         {
00078         }
00079 
00080         void CConstraintChkMethodeType::getError(char *txt) const
00081         {                       
00082                 strcpy(txt,_TxtInfo);
00083         }
00084 
00085         CConstraintChkMethodeType::~CConstraintChkMethodeType()
00086         {                                                       
00087                 if(!_RunIsDone) ((CConstraintMethode *)_Constraint)->popConstraint(this);               
00088                 _Constraint->release();
00089                 delete _TxtInfo;
00090         }       
00091 }