# 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  

libcode.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/interpret_object_message.h"
00026 #include "nel/ai/script/interpret_object_manager.h"
00027 #include "nel/ai/script/interpret_actor.h"
00028 #include "nel/ai/logic/interpret_object_operator.h"
00029 #include "nel/ai/script/libcode.h"
00030 #include "nel/ai/script/test_method.h"
00031 #include "nel/ai/script/type_def.h"
00032 #include "nel/ai/script/object_unknown.h"
00033 
00034 
00035 namespace NLAISCRIPT
00036 {
00037         const NLAIC::CIdentType CCallPrint::IdCallPrint = NLAIC::CIdentType(    "Print",
00038                                                                                                                                         NLAIC::CSelfClassFactory(CCallPrint()),                                                                                                                         
00039                                                                                                                                         NLAIC::CTypeOfObject(NLAIC::CTypeOfObject::tObject),NLAIC::CTypeOfOperator(0));
00040 
00041         NLAIC::IIO *CCallPrint::inputOutput = NULL;
00042 
00043         NLAIAGENT::tQueue CCallPrint::isMember(const NLAIAGENT::IVarName *className,const NLAIAGENT::IVarName *mathodName,const NLAIAGENT::IObjectIA &p) const  
00044         {
00045                 NLAIAGENT::CStringVarName print((const char *)IdCallPrint);
00046                 NLAIAGENT::CStringVarName format("Format");
00047                 NLAIAGENT::CStringVarName constructor(_CONSTRUCTOR_);
00048                 NLAIAGENT::tQueue m;
00049                 //const CParam &param = (const CParam &)p;
00050                 CParam param;
00051                 
00052 
00053                 if(className != NULL)
00054                 {
00055                         if(*className == print)
00056                         {
00057                                 if(*mathodName == format)
00058                                 {
00059                                         NLAISCRIPT::COperandSimple typeR(new NLAIC::CIdentType(NLAIAGENT::CStringType::IdStringType));
00060                                         NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00061                                         m.push(NLAIAGENT::CIdMethod(2,0.0,NULL,t));
00062                                 }
00063                                 else
00064                                 if(*mathodName == print)
00065                                 {
00066                                         NLAISCRIPT::COperandVoid typeR;
00067                                         NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00068                                         m.push(NLAIAGENT::CIdMethod(0,0.0,NULL,t));
00069                                 }                               
00070                                 else
00071                                 if(*mathodName == constructor && p == param)
00072                                 {
00073                                         NLAISCRIPT::COperandVoid typeR;
00074                                         NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00075                                         m.push(NLAIAGENT::CIdMethod(1,0.0,NULL,t));
00076                                 }
00077                         }
00078                 }               
00079                 else 
00080                 {
00081                         if(*mathodName == format)
00082                         {
00083                                 NLAISCRIPT::COperandSimple typeR(new NLAIC::CIdentType(NLAIAGENT::CStringType::IdStringType));
00084                                 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00085                                 m.push(NLAIAGENT::CIdMethod(2,0.0,NULL,t));
00086                         }
00087                         else
00088                         if(*mathodName == print)
00089                         {
00090                                 NLAISCRIPT::COperandVoid typeR;
00091                                 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00092                                 m.push(NLAIAGENT::CIdMethod(0,0.0,NULL,t));
00093                         }
00094                         else
00095                         if(*mathodName == constructor && p == param)
00096                         {
00097                                 NLAISCRIPT::COperandVoid typeR;
00098                                 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00099                                 m.push(NLAIAGENT::CIdMethod(1,0.0,NULL,t));
00100                         }
00101                 }
00102                 return m;
00103         }       
00104 
00105         NLAIAGENT::IObjectIA::CProcessResult CCallPrint::format(const NLAIAGENT::IBaseGroupType *g)
00106         {
00107                 NLAIAGENT::CStringVarName str("");
00108                 NLAIAGENT::CConstIteratorContener i = g->getConstIterator();
00109                 while(!i.isInEnd())
00110                 {
00111                         std::string temp;
00112                         (i++)->getDebugString(temp);                            
00113                         str += NLAIAGENT::CStringVarName(temp.c_str());
00114                         if(!i.isInEnd()) str += NLAIAGENT::CStringVarName(" ");
00115                 }
00116 
00117                 NLAIAGENT::CStringType s(str);          
00118                 NLAIAGENT::IObjectIA::CProcessResult r;
00119                 r.ResultState =  NLAIAGENT::processIdle;
00120                 r.Result =  (NLAIAGENT::IObjectIA *)s.clone();
00121                 return r;
00122         }
00123 
00124         NLAIAGENT::IObjectIA::CProcessResult CCallPrint::printList(const NLAIAGENT::IBaseGroupType *g)
00125         {
00126                 std::string str;                
00127                 NLAIAGENT::CConstIteratorContener i = g->getConstIterator();
00128                 
00129                 while(!i.isInEnd())
00130                 {
00131                         std::string temp;
00132                         (i++)->getDebugString(temp);
00133                         str += temp.c_str();
00134                         if(!i.isInEnd()) str += " ";
00135                 }
00136 
00137                 NLAIAGENT::IObjectIA::CProcessResult r;
00138                 NLAIC::Out("%s\n",str.c_str());         
00139 
00140                 //nlinfo("%s",str.c_str());
00141 
00142                 r.ResultState =  NLAIAGENT::processIdle;
00143                 r.Result =  NULL;
00144                 return r;
00145         }
00146 
00147         NLAIAGENT::IObjectIA::CProcessResult CCallPrint::runMethodeMember(sint32 heritance, sint32 index, NLAIAGENT::IObjectIA *param)
00148         {
00149                 switch(heritance)
00150                 {
00151                 case 1:
00152                         return runMethodeMember(index,param);
00153                         break;
00154                 }
00155                 NLAIAGENT::IObjectIA::CProcessResult r;
00156                 r.ResultState =  NLAIAGENT::processIdle;
00157                 r.Result =  NULL;
00158                 return r;
00159         }
00160 
00161         NLAIAGENT::IObjectIA::CProcessResult CCallPrint::runMethodeMember(sint32 index,NLAIAGENT::IObjectIA *param)
00162         {
00163                 NLAIAGENT::IObjectIA::CProcessResult r;
00164                 r.ResultState =  NLAIAGENT::processIdle;
00165                 r.Result =  NULL;
00166                 switch(index)
00167                 {
00168                 case 0:
00169                         return printList((const NLAIAGENT::IBaseGroupType *)param);
00170                 case 1:                 
00171                         return r;
00172                 case 2:                 
00173                         return format((const NLAIAGENT::IBaseGroupType *)param);
00174                         break;
00175                 }
00176                 return r;
00177         }
00178                 
00179 }