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