From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/agent__script_8cpp-source.html | 2478 +++++++++++++++++++++++ 1 file changed, 2478 insertions(+) create mode 100644 docs/doxygen/nel/agent__script_8cpp-source.html (limited to 'docs/doxygen/nel/agent__script_8cpp-source.html') diff --git a/docs/doxygen/nel/agent__script_8cpp-source.html b/docs/doxygen/nel/agent__script_8cpp-source.html new file mode 100644 index 00000000..f952dd49 --- /dev/null +++ b/docs/doxygen/nel/agent__script_8cpp-source.html @@ -0,0 +1,2478 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# 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  
+

agent_script.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 
+00025 #include "nel/ai/nl_ai.h"
+00026 #include "nel/ai/agent/agent_script.h"
+00027 #include "nel/ai/agent/agent_manager.h"
+00028 #include "nel/ai/agent/agent_local_mailer.h"
+00029 #include "nel/ai/script/interpret_object_agent.h"
+00030 #include "nel/ai/script/codage.h"
+00031 #include "nel/ai/script/type_def.h"
+00032 #include "nel/ai/script/object_unknown.h"
+00033 #include "nel/ai/agent/agent_method_def.h"
+00034 #include "nel/ai/agent/message_script.h"
+00035 #include "nel/ai/script/interpret_object_message.h"
+00036 #include "nel/ai/script/interpret_message_action.h"
+00037 #include "nel/ai/script/interpret_message_getvalue.h"
+00038 #include "nel/ai/script/interpret_message_setvalue.h"
+00039 #include "nel/ai/script/interpret_object_agent.h"
+00040 #include "nel/ai/agent/agent_nombre.h"
+00041 #include "nel/ai/agent/performative.h"
+00042 #include "nel/ai/agent/msg_notify.h"
+00043 #include "nel/ai/agent/msg_goal.h"
+00044 #include "nel/ai/agent/msg_fact.h"
+00045 #include "nel/ai/agent/msg_setvalue.h"
+00046 #include "nel/ai/logic/factbase.h"
+00047 #include "nel/ai/logic/goal.h"
+00048 #include "nel/ai/agent/key_agent.h"
+00049 #include "nel/ai/agent/list_manager.h"
+00050 #include "nel/ai/logic/fact.h"
+00051 #include "nel/ai/agent/msg_fact.h"
+00052 #include "nel/ai/script/libcode.h"
+00053 
+00054 //#define PROFILE
+00055 #ifdef PROFILE
+00056 #include "nel/misc/time_nl.h"
+00057 #endif
+00058 
+00059 
+00060 namespace NLAIAGENT
+00061 {       
+00062         NLAISCRIPT::COperandSimpleListOr *CAgentScript::msgType = NULL;
+00063         NLAISCRIPT::COperandSimpleListOr *CAgentScript::msgPerf = NULL;
+00064         NLAISCRIPT::CParam *CAgentScript::SendParamMessageScript = NULL;
+00065         NLAISCRIPT::CParam *CAgentScript::SendCompParamMessageScript = NULL;
+00066         NLAISCRIPT::COperandSimple *CAgentScript::IdMsgNotifyParentClass = NULL;
+00067         NLAISCRIPT::COperandSimpleListOr *CAgentScript::IdMsgNotifyParent = NULL;
+00068         NLAISCRIPT::CParam *CAgentScript::ParamRunParentNotify = NULL;
+00069         CAgentScript::CMethodCall **CAgentScript::StaticMethod = NULL;
+00070         NLAISCRIPT::COperandSimpleListOr *CAgentScript::ParamIdGetValueMsg = NULL;
+00071         NLAISCRIPT::CParam *CAgentScript::ParamGetValueMsg = NULL;
+00072         NLAISCRIPT::COperandSimpleListOr *CAgentScript::ParamIdSetValueMsg = NULL;
+00073         NLAISCRIPT::CParam *CAgentScript::ParamSetValueMsg = NULL;
+00074         NLAISCRIPT::COperandSimpleListOr *CAgentScript::ParamIdTellComponentMsg = NULL;
+00075         NLAISCRIPT::CParam *CAgentScript::ParamTellComponentMsg = NULL;
+00076         NLAISCRIPT::COperandSimpleListOr *CAgentScript::ParamIdInitComponentMsg = NULL;
+00077         NLAISCRIPT::CParam *CAgentScript::ParamInitComponentMsg = NULL;
+00078 
+00079         const NLAIAGENT::IVarName *CAgentScript::getClassName() const
+00080         {
+00081                 const NLAIAGENT::IVarName *classname;
+00082                 if ( _AgentClass != NULL )
+00083                 {
+00084                         classname = _AgentClass->getClassName();
+00085                 }
+00086                 else
+00087                         classname = new CStringVarName("<unknown>"); // Memory leak ?
+00088 
+00089                 return classname;
+00090         }
+00091 
+00092         void CAgentScript::initAgentScript()
+00093         {
+00094 
+00095                 std::string msgStr;
+00096                 std::string scriptName("MsgAgentScript");
+00097                 msgStr = std::string("From Message : Define MsgTellComponent\n{");
+00098                 msgStr += std::string("Component:\n");          
+00099                 msgStr += std::string("\tString<'CompomentName'>;\n");
+00100                 msgStr += std::string("\tMessage<'MsgType'>;\n");
+00101                 msgStr += std::string("End\n");
+00102 
+00103 
+00104                 msgStr += std::string("Constructor(String i; Message msg)\n");
+00105                 msgStr += std::string("\tCompomentName = i;\n");
+00106                 msgStr += std::string("\tMsgType = msg;\n");
+00107                 msgStr += std::string("End\n");
+00108                 msgStr += std::string("}\n");
+00109                 //NLAILINK::buildScript(msgStr,scriptName);
+00110 
+00111                 msgStr += std::string("From Message : Define MsgInitCompoment\n{");
+00112                 msgStr += std::string("Component:\n");                          
+00113                 msgStr += std::string("End\n}\n");
+00114                 
+00115                 NLAILINK::buildScript(msgStr,scriptName);
+00116 
+00117                 static NLAIC::CIdentType idMsgTellComponentType ("MsgTellComponent");
+00118                 static NLAIC::CIdentType idMsgInitComponentType ("MsgInitCompoment");
+00119 
+00120                 msgType = new NLAISCRIPT::COperandSimpleListOr(3,       
+00121                                                                                                                 new NLAIC::CIdentType(CMessageList::IdMessage),
+00122                                                                                                                 new NLAIC::CIdentType(CMessageVector::IdMessageVector),
+00123                                                                                                                 new NLAIC::CIdentType(NLAISCRIPT::CMessageClass::IdMessageClass));
+00124 
+00125                 msgPerf = new NLAISCRIPT::COperandSimpleListOr(7,       
+00126                                                                                                                 new NLAIC::CIdentType(CPExec::IdPExec),
+00127                                                                                                                 new NLAIC::CIdentType(CPAchieve::IdPAchieve),
+00128                                                                                                                 new NLAIC::CIdentType(CPAsk::IdPAsk),
+00129                                                                                                                 new NLAIC::CIdentType(CPBreak::IdPBreak),
+00130                                                                                                                 new NLAIC::CIdentType(CPTell::IdPTell),
+00131                                                                                                                 new NLAIC::CIdentType(CPKill::IdPKill),
+00132                                                                                                                 new NLAIC::CIdentType(CPError::IdPError));
+00133 
+00134 
+00135                 SendParamMessageScript = new NLAISCRIPT::CParam(2,msgPerf, msgType);
+00136 
+00137                 msgPerf->incRef();
+00138                 msgType->incRef();
+00139 
+00140                 SendCompParamMessageScript = new NLAISCRIPT::CParam(3,new NLAISCRIPT::COperandSimple(new NLAIC::CIdentType(CStringType::IdStringType)),
+00141                                                                                                                 msgPerf, msgType);
+00142 
+00143                 IdMsgNotifyParentClass = new NLAISCRIPT::COperandSimple(new NLAIC::CIdentType(NLAISCRIPT::CMsgNotifyParentClass::IdMsgNotifyParentClass));
+00144 
+00145                 IdMsgNotifyParent = new NLAISCRIPT::COperandSimpleListOr(2,
+00146                                                                                                                                 new NLAIC::CIdentType(NLAISCRIPT::CMsgNotifyParentClass::IdMsgNotifyParentClass),
+00147                                                                                                                                 new NLAIC::CIdentType(CNotifyParentScript::IdNotifyParentScript));
+00148 
+00149                 ParamRunParentNotify = new NLAISCRIPT::CParam(1,IdMsgNotifyParent); 
+00150                 
+00151                 NLAISCRIPT::COperandSimple *idMsgTellComponent = new NLAISCRIPT::COperandSimple(new NLAIC::CIdentType(idMsgTellComponentType));
+00152                 NLAISCRIPT::CParam *ParamTellComponentMsg = new NLAISCRIPT::CParam(1,idMsgTellComponent);
+00153 
+00154                 CAgentScript::ParamIdGetValueMsg = new NLAISCRIPT::COperandSimpleListOr(2,
+00155                                                                                                                                   new NLAIC::CIdentType(NLAIAGENT::CGetValueMsg::IdGetValueMsg),
+00156                                                                                                                                   new NLAIC::CIdentType(NLAISCRIPT::CGetValueMsgClass::IdGetValueMsgClass)      );
+00157 
+00158                 CAgentScript::ParamGetValueMsg = new NLAISCRIPT::CParam(1,ParamIdGetValueMsg);
+00159 
+00160                 CAgentScript::ParamIdSetValueMsg = new NLAISCRIPT::COperandSimpleListOr(2,
+00161                                                                                                                                   new NLAIC::CIdentType(NLAIAGENT::CSetValueMsg::IdSetValueMsg),
+00162                                                                                                                                   new NLAIC::CIdentType(NLAISCRIPT::CSetValueMsgClass::IdSetValueMsgClass)      );
+00163 
+00164                 CAgentScript::ParamSetValueMsg = new NLAISCRIPT::CParam(1,ParamIdSetValueMsg);
+00165 
+00167                 CAgentScript::ParamIdInitComponentMsg = new NLAISCRIPT::COperandSimpleListOr(2,
+00168                                                                                                                                   new NLAIC::CIdentType(idMsgInitComponentType),
+00169                                                                                                                                   new NLAIC::CIdentType(idMsgInitComponentType) );
+00170 
+00171                 CAgentScript::ParamInitComponentMsg = new NLAISCRIPT::CParam(1,ParamIdInitComponentMsg);
+00173 
+00174                 StaticMethod = new CAgentScript::CMethodCall *[CAgentScript::TLastM];
+00175 
+00176                 StaticMethod[CAgentScript::TRunAskParentNotify] = new CAgentScript::CMethodCall(        _RUNASK_, 
+00177                                                                                                                                                                                 CAgentScript::TRunAskParentNotify, ParamRunParentNotify,
+00178                                                                                                                                                                                 CAgentScript::CheckAll,
+00179                                                                                                                                                                                 1,
+00180                                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(IdMsgNotifyParentClass));
+00181 
+00182                 IdMsgNotifyParentClass->incRef();               
+00183                 ParamRunParentNotify->incRef();
+00184                 StaticMethod[CAgentScript::TRunTellParentNotify] = new CAgentScript::CMethodCall(       _RUNTEL_, 
+00185                                                                                                                                                                                 CAgentScript::TRunTellParentNotify, ParamRunParentNotify,
+00186                                                                                                                                                                                 CAgentScript::CheckAll,
+00187                                                                                                                                                                                 1,
+00188                                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(IdMsgNotifyParentClass));
+00189                 
+00190                 idMsgTellComponent->incRef();
+00191                 StaticMethod[CAgentScript::TRunTellComponent] = new CAgentScript::CMethodCall(  _RUNTEL_, 
+00192                                                                                                                                                                                 CAgentScript::TRunTellComponent, ParamTellComponentMsg,
+00193                                                                                                                                                                                 CAgentScript::CheckAll,
+00194                                                                                                                                                                                 1,
+00195                                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(idMsgTellComponent));
+00196 
+00197                 ParamTellComponentMsg->incRef();
+00198                 idMsgTellComponent->incRef();
+00199                 StaticMethod[CAgentScript::TRunAskComponent] = new CAgentScript::CMethodCall(   _RUNASK_, 
+00200                                                                                                                                                                                 CAgentScript::TRunAskComponent, ParamTellComponentMsg,
+00201                                                                                                                                                                                 CAgentScript::CheckAll,
+00202                                                                                                                                                                                 1,
+00203                                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(idMsgTellComponent));
+00204 
+00205                 StaticMethod[CAgentScript::TSend] = new CAgentScript::CMethodCall(      _SEND_, 
+00206                                                                                                                                                 CAgentScript::TSend, SendParamMessageScript,
+00207                                                                                                                                                 CAgentScript::CheckAll,
+00208                                                                                                                                                 2,
+00209                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid));
+00210 
+00211                 StaticMethod[CAgentScript::TSendComponent] = new CAgentScript::CMethodCall(     _SEND_, 
+00212                                                                                                                                                 CAgentScript::TSendComponent, 
+00213                                                                                                                                                 SendCompParamMessageScript,CAgentScript::CheckAll,
+00214                                                                                                                                                 3,
+00215                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid));
+00216 
+00217                 StaticMethod[CAgentScript::TGetChildTag] = new CAgentScript::CMethodCall(       _GETCHILD_,
+00218                                                                                                                                                                 CAgentScript::TGetChildTag, 
+00219                                                                                                                                                                 NULL,
+00220                                                                                                                                                                 CAgentScript::CheckCount,
+00221                                                                                                                                                                 1,
+00222                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(new 
+00223                                                                                                                                                                 NLAISCRIPT::COperandSimple(
+00224                                                                                                                                                                 new NLAIC::CIdentType(CVectorGroupManager::IdVectorGroupManager))));
+00225 
+00226                 StaticMethod[CAgentScript::TAddChildTag] = new CAgentScript::CMethodCall(       _ADDCHILD_, 
+00227                                                                                                                                                                                 CAgentScript::TAddChildTag, 
+00228                                                                                                                                                                                 NULL,CAgentScript::DoNotCheck,
+00229                                                                                                                                                                                 2,
+00230                                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(
+00231                                                                                                                                                                                 new NLAISCRIPT::COperandSimple(
+00232                                                                                                                                                                                 new NLAIC::CIdentType(DigitalType::IdDigitalType))));
+00233 
+00234                 StaticMethod[CAgentScript::TFather] = new CAgentScript::CMethodCall(    _FATHER_, 
+00235                                                                                                                                                         CAgentScript::TFather, 
+00236                                                                                                                                                         NULL,CAgentScript::CheckCount,
+00237                                                                                                                                                         0,
+00238                                                                                                                                                         new NLAISCRIPT::CObjectUnknown(
+00239                                                                                                                                                         new NLAISCRIPT::COperandSimple(
+00240                                                                                                                                                         //check if correct
+00241                                                                                                                                                         new NLAIC::CIdentType(*IAgent::IdAgent))));     
+00242 
+00243 
+00244                 StaticMethod[CAgentScript::TSelf] = new CAgentScript::CMethodCall(      _SELF_, 
+00245                                                                                                                                                 CAgentScript::TSelf, 
+00246                                                                                                                                                 NULL,CAgentScript::CheckCount,
+00247                                                                                                                                                 0,
+00248                                                                                                                                                 new NLAISCRIPT::CObjectUnknown( new NLAISCRIPT::COperandSimple(
+00249                                                                                                                                                 new NLAIC::CIdentType(CAgentScript::IdAgentScript))));
+00250 
+00251                 StaticMethod[CAgentScript::TGetName] = new CAgentScript::CMethodCall(   _GETNAME_, 
+00252                                                                                                                                                         CAgentScript::TGetName, 
+00253                                                                                                                                                         NULL,CAgentScript::CheckCount,
+00254                                                                                                                                                         0,
+00255                                                                                                                                                         new NLAISCRIPT::CObjectUnknown(
+00256                                                                                                                                                         new NLAISCRIPT::COperandSimple(
+00257                                                                                                                                                         new NLAIC::CIdentType(CStringType::IdStringType))));
+00258 
+00259                 StaticMethod[CAgentScript::TGetClassName] = new CAgentScript::CMethodCall(      "GetClassName", 
+00260                                                                                                                                                         CAgentScript::TGetClassName, 
+00261                                                                                                                                                         NULL,CAgentScript::CheckCount,
+00262                                                                                                                                                         0,
+00263                                                                                                                                                         new NLAISCRIPT::CObjectUnknown(
+00264                                                                                                                                                         new NLAISCRIPT::COperandSimple(
+00265                                                                                                                                                         new NLAIC::CIdentType(CStringType::IdStringType))));
+00266 
+00267                 StaticMethod[CAgentScript::TIsInherited] = new CAgentScript::CMethodCall(       "IsInherited", 
+00268                                                                                                                                                         CAgentScript::TIsInherited, 
+00269                                                                                                                                                         NULL,CAgentScript::CheckCount,
+00270                                                                                                                                                         1,
+00271                                                                                                                                                         new NLAISCRIPT::CObjectUnknown(
+00272                                                                                                                                                         new NLAISCRIPT::COperandSimple(
+00273                                                                                                                                                         new NLAIC::CIdentType(NLAILOGIC::CBoolType::IdBoolType))));
+00274 
+00275                 StaticMethod[CAgentScript::TRemoveChild] = new CAgentScript::CMethodCall(       _REMOVECHILD_, 
+00276                                                                                                                                                                 CAgentScript::TRemoveChild, 
+00277                                                                                                                                                                 NULL,CAgentScript::CheckCount,
+00278                                                                                                                                                                 0,
+00279                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(
+00280                                                                                                                                                                 new NLAISCRIPT::COperandSimple(                                                                                                                         
+00281                                                                                                                                                                 new NLAIC::CIdentType(DigitalType::IdDigitalType))));           
+00282 
+00283                 StaticMethod[CAgentScript::TSetStatic] = new CAgentScript::CMethodCall( _SETSTATIC_, 
+00284                                                                                                                                                                 CAgentScript::TSetStatic, NULL,
+00285                                                                                                                                                                 CAgentScript::CheckCount,
+00286                                                                                                                                                                 2,
+00287                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid)) ;
+00288 
+00289 
+00290                 StaticMethod[CAgentScript::TGetValue] = new CAgentScript::CMethodCall(  _RUNASK_, 
+00291                                                                                                                                                                 CAgentScript::TGetValue, ParamGetValueMsg,
+00292                                                                                                                                                                 CAgentScript::CheckAll,
+00293                                                                                                                                                                 1,
+00294                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid)) ;
+00295 
+00296                 StaticMethod[CAgentScript::TSetValue] = new CAgentScript::CMethodCall(  _RUNTEL_, 
+00297                                                                                                                                                                 CAgentScript::TSetValue, ParamSetValueMsg,
+00298                                                                                                                                                                 CAgentScript::CheckAll,
+00299                                                                                                                                                                 1,
+00300                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid)) ;
+00301 
+00302                 ParamIdInitComponentMsg->incRef();
+00303                 StaticMethod[CAgentScript::TInitComponent] = new CAgentScript::CMethodCall(     _RUNTEL_, 
+00304                                                                                                                                                                 CAgentScript::TInitComponent, ParamInitComponentMsg,
+00305                                                                                                                                                                 CAgentScript::CheckAll,
+00306                                                                                                                                                                 1,
+00307                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(ParamIdInitComponentMsg)) ;
+00308 
+00309                 NLAISCRIPT::CParam *ParamString =  new NLAISCRIPT::CParam(1,new NLAISCRIPT::COperandSimple(new NLAIC::CIdentType(CStringType::IdStringType)));
+00310                 StaticMethod[CAgentScript::TIsEUU] = new CAgentScript::CMethodCall(     _ISA_,
+00311                                                                                                                                                 CAgentScript::TIsEUU,
+00312                                                                                                                                                 ParamString,CAgentScript::CheckAll,
+00313                                                                                                                                                 0, new NLAISCRIPT::CObjectUnknown(      new NLAISCRIPT::COperandSimple(
+00314                                                                                                                                                    new NLAIC::CIdentType(NLAIAGENT::UInt32Type::IdUInt32Type))));
+00315                 ParamString->incRef();
+00316                 StaticMethod[CAgentScript::TAddSet] = new CAgentScript::CMethodCall(_ADD_SET_,
+00317                                                                                                                                                         CAgentScript::TAddSet,
+00318                                                                                                                                                         ParamString,CAgentScript::CheckAll,
+00319                                                                                                                                                         0, new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid));               
+00320 
+00321 
+00322                 StaticMethod[CAgentScript::TDeflautProccessMsg] = new CAgentScript::CMethodCall("DeflautProccessMsg",
+00323                                                                                                                                                                                 CAgentScript::TDeflautProccessMsg, NULL,
+00324                                                                                                                                                                                 CAgentScript::CheckCount,
+00325                                                                                                                                                                                 1,
+00326                                                                                                                                                                                 new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid));
+00327 
+00328         }
+00329 
+00330 
+00331         void CAgentScript::releaseAgentScript()
+00332         {               
+00333                 //SendParamMessageScript->release();
+00334                 //IdMsgNotifyParentClass->release();            
+00336         // Temp, to be transfered in CGDAgentScript (Goal Driven Agent)
+00337         // IdGoalMsgClass->release();
+00338         // IdGoalMsg->release();
+00339                 //ParamGoalMsg->release();
+00340                 //ParamCancelGoalMsg->release();
+00342 
+00343                 //ParamRunParentNotify->release();
+00344                 //SendCompParamMessageScript->release();
+00345                 sint i;
+00346                 for(i = 0; i < CAgentScript::TLastM; i++)
+00347                 {
+00348                                 delete StaticMethod[i];
+00349                 }
+00350                 delete StaticMethod;
+00351         }
+00352 
+00353         CAgentScript::CAgentScript(const CAgentScript &a): IAgentManager(a)
+00354         {
+00355                 _iComponents = 0;
+00356 
+00357                 _AgentClass = a._AgentClass;
+00358                 /*if ( a._AgentClass )
+00359                 {                       
+00360                         a._AgentClass->incRef();
+00361                 }*/
+00362 
+00363                 _NbComponents = a._NbComponents;
+00364                 if ( _NbComponents != 0 )
+00365                 {
+00366                         _Components = new IObjectIA *[ _NbComponents ];
+00367 
+00368                         //sint32 nb_scripted = 0;
+00369                         for ( int i = 0; i < _NbComponents; i++ )
+00370                         {
+00371                                 _Components[i] = (IObjectIA *)a._Components[i]->clone();                
+00372 
+00373                                 uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tAgent;
+00374                                 const NLAIC::CTypeOfObject &t = (const NLAIC::CTypeOfObject &)_Components[i]->getType();
+00375                                 if( (t.getValue() & b ) == b)
+00376                                 {                                       
+00377                                         ((CAgentScript *)_Components[i])->setParent( (const IWordNumRef *) *this);
+00378                                 }
+00379                         }
+00380                 }
+00381                 else
+00382                         _Components = NULL;
+00383 
+00384                 _AgentManager = a._AgentManager;
+00385 
+00386                 mapSet = a.mapSet;
+00387                 //if(_AgentManager) _AgentManager->incRef();
+00388 
+00389 /*              std::vector<NLAILOGIC::IBaseOperator *>::const_iterator it_o = a._Operators.begin();
+00390                 while ( it_o != a._Operators.end() )
+00391                 {
+00392                         addOperator( *it_o );
+00393                         it_o++;
+00394                 }*/
+00395         }
+00396         
+00397         CAgentScript::CAgentScript(IAgentManager *manager) : IAgentManager( NULL ), _AgentClass( NULL )
+00398         {
+00399                 _iComponents = 0;
+00400                 _Components = NULL;
+00401                 _NbComponents = 0;              
+00402                 _AgentManager = manager;
+00403         }
+00404 
+00405         CAgentScript::CAgentScript(IAgentManager *manager, IBasicAgent *father,         //The agent's father 
+00406                                                           std::list<IObjectIA *> &components,                           //Static components                                                       
+00407                                                           NLAISCRIPT::CAgentClass *agent_class )                        //Class
+00408         
+00409         : IAgentManager(father), _AgentClass( agent_class )
+00410         {       
+00411                 /*if ( _AgentClass )
+00412                         _AgentClass->incRef();*/
+00413 
+00414                 _iComponents = 0;
+00415 
+00416                 _AgentManager = manager;
+00417                 // Creates the static components array
+00418 //              _NbComponents = components.size();
+00419 /*
+00420                 if ( _NbComponents )
+00421                 {
+00422                         _Components = new IObjectIA *[ _NbComponents ];
+00423                         std::list<IObjectIA *>::iterator it_c = components.begin();
+00424                         int id_c = 0;
+00425                         //sint32 nb_scripted = 0;
+00426                         while ( it_c != components.end() )
+00427                         {
+00428                                 IObjectIA *o = (IObjectIA *)*it_c;
+00429                                 _Components[id_c] = o;
+00430 
+00431                                 uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tAgent;
+00432                                 const NLAIC::CTypeOfObject &t = o->getType();
+00433 
+00434                                 if((t.getValue() & b) == b)
+00435                                 {
+00436                                         ((CAgentScript *)o)->setParent( (const IWordNumRef *) *this);
+00437                                 }
+00438 
+00439                                 it_c++;
+00440                                 id_c++;
+00441                         }               
+00442                 }
+00443                 else
+00444                 {
+00445                         _Components =NULL;
+00446                         _AgentManager = manager;
+00447                 }
+00448                 */
+00449                 createComponents( components );
+00450         }       
+00451 
+00452         CAgentScript::~CAgentScript()
+00453         {
+00454                 Kill();
+00455                 /*if ( _AgentClass )
+00456                         _AgentClass->release();*/
+00457 
+00458                 // destruction of static components
+00459                 if(_Components != NULL)
+00460                 {
+00461                         for ( int i = 0; i < _NbComponents; i++ )
+00462                         {
+00463 #ifdef NL_DEBUG
+00464                                 const IObjectIA *o = _Components[i];
+00465 #endif
+00466                                 _Components[i]->release();
+00467                         }
+00468                         delete[] _Components;
+00469                 }               
+00470         }
+00471 
+00472         void CAgentScript::setAgentManager(IAgentManager *manager)
+00473         {
+00474                 //if(_AgentManager != NULL) _AgentManager->release();
+00475                 _AgentManager = manager;
+00476                 for ( int i = 0; i < _NbComponents; i++ )
+00477                 {                       
+00478 
+00479                         uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tAgent;
+00480                         const NLAIC::CTypeOfObject &t = (const NLAIC::CTypeOfObject &)_Components[i]->getType();
+00481                         if( (t.getValue() & b ) == b)                   
+00482                         {                               
+00483                                 ((CAgentScript *)_Components[i])->setAgentManager(_AgentManager);                       
+00484                         }
+00485                 }
+00486         }
+00487 
+00488         sint32 CAgentScript::getChildMessageIndex(const IMessageBase *msg, sint32 child_index )
+00489         {
+00490                 return _AgentClass->getChildMessageIndex( msg, child_index );
+00491         }
+00492 
+00493         bool CAgentScript::setStaticMember(sint32 index,IObjectIA *op)
+00494         {
+00495 #ifdef NL_DEBUG
+00496                 if ( index >= _NbComponents )
+00497                 {
+00498                         throw NLAIE::CExceptionIndexError();
+00499                 }
+00500 #endif
+00501                 IObjectIA *old_comp = _Components[ index ];
+00502                 _Components[ index ] = op;              
+00503 
+00504                 uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tAgent;
+00505                 const NLAIC::CTypeOfObject &t = op->getType();
+00506                 if((t.getValue() & b) == b)
+00507                 {
+00508                         ((CAgentScript *)op)->setParent( (const IWordNumRef *) *this);
+00509                 }
+00510                 if(op != old_comp)  
+00511                 {
+00512                         old_comp->release();
+00513                         return false;
+00514                 }
+00515                 return true;
+00516         }
+00517 
+00518         sint32 CAgentScript::getStaticMemberSize() const
+00519         {
+00520                 return _NbComponents;//_AgentClass->getStaticMemberSize();
+00521         }
+00522         
+00523         const IObjectIA *CAgentScript::getStaticMember(sint32 index) const
+00524         {
+00525 #ifdef NL_DEBUG
+00526                 if ( index >= _NbComponents )
+00527                 {
+00528                         throw NLAIE::CExceptionIndexError();
+00529                 }
+00530 #endif
+00531                 return _Components[ index ];
+00532         }
+00533 
+00534         NLAISCRIPT::IOpCode *CAgentScript::getMethode(sint32 inheritance,sint32 index)
+00535         {
+00536 #ifdef NL_DEBUG
+00537                 if ( index >= _AgentClass->getMethodIndexSize())
+00538                 {
+00539                         throw NLAIE::CExceptionIndexError();
+00540                 }
+00541 
+00542                 if ( inheritance >= _AgentClass->sizeVTable())
+00543                 {
+00544                         throw NLAIE::CExceptionIndexError();
+00545                 }
+00546 #endif
+00547                 return (NLAISCRIPT::IOpCode *)_AgentClass->getBrancheCode(inheritance,index).getCode();
+00548         }
+00549 
+00550         NLAISCRIPT::IOpCode *CAgentScript::getMethode(sint32 index)
+00551         {
+00552                 if ( _AgentClass != NULL )
+00553                 {
+00554 #ifdef NL_DEBUG         
+00555                         const char *dbg_class_name = (const char *) getType();
+00556                         const char *dbg_base_class_name = (const char *) _AgentClass->getType();
+00557 
+00558                         if ( index >= _AgentClass->getMethodIndexSize())
+00559                         {
+00560                                 throw NLAIE::CExceptionIndexError();
+00561                         }
+00562 #endif
+00563                         return (NLAISCRIPT::IOpCode *)_AgentClass->getBrancheCode(index).getCode();
+00564                 }
+00565                 else 
+00566                         return NULL;
+00567         }
+00568 
+00569         void CAgentScript::save(NLMISC::IStream &os)
+00570         {
+00571                 IBasicAgent::save(os);
+00572                 sint32 size = _NbComponents;
+00573                 os.serial( size );
+00574                 for ( int i = 0; i < _NbComponents; i++ )
+00575                 {
+00576                         os.serial( (NLAIC::CIdentType &) _Components[i]->getType() );
+00577                         _Components[i]->save(os);
+00578                 }               
+00579         }       
+00580 
+00581         void CAgentScript::load(NLMISC::IStream &is)
+00582         {
+00583                 IBasicAgent::load(is);
+00584                 
+00585                 // Loads static components
+00586                 sint32 size;
+00587                 is.serial( size );
+00588                 _NbComponents = size;
+00589 
+00590                 if(_Components)
+00591                 {
+00592                         for ( int i = 0; i < _NbComponents; i++ )
+00593                                                         _Components[i]->release();
+00594                         delete[] _Components;
+00595                 }
+00596                 _Components = new IObjectIA *[ _NbComponents ];
+00597 
+00598                 for ( int i = 0; i < _NbComponents; i++ )
+00599                 {
+00600                         NLAIC::CIdentTypeAlloc id;
+00601                         is.serial( id );
+00602                         IObjectIA *tmp_c = (IObjectIA *)id.allocClass();
+00603                         tmp_c->load(is);
+00604                         _Components[i] = tmp_c;
+00605                 }
+00606         }
+00607 
+00608         sint32 CAgentScript::getMethodIndexSize() const
+00609         {
+00610                 /*if(_AgentClass)
+00611                 {
+00612                         return _AgentClass->getMethodIndexSize();
+00613                 }
+00614                 else*/
+00615                 {
+00616                         return IAgent::getMethodIndexSize() + TLastM;
+00617                 }
+00618         }
+00619 
+00620         const NLAIC::IBasicType *CAgentScript::clone() const
+00621         {               
+00622                 CAgentScript *result = new CAgentScript(*this);
+00623                 return result;
+00624         }
+00625 
+00626         const NLAIC::IBasicType *CAgentScript::newInstance() const
+00627         {
+00628                 CAgentScript *instance;
+00629                 if ( _AgentClass )
+00630                 {
+00631                         instance = (CAgentScript *) _AgentClass->buildNewInstance();
+00632                 }
+00633                 else 
+00634                 {                       
+00635                         instance = new CAgentScript(NULL);
+00636                 }
+00637                 return instance;
+00638         }
+00639 
+00640         void CAgentScript::getDebugString(std::string &t) const
+00641         {               
+00642 
+00643                 if( _AgentManager != NULL)
+00644                 {
+00645                         const NLAISCRIPT::CParam p;
+00646                         static CStringVarName debugStringF("GetDebugString");
+00647 
+00648                         tQueue r = isMember(NULL,&debugStringF,p);
+00649                         if(r.size())
+00650                         {
+00651                                 NLAISCRIPT::CCodeContext *c = (NLAISCRIPT::CCodeContext *)_AgentManager->getAgentContext()->clone();
+00652                                 NLAIAGENT::CIdMethod m = r.top();
+00653                                 //msg->setMethodIndex(0,m.Index);       
+00654                                 c->Self = this;
+00655 
+00656                                 IBaseGroupType *param = new CGroupType();                                                               
+00657                                 (*c).Stack ++;
+00658                                 (*c).Stack[(int)(*c).Stack] = param;
+00659                                 NLAISCRIPT::IMethodContext *methodContex = new NLAISCRIPT::CMethodContext();
+00660                                 NLAISCRIPT::CCallMethod opCall(methodContex,0,m.Index);
+00661                                 opCall.runOpCode(*c);                                                                                           
+00662                                 const NLAIAGENT::CStringType *returnMsg = (const NLAIAGENT::CStringType *)c->Stack[(int)(*c).Stack];                            
+00663                                 t += returnMsg->getStr().getString();
+00664                                 (*c).Stack--;
+00665                                 c->release();
+00666                                 return;
+00667                         }
+00668                 }
+00669                 
+00670                 t += NLAIC::stringGetBuild("class type <%s> ",(const char *)getType());
+00671                 if ( _AgentClass )
+00672                         t += NLAIC::stringGetBuild("<%s> (scripted)  -StaticComponents:\n",(const char *)_AgentClass->getType());
+00673                 else
+00674                         t += "<undefined_class> (scripted) -StaticComponents:\n";
+00675                 for (int i = 0; i < _NbComponents; i++ )
+00676                 {
+00677                         std::string buf;
+00678                         t += "\t\t";
+00679                         if ( _AgentClass->getComponentName(i) )
+00680                         {
+00681                                 t += _AgentClass->getComponentName(i);
+00682                         }
+00683                         else
+00684                                 t += "<unnamed>";
+00685 
+00686                         t += "\t\t";
+00687                         _Components[i]->getDebugString(buf);
+00688                         t += "[ ";
+00689                         t += buf;
+00690                         t += " ]";
+00691                         if(i != (_NbComponents-1)) t += "\n";
+00692                 }
+00693                 
+00694         }
+00695 
+00696         bool CAgentScript::isEqual(const IBasicObjectIA &a) const
+00697         {
+00698                 return false;
+00699         }
+00700 
+00701         void CAgentScript::onKill(IConnectIA *a)
+00702         {               
+00703                 tsetDefNameAgent::iterator iter = _DynamicAgentName.begin();
+00704                 while( iter != _DynamicAgentName.end() )
+00705                 {                       
+00706                         if((*(*iter).Itr) == a)
+00707                         {
+00708                                 _DynamicAgentName.erase(iter);
+00709                                 break;
+00710                         }
+00711                         iter++;
+00712                 }
+00713                 IAgent::onKill(a);
+00714         }
+00715 
+00717         bool CAgentScript::isa(const std::string &s) const
+00718         {
+00719                 std::set<std::string>::iterator it = mapSet.find(s);
+00720                 if(it != mapSet.end()) return true;
+00721                 else
+00722                 if(isClassInheritedFrom(CStringVarName(s.c_str())) >= 0) 
+00723                         return true;
+00724                 else
+00725                         if(s == (const char *) getType()) 
+00726                                 return true;
+00727                 
+00728                 return false;
+00729         }
+00730 
+00732         void CAgentScript::addSet(const std::string &s)
+00733         {
+00734                 mapSet.insert(s);
+00735         }
+00736 
+00737         IObjectIA::CProcessResult CAgentScript::addDynamicAgent(IBaseGroupType *g)
+00738         {
+00739                 CIteratorContener i = g->getIterator();
+00740                 CStringType &s = (CStringType &)*i++;
+00741                 IBasicAgent *a = (IBasicAgent *)i++;
+00742                 IBasicAgent *o = a;
+00743                 sint n = 1;
+00744 
+00745 #ifdef NL_DEBUG
+00746                 std::string name;
+00747                 const char *type;
+00748                 s.getDebugString(name);
+00749 
+00750                 type = (const char *)a->getType();
+00751                 const char *tname = name.c_str();
+00752 #endif
+00753                 if(!i.isInEnd())
+00754                 {
+00755                         n = (sint)((NLAIAGENT::INombreDefine *)i++)->getNumber();
+00756                 }
+00757 
+00758                 IObjectIA::CProcessResult r;
+00759                 r.ResultState = IObjectIA::ProcessIdle;
+00760 
+00761                 while(n --)
+00762                 {
+00763                         o->setParent( (const IWordNumRef *) *this );
+00764                         CNotifyParentScript *m = new CNotifyParentScript(this);
+00765                         //this->incRef();
+00766                         m->setSender(this);
+00767                         m->setPerformatif(IMessageBase::PTell);
+00768                         ((IObjectIA *)o)->sendMessage(m);
+00769 
+00770                         uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tAgent;
+00771                         const NLAIC::CTypeOfObject &t = o->getType();
+00772 
+00773                         if((t.getValue() & b) == b)
+00774                         {
+00775                                 ((CAgentScript *)o)->setAgentManager(this);
+00776                         }
+00777 
+00778                         _DynamicAgentName.insert(CKeyAgent(s,addChild(o)));
+00779                         if(n) o = (IBasicAgent *)a->clone();
+00780                 }
+00781                 
+00782                 r.Result = NULL;
+00783 
+00784                 return r;
+00785         }
+00786 
+00787         IObjectIA::CProcessResult CAgentScript::addDynamicAgent(CStringType &name, IBasicAgent *agent)
+00788         {
+00789 #ifdef NL_DEBUG
+00790                 std::string dbg_name;
+00791                 const char *type;
+00792                 name.getDebugString( dbg_name );
+00793                 type = (const char *)agent->getType();
+00794                 const char *tname = dbg_name.c_str();
+00795 #endif
+00796                 IObjectIA::CProcessResult r;
+00797                 r.ResultState = IObjectIA::ProcessIdle;
+00798 
+00799                 agent->setParent( (const IWordNumRef *) *this );
+00800                 CNotifyParentScript *m = new CNotifyParentScript(this);
+00801                 m->setSender(this);
+00802                 m->setPerformatif(IMessageBase::PTell);
+00803                 ((IObjectIA *) agent )->sendMessage(m);
+00804                 uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tAgent;
+00805                 const NLAIC::CTypeOfObject &t = agent->getType();
+00806                 if((t.getValue() & b) == b)
+00807                 {
+00808                         ((CAgentScript *) agent )->setAgentManager(this);
+00809                 }
+00810                 _DynamicAgentName.insert(CKeyAgent(name,addChild( agent )));
+00811                 
+00812                 r.Result = NULL;
+00813                 return r;
+00814         }
+00815 
+00816         IObjectIA::CProcessResult CAgentScript::removeDynamic(NLAIAGENT::IBaseGroupType *g)
+00817         {
+00818                 CStringType *s = (CStringType *)g->getFront();
+00819                 IObjectIA::CProcessResult r;
+00820                 r.ResultState = IObjectIA::ProcessIdle;
+00821                 std::pair<tsetDefNameAgent::iterator,tsetDefNameAgent::iterator>  p = _DynamicAgentName.equal_range(CKeyAgent(*s));
+00822 
+00823                 if(p.first != p.second)
+00824                 {       
+00825                         while(p.first != p.second)
+00826                         {
+00827                                 tsetDefNameAgent::iterator iTmp = p.first;
+00828                                 p.first ++;
+00829 
+00830                                 NLAIAGENT::IBasicAgent *o = *iTmp->Itr;
+00831                                 _DynamicAgentName.erase(iTmp);                          
+00832                                 removeChild(o);                         
+00833                         }                       
+00834                         r.Result = new DigitalType(1.0);
+00835                         return r;
+00836                 }               
+00837                 r.Result = &DigitalType::NullOperator;
+00838                 r.Result->incRef();
+00839                 return r;
+00840         }
+00841 
+00842 
+00843         void CAgentScript::removeDynamic(NLAIAGENT::IBasicAgent *ag)
+00844         {               
+00845                 
+00846                 tsetDefNameAgent::iterator p = _DynamicAgentName.begin();
+00847                 
+00848                 while(p != _DynamicAgentName.end())
+00849                 {
+00850                         if((*(*p).Itr) == ag)
+00851                         {
+00852                                 _DynamicAgentName.erase(p);                             
+00853                                 removeChild(ag);                        
+00854                                 break;
+00855                         }
+00856                         p ++;
+00857                 }                                       
+00858         }
+00859 
+00860         IObjectIA::CProcessResult CAgentScript::getDynamicAgent(IBaseGroupType *g)
+00861         {               
+00862                 CStringType *s = (CStringType *)g->get();
+00863                 IObjectIA::CProcessResult r;
+00864                 r.ResultState = IObjectIA::ProcessIdle;
+00865                 std::pair<tsetDefNameAgent::iterator,tsetDefNameAgent::iterator>  p = _DynamicAgentName.equal_range(CKeyAgent(*s));
+00866                 
+00867                 if(p.first != p.second)
+00868                 {                       
+00869                         sint size = _DynamicAgentName.count(CKeyAgent(*s));
+00870                         sint n = 0;
+00871                         CVectorGroupManager *x;
+00872                         x = new CVectorGroupManager(size);
+00873                         while(p.first != p.second)
+00874                         {                               
+00875                                 (*p.first->Itr)->incRef();
+00876                                 x->set(n++, *p.first->Itr);
+00877                                 p.first++;
+00878                         }
+00879 
+00880                         r.Result = x;                   
+00881                         return r;
+00882                         
+00883                 }
+00884                 r.Result = new CVectorGroupManager();           
+00885                 return r;
+00886         }
+00887 
+00888         IObjectIA::CProcessResult CAgentScript::runAskParentNotify(IBaseGroupType *g)
+00889         {
+00890                 CNotifyParentScript *m = new CNotifyParentScript((IBasicAgent *)getParent());
+00891                 m->setPerformatif(IMessageBase::PTell);
+00892                 //this->incRef();
+00893                 m->setSender(this);
+00894                 IObjectIA::CProcessResult r;
+00895                 r.Result = m;
+00896                 return r;
+00897         }
+00898 
+00899         IObjectIA::CProcessResult CAgentScript::runTellParentNotify(IBaseGroupType *g)
+00900         {       
+00901                 sint i;
+00902 
+00903 #ifdef NL_DEBUG
+00904                 const char *text = (const char *)getType();
+00905                 const char *textP = (const char *)getParent()->getType();
+00906 #endif
+00907                 CNotifyParentScript *m = new CNotifyParentScript(this);
+00908                 m->setPerformatif(IMessageBase::PTell);         
+00909                 m->setSender(this);
+00910 
+00911                 for(i = 0; i < _NbComponents; i++)
+00912                 {
+00913                         if(_Components[i] != NULL)
+00914                         {                               
+00915                                 CNotifyParentScript *msg = (CNotifyParentScript *)m->clone();
+00916                                 try
+00917                                 {
+00918                                         uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tAgent;
+00919                                         const NLAIC::CTypeOfObject &t = _Components[i]->getType();
+00920 
+00921                                         if((t.getValue() & b) == b)
+00922                                                                         _Components[i]->sendMessage(msg);                                       
+00923                                 }
+00924                                 catch(NLAIE::IException &)
+00925                                 {
+00926                                         msg->release();
+00927                                 }
+00928                         }
+00929                 }
+00930                 IObjectIA::CProcessResult r;
+00931                 r.Result = m;
+00932                 return r;
+00933         }
+00934 
+00935         IObjectIA::CProcessResult CAgentScript::runTellComponent(IBaseGroupType *g)
+00936         {       
+00937                 NLAIAGENT::IMessageBase &mOriginal = (NLAIAGENT::IMessageBase &)*g->get();
+00938                 CStringType *c = (CStringType *)mOriginal[(sint32)0];
+00939                 NLAIAGENT::IMessageBase *m = (NLAIAGENT::IMessageBase *)mOriginal[(sint32)1];
+00940                 m->incRef();
+00941                 m->setSender((IObjectIA *)mOriginal.getSender());
+00942                 m->setPerformatif(mOriginal.getPerformatif());
+00943                 sendMessage(c->getStr(), (IObjectIA *)m);
+00944 
+00945                 IObjectIA::CProcessResult r;
+00946 
+00947                 m->incRef();
+00948                 r.Result = m;
+00949                 return r;
+00950         }
+00951 
+00952         IObjectIA::CProcessResult CAgentScript::runAskGetValue(IBaseGroupType *g)
+00953         {
+00954                 NLAIAGENT::IMessageBase &msg_result = (NLAIAGENT::IMessageBase &)*g->get();
+00955                 msg_result.incRef();
+00956 
+00957                 CStringType *comp_name = (CStringType *)msg_result[(sint32)0];
+00958                 
+00959                 msg_result.setPerformatif(IMessageBase::PTell);
+00960                 msg_result.setMethodIndex(-1,-1);
+00961                 msg_result.setContinuation( (IObjectIA *) msg_result.getSender() );
+00962                 
+00963                 sint32 index = _AgentClass->getInheritedStaticMemberIndex(  comp_name->getStr()  );
+00964                 if ( index != -1 )
+00965                 {
+00966                         msg_result.set( 1, _Components[ index ] );
+00967                 }
+00968                 else
+00969                 {
+00970                         // Component not foud: return error msg
+00971                 }
+00972 
+00973                 IObjectIA::CProcessResult r;
+00974                 r.Result = &msg_result;
+00975                 return r;
+00976         }
+00977 
+00978         IObjectIA::CProcessResult CAgentScript::runTellSetValue(IBaseGroupType *g)
+00979         {
+00980                 NLAIAGENT::IMessageBase &msg_result = (NLAIAGENT::IMessageBase &)*g->get();
+00981                 msg_result.incRef();
+00982 
+00983                 while ( msg_result.size() )
+00984                 {
+00985                         CStringType *comp_name = (CStringType *) msg_result[ (sint32) 0 ];
+00986                         IObjectIA *comp_val = (IObjectIA *) msg_result[ (sint32) 1 ];
+00987                         
+00988                         sint32 index = getStaticMemberIndex( comp_name->getStr() );
+00989                         if ( index != -1 )
+00990                         {
+00991                                 // Sets the component to the new value
+00992                                 setStaticMember( index, comp_val );             
+00993                         }
+00994                         else
+00995                         {
+00996                                 // Component not found: creates it
+00997                                 
+00998                         }
+00999                 }
+01000                 IObjectIA::CProcessResult r;
+01001                 msg_result.incRef();
+01002                 r.Result = &msg_result;
+01003                 return r;
+01004         }
+01005 
+01006         IObjectIA::CProcessResult CAgentScript::runInitComponent(IBaseGroupType *g)
+01007         {
+01008                 NLAIAGENT::IMessageBase &msg_result = (NLAIAGENT::IMessageBase &)*g->get();
+01009                 msg_result.incRef();
+01010 
+01011 
+01012                 // Cleans previous components
+01013                 if ( _Components != NULL )
+01014                 {
+01015                         for ( int i = 0; i < _NbComponents; i++ )
+01016                                 _Components[i]->release();
+01017                 }
+01018 
+01019                 // Creates a new component array
+01020                 _NbComponents = (sint32) msg_result.size() / 3;
+01021                 _Components = new IObjectIA *[ _NbComponents ];
+01022 
+01023                 int test = 0;
+01024 
+01025                 for ( int i = 0; i < msg_result.size() ; i += 3 )
+01026                 {
+01027                         CStringType *comp_name = (CStringType *) msg_result[ (sint32) i ];
+01028                         IObjectIA *comp_val = (IObjectIA *) msg_result[ (sint32) (i + 2) ];
+01029                         
+01030                         sint32 index = getStaticMemberIndex( comp_name->getStr() ); //_AgentClass->getInheritedStaticMemberIndex(  comp_name->getStr()  );
+01031                         if ( index != -1 )
+01032                         {
+01033                                 // Sets the component to the new value
+01034                                 setStaticMember( index, comp_val );             
+01035                         }
+01036                         else
+01037                         {
+01038                                 setStaticMember( (sint32) (i / 3) , comp_val );
+01039                         }
+01040                         test++;
+01041                 }
+01042 
+01043                 IObjectIA::CProcessResult r;
+01044                 msg_result.incRef();
+01045                 r.Result = &msg_result;
+01046                 return r;
+01047         }
+01048 
+01049         IObjectIA::CProcessResult CAgentScript::runInitClass(IBaseGroupType *g)
+01050         {
+01051                 const char * class_name = ((NLAIAGENT::CStringVarName *)g->get())->getString();
+01052                 NLAIC::CIdentType id_class( class_name );       
+01053 
+01054                 
+01055 
+01056                 /*
+01057                 NLAIAGENT::IMessageBase &msg_result = (NLAIAGENT::IMessageBase &)*g->get();
+01058                 msg_result.incRef();
+01059 
+01060 
+01061                 // Cleans previous components
+01062                 if ( _Components != NULL )
+01063                 {
+01064                         for ( int i = 0; i < _NbComponents; i++ )
+01065                                 _Components[i]->release();
+01066                 }
+01067 
+01068                 // Creates a new component array
+01069                 _NbComponents = (sint32) msg_result.size() / 3;
+01070                 _Components = new IObjectIA *[ _NbComponents ];
+01071 
+01072                 int test = 0;
+01073 
+01074                 for ( int i = 0; i < msg_result.size() ; i += 3 )
+01075                 {
+01076                         CStringType *comp_name = (CStringType *) msg_result[ (sint32) i ];
+01077                         CStringType *comp_type = (CStringType *) msg_result[ (sint32) (i + 1) ];
+01078                         IObjectIA *comp_val = (IObjectIA *) msg_result[ (sint32) (i + 2) ];
+01079                         
+01080                         sint32 index = getStaticMemberIndex( comp_name->getStr() ); //_AgentClass->getInheritedStaticMemberIndex(  comp_name->getStr()  );
+01081                         if ( index != -1 )
+01082                         {
+01083                                 // Sets the component to the new value
+01084                                 setStaticMember( index, comp_val );             
+01085                         }
+01086                         else
+01087                         {
+01088                                 setStaticMember( (sint32) (i / 3) , comp_val );
+01089                         }
+01090                         test++;
+01091                 }
+01092                 */
+01093                 IObjectIA::CProcessResult r;
+01094                 r.Result = NULL;
+01095                 return r;
+01096         }
+01097 
+01098 
+01099 
+01100 
+01101         IObjectIA::CProcessResult CAgentScript::getDynamicName(NLAIAGENT::IBaseGroupType *g)
+01102         {
+01103 
+01104                 IObjectIA::CProcessResult r;
+01105                 const IObjectIA *o = ((CLocalAgentMail *)g->get())->getHost();
+01106                 tsetDefNameAgent::iterator i = _DynamicAgentName.begin();
+01107 
+01108                 while(i != _DynamicAgentName.end())
+01109                 {
+01110                         CKeyAgent key = *i;
+01111                         if( o == *key.Itr )
+01112                         {
+01113                                 CStringType *s = new CStringType(key.Name);
+01114                                 r.Result = s;
+01115                                 return r;
+01116                         }
+01117                         i ++;
+01118                 }
+01119                 r.Result = new CStringType(CStringVarName("Unknown"));
+01120                 return r;
+01121         }
+01122 
+01123         IObjectIA::CProcessResult CAgentScript::sendMethod(IObjectIA *param)
+01124         {
+01125                 INombreDefine *p = (INombreDefine *)((IBaseGroupType *)param)->popFront();
+01126                 IMessageBase *msg = (IMessageBase *)((IBaseGroupType *)param)->popFront();
+01127                 msg->setPerformatif((IMessageBase::TPerformatif)(sint)p->getNumber());
+01128                 p->release();
+01129                 return sendMessage(msg);
+01130         }
+01131 
+01132         IObjectIA::CProcessResult CAgentScript::sendMethodCompoment(IObjectIA *param)
+01133         {
+01134                 NLAIAGENT::CIteratorContener It = ((IBaseGroupType *)param)->getIterator();
+01135                 const CStringType *n = (const CStringType *)It++;
+01136                 INombreDefine *p = (INombreDefine *)((IBaseGroupType *)It++);
+01137                 IMessageBase *msg = (IMessageBase *)((IBaseGroupType *)It++);
+01138                 msg->setPerformatif((IMessageBase::TPerformatif)(sint)p->getNumber());
+01139                 msg->incRef();
+01140                 return sendMessage(n->getStr(),msg);
+01141         }       
+01142 
+01143         IObjectIA::CProcessResult CAgentScript::sendBroadCast(IObjectIA *m)
+01144         {
+01145                 tsetDefNameAgent::iterator i = _DynamicAgentName.begin();
+01146 
+01147                 if(i != _DynamicAgentName.end()) 
+01148                 {
+01149                         ((IObjectIA *)(*(*(i)).Itr))->sendMessage(m);
+01150                         i ++;
+01151 
+01152                         while(i != _DynamicAgentName.end())
+01153                         {
+01154                                 m->incRef();
+01155                                 IObjectIA *o = ((IObjectIA *)(*(*(i)).Itr));
+01156                                 o->sendMessage(m);
+01157                                 i++;
+01158                         }
+01159                 }
+01160 
+01161                 return IObjectIA::CProcessResult();
+01162         }
+01163         
+01164         IObjectIA::CProcessResult CAgentScript::sendMessageToDynmaicChild(const IVarName &compName,IObjectIA *msg)
+01165         {
+01166                 //tsetDefNameAgent::iterator  p = _DynamicAgentName.find(CKeyAgent(CStringType(compName)));
+01167                 std::pair<tsetDefNameAgent::iterator,tsetDefNameAgent::iterator>  p = _DynamicAgentName.equal_range(CKeyAgent(CStringType(compName)));
+01168 
+01169 #ifdef NL_DEBUG
+01170                 const char *txt = (const char *)msg->getType();
+01171                 std::string txtName;
+01172                 compName.getDebugString(txtName);
+01173 #endif
+01174 
+01175                 IObjectIA::CProcessResult r;
+01176 
+01177                 if(p.first != p.second)
+01178                 {
+01179                         while(p.first != p.second)
+01180                         {
+01181                                 CAgentScript *o = (CAgentScript *)*((*(p.first)).Itr);
+01182                                 o->sendMessage(msg);
+01183                                 p.first ++;
+01184                                 if(p.first != p.second) msg = (IObjectIA *)msg->clone();
+01185                         }
+01186                 }
+01187                 else
+01188                 {
+01189                         r.ResultState = processError;
+01190                         r.Result = NULL;                        
+01191                 }
+01192 
+01193                 return r;
+01194         }
+01195 
+01196         IObjectIA::CProcessResult CAgentScript::sendMessage(const IVarName &compName,IObjectIA *msg)
+01197         {
+01198 #ifdef NL_DEBUG
+01199         const char *txt = (const char *)msg->getType();
+01200         const char *compNameDb = (const char *)compName.getString();
+01201         //nlinfo("MSG %s %4x", txt, this);
+01202 #endif
+01203                 if(_AgentClass != NULL)
+01204                 {
+01205                         int i = getStaticMemberIndex(compName);
+01206                         if(i >= 0)
+01207                         {
+01208                                 IObjectIA *comp = (IObjectIA *)getStaticMember(i);
+01209                                 if(comp != NULL)
+01210                                 {
+01211                                         comp->sendMessage(msg);
+01212                                 }
+01213                                 else
+01214                                 {
+01215                                         if(sendMessageToDynmaicChild(compName,msg).ResultState == processError) msg->release();
+01216                                 }
+01217                         }
+01218                         else
+01219                         {
+01220                                 if(sendMessageToDynmaicChild(compName,msg).ResultState == processError) msg->release();
+01221                         }
+01222                 }
+01223                 else                    
+01224                 {                                               
+01225                         if(sendMessageToDynmaicChild(compName,msg).ResultState == processError) msg->release();
+01226                 }
+01227                 return IObjectIA::CProcessResult();
+01228         }
+01229 
+01230         IObjectIA::CProcessResult CAgentScript::sendMessage(IObjectIA *m)
+01231         {
+01232 #ifdef NL_DEBUG
+01233         const char *txt = (const char *)m->getType();
+01234         const char *classBase = (const char *)getType();
+01235         //nlinfo("MSG %s %4x", txt, m);
+01236 #endif
+01237                 IMessageBase *msg = (IMessageBase *)m;
+01238                 //this->incRef();
+01239                 msg->setReceiver(this);
+01240                 if(msg->getMethodIndex() < 0)
+01241                 {                       
+01242                         uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tMessage;
+01243                         const NLAIC::CTypeOfObject &t = m->getType();
+01244 
+01245                         if((t.getValue() & b) == b)                     
+01246                         {
+01247                                 //char runMsg[1024];
+01248                                 //strcpy(runMsg,_RUN_);
+01249                                 static CStringVarName sRunTell("RunTell");
+01250                                 static CStringVarName sRunAchieve("RunAchieve");
+01251                                 static CStringVarName sRunAsk("RunAsk");
+01252                                 static CStringVarName sRunExec("RunExec");
+01253                                 static CStringVarName sRunBreak("RunBreak");
+01254                                 static CStringVarName sRunKill("RunKill");
+01255                                 static CStringVarName sRunError("RunError");
+01256 
+01257                                 CStringVarName *runMsg = NULL;//sRunTell;
+01258 
+01259                                 switch(msg->getPerformatif())
+01260                                 {
+01261                                 case IMessageBase::PExec:
+01262                                         //strcat(runMsg,"Exec");
+01263                                         runMsg = &sRunExec;
+01264                                         break;
+01265                                 case IMessageBase::PAchieve:
+01266                                         //strcat(runMsg,"Achieve");
+01267                                         runMsg = &sRunAchieve;
+01268                                         break;
+01269                                 case IMessageBase::PAsk:
+01270                                         //strcat(runMsg,"Ask");
+01271                                         runMsg = &sRunAsk;
+01272                                         break;
+01273                                 case IMessageBase::PTell:
+01274                                         //strcat(runMsg,"Tell");
+01275                                         runMsg = &sRunTell;
+01276                                         break;
+01277                                 case IMessageBase::PBreak:
+01278                                         runMsg = &sRunBreak;
+01279                                         break;
+01280                                 case IMessageBase::PKill:
+01281                                         runMsg = &sRunKill;
+01282                                         break;
+01283                                 case IMessageBase::PError:
+01284                                         runMsg = &sRunError;
+01285                                         break;
+01286 
+01287                                 default:
+01288                                         throw;
+01289                                         break;
+01290                                 }
+01291 
+01292                                 CStringVarName &tmp_name = *runMsg;
+01293 
+01294                                 NLAISCRIPT::COperandSimple *t = new NLAISCRIPT::COperandSimple(new NLAIC::CIdentType(m->getType()));
+01295                                 NLAISCRIPT::CParam p(1,t);
+01296                                 
+01297                                 tQueue r = isMember(NULL,&tmp_name,p);
+01298                                 if(r.size())
+01299                                 {
+01300                                         NLAIAGENT::CIdMethod m = r.top();
+01301                                         msg->setMethodIndex(0,m.Index);
+01302                                 }                               
+01303                         }                       
+01304                 }
+01305 
+01306                 IObjectIA::CProcessResult r = IAgent::sendMessage(msg);
+01307 
+01308         
+01309 
+01310 #ifdef PROFILE
+01311                 time = NLMISC::CTime::getPerformanceTime() - time;
+01312                 //if(time)
+01313                 {
+01314                         TimeSend += time;
+01315                         NbSend ++;                      
+01316                 }
+01317 #endif
+01318 
+01319                 return r;
+01320                 //return IObjectIA::CProcessResult();
+01321         }
+01322 
+01323         void CAgentScript::runChildren()
+01324         {
+01325 #ifdef NL_DEBUG         
+01326         const char *classBase = (const char *)getType();        
+01327 #endif
+01328                 // Activation des agents de la partie statique
+01329                 int i = _NbComponents;
+01330 
+01331                 IObjectIA **com = _Components;
+01332 
+01333                 while(i --)
+01334                         (*com ++)->run();               
+01335 
+01336                 // Activation des fils
+01337                 IAgent::runChildren();
+01338         }
+01339 
+01340         bool CAgentScript::runChildrenStepByStep()
+01341         {
+01342                 if(_iComponents == _NbComponents)
+01343                 {
+01344                         if(IAgent::runChildrenStepByStep())
+01345                         {
+01346                                 _iComponents = 0;
+01347                                 return true;                            
+01348                         }
+01349                         else return false;                      
+01350                 }
+01351 
+01352                 IObjectIA *o = _Components[_iComponents ++];
+01353                 o->run();
+01354 
+01355                 return false;
+01356         }
+01357 
+01358         void CAgentScript::processMessages(IMessageBase *msg,IObjectIA *c)
+01359         {
+01360 #ifdef NL_DEBUG
+01361         const char *txt = (const char *)msg->getType(); 
+01362         bool dbugB = false;     
+01363 #endif
+01364                 NLAISCRIPT::CCodeContext &context = (NLAISCRIPT::CCodeContext &)*c;
+01365                 IBaseGroupType *param = new CGroupType();
+01366                 msg->incRef();
+01367                 param->push(msg);
+01368                 context.Stack ++;
+01369                 context.Stack[(int)context.Stack] = param;
+01370 
+01371                 int indexM = msg->getMethodIndex() - getBaseMethodCount();
+01372                 if(indexM >= 0)
+01373                 {
+01374                         IObjectIA *code = getMethode(indexM);
+01375                         if(code == NULL)
+01376                         {
+01377                                 getMail()->popMessage();
+01378                                 return;
+01379                         }
+01380                 }
+01381 
+01382                 NLAISCRIPT::IMethodContext *methodContex;
+01383 
+01384                 if (context.ContextDebug.Active)
+01385                 {
+01386                         /*context.ContextDebug.Param.push_back(&listBidon);                                     
+01387                         listBidon.incRef();*/
+01388                         methodContex = new NLAISCRIPT::CMethodContextDebug();
+01389                 }                               
+01390                 else
+01391                 {
+01392                         methodContex = new NLAISCRIPT::CMethodContext();
+01393                 }
+01394                 const IObjectIA *self = context.Self;
+01395                 context.Self = this;
+01396                 NLAISCRIPT::CCallMethod opCall(methodContex,msg->getHeritanceIndex(),msg->getMethodIndex());
+01397                 opCall.runOpCode(context);
+01398                 context.Self = self;
+01399                 IMessageBase *returnMsg = (IMessageBase *)context.Stack[(int)context.Stack];
+01400                 returnMsg->incRef();
+01401                 context.Stack--;
+01402                 processContinuation(msg, returnMsg);
+01403 
+01404                 returnMsg->release();
+01405         }
+01406 
+01407         void CAgentScript::processContinuation(IMessageBase *msg, IMessageBase *returnMsg)
+01408         {
+01409                 switch(msg->getPerformatif())
+01410                 {
+01411                 case IMessageBase::PExec:
+01412                         if(msg->getContinuation() != NULL)
+01413                         {
+01414                                 IMessageBase *o = (IMessageBase *)returnMsg->clone();
+01415                                 o->setMethodIndex(-1,-1);
+01416                                 //this->incRef();
+01417                                 o->setSender(this);
+01418                                 //((IObjectIA *)msg->getContinuation())->incRef();
+01419                                 o->setReceiver((IObjectIA *)msg->getContinuation());
+01420                                 ((IObjectIA *)msg->getContinuation())->sendMessage(o);
+01421                         }
+01422                         break;
+01423                 case IMessageBase::PAchieve:
+01424                         if(msg->getContinuation() != NULL)
+01425                         {
+01426                                 IMessageBase *o = (IMessageBase *)returnMsg->clone();
+01427                                 o->setMethodIndex(-1,-1);
+01428                                 //this->incRef();
+01429                                 o->setSender(this);
+01430                                 //((IObjectIA *)msg->getContinuation())->incRef();
+01431                                 o->setReceiver((IObjectIA *)msg->getContinuation());
+01432                                 ((IObjectIA *)msg->getContinuation())->sendMessage(o);
+01433                         }
+01434                         break;
+01435                 case IMessageBase::PAsk:
+01436                         {
+01437                                 IMessageBase *o = (IMessageBase *)returnMsg->clone();
+01438                                 o->setMethodIndex(-1,-1);
+01439                                 //this->incRef();
+01440                                 o->setSender(this);
+01441                                 o->setPerformatif(IMessageBase::PTell);
+01442                                 //if(returnMsg->getSender() != NULL) ((IObjectIA *)returnMsg->getSender())->incRef();
+01443                                 o->setReceiver((IObjectIA *)returnMsg->getSender());
+01444                                 ((IObjectIA *)msg->getSender())->sendMessage(o);
+01445 
+01446 
+01447                                 if(msg->getContinuation() != NULL)
+01448                                 {
+01449                                         IMessageBase *o = (IMessageBase *)returnMsg->clone();
+01450                                         o->setMethodIndex(-1,-1);
+01451                                         //this->incRef();
+01452                                         o->setSender(this);
+01453                                         //if(msg->getContinuation() != NULL) ((IObjectIA *)msg->getContinuation())->incRef();
+01454                                         o->setReceiver((IObjectIA *)msg->getContinuation());
+01455                                         o->setPerformatif(IMessageBase::PTell);
+01456                                         ((IObjectIA *)msg->getContinuation())->sendMessage(o);
+01457                                 }
+01458                         }
+01459                         break;
+01460                 case IMessageBase::PTell:
+01461                         if(msg->getContinuation() != NULL)
+01462                         {
+01463                                 IMessageBase *o = (IMessageBase *)returnMsg->clone();
+01464                                 o->setMethodIndex(-1,-1);
+01465                                 //this->incRef();
+01466                                 o->setSender(this);
+01467                                 //if(msg->getContinuation() != NULL) ((IObjectIA *)msg->getContinuation())->incRef();
+01468                                 o->setReceiver((IObjectIA *)msg->getContinuation());
+01469                                 ((IObjectIA *)msg->getContinuation())->sendMessage(o);
+01470                         }
+01471                         break;
+01472                 case IMessageBase::PBreak:
+01473                         if(msg->getContinuation() != NULL)
+01474                         {
+01475                                 IMessageBase *o = (IMessageBase *)returnMsg->clone();
+01476                                 o->setMethodIndex(-1,-1);
+01477                                 //this->incRef();
+01478                                 o->setSender(this);
+01479                                 //if(msg->getContinuation() != NULL) ((IObjectIA *)msg->getContinuation())->incRef();
+01480                                 o->setReceiver((IObjectIA *)msg->getContinuation());
+01481                                 ((IObjectIA *)msg->getContinuation())->sendMessage(o);
+01482                         }
+01483                         break;
+01484                 case IMessageBase::PKill:
+01485                         if(msg->getContinuation() != NULL)
+01486                         {
+01487                                 IMessageBase *o = (IMessageBase *)returnMsg->clone();
+01488                                 o->setMethodIndex(-1,-1);
+01489                                 //this->incRef();
+01490                                 o->setSender(this);
+01491                                 //if(msg->getContinuation() != NULL) ((IObjectIA *)msg->getContinuation())->incRef();
+01492                                 o->setReceiver((IObjectIA *)msg->getContinuation());
+01493                                 ((IObjectIA *)msg->getContinuation())->sendMessage(o);
+01494                         }
+01495                         break;
+01496                         default: break;
+01497                 }
+01498         }
+01499 
+01500         void CAgentScript::processMessages()
+01501         {
+01502                 IObjectIA *c = NULL;
+01503                 if( _AgentManager != NULL) 
+01504                         c = (IObjectIA *)_AgentManager->getAgentContext();
+01505                 else 
+01506                         c = NULL;
+01507 
+01508                 IMailBox *mail = getMail();
+01509 
+01510                 
+01511                 //const IMailBox::tListMessage &l = mail->getMesseageListe();
+01512                 sint n = mail->size();
+01513 
+01514                 while(/*l.begin() != l.end()*/n--)
+01515                 {
+01516                         IMessageBase &msg = (IMessageBase &)mail->getMessage();
+01517 #ifdef NL_DEBUG
+01518                 const char *dbg_this = (const char *) getType();
+01519                 const char *dbg_msg = (const char *) msg.getType();
+01520 #endif
+01521                         
+01522                         if(msg.getMethodIndex() >= 0 && c != NULL)
+01523                         {
+01524                                 sint indexM = msg.getMethodIndex() - IAgent::getMethodIndexSize();
+01525                                 IObjectIA *o;
+01526                                 if(indexM != CAgentScript::TDeflautProccessMsg) processMessages(&msg,c);
+01527                                 else 
+01528                                 {
+01529                                         o = IBasicAgent::run( msg );
+01530                                         if(o != NULL) o->release();
+01531                                 }
+01532                                 if ( mail->size() != 0 )
+01533                                         mail->popMessage();
+01534                         }
+01535                         else 
+01536                         {
+01537                                 try
+01538                                 {
+01539                                         IObjectIA *o = IBasicAgent::run( msg );
+01540                                         if (o != NULL) 
+01541                                                 o->release();
+01542                                         mail->popMessage();
+01543                                 }
+01544                                 catch(NLAIE::CExceptionNotImplemented &e)
+01545                                 {
+01546                                         mail->popMessage();
+01547                                         throw NLAIE::CExceptionNotImplemented(e.what());
+01548                                 }
+01549                         }                       
+01550                 }
+01551         }
+01552 
+01553         IObjectIA::CProcessResult CAgentScript::runActivity()
+01554         {
+01555                 
+01556                 NLAISCRIPT::CCodeContext *context = (NLAISCRIPT::CCodeContext *)_AgentManager->getAgentContext();
+01557                 context->Self = this;
+01558                 if(_AgentClass->getRunMethod() >= 0) runMethodeMember(_AgentClass->getRunMethod(), context);
+01559                 
+01560                 return ProcessRun;
+01561         }
+01562 
+01563         bool CAgentScript::haveActivity() const
+01564         {
+01565                 return _AgentClass != NULL && (_AgentClass->getRunMethod() >= 0);
+01566         }
+01567 
+01568 
+01569 #ifdef PROFILE
+01570         NLMISC::TTicks TimeRun = 0;
+01571         NLMISC::TTicks NbRun = 0;
+01572 #endif
+01573 
+01574         const IObjectIA::CProcessResult &CAgentScript::run()
+01575         {
+01576                 
+01577 #ifdef NL_DEBUG
+01578                 const char *dbg_class_name = (const char *) getType();
+01579                 //const NLAIAGENT::IRefrence *dbg_mail_parent = _ScriptMail->getParent();
+01580 #endif
+01581 
+01582 #ifdef PROFILE
+01583                 NLMISC::TTicks time = NLMISC::CTime::getPerformanceTime();
+01584 #endif
+01585 
+01586                 const IObjectIA::CProcessResult &r = IAgentManager::run();
+01587 
+01588 #ifdef PROFILE
+01589                 time = NLMISC::CTime::getPerformanceTime() - time;
+01590                 //if(time)
+01591                 {
+01592                         TimeRun = time;
+01593                         NbRun = 1;              
+01594                 }
+01595 #endif
+01596 
+01597                 return r;
+01598                                 
+01599         }
+01600 
+01601         const IObjectIA::CProcessResult &CAgentScript::runStep()
+01602         {
+01603                 
+01604 #ifdef NL_DEBUG
+01605                 const char *dbg_class_name = (const char *) getType();
+01606                 //const NLAIAGENT::IRefrence *dbg_mail_parent = _ScriptMail->getParent();
+01607 #endif
+01608 
+01609                 return IAgentManager::runStep();
+01610                                 
+01611         }
+01612 
+01613         void CAgentScript::addOperator(NLAILOGIC::IBaseOperator *op)
+01614         {
+01615 //              _Operators.push_back(op);
+01616         }
+01617 
+01618         void CAgentScript::remOperator(NLAILOGIC::IBaseOperator *op)
+01619         {
+01620 /*              std::vector<NLAILOGIC::IBaseOperator *>::iterator it_o = _Operators.begin();
+01621                 while ( it_o != _Operators.end() )
+01622                 {
+01623                         if ( op == *it_o )
+01624                         {
+01625                                 _Operators.erase( it_o );
+01626                                 return;
+01627                         }
+01628                         it_o++;
+01629                 }
+01630                 char buf[2048];
+01631                 op->getDebugString(buf);
+01632                 throw NLAIE::CExceptionObjectNotFoundError(buf);
+01633                 */
+01634         }       
+01635 
+01636         const NLAIC::CIdentType &CAgentScript::getType() const
+01637         {
+01638                 if ( _AgentClass ) 
+01639                         return _AgentClass->getType();
+01640                 else
+01641                         return IdAgentScript;
+01642         }
+01643 
+01644         IObjectIA::CProcessResult CAgentScript::runMethodBase(int heritance, int index,IObjectIA *o)
+01645         {
+01646                 switch(index - IAgent::getMethodIndexSize())
+01647                 {
+01648                 case TSend:
+01649                         {
+01650                                 return sendMethod(o);
+01651                         }
+01652 
+01653                 case TSendComponent:
+01654                         {
+01655                                 return sendMethodCompoment(o);
+01656                         }
+01657 
+01658                 case TGetChildTag:
+01659                         {
+01660                                 return getDynamicAgent((IBaseGroupType *)o);
+01661                         }
+01662 
+01663                 case TAddChildTag:
+01664                         {
+01665                                 return addDynamicAgent((IBaseGroupType *)o);
+01666                         }
+01667 
+01668                 case TFather:
+01669                         {
+01670                                 IObjectIA::CProcessResult a;
+01671                                 a.Result = (IObjectIA *)getParent();
+01672                                 a.Result->incRef();
+01673                                 return a;
+01674                         }
+01675 
+01676                 case TSelf:
+01677                         {
+01678                                 IObjectIA::CProcessResult a;
+01679                                 a.Result = new CLocalAgentMail(this);
+01680                                 return a;
+01681                         }
+01682 
+01683                 case TGetName:
+01684                         {               
+01685                                 IObjectIA::CProcessResult r;
+01686                                 const CAgentScript *p = (CAgentScript *)getParent();
+01687                                 tsetDefNameAgent::iterator i = p->_DynamicAgentName.begin();
+01688 
+01689                                 while(i != p->_DynamicAgentName.end())
+01690                                 {
+01691                                         CKeyAgent key = *i;
+01692                                         if( this == *key.Itr )
+01693                                         {
+01694                                                 CStringType *s = new CStringType(key.Name);
+01695                                                 r.Result = s;
+01696                                                 return r;
+01697                                         }
+01698                                         i ++;
+01699                                 }
+01700                                 r.Result = new CStringType(CStringVarName("Unknown"));
+01701                                 
+01702                                 return r;
+01703                         }
+01704 
+01705                 case TGetClassName:
+01706                         {
+01707                                 IObjectIA::CProcessResult r;
+01708                                 if ( _AgentClass != NULL )
+01709                                 {
+01710                                         const NLAIAGENT::IVarName *classname = getClassName();
+01711                                         r.Result = new CStringType( *classname );
+01712                                 }
+01713                                 else
+01714                                         r.Result = new CStringType( CStringVarName("<unknown>"));                               
+01715                                 return r;
+01716                         }
+01717 
+01718                 case TIsInherited:
+01719                         {
+01720                                 IObjectIA::CProcessResult r;
+01721                                 if ( _AgentClass != NULL )
+01722                                 {
+01723                                         CGroupType *param = (CGroupType *) o;
+01724                                         CStringType *comp_name = (CStringType *)((IBaseGroupType *)param)->popFront();
+01725                                         if ( isClassInheritedFrom( comp_name->getStr() ) != -1 )
+01726                                                 r.Result = new NLAILOGIC::CBoolType( true );
+01727                                         else
+01728                                                 r.Result = new NLAILOGIC::CBoolType( false );
+01729                                 }
+01730                                 else
+01731                                         r.Result = new NLAILOGIC::CBoolType( false );
+01732                                 
+01733                                 return r;
+01734                         }
+01735 
+01736                 case TRemoveChild:
+01737                         {
+01738                                 return removeDynamic((IBaseGroupType *)o);
+01739                         }
+01740 
+01741                 case TRunAskParentNotify:
+01742                         {                               
+01743                                 return runAskParentNotify((IBaseGroupType *)o);
+01744                         }
+01745 
+01746                 case TRunTellParentNotify:
+01747                         {                               
+01748                                 return runTellParentNotify((IBaseGroupType *)o);
+01749                         }
+01750 
+01751                 case TRunAskComponent:
+01752                 case TRunTellComponent:
+01753                         {                               
+01754                                 return runTellComponent((IBaseGroupType *)o);
+01755                         }
+01756 
+01757 
+01758                 case TSetStatic:
+01759                         {
+01760                                 CGroupType *param = (CGroupType *) o;
+01761                                 CStringType *comp_name = (CStringType *)((IBaseGroupType *)param)->popFront();
+01762                                 IObjectIA *value = (IObjectIA *)((IBaseGroupType *)param)->popFront();
+01763                                 int index = _AgentClass->getComponentIndex(  comp_name->getStr()  );
+01764                                 _AgentClass->updateStaticMember(index, value);
+01765                                 return IObjectIA::CProcessResult();
+01766                         }
+01767 
+01768                 case TGetValue:
+01769                         {
+01770                                 return runAskGetValue( (IBaseGroupType *) o );
+01771                         }
+01772 
+01773                 case TSetValue:
+01774                         {
+01775                                 return runTellSetValue( (IBaseGroupType *) o );
+01776                         }
+01777 
+01778                 case TInitComponent:
+01779                         {
+01780                                 return runInitComponent( (IBaseGroupType *) o );
+01781                         }
+01782 
+01783 
+01784                 default:
+01785                         return IAgent::runMethodeMember(index,o);
+01786                                 
+01787                 }               
+01788         }
+01789 
+01790         IObjectIA::CProcessResult CAgentScript::runMethodBase(int index,IObjectIA *o)
+01791         {               
+01792                 switch(index - IAgent::getMethodIndexSize())
+01793                 {
+01794                 case TSend:
+01795                         {
+01796                                 return sendMethod(o);
+01797                         }
+01798 
+01799                 case TSendComponent:
+01800                         {
+01801                                 return sendMethodCompoment(o);
+01802                         }
+01803 
+01804                 case TGetChildTag:
+01805                         {
+01806                                 return getDynamicAgent((IBaseGroupType *)o);
+01807                         }
+01808 
+01809                 case TAddChildTag:
+01810                         {
+01811                                 return addDynamicAgent((IBaseGroupType *)o);
+01812                         }
+01813                 case TFather:
+01814                         {
+01815                                 IObjectIA::CProcessResult a;
+01816                                 a.Result = (IObjectIA *)getParent();
+01817                                 //if(a.Result != NULL) 
+01818                                 a.Result->incRef();
+01819                                 return a;
+01820                         }
+01821 
+01822                 case TSelf:
+01823                         {
+01824                                 IObjectIA::CProcessResult a;
+01825                                 a.Result = new CLocalAgentMail(this);
+01826                                 return a;
+01827                         }
+01828                 case TGetName:
+01829                         {
+01830                                 IObjectIA::CProcessResult r;
+01831                                 const CAgentScript *p = (CAgentScript *)getParent();
+01832                                 tsetDefNameAgent::iterator i = p->_DynamicAgentName.begin();
+01833 
+01834                                 while(i != p->_DynamicAgentName.end())
+01835                                 {
+01836                                         CKeyAgent key = *i;
+01837                                         if( this == *key.Itr )
+01838                                         {
+01839                                                 CStringType *s = new CStringType(key.Name);
+01840                                                 r.Result = s;
+01841                                                 return r;
+01842                                         }
+01843                                         i ++;
+01844                                 }
+01845                                 r.Result = new CStringType(CStringVarName("Unknown"));
+01846                                 return r;
+01847                         }
+01848 
+01849                 case TGetClassName:
+01850                         {
+01851                                 IObjectIA::CProcessResult r;
+01852                                 const NLAIAGENT::IVarName *classname = getClassName();
+01853                                 r.Result = new CStringType( *classname );
+01854 
+01855                                 r.Result->incRef();
+01856                                 return r;
+01857                         }
+01858 
+01859                 case TIsInherited:
+01860                         {
+01861                                 IObjectIA::CProcessResult r;
+01862                                 if ( _AgentClass != NULL )
+01863                                 {
+01864                                         CGroupType *param = (CGroupType *) o;
+01865                                         CStringType *comp_name = (CStringType *)((IBaseGroupType *)param)->popFront();
+01866                                         if ( isClassInheritedFrom( comp_name->getStr() ) != -1 )
+01867                                                 r.Result = new NLAILOGIC::CBoolType( true );
+01868                                         else
+01869                                                 r.Result = new NLAILOGIC::CBoolType( false );
+01870                                         
+01871                                 }
+01872                                 else
+01873                                         r.Result = new NLAILOGIC::CBoolType( false );
+01874 
+01875                                 r.Result->incRef();
+01876                                 return r;
+01877                         }
+01878 
+01879                 case TRunAskParentNotify:
+01880                         {                               
+01881                                 return runAskParentNotify((IBaseGroupType *)o);
+01882                         }
+01883 
+01884                 case TRunTellParentNotify:
+01885                         {                               
+01886                                 return runTellParentNotify((IBaseGroupType *)o);
+01887                         }
+01888 
+01889                 case TRunAskComponent:
+01890                 case TRunTellComponent:
+01891                         {                               
+01892                                 return runTellComponent((IBaseGroupType *)o);
+01893                         }
+01894                 case TSetStatic:
+01895                         {
+01896                                 CGroupType *param = (CGroupType *) o;
+01897                                 CStringType *comp_name = (CStringType *)((IBaseGroupType *)param)->popFront();
+01898                                 IObjectIA *value = (IObjectIA *)((IBaseGroupType *)param)->popFront();
+01899                                 int index = _AgentClass->getInheritedStaticMemberIndex( comp_name->getStr() );
+01900                                 _AgentClass->updateStaticMember(index, value);
+01901                                 IObjectIA::CProcessResult a;
+01902                                 a.Result = NULL;
+01903                                 return a;
+01904                         }
+01905 
+01906                 case TGetValue:
+01907                         {
+01908                                 return runAskGetValue( (IBaseGroupType *) o );
+01909                         }
+01910 
+01911                 case TSetValue:
+01912                         {
+01913                                 return runTellSetValue( (IBaseGroupType *) o );
+01914                         }
+01915 
+01916                 case TInitComponent:
+01917                         {
+01918                                 return runInitComponent( (IBaseGroupType *) o );
+01919                         }
+01920 
+01921                 case TIsEUU:
+01922                         {
+01923                                 CGroupType *param = (CGroupType *) o;
+01924                                 std::string s(((NLAIAGENT::CStringType *)param->get())->getStr().getString());
+01925                                 NLAIAGENT::IObjectIA::CProcessResult r;
+01926                                 
+01927                                 if(isa(s))                              
+01928                                         r.Result = new NLAIAGENT::DigitalType(1.0);                             
+01929                                 else
+01930                                         r.Result = new NLAIAGENT::DigitalType(0.0);
+01931                                 return r;
+01932                         }                       
+01933 
+01934                 case TAddSet:
+01935                         {
+01936                                 CGroupType *param = (CGroupType *) o;
+01937                                 std::string s(((NLAIAGENT::CStringType *)param->get())->getStr().getString());                          
+01938                                 addSet(s);
+01939 
+01940                                 return NLAIAGENT::IObjectIA::CProcessResult();
+01941                         }                       
+01942 
+01943                 default:
+01944                         return IAgent::runMethodeMember(index,o);
+01945                 }
+01946         }
+01947 
+01948         std::string CAgentScript::getMethodeMemberDebugString(sint32 h, sint32 id) const
+01949         {
+01950                 int i = id - getBaseMethodCount();
+01951                 if(i >= 0)
+01952                 {
+01953                         std::string name;
+01954                         if(h)
+01955                         {
+01956                                 _AgentClass->getBrancheCode(h,i).getName().getDebugString(name);
+01957                                 _AgentClass->getBrancheCode(h,i).getParam().getDebugString(name);
+01958                         }
+01959                         else
+01960                         {
+01961                                 _AgentClass->getBrancheCode(i).getName().getDebugString(name);
+01962                                 _AgentClass->getBrancheCode(i).getParam().getDebugString(name);
+01963                         }
+01964                         return name;
+01965                 }
+01966 
+01967                 switch(id - IAgent::getMethodIndexSize())
+01968                 {
+01969                 case TSend:
+01970                         {
+01971                                 return std::string("CAgentScript::sendMessage(IMessage)");
+01972                         }
+01973 
+01974                 case TSendComponent:
+01975                         {
+01976                                 return std::string("CAgentScript::sendMessage(String,IMessage)");                               
+01977                         }
+01978 
+01979                 case TGetChildTag:
+01980                         {
+01981                                 return std::string("CAgentScript::getDynamicAgent(String)");
+01982                         }
+01983 
+01984                 case TAddChildTag:
+01985                         {
+01986                                 return std::string("CAgentScript::addDynamicAgent(String,IAgent)");                             
+01987                         }
+01988                 case TFather:
+01989                         {
+01990                                 return std::string("CAgentScript::Father()");                           
+01991                         }
+01992 
+01993                 case TSelf:
+01994                         {
+01995                                 return std::string("CAgentScript::Self()");
+01996                         }
+01997                 case TGetName:
+01998                         {                               
+01999                                 return std::string("CAgentScript::GetAgentName()");
+02000                         }
+02001 
+02002                 case TRunAskParentNotify:
+02003                         {       
+02004                                 return std::string("CAgentScript::runAskParentNotify(CNotifyParent)");
+02005                         }
+02006 
+02007                 case TRunTellParentNotify:
+02008                         {                               
+02009                                 return std::string("CAgentScript::runTellarentNotify(CNotifyParent)");
+02010                         }
+02011 
+02012                 case TRunAskComponent:
+02013                 case TRunTellComponent:
+02014                         {                               
+02015                                 return std::string("CAgentScript::runTell/AskCompoment(MsgTellCompoment)");
+02016                         }
+02017                 case TSetStatic:
+02018                         {                                                               
+02019                                 return std::string("CAgentScript::updateStaticMember(String, IObjectIA *)");                            
+02020                         }
+02021 
+02022                 case TGetValue:
+02023                         {                               
+02024                                 return std::string("CAgentScript::runAskGetValue(MsgGetValue)");
+02025                         }
+02026 
+02027                 case TSetValue:
+02028                         {                               
+02029                                 return std::string("CAgentScript::runTellSetValue(MsgGetValue)");
+02030                         }
+02031 
+02032                 case TInitComponent:
+02033                         {                               
+02034                                 return std::string("CAgentScript::runInitComponent(MsgGetValue)");
+02035                         }
+02036 
+02037 
+02038                 default:
+02039                         return IAgentManager::getMethodeMemberDebugString(h,id);                
+02040                 }               
+02041         }
+02042 
+02043         int CAgentScript::getBaseMethodCount() const
+02044         {
+02045                 return IAgentManager::getBaseMethodCount() + CAgentScript::TLastM;
+02046         }
+02047 
+02048         IObjectIA::CProcessResult CAgentScript::runMethodeMember(sint32 inheritance, sint32 index, IObjectIA *c)        
+02049         {
+02050 
+02051                 if(c->getType() != NLAISCRIPT::CCodeContext::IdCodeContext)
+02052                 {
+02053                         return IAgent::runMethodeMember(inheritance,index, c);
+02054                 }
+02055                 
+02056                 NLAISCRIPT::IOpCode *opPtr = NULL;
+02057                 NLAISCRIPT::CCodeContext &context = (NLAISCRIPT::CCodeContext &)*c;
+02058 
+02059                 int i = index - getBaseMethodCount();
+02060                 if(i < 0)
+02061                 {                       
+02062                         /*if (context.ContextDebug.Active)
+02063                         {
+02064                                 context.ContextDebug.Param.push_back(&listBidon);
+02065                                 listBidon.incRef();
+02066                         }*/
+02067                 
+02068                         IObjectIA::CProcessResult r = runMethodBase(index,(IObjectIA *)context.Param.back());
+02069                         if(r.Result != NULL)
+02070                         {
+02071                                 context.Stack++;
+02072                                 context.Stack[(int)context.Stack] = r.Result;
+02073                         }
+02074                         r.Result = NULL;
+02075                         return r;
+02076                 }
+02077                 else
+02078                 {
+02079                         opPtr = getMethode(inheritance,i);
+02080                 }
+02081                 
+02082                 IObjectIA::CProcessResult r;
+02083                 if(opPtr != NULL)
+02084                 {
+02085 #ifdef NL_DEBUG
+02086                 std::string nameDbg;
+02087                 _AgentClass->getBrancheCode(inheritance,i).getName().getDebugString(nameDbg);
+02088                 _AgentClass->getBrancheCode(inheritance,i).getParam().getDebugString(nameDbg);
+02089 #endif
+02090                         NLAISCRIPT::IOpCode &op = *opPtr;
+02091                         NLAISCRIPT::CCodeBrancheRun *opTmp = context.Code;
+02092                         int ip = (uint32)*context.Code;
+02093                         context.Code = (NLAISCRIPT::CCodeBrancheRun *)&op;              
+02094                         *context.Code = 0;
+02095 
+02096                         r = ((NLAISCRIPT::ICodeBranche *)opPtr)->run(context);
+02097                         // If we are in Debug Mode
+02098                         if (context.ContextDebug.Active)
+02099                         {
+02100                                 context.ContextDebug.callStackPop();
+02101                         }
+02102                         *context.Code = ip;
+02103                         context.Code = opTmp;           
+02104                 }
+02105                 return r;
+02106         }
+02107 
+02108         IObjectIA::CProcessResult CAgentScript::runMethodeMember(sint32 index, IObjectIA *c)    
+02109         {
+02110                 if(c->getType() != NLAISCRIPT::CCodeContext::IdCodeContext)
+02111                 {
+02112                         return IAgent::runMethodeMember(index, c);
+02113                 }
+02114 
+02115                 NLAISCRIPT::IOpCode *opPtr = NULL;
+02116                 NLAISCRIPT::CCodeContext &context = (NLAISCRIPT::CCodeContext &)*c;
+02117 
+02118                 int i = index - getBaseMethodCount();
+02119                 if(i < 0)
+02120                 {
+02121                         /*if (context.ContextDebug.Active)
+02122                         {
+02123                                 context.ContextDebug.Param.push_back(&listBidon);
+02124                                 listBidon.incRef();
+02125                         }*/
+02126 
+02127                         IObjectIA::CProcessResult r = runMethodBase(index,(IObjectIA *)context.Param.back());
+02128                         if(r.Result != NULL)
+02129                         {
+02130                                 context.Stack++;
+02131                                 context.Stack[(int)context.Stack] = r.Result;
+02132                         }
+02133                         r.Result = NULL;
+02134                         return r;
+02135                 }
+02136                 else
+02137                 {
+02138                         opPtr = getMethode(i);
+02139                 }
+02140                 IObjectIA::CProcessResult r;
+02141                 if(opPtr != NULL)
+02142                 {
+02143                         NLAISCRIPT::CCodeBrancheRun *opTmp = context.Code;
+02144                         int ip;
+02145                         if(context.Code != NULL) ip = (uint32)*context.Code;
+02146                         else ip =0;
+02147                         context.Code = (NLAISCRIPT::CCodeBrancheRun *)opPtr;
+02148                         *context.Code = 0;
+02149                         
+02150                         r = ((NLAISCRIPT::ICodeBranche *)opPtr)->run(context);
+02151 
+02152                         // If we are in Debug Mode
+02153                         if (context.ContextDebug.Active)
+02154                         {
+02155                                 context.ContextDebug.callStackPop();
+02156                         }
+02157 
+02158                         *context.Code = ip;
+02159                         context.Code = opTmp;           
+02160                 }
+02161                 return r;
+02162         }
+02163 
+02164         tQueue CAgentScript::getPrivateMember(const IVarName *className,const IVarName *methodName,const IObjectIA &param) const
+02165         {               
+02166 
+02167 #ifdef NL_DEBUG
+02168                 const char *dgb_meth_name = methodName->getString();
+02169 #endif
+02170                 return isTemplateMember(CAgentScript::StaticMethod,CAgentScript::TLastM,IAgent::getMethodIndexSize(),className,methodName,param);               
+02171         }
+02172 
+02173         tQueue CAgentScript::isMember(const IVarName *className,const IVarName *methodName,const IObjectIA &param) const
+02174         {
+02175                 
+02176 
+02177                 if(className == NULL)
+02178                 {
+02179 
+02180                         tQueue r;
+02181                         if(_AgentClass != NULL) 
+02182                                 r = _AgentClass->getPrivateMember(className,methodName,param);                  
+02183 
+02184                         if(r.size()) 
+02185                                 return r;
+02186                         else
+02187                         {
+02188                                 r = getPrivateMember(className,methodName,param);
+02189                                 if(r.size()) return r;
+02190                                 else
+02191                                 {
+02192                                         r = IAgent::isMember(className,methodName,param);
+02193                                         if(r.size())
+02194                                                 return r;
+02195                                         else
+02196                                                 return isDeflautProccessMsg(className,methodName,param);
+02197                                 }
+02198                         }
+02199                 
+02200                 }               
+02201                 else 
+02202                 if(*className == CStringVarName("Agent"))
+02203                 {                                       
+02204                         tQueue r;
+02205                         r = getPrivateMember(className,methodName,param);
+02206                         if(r.size()) 
+02207                                 return r;
+02208                         else
+02209                         {
+02210                                 r = _AgentClass->getPrivateMember(className,methodName,param);                  
+02211 
+02212                                 if ( r.size() ) 
+02213                                         return r;
+02214                                 else
+02215                                 {                       
+02216                                         r = IAgent::isMember(className,methodName,param);
+02217                                         if(r.size())
+02218                                                 return r;
+02219                                         else
+02220                                                 return isDeflautProccessMsg(className,methodName,param);
+02221                                 }
+02222                         }
+02223                         
+02224                 }
+02225                 return tQueue();
+02226         }
+02227 
+02228         tQueue CAgentScript::isDeflautProccessMsg(const IVarName *className,const IVarName *methodName,const IObjectIA &param) const
+02229         {
+02230                 const char *name = methodName->getString();
+02231                 if(name[0] == 'R' && name[1] == 'u' && name[2] == 'n')
+02232                 {
+02233                         static CStringVarName runMsgName[7] = {"RunTell", "RunAchieve", "RunAsk", "RunExec", "RunBreak", "RunKill", "RunError"};
+02234                         sint i;
+02235                         for(i = 0; i < 7; i ++)
+02236                         {
+02237                                 if(*methodName == runMsgName[i])
+02238                                 {
+02239                                         tQueue r;                       
+02240                                         CObjectType *c = new CObjectType(new NLAIC::CIdentType(NLAIC::CIdentType::VoidType));
+02241                                         r.push(CIdMethod(TDeflautProccessMsg + IAgent::getMethodIndexSize(),0.0,NULL,c));
+02242                                         return r;
+02243                                 }
+02244                         }
+02245                 }
+02246 
+02247                 return tQueue();
+02248         }
+02249 
+02250         sint32 CAgentScript::isClassInheritedFrom(const IVarName &name) const
+02251         {
+02252                 return _AgentClass->isClassInheritedFrom( name );
+02253         }       
+02254 
+02255         sint32 CAgentScript::getStaticMemberIndex(const IVarName &name) const
+02256         {
+02257                 return _AgentClass->getInheritedStaticMemberIndex(name);
+02258         }
+02259 
+02260         NLAIAGENT::tQueue isTemplateMember(     CAgentScript::CMethodCall **StaticMethod,int count,int shift,
+02261                                                                                                 const NLAIAGENT::IVarName *className,
+02262                                                                                                 const NLAIAGENT::IVarName *methodName,
+02263                                                                                                 const NLAIAGENT::IObjectIA &param)
+02264         {
+02265                 int index = count;
+02266                 int i;
+02267 
+02268                 for(i = 0; i < count; i ++)
+02269                 {
+02270                         if(StaticMethod[i]->MethodName == *methodName)
+02271                         {
+02272                                 index = StaticMethod[i]->Index;
+02273                                 switch(StaticMethod[i]->CheckArgType)
+02274                                 {
+02275                                 case CAgentScript::CheckAll:
+02276                                         {
+02277                                                 double d = ((NLAISCRIPT::CParam &)*StaticMethod[i]->ArgType).eval((NLAISCRIPT::CParam &)param);
+02278                                                 if(d >= 0.0)
+02279                                                 {                                                               
+02280                                                         NLAIAGENT::tQueue r;
+02281                                                         StaticMethod[i]->ReturnValue->incRef();
+02282                                                         r.push(NLAIAGENT::CIdMethod(    (shift + StaticMethod[i]->Index),
+02283                                                                                                                         0.0,
+02284                                                                                                                         NULL,
+02285                                                                                                                         StaticMethod[i]->ReturnValue));
+02286                                                         return r;
+02287                                                 }
+02288                                         }       
+02289                                         index = count;
+02290                                         break;
+02291                                 
+02292 
+02293                                 case CAgentScript::CheckCount:
+02294                                         {
+02295                                                 if(((NLAISCRIPT::CParam &)param).size() == StaticMethod[i]->ArgCount)
+02296                                                 {                                                               
+02297                                                         NLAIAGENT::tQueue r;
+02298                                                         StaticMethod[i]->ReturnValue->incRef();
+02299                                                         r.push(NLAIAGENT::CIdMethod(    (shift + StaticMethod[i]->Index),
+02300                                                                                                                         0.0,
+02301                                                                                                                         NULL,
+02302                                                                                                                         StaticMethod[i]->ReturnValue ));
+02303                                                         return r;
+02304                                                 }
+02305                                         }
+02306                                         index = count;
+02307                                         break;
+02308 
+02309                                 case CAgentScript::DoNotCheck:
+02310                                         {                                                       
+02311                                                 NLAIAGENT::tQueue r;
+02312                                                 StaticMethod[i]->ReturnValue->incRef();
+02313                                                 r.push(NLAIAGENT::CIdMethod(    (shift + StaticMethod[i]->Index),
+02314                                                                                                                 0.0,
+02315                                                                                                                 NULL,
+02316                                                                                                                 StaticMethod[i]->ReturnValue));
+02317                                                 return r;                                               
+02318                                         }
+02319                                         index = count;
+02320                                         break;
+02321                                 }
+02322                         }
+02323                 }               
+02324                 return NLAIAGENT::tQueue();
+02325         }
+02326 
+02327         void CAgentScript::createComponents(std::list<IObjectIA *> &components)
+02328         {
+02329                 _NbComponents = components.size();
+02330                 if ( _NbComponents )
+02331                 {
+02332                         _Components = new IObjectIA *[ _NbComponents ];
+02333                         std::list<IObjectIA *>::iterator it_c = components.begin();
+02334                         int id_c = 0;
+02335                         while ( it_c != components.end() )
+02336                         {
+02337                                 IObjectIA *o = (IObjectIA *)*it_c;
+02338                                 _Components[id_c] = o;
+02339 
+02340                                 uint b = NLAIC::CTypeOfObject::tInterpret | NLAIC::CTypeOfObject::tAgent;
+02341                                 const NLAIC::CTypeOfObject &t = o->getType();
+02342 
+02343                                 if((t.getValue() & b) == b)
+02344                                 {
+02345                                         ((CAgentScript *)o)->setParent( (const IWordNumRef *) *this);
+02346                                 }
+02347 
+02348                                 it_c++;
+02349                                 id_c++;
+02350                         }               
+02351                 }
+02352                 else
+02353                         _Components = NULL;
+02354         }
+02355 
+02356         void CAgentScript::callConstructor()
+02357         {
+02358                 NLAIAGENT::CStringVarName constructor_func_name("Constructor");
+02359                 sint32 id_func = getClass()->findMethod( constructor_func_name, NLAISCRIPT::CParam() );
+02360 
+02361 #ifdef NL_DEBUG
+02362 
+02363                 const char * ttt = (const char *) getType();
+02364 #endif
+02365                 if ( id_func != -1 )
+02366                 {       
+02367                         NLAISCRIPT::CStackPointer stack;
+02368                         NLAISCRIPT::CStackPointer heap;
+02369                         NLAISCRIPT::CCodeContext codeContext(stack, heap, NULL, this, NLAISCRIPT::CCallPrint::inputOutput);
+02370                         codeContext.Self = this;
+02371                         NLAISCRIPT::CCodeBrancheRun *o = (NLAISCRIPT::CCodeBrancheRun *) getClass()->getBrancheCode( id_func ).getCode();                       
+02372                         codeContext.Code = o;
+02373                         int ip;
+02374                         if(codeContext.Code != NULL) ip = (uint32)*codeContext.Code;
+02375                         else ip =0;
+02376 
+02377                         *codeContext.Code = 0;
+02378 
+02379                         (void)o->run(codeContext);
+02380 
+02381                         *codeContext.Code = ip;
+02382 
+02383                 }
+02384         }
+02385 
+02386         void CAgentScript::callFunction(std::string &f_name, NLAIAGENT::IObjectIA *p)
+02387         {
+02388                 NLAIAGENT::CStringVarName func_name( f_name.c_str() );
+02389                 sint32 id_func = getClass()->findMethod( func_name, NLAISCRIPT::CParam() );
+02390 
+02391 #ifdef NL_DEBUG
+02392                 const char * ttt = (const char *) getType();
+02393 #endif
+02394                 if ( id_func != -1 )
+02395                 {       
+02396                         NLAISCRIPT::CStackPointer stack;
+02397                         NLAISCRIPT::CStackPointer heap;
+02398                         NLAISCRIPT::CCodeContext codeContext(stack, heap, NULL, this, NLAISCRIPT::CCallPrint::inputOutput);
+02399                         codeContext.Self = this;
+02400                         NLAISCRIPT::CCodeBrancheRun *o = (NLAISCRIPT::CCodeBrancheRun *) getClass()->getBrancheCode( id_func ).getCode();                       
+02401                         codeContext.Code = o;
+02402                         int ip;
+02403                         if(codeContext.Code != NULL) ip = (uint32)*codeContext.Code;
+02404                         else ip =0;
+02405 
+02406                         *codeContext.Code = 0;
+02407 
+02408                         (void)o->run(codeContext);
+02409 
+02410                         *codeContext.Code = ip;
+02411 
+02412                 }
+02413         }
+02414 }
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1