# 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  

msg_action.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/agent/msg_action.h"
00026 #include "nel/ai/agent/agent_digital.h"
00027 #include "nel/ai/script/interpret_message_action.h"
00028 //#include "nel/ai/logic/goal.h"
00029 #include "nel/ai/agent/object_type.h"
00030 #include "nel/ai/script/codage.h"
00031 #include "nel/ai/script/object_unknown.h"
00032 
00033 
00034 namespace NLAIAGENT
00035 {
00036         CSuccessMsg::CSuccessMsg( std::list<IObjectIA *> &l, NLAISCRIPT::CMessageClass *b):CMessageScript(l,b)
00037         {
00038                 set(0, new DigitalType(0) );
00039         }
00040 
00041         CSuccessMsg::CSuccessMsg(NLAISCRIPT::CMessageClass *b):CMessageScript(b)
00042         {               
00043                 CVectorGroupType *x = new CVectorGroupType(1);          
00044                 setMessageGroup(x);
00045                 setGroup(CMessageGroup::msgScriptingGroup);             
00046                 set(0, new DigitalType(0) );
00047         }
00048 
00049         CSuccessMsg::CSuccessMsg(IBasicAgent *agent):
00050                         CMessageScript((NLAISCRIPT::CMessageClass *)NLAISCRIPT::CSuccessMsgClass::IdSuccessMsgClass.getFactory()->getClass())
00051         {               
00052                 CVectorGroupType *x = new CVectorGroupType(1);
00053                 setMessageGroup(x);
00054                 setGroup(CMessageGroup::msgScriptingGroup);
00055                 set(0, new DigitalType(0) );
00056         }
00057 
00058         CSuccessMsg::CSuccessMsg(const CSuccessMsg &m): CMessageScript(m)
00059         {
00060         }
00061 
00062         CSuccessMsg::~CSuccessMsg()
00063         {
00064                 
00065         }
00066 
00067         const NLAIC::IBasicType *CSuccessMsg::clone() const
00068         {
00069                 const NLAIC::IBasicType *x;
00070                 x = new CSuccessMsg(*this);
00071                 return x;
00072         }
00073 
00074         const NLAIC::CIdentType &CSuccessMsg::getType() const
00075         {
00076                 if ( getCreatorClass() ) 
00077                         return getCreatorClass()->getType();
00078                 else
00079                         return IdSuccessMsg;
00080         }       
00081 
00082         void CSuccessMsg::getDebugString(std::string &t) const
00083         {
00084                 std::string txt;
00085                 get()->getDebugString(txt);
00086                 t += NLAIC::stringGetBuild("CSuccessMsg<%s>",txt.c_str());
00087         }
00088 
00089 
00090         tQueue CSuccessMsg::isMember(const IVarName *className,const IVarName *funcName,const IObjectIA &params) const
00091         {
00092 
00093                 tQueue r;
00094 
00095                 if(className == NULL)
00096                 {
00097                         if( (*funcName) == CStringVarName( "Constructor" ) )
00098                         {                                       
00099                                 r.push( CIdMethod( IMessageBase::getMethodIndexSize(), 0.0, NULL, new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid) ) );                     
00100                         }
00101                 }
00102 
00103                 if ( r.empty() )
00104                         return CMessageScript::isMember(className, funcName, params);
00105                 else
00106                         return r;
00107         }
00108 
00109         NLAIAGENT::IObjectIA::CProcessResult CSuccessMsg::runMethodeMember(sint32, sint32, NLAIAGENT::IObjectIA *)
00110         {
00111                 return IObjectIA::CProcessResult();
00112         }
00113 
00114         IObjectIA::CProcessResult CSuccessMsg::runMethodeMember(sint32 index, IObjectIA *context)
00115         {
00116                 IBaseGroupType *arg = (IBaseGroupType *) ( (NLAISCRIPT::CCodeContext *)context )->Param.back();
00117 
00118                 switch( index - IMessageBase::getMethodIndexSize() )
00119                 {
00120                 case 0:
00121                         {                                       
00122                                 IObjectIA *param = (IObjectIA *) arg->get();
00123                                 arg->popFront();
00124 #ifdef NL_DEBUG
00125                                 std::string buffer;
00126                                 param->getDebugString( buffer );
00127 #endif
00128                                 set(0, param);
00129                         }
00130                         break;
00131                 }
00132                 return IObjectIA::CProcessResult();
00133         }
00134 
00135         sint32 CSuccessMsg::getBaseMethodCount() const
00136         {
00137                 return CMessageScript::getBaseMethodCount() + 1;
00138         }
00139 
00140 
00141 
00144 
00145         CFailureMsg::CFailureMsg( std::list<IObjectIA *> &l, NLAISCRIPT::CMessageClass *b):CMessageScript(l,b)
00146         {
00147                 set(0, new DigitalType(0) );
00148         }
00149 
00150         CFailureMsg::CFailureMsg(NLAISCRIPT::CMessageClass *b):CMessageScript(b)
00151         {               
00152                 CVectorGroupType *x = new CVectorGroupType(1);          
00153                 setMessageGroup(x);
00154                 setGroup(CMessageGroup::msgScriptingGroup);             
00155                 set(0, new DigitalType(0) );
00156         }
00157 
00158         CFailureMsg::CFailureMsg(IBasicAgent *agent):
00159                         CMessageScript((NLAISCRIPT::CMessageClass *)NLAISCRIPT::CFailureMsgClass::IdFailureMsgClass.getFactory()->getClass())
00160         {               
00161                 CVectorGroupType *x = new CVectorGroupType(1);
00162                 setMessageGroup(x);
00163                 setGroup(CMessageGroup::msgScriptingGroup);
00164                 set(0, new DigitalType(0) );
00165         }
00166 
00167         CFailureMsg::CFailureMsg(const CFailureMsg &m): CMessageScript(m)
00168         {
00169         }
00170 
00171         CFailureMsg::~CFailureMsg()
00172         {
00173                 
00174         }
00175 
00176         const NLAIC::IBasicType *CFailureMsg::clone() const
00177         {
00178                 const NLAIC::IBasicType *x;
00179                 x = new CFailureMsg(*this);
00180                 return x;
00181         }
00182 
00183         const NLAIC::CIdentType &CFailureMsg::getType() const
00184         {
00185                 if ( getCreatorClass() ) 
00186                         return getCreatorClass()->getType();
00187                 else
00188                         return IdFailureMsg;
00189         }       
00190 
00191         void CFailureMsg::getDebugString(std::string &t) const
00192         {
00193                 std::string txt;
00194                 get()->getDebugString(txt);
00195                 t += NLAIC::stringGetBuild("CFailureMsg<%s>",txt.c_str());
00196         }
00197 
00198 
00199         tQueue CFailureMsg::isMember(const IVarName *className,const IVarName *funcName,const IObjectIA &params) const
00200         {
00201 
00202                 tQueue r;
00203 
00204                 if(className == NULL)
00205                 {
00206                         if( (*funcName) == CStringVarName( "Constructor" ) )
00207                         {                                       
00208                                 r.push( CIdMethod( IMessageBase::getMethodIndexSize(), 0.0, NULL, new NLAISCRIPT::CObjectUnknown(new NLAISCRIPT::COperandVoid) ) );                     
00209                         }
00210                 }
00211 
00212                 if ( r.empty() )
00213                         return CMessageScript::isMember(className, funcName, params);
00214                 else
00215                         return r;
00216         }
00217 
00218         NLAIAGENT::IObjectIA::CProcessResult CFailureMsg::runMethodeMember(sint32, sint32, NLAIAGENT::IObjectIA *)
00219         {
00220                 return IObjectIA::CProcessResult();
00221         }
00222 
00223         IObjectIA::CProcessResult CFailureMsg::runMethodeMember(sint32 index, IObjectIA *context)
00224         {
00225                 IBaseGroupType *arg = (IBaseGroupType *) ( (NLAISCRIPT::CCodeContext *)context )->Param.back();
00226 
00227                 switch( index - IMessageBase::getMethodIndexSize() )
00228                 {
00229                 case 0:
00230                         {                                       
00231                                 IObjectIA *param = (IObjectIA *) arg->get()->clone();                           
00232 #ifdef NL_DEBUG
00233                                 std::string buffer;
00234                                 param->getDebugString( buffer );
00235 #endif
00236                                 set(0, param);
00237                         }
00238                         break;
00239                 }
00240                 return IObjectIA::CProcessResult();
00241         }
00242 
00243         sint32 CFailureMsg::getBaseMethodCount() const
00244         {
00245                 return CMessageScript::getBaseMethodCount() + 1;
00246         }
00247 }