# 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  

varstack.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_VAR_STACK_H
00027 #define NL_VAR_STACK_H
00028 
00029 
00030 namespace NLAISCRIPT
00031 {
00042         class CVarPStack:public NLAIAGENT::IObjetOp
00043         {
00044 
00045         public:
00046                 static NLAIC::CIdentType IdVarPStack;           
00047         private:                
00049                 sint32          _Val;   
00050 
00051         #ifdef NL_DEBUG
00052                 NLAIAGENT::IVarName *_NameVar;
00053         #endif
00054 
00055 
00056         public:
00057                 static NLAIAGENT::IObjectIA**   _LocalTableRef;
00058 
00059         public:
00060         #ifdef NL_DEBUG
00061                 CVarPStack(sint32 val, const char *nameVar):
00062                   _Val(val),_NameVar(new NLAIAGENT::CIndexedVarName(nameVar))
00063                 {                         
00064                 }
00065 
00066                 CVarPStack(const CVarPStack &v):NLAIAGENT::IObjetOp(v),_Val(v._Val),_NameVar((NLAIAGENT::IVarName *)v._NameVar->clone())
00067                 {               
00068                 }
00069         #else
00070                 CVarPStack(sint32 val):
00071                   _Val(val)
00072                 {
00073                 }
00074 
00075                 CVarPStack(const CVarPStack &v):NLAIAGENT::IObjetOp(v), _Val(v._Val)
00076                 {
00077                 }
00078         #endif
00079 
00081                 const NLAIC::CIdentType &getVarType(void) const
00082                 {                       
00083                         return _LocalTableRef[_Val]->getType();
00084                 }
00085 
00087                 sint32 getIndex() const
00088                 {
00089                         return _Val;
00090                 }               
00091                                 
00093 
00094                 const NLAIC::IBasicType *clone() const
00095                 {
00096                         NLAIC::IBasicType *x = new CVarPStack(*this);
00097                         return x;
00098                 }
00099                 
00100                 const NLAIC::IBasicType *newInstance() const 
00101                 {
00102                         return clone();
00103                 }
00104 
00105                 void save(NLMISC::IStream &os)
00106                 {
00107                         sint32 val = _Val;
00108                         os.serial(val);
00109                 }
00110 
00111                 void load (NLMISC::IStream &is)
00112                 {
00113                         sint32 val;
00114                         is.serial(val);
00115                         val = _Val;
00116                 }
00117 
00118                 const NLAIC::CIdentType &getType(void) const
00119                 {
00120                         return IdVarPStack;
00121                 }               
00122 
00123                 void getDebugString(std::string &text) const
00124                 {               
00125                         std::string valVar;
00126                         _LocalTableRef[_Val]->getDebugString(valVar);
00127                         text = NLAIC::stringGetBuild("CVarPStack<%d>: _vale<%d> pointe la variable %s",this,_Val,valVar.c_str());
00128                 }
00129 
00130                 bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const
00131                 {
00132                         const CVarPStack &t = (const CVarPStack &)a;
00133                         return t._Val == _Val;
00134                 }
00135 
00136                 const NLAIAGENT::IObjectIA::CProcessResult &run()
00137                 {
00138                         return NLAIAGENT::IObjectIA::ProcessRun;
00139                 }
00140 
00141                 virtual NLAIAGENT::IObjetOp &neg()
00142                 {
00143                         ((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val])->neg();
00144                         return *this;
00145                 }
00146 
00147                 NLAIAGENT::IObjetOp &operator += (const NLAIAGENT::IObjetOp &a)
00148                 {
00149                         *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) += a;
00150                         return *this;
00151                 }
00152 
00153                 NLAIAGENT::IObjetOp &operator -= (const NLAIAGENT::IObjetOp &a)
00154                 {
00155                         *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) -= a;
00156                         return *this;
00157                 }       
00158 
00159                 NLAIAGENT::IObjetOp &operator *= (const NLAIAGENT::IObjetOp &a)
00160                 {
00161                         *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) *= a;
00162                         return *this;
00163                 }
00164                 NLAIAGENT::IObjetOp &operator /= (const NLAIAGENT::IObjetOp &a)
00165                 {
00166                         *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) /= a;
00167                         return *this;
00168                 }       
00169 
00170                 NLAIAGENT::IObjetOp *operator + (const NLAIAGENT::IObjetOp &a) 
00171                 {
00172                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) + a;
00173                         
00174                 }
00175 
00176                 NLAIAGENT::IObjetOp *operator - (const NLAIAGENT::IObjetOp &a)
00177                 {
00178                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) - a;
00179                 }
00180 
00181                 NLAIAGENT::IObjetOp *operator * (const NLAIAGENT::IObjetOp &a)
00182                 {
00183                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) * a;
00184                 }
00185 
00186                 NLAIAGENT::IObjetOp *operator / (const NLAIAGENT::IObjetOp &a) 
00187                 {
00188                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) / a;
00189                 }
00190                 
00191 
00192                 NLAIAGENT::IObjetOp *operator < (NLAIAGENT::IObjetOp &a)  const
00193                 {
00194                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) < a;
00195                 }
00196                 NLAIAGENT::IObjetOp *operator > (NLAIAGENT::IObjetOp &a)  const
00197                 {
00198                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) > a;
00199                 }
00200 
00201                 NLAIAGENT::IObjetOp *operator <= (NLAIAGENT::IObjetOp &a)  const
00202                 {
00203                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) <= a;
00204                 }
00205 
00206                 NLAIAGENT::IObjetOp *operator >= (NLAIAGENT::IObjetOp &a)  const
00207                 {
00208                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) >= a;
00209                 }
00210                 
00211                 NLAIAGENT::IObjetOp *operator ! ()  const
00212                 {
00213                         return !*((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]);
00214                 }
00215 
00216                 NLAIAGENT::IObjetOp *operator != (NLAIAGENT::IObjetOp &a) const
00217                 {
00218                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) != a;
00219                 }               
00220 
00221                 NLAIAGENT::IObjetOp *operator == (NLAIAGENT::IObjetOp &a) const
00222                 {
00223                         return *((NLAIAGENT::IObjetOp *)_LocalTableRef[_Val]) == a;
00224                 }
00225 
00226                 bool isTrue() const
00227                 {
00228                         return ((NLAIAGENT::IObjetOp*)_LocalTableRef[_Val])->isTrue();
00229                 }
00231                 
00232                 virtual ~CVarPStack()
00233                 {
00234         #ifdef NL_DEBUG
00235                         _NameVar->release();
00236         #endif
00237                 }
00238         };
00239 
00240 
00252         class CVarPStackParam:public NLAIAGENT::IObjetOp
00253         {
00254 
00255         public:
00256                 static NLAIC::CIdentType IdVarPStackParam;
00257                 static  sint32  _Shift;
00258         private:                
00259                 sint32          _Val;           
00260 
00261 #ifdef NL_DEBUG
00262                 NLAIAGENT::IVarName *_NameVar;
00263 #endif  
00264 
00265         public:
00266 #ifdef NL_DEBUG
00267                 CVarPStackParam(sint32 val, const char *nameVar): _Val(val),_NameVar(new NLAIAGENT::CIndexedVarName(nameVar))
00268                 {                         
00269                 }
00270 
00271                 CVarPStackParam(const CVarPStackParam &v):NLAIAGENT::IObjetOp(v),_Val(v._Val),_NameVar((NLAIAGENT::IVarName *)v._NameVar->clone())
00272                 {               
00273                 }
00274 #else
00275                 CVarPStackParam( sint32 val): _Val(val)
00276                 {
00277                 }
00278 
00279                 CVarPStackParam(const CVarPStackParam &v):NLAIAGENT::IObjetOp(v), _Val(v._Val)
00280                 {
00281                 }
00282 #endif
00283                                 
00284 
00286                 const NLAIAGENT::IObjectIA *getObjectIAClone() const
00287                 {
00288                         return (NLAIAGENT::IObjectIA  *)CVarPStack::_LocalTableRef[_Val + _Shift]->clone();
00289                 }
00290 
00292                 const NLAIC::CIdentType &getVarType(void) const
00293                 {                       
00294                         return CVarPStack::_LocalTableRef[_Val + _Shift]->getType();
00295                 }
00296 
00298                 const NLAIAGENT::IObjectIA *getObject(void) const
00299                 {                       
00300                         return CVarPStack::_LocalTableRef[_Val + _Shift];
00301                 }
00302 
00304                 sint32 getIndex() const
00305                 {
00306                         return _Val;
00307                 }
00308 
00310 
00311                 const NLAIC::IBasicType *clone() const
00312                 {
00313                         NLAIC::IBasicType *x = new CVarPStackParam(*this);
00314                         return x;
00315                         //return (NLAIAGENT::IObjectIA  *)CVarPStack::_LocalTableRef[_Val + _Shift]->clone();
00316                 }
00317                 
00318                 const NLAIC::IBasicType *newInstance() const 
00319                 {
00320                         NLAIC::IBasicType *x = new CVarPStackParam(*this);
00321                         return x;
00322                 }
00323 
00324                 void save(NLMISC::IStream &os)
00325                 {
00326                         sint32 val = _Val;
00327                         os.serial( val );
00328                         sint32 shift = _Shift;
00329                         os.serial( shift );
00330                 }
00331 
00332                 void load(NLMISC::IStream &is)
00333                 {
00334                         sint32 val;
00335                         is.serial( val );
00336                         _Val = val;
00337                         sint32 shift;
00338                         is.serial( shift );
00339                         _Shift = shift;
00340                 }
00341 
00342                 const NLAIC::CIdentType &getType(void) const
00343                 {
00344                         return IdVarPStackParam;
00345                 }               
00346 
00347                 void getDebugString(std::string &text) const
00348                 {               
00349                         std::string valVar;
00350                         CVarPStack::_LocalTableRef[_Val + _Shift]->getDebugString(valVar);
00351 #ifdef NL_DEBUG                 
00352                         text = NLAIC::stringGetBuild("Stack<%d,%s>: pointe la variable %s",_Val,_NameVar->getString(),valVar.c_str());
00353 #else                   
00354                         text = NLAIC::stringGetBuild("Stack<%d>: pointe la variable %s",_Val,valVar.c_str());
00355 #endif
00356                 }
00357 
00358                 bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const
00359                 {
00360                         const CVarPStackParam &t = (const CVarPStackParam &)a;
00361                         return t._Val == _Val;
00362                 }
00363 
00364                 const NLAIAGENT::IObjectIA::CProcessResult &run()
00365                 {
00366                         return NLAIAGENT::IObjectIA::ProcessRun;
00367                 }
00368 
00369                 virtual NLAIAGENT::IObjetOp &neg()
00370                 {
00371                         ((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift])->neg();
00372                         return *this;
00373                 }
00374 
00375                 NLAIAGENT::IObjetOp &operator += (const NLAIAGENT::IObjetOp &a)
00376                 {
00377                         *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) += a;
00378                         return *this;
00379                 }
00380 
00381                 NLAIAGENT::IObjetOp &operator -= (const NLAIAGENT::IObjetOp &a)
00382                 {
00383                         *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) -= a;
00384                         return *this;
00385                 }       
00386 
00387                 NLAIAGENT::IObjetOp &operator *= (const NLAIAGENT::IObjetOp &a)
00388                 {
00389                         *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) *= a;
00390                         return *this;
00391                 }
00392                 NLAIAGENT::IObjetOp &operator /= (const NLAIAGENT::IObjetOp &a)
00393                 {
00394                         *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) /= a;
00395                         return *this;
00396                 }       
00397 
00398                 NLAIAGENT::IObjetOp *operator + (const NLAIAGENT::IObjetOp &a)
00399                 {
00400                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) + a;
00401                         
00402                 }
00403 
00404                 NLAIAGENT::IObjetOp *operator - (const NLAIAGENT::IObjetOp &a)
00405                 {
00406                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) - a;
00407                 }
00408 
00409                 NLAIAGENT::IObjetOp *operator * (const NLAIAGENT::IObjetOp &a)
00410                 {
00411                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) * a;
00412                 }
00413 
00414                 NLAIAGENT::IObjetOp *operator / (const NLAIAGENT::IObjetOp &a)
00415                 {
00416                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) / a;
00417                 }
00418                 
00419 
00420                 NLAIAGENT::IObjetOp *operator < (NLAIAGENT::IObjetOp &a)  const
00421                 {
00422                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) < a;
00423                 }
00424                 NLAIAGENT::IObjetOp *operator > (NLAIAGENT::IObjetOp &a)  const
00425                 {
00426                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) > a;
00427                 }
00428 
00429                 NLAIAGENT::IObjetOp *operator <= (NLAIAGENT::IObjetOp &a)  const
00430                 {
00431                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) <= a;
00432                 }
00433 
00434                 NLAIAGENT::IObjetOp *operator >= (NLAIAGENT::IObjetOp &a)  const
00435                 {
00436                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) >= a;
00437                 }
00438                 
00439                 NLAIAGENT::IObjetOp *operator ! ()  const
00440                 {
00441                         return !*((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]);
00442                 }
00443 
00444                 NLAIAGENT::IObjetOp *operator != (NLAIAGENT::IObjetOp &a) const
00445                 {
00446                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) != a;
00447                 }               
00448 
00449                 NLAIAGENT::IObjetOp *operator == (NLAIAGENT::IObjetOp &a) const
00450                 {
00451                         return *((NLAIAGENT::IObjetOp *)CVarPStack::_LocalTableRef[_Val + _Shift]) == a;
00452                 }
00453 
00454                 bool isTrue() const
00455                 {
00456                         return ((NLAIAGENT::IObjetOp*)CVarPStack::_LocalTableRef[_Val + _Shift])->isTrue();
00457                 }               
00459                 virtual ~CVarPStackParam()
00460                 {
00461         #ifdef NL_DEBUG
00462                         _NameVar->release();
00463         #endif
00464                 }
00465         };
00466                 
00467 }
00468 #endif