# 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  

interpret_object_message.cpp

Go to the documentation of this file.
00001 
00006 /* Copyright, 2000 Nevrax Ltd.
00007  *
00008  * This file is part of NEVRAX NEL.
00009  * NEVRAX NEL is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2, or (at your option)
00012  * any later version.
00013 
00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * General Public License for more details.
00018 
00019  * You should have received a copy of the GNU General Public License
00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00022  * MA 02111-1307, USA.
00023  */
00024 #include "nel/ai/c/registry_class.h"
00025 #include "nel/ai/agent/message_script.h"
00026 #include "nel/ai/script/lexsupport.h"
00027 
00028 #include "nel/ai/script/interpret_object_message.h"
00029 #include "nel/ai/agent/msg_notify.h"
00030 #include "nel/ai/agent/msg_goal.h"
00031 #include "nel/ai/agent/msg_fact.h"
00032 #include "nel/ai/agent/msg_debug.h"
00033 #include "nel/ai/agent/msg_on_change.h"
00034 #include "nel/ai/c/registry_type.h"
00035 
00036 namespace NLAISCRIPT
00037 {
00038         //###############################
00039         //CMessageClass
00040         //###############################
00041         CMessageClass::CMessageClass(const NLAIAGENT::IVarName &n) : CAgentClass(n)
00042         {
00043                 if ( _IdType != NULL )
00044                         _IdType->addObjectType( NLAIC::CTypeOfObject::tMessage );
00045                 setBaseMethodCount(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass()))->getBaseMethodCount());         
00046                 setBaseObjectInstance(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass())));            
00047         }
00048         
00049         CMessageClass::CMessageClass(const NLAIC::CIdentType &id): CAgentClass(id)
00050         {
00051                 if ( _IdType != NULL )
00052                         _IdType->addObjectType( NLAIC::CTypeOfObject::tMessage );
00053                 setBaseMethodCount(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass()))->getBaseMethodCount());
00054                 setBaseObjectInstance(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass())));            
00055         }
00056 
00057         CMessageClass::CMessageClass(const NLAIAGENT::IVarName &n, const NLAIAGENT::IVarName &inheritance) : CAgentClass( inheritance )
00058         {
00059                 if ( _IdType != NULL )
00060                         _IdType->addObjectType( NLAIC::CTypeOfObject::tMessage );
00061                 setBaseMethodCount(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass()))->getBaseMethodCount());
00062                 setBaseObjectInstance(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass())));            
00063         }
00064 
00065         CMessageClass::CMessageClass(const CMessageClass &c) : CAgentClass( c )
00066         {
00067                 if ( _IdType != NULL )
00068                         _IdType->addObjectType( NLAIC::CTypeOfObject::tMessage );
00069                 setBaseMethodCount(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass()))->getBaseMethodCount());
00070                 setBaseObjectInstance(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass())));            
00071         }       
00072 
00073         CMessageClass::CMessageClass()
00074         {
00075                 if ( _IdType != NULL )
00076                         _IdType->addObjectType( NLAIC::CTypeOfObject::tMessage );
00077                 setBaseMethodCount(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass()))->getBaseMethodCount());
00078                 setBaseObjectInstance(((NLAIAGENT::CMessageScript *)(NLAIAGENT::CMessageScript::IdMessageScript.getFactory()->getClass())));
00079         }
00080 
00081 
00082         const NLAIC::IBasicType *CMessageClass::clone() const
00083         {
00084                 NLAIC::IBasicType *clone = new CMessageClass(*this);
00085                 return clone;
00086         }
00087 
00088         const NLAIC::IBasicType *CMessageClass::newInstance() const
00089         {
00090                 NLAIC::IBasicType *instance = new CMessageClass();
00091                 return instance;
00092         }
00093 
00094         void CMessageClass::getDebugString(std::string &t) const
00095         {
00096         }
00097 
00098         NLAIAGENT::IObjectIA *CMessageClass::buildNewInstance() const
00099         {
00100                 // Création des composants statiques
00101                 std::list<NLAIAGENT::IObjectIA *> components;
00102                 createBaseClassComponents( components );
00103 
00104                 // Création du message
00105                 NLAIAGENT::CMessageScript *instance = new NLAIAGENT::CMessageScript( components,  (CMessageClass *) this );
00106                 return instance;
00107         }
00108 
00109         const NLAIC::CIdentType &CMessageClass::getType() const
00110         {
00111                 /*if ( _IdType != NULL )
00112                         _IdType->addObjectType( NLAIC::CTypeOfObject::tMessage );*/
00113 
00114                 return *_IdType;
00115         }               
00116 
00117         CMessageClass::~CMessageClass()
00118         {
00119         }
00120 
00121 //#########################################
00122 //              CMsgNotifyParentClass
00123 //#########################################
00124         CMsgNotifyParentClass::CMsgNotifyParentClass(const NLAIAGENT::IVarName &s):CMessageClass(s)
00125         {
00126                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CNotifyParentScript::IdNotifyParentScript.getFactory()->getClass());           
00127                 registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00128                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));
00129                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00130                 setClassName(NLAIAGENT::CStringVarName("CMsgNotifyParentClass"));
00131                 buildVTable();
00132         }
00133 
00134         CMsgNotifyParentClass::CMsgNotifyParentClass(const NLAIC::CIdentType &id):CMessageClass(id)
00135         {
00136                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CNotifyParentScript::IdNotifyParentScript.getFactory()->getClass());           
00137                 registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00138                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));
00139                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00140                 setClassName(NLAIAGENT::CStringVarName("CMsgNotifyParentClass"));
00141                 buildVTable();
00142         }
00143 
00144         CMsgNotifyParentClass::CMsgNotifyParentClass()
00145         {               
00146                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CNotifyParentScript::IdNotifyParentScript.getFactory()->getClass());           
00147                 registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00148                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));
00149                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00150                 setClassName(NLAIAGENT::CStringVarName("CMsgNotifyParentClass"));
00151                 buildVTable();
00152         }
00153         
00154         const NLAIC::IBasicType *CMsgNotifyParentClass::clone() const
00155         {
00156                 return new CMsgNotifyParentClass();
00157         }
00158         const NLAIC::IBasicType *CMsgNotifyParentClass::newInstance() const
00159         {
00160                 return new CMsgNotifyParentClass();
00161         }
00162 
00163         NLAIAGENT::IObjectIA *CMsgNotifyParentClass::buildNewInstance() const
00164         {
00165                 return new NLAIAGENT::CNotifyParentScript( (CMessageClass *) this );
00166                 std::list<NLAIAGENT::IObjectIA *> components;
00167                 createBaseClassComponents( components );
00168 
00169                 // Création du message
00170                 return new NLAIAGENT::CNotifyParentScript( components,  (CMessageClass *) this );               
00171         }       
00172         
00173 
00174 
00175 //#########################################
00176 //              CGoalMsgClass
00177 //#########################################     
00178         CGoalMsgClass::CGoalMsgClass(const NLAIAGENT::IVarName &s):CMessageClass(s)
00179         {
00180                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CGoalMsg::IdGoalMsg.getFactory()->getClass());         
00181                 registerComponent(NLAIAGENT::CStringVarName("GoalObject"),NLAIAGENT::CStringVarName("Goal"));
00182                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00183                 setClassName(NLAIAGENT::CStringVarName("CGoalMsgClass"));
00184                 buildVTable();
00185         }
00186         CGoalMsgClass::CGoalMsgClass(const NLAIC::CIdentType &id):CMessageClass(id)
00187         {
00188                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CGoalMsg::IdGoalMsg.getFactory()->getClass());         
00189                 registerComponent(NLAIAGENT::CStringVarName("GoalObject"),NLAIAGENT::CStringVarName("Goal"));
00190                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00191                 setClassName(NLAIAGENT::CStringVarName("CGoalMsgClass"));
00192                 buildVTable();
00193         }
00194 
00195         CGoalMsgClass::CGoalMsgClass()
00196         {               
00197                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CGoalMsg::IdGoalMsg.getFactory()->getClass());         
00198                 registerComponent(NLAIAGENT::CStringVarName("GoalObject"),NLAIAGENT::CStringVarName("Goal"));
00199                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00200                 setClassName(NLAIAGENT::CStringVarName("CGoalMsgClass"));
00201                 buildVTable();
00202         }
00203         
00204         const NLAIC::IBasicType *CGoalMsgClass::clone() const
00205         {
00206                 return new CGoalMsgClass();
00207         }
00208 
00209         const NLAIC::IBasicType *CGoalMsgClass::newInstance() const
00210         {
00211                 return new CGoalMsgClass();
00212         }
00213 
00214         NLAIAGENT::IObjectIA *CGoalMsgClass::buildNewInstance() const
00215         {
00216 //              return new NLAIAGENT::CGoalMsg( (CMessageClass *) this );
00217                 std::list<NLAIAGENT::IObjectIA *> components;
00218                 createBaseClassComponents( components );
00219 
00220                 // Création du message
00221                 NLAIAGENT::IObjectIA *x = new NLAIAGENT::CGoalMsg( components,  (CMessageClass *) this );               
00222                 return x;
00223         }       
00224 
00225 
00226 //#########################################
00227 //              CCancelGoalMsgClass
00228 //#########################################
00229 
00230         CCancelGoalMsgClass::CCancelGoalMsgClass(const NLAIAGENT::IVarName &s):CMessageClass(s)
00231         {
00232                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CCancelGoalMsg::IdCancelGoalMsg.getFactory()->getClass());             
00233                 registerComponent(NLAIAGENT::CStringVarName("GoalObject"),NLAIAGENT::CStringVarName("Goal"));
00234                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00235                 setClassName(NLAIAGENT::CStringVarName("CCancelGoalMsgClass"));
00236                 buildVTable();
00237         }
00238 
00239         CCancelGoalMsgClass::CCancelGoalMsgClass(const NLAIC::CIdentType &id):CMessageClass(id)
00240         {
00241                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CCancelGoalMsg::IdCancelGoalMsg.getFactory()->getClass());             
00242                 registerComponent(NLAIAGENT::CStringVarName("GoalObject"),NLAIAGENT::CStringVarName("Goal"));
00243                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00244                 setClassName(NLAIAGENT::CStringVarName("CCancelGoalMsgClass"));
00245                 buildVTable();
00246         }
00247 
00248         CCancelGoalMsgClass::CCancelGoalMsgClass()
00249         {               
00250                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CCancelGoalMsg::IdCancelGoalMsg.getFactory()->getClass());             
00251                 registerComponent(NLAIAGENT::CStringVarName("GoalObject"),NLAIAGENT::CStringVarName("Goal"));
00252                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00253                 setClassName(NLAIAGENT::CStringVarName("CCancelGoalMsgClass"));
00254                 buildVTable();
00255         }
00256         
00257         const NLAIC::IBasicType *CCancelGoalMsgClass::clone() const
00258         {
00259                 return new CCancelGoalMsgClass();
00260         }
00261 
00262         const NLAIC::IBasicType *CCancelGoalMsgClass::newInstance() const
00263         {
00264                 return new CCancelGoalMsgClass();
00265         }
00266 
00267         NLAIAGENT::IObjectIA *CCancelGoalMsgClass::buildNewInstance() const
00268         {
00269 //              return new NLAIAGENT::CGoalMsg( (CMessageClass *) this );
00270                 std::list<NLAIAGENT::IObjectIA *> components;
00271                 createBaseClassComponents( components );
00272 
00273                 // Création du message
00274                 NLAIAGENT::IObjectIA *x = new NLAIAGENT::CCancelGoalMsg( components,  (CMessageClass *) this );
00275                 return x;
00276         }       
00277 
00278 //#########################################
00279 //              CFactMsgClass
00280 //#########################################
00281 
00282         CFactMsgClass::CFactMsgClass(const NLAIAGENT::IVarName &s):CMessageClass(s)
00283         {
00284                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CFactMsg::IdFactMsg.getFactory()->getClass());         
00285                 registerComponent(NLAIAGENT::CStringVarName("FactObject"),NLAIAGENT::CStringVarName("Fact"));
00286                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00287                 setClassName(NLAIAGENT::CStringVarName("CFactMsgClass"));
00288                 buildVTable();
00289         }
00290 
00291         CFactMsgClass::CFactMsgClass(const NLAIC::CIdentType &id):CMessageClass(id)
00292         {
00293                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CFactMsg::IdFactMsg.getFactory()->getClass());         
00294                 registerComponent(NLAIAGENT::CStringVarName("FactObject"),NLAIAGENT::CStringVarName("Fact"));
00295                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00296                 setClassName(NLAIAGENT::CStringVarName("CFactMsgClass"));
00297                 buildVTable();
00298         }
00299 
00300         CFactMsgClass::CFactMsgClass() : CMessageClass()
00301         {               
00302                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CGoalMsg::IdGoalMsg.getFactory()->getClass());         
00303                 registerComponent(NLAIAGENT::CStringVarName("FactObject"),NLAIAGENT::CStringVarName("Fact"));
00304                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00305                 setClassName(NLAIAGENT::CStringVarName("CFactMsgClass"));
00306                 buildVTable();
00307         }
00308         
00309         const NLAIC::IBasicType *CFactMsgClass::clone() const
00310         {
00311                 return new CFactMsgClass();
00312         }
00313 
00314         const NLAIC::IBasicType *CFactMsgClass::newInstance() const
00315         {
00316                 return new CFactMsgClass();
00317         }
00318 
00319         NLAIAGENT::IObjectIA *CFactMsgClass::buildNewInstance() const
00320         {
00321                 std::list<NLAIAGENT::IObjectIA *> components;
00322                 createBaseClassComponents( components );
00323 
00324                 NLAIAGENT::IObjectIA *x = new NLAIAGENT::CFactMsg( components,  (CMessageClass *) this );               
00325                 return x;
00326         }       
00327 
00328 
00329 //#########################################
00330 //              CDebugMsgClass
00331 //#########################################
00332         
00333         CDebugMsgClass::CDebugMsgClass(const NLAIAGENT::IVarName &s):CMessageClass(s)
00334         {
00335                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CGoalMsg::IdGoalMsg.getFactory()->getClass());         
00336                 registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00337                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));
00338                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00339                 setClassName(NLAIAGENT::CStringVarName("CDebugMsgClass"));
00340                 buildVTable();
00341         }
00342         CDebugMsgClass::CDebugMsgClass(const NLAIC::CIdentType &id):CMessageClass(id)
00343         {
00344                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CGoalMsg::IdGoalMsg.getFactory()->getClass());         
00345                 registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00346                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));
00347                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00348                 setClassName(NLAIAGENT::CStringVarName("CDebugMsgClass"));
00349                 buildVTable();
00350         }
00351 
00352         CDebugMsgClass::CDebugMsgClass() : CMessageClass()
00353         {               
00354                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::CGoalMsg::IdGoalMsg.getFactory()->getClass());         
00355                 registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00356                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));
00357                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00358                 setClassName(NLAIAGENT::CStringVarName("CDebugMsgClass"));
00359                 buildVTable();
00360         }
00361         
00362         const NLAIC::IBasicType *CDebugMsgClass::clone() const
00363         {
00364                 return new CDebugMsgClass();
00365         }
00366 
00367         const NLAIC::IBasicType *CDebugMsgClass::newInstance() const
00368         {
00369                 return new CDebugMsgClass();
00370         }
00371 
00372         NLAIAGENT::IObjectIA *CDebugMsgClass::buildNewInstance() const
00373         {
00374 //              return new NLAIAGENT::CGoalMsg( (CMessageClass *) this );
00375                 std::list<NLAIAGENT::IObjectIA *> components;
00376                 createBaseClassComponents( components );
00377 
00378                 // Création du message
00379                 NLAIAGENT::IObjectIA *x = new NLAIAGENT::CMsgDebug( components,  (CMessageClass *) this );              
00380                 return x;
00381         }
00382 
00383 //#########################################
00384 //              COnChangeMsgClass
00385 //#########################################
00386 
00387         COnChangeMsgClass::COnChangeMsgClass(const NLAIAGENT::IVarName &s):CMessageClass(s)
00388         {
00389                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::COnChangeMsg::IdOnChangeMsg.getFactory()->getClass());         
00390                 /*registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00391                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));*/
00392                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00393         }
00394 
00395 
00396         COnChangeMsgClass::COnChangeMsgClass(const NLAIC::CIdentType &id):CMessageClass(id)
00397         {
00398                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::COnChangeMsg::IdOnChangeMsg.getFactory()->getClass());         
00399                 /*registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00400                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));*/
00401                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00402         }
00403 
00404         COnChangeMsgClass::COnChangeMsgClass() : CMessageClass()
00405         {               
00406                 setBaseObjectInstance((NLAIAGENT::IObjectIA *)NLAIAGENT::COnChangeMsg::IdOnChangeMsg.getFactory()->getClass());         
00407                 /*registerComponent(NLAIAGENT::CStringVarName("Float"),NLAIAGENT::CStringVarName("ParentState"));
00408                 registerComponent(NLAIAGENT::CStringVarName("GenericAgent"),NLAIAGENT::CStringVarName("Parent"));*/
00409                 setInheritanceName(NLAIAGENT::CStringVarName("Message"));
00410         }
00411         
00412         const NLAIC::IBasicType *COnChangeMsgClass::clone() const
00413         {
00414                 return new COnChangeMsgClass();
00415         }
00416 
00417         const NLAIC::IBasicType *COnChangeMsgClass::newInstance() const
00418         {
00419                 return new COnChangeMsgClass();
00420         }
00421 
00422         NLAIAGENT::IObjectIA *COnChangeMsgClass::buildNewInstance() const
00423         {
00424                 std::list<NLAIAGENT::IObjectIA *> components;
00425                 createBaseClassComponents( components );
00426 
00427                 // Création du message
00428                 NLAIAGENT::IObjectIA *x = new NLAIAGENT::COnChangeMsg( components,  (CMessageClass *) this );           
00429                 return x;
00430         }       
00431 }