# 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_fact.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_fact.h"
00026 #include "nel/ai/agent/agent_digital.h"
00027 #include "nel/ai/script/interpret_object_message.h"
00028 #include "nel/ai/agent/object_type.h"
00029 #include "nel/ai/script/codage.h"
00030 #include "nel/ai/script/object_unknown.h"
00031 #include "nel/ai/logic/fact.h"
00032 
00033 
00034 namespace NLAIAGENT
00035 {
00036         CFactMsg::CFactMsg( std::list<IObjectIA *> &l, NLAISCRIPT::CMessageClass *b):CMessageScript(l,b)
00037         {
00038                 set(0, new NLAILOGIC::CFact() );
00039         }
00040 
00041         CFactMsg::CFactMsg(NLAISCRIPT::CMessageClass *b):CMessageScript(b)
00042         {               
00043                 CVectorGroupType *x = new CVectorGroupType(1);          
00044                 setMessageGroup(x);
00045                 setGroup(CMessageGroup::msgScriptingGroup);             
00046                 set(0, new NLAILOGIC::CFact());
00047         }
00048 
00049         CFactMsg::CFactMsg(IBasicAgent *agent):
00050                         CMessageScript((NLAISCRIPT::CMessageClass *)NLAISCRIPT::CFactMsgClass::IdFactMsgClass.getFactory()->getClass())
00051         {               
00052                 CVectorGroupType *x = new CVectorGroupType(1);
00053                 setMessageGroup(x);
00054                 setGroup(CMessageGroup::msgScriptingGroup);
00055                 set(0, new NLAILOGIC::CFact());
00056         }
00057 
00058         CFactMsg::CFactMsg(const CFactMsg &m): CMessageScript(m)
00059         {
00060         }
00061 
00062         CFactMsg::~CFactMsg()
00063         {
00064                 
00065         }
00066 
00067         const NLAIC::IBasicType *CFactMsg::clone() const
00068         {
00069                 const NLAIC::IBasicType *x;
00070                 x = new CFactMsg(*this);
00071                 return x;
00072         }
00073 
00074         const NLAIC::CIdentType &CFactMsg::getType() const
00075         {
00076                 if ( getCreatorClass() ) 
00077                         return getCreatorClass()->getType();
00078                 else
00079                         return IdFactMsg;
00080         }       
00081 
00082         void CFactMsg::getDebugString(std::string &t) const
00083         {               
00084                 CMessageScript::getDebugString(t);
00085                 t +=">";
00086         }
00087 
00088 
00089         tQueue CFactMsg::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 CFactMsg::runMethodeMember(sint32, sint32, NLAIAGENT::IObjectIA *)
00109         {
00110                 return IObjectIA::CProcessResult();
00111         }
00112 
00113         IObjectIA::CProcessResult CFactMsg::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::CFact *fact = (NLAILOGIC::CFact *) param->get();
00122                                 param->popFront();
00123 #ifdef NL_DEBUG
00124                                 std::string buffer;
00125                                 fact->getDebugString( buffer );
00126 #endif
00127                                 set(0, fact);
00128                         }
00129                         break;
00130                 }
00131                 return IObjectIA::CProcessResult();
00132         }
00133 
00134         sint32 CFactMsg::getBaseMethodCount() const
00135         {
00136                 return CMessageScript::getBaseMethodCount() + 1;
00137         }
00138 }