# 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_local_mailer.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 #ifndef NL_AGENT_LOCAL_MAILER_H
00026 #define NL_AGENT_LOCAL_MAILER_H
00027 
00028 #include "nel/ai/agent/agent.h"
00029 
00030 namespace NLAIAGENT
00031 {       
00040         class CLocalAgentMail: public IAgent
00041         {
00042 
00043         public:
00044                 static const NLAIC::CIdentType LocalAgentMail;
00045         private:
00046                 IBasicAgent *_HostAgent;
00047 
00048         public:
00049                 CLocalAgentMail():IAgent(NULL),_HostAgent(NULL)
00050                 {
00051                 }
00052                 CLocalAgentMail(IBasicAgent *host);
00053                 virtual ~CLocalAgentMail();
00054 
00055                 const IBasicAgent *getHost() const
00056                 {
00057                         return _HostAgent;
00058                 }
00059 
00061 
00062                 virtual void save(NLMISC::IStream &os)
00063                 {
00064                         IBasicAgent::save(os);
00065                         IWordNumRef &r = (IWordNumRef&)*((IConnectIA *)_HostAgent);
00066                         os.serial( (NLAIC::CIdentType &) (r.getType()) );
00067                         r.save(os);
00068                 }
00069                 virtual void load(NLMISC::IStream &is)
00070                 {
00071                         IBasicAgent::load(is);
00072 
00073                         NLAIC::CIdentTypeAlloc id;
00074                         is >> id;
00075                         IWordNumRef *num = (IWordNumRef *)id.allocClass();
00076                         num->load(is);
00077                         if(_HostAgent != NULL) _HostAgent->release();
00078                         _HostAgent = (IBasicAgent *)((const IRefrence *)*num);
00079                         delete num;
00080                 }
00081                 virtual const NLAIC::CIdentType &getType() const
00082                 {
00083                         return LocalAgentMail;
00084                 }
00085 
00086                 virtual const NLAIC::IBasicType *newInstance() const
00087                 {                       
00088                         NLAIC::IBasicType *x = new CLocalAgentMail(_HostAgent);
00089                         //incRef();
00090                         return x;
00091                 }
00092 
00093                 virtual const NLAIC::IBasicType *clone() const
00094                 {
00095                         //if(_HostAgent != NULL) _HostAgent->incRef();
00096                         NLAIC::IBasicType *x = new CLocalAgentMail(_HostAgent);                 
00097                         return x;
00098                 }
00099 
00100                 virtual void getDebugString(char *t) const
00101                 {
00102                         if(_HostAgent != NULL)  sprintf(t,"CLocalAgentMail for '%s' agents",(const char *)_HostAgent->getType());
00103                         else sprintf(t,"CLocalAgentMail for 'NILL' agents");
00104                 }
00106 
00108 
00109                 virtual const CProcessResult &run()
00110                 {
00111                         return IObjectIA::ProcessRun;
00112                 }
00113 
00114                 virtual sint32 getStaticMemberSize() const
00115                 {
00116                         return _HostAgent->getStaticMemberSize();
00117                 }
00118 
00119                 virtual sint32 getStaticMemberIndex(const IVarName &m) const
00120                 {
00121                         return _HostAgent->getStaticMemberIndex(m);
00122                 }
00123 
00124                 virtual const IObjectIA *getStaticMember(sint32 i) const
00125                 {
00126                         return _HostAgent->getStaticMember(i);
00127                 }
00128 
00129                 virtual void setStaticMember(sint32 i,IObjectIA *o)
00130                 {
00131                         _HostAgent->setStaticMember(i,o);
00132                 }
00133 
00134                 virtual sint32 getMethodIndexSize() const
00135                 {
00136                         return _HostAgent->getMethodIndexSize();
00137                 }
00138 
00139                 virtual tQueue isMember(const IVarName *h,const IVarName *m,const IObjectIA &p) const;
00140                 
00141                 virtual sint32 isClassInheritedFrom(const IVarName &h) const
00142                 {
00143                         return _HostAgent->isClassInheritedFrom(h);
00144                 }
00145 
00146                 virtual CProcessResult runMethodeMember(sint32 h, sint32 m, IObjectIA *p)
00147                 {
00148                         return _HostAgent->runMethodeMember(h,m,p);
00149                 }
00150 
00151                 virtual CProcessResult runMethodeMember(sint32 m,IObjectIA *p)
00152                 {
00153                         return _HostAgent->runMethodeMember(m,p);
00154                 }               
00155 
00156                 virtual tQueue canProcessMessage(const IVarName &m)
00157                 {
00158                         return _HostAgent->canProcessMessage(m);
00159                 }
00161 
00163 
00164                 virtual bool isEqual(const IBasicObjectIA &a) const
00165                 {
00166                         const CLocalAgentMail &l = (const CLocalAgentMail &)a;
00167                         if(l._HostAgent != NULL && _HostAgent != NULL)
00168                         {
00169                                 return _HostAgent->isEqual(*l._HostAgent);
00170                         }
00171                         else
00172                         {
00173                                 return false;
00174                         }
00175                 }
00177 
00179 
00180                 virtual void onKill(IConnectIA *a);
00181                 virtual std::list<IBasicAgent *>::iterator addChild(IBasicAgent *p)
00182                 {
00183                         return _HostAgent->addChild(p);
00184                 }
00185                 virtual void removeChild(const IBasicAgent *p)
00186                 {
00187                         _HostAgent->removeChild(p);
00188                 }
00189 
00190                 virtual void removeChild(std::list<IBasicAgent *>::iterator &iter)
00191                 {
00192                         _HostAgent->removeChild(iter);
00193                 }
00194 
00195                 virtual void runChildren();
00196                 virtual void processMessages();                 
00197                 virtual IObjectIA::CProcessResult sendMessage(IObjectIA *msg);          
00198                 //virtual IObjectIA::CProcessResult sendMessage(IMessageBase *msg, IBasicAgent &receiver);              
00199 
00201                 virtual IObjectIA::CProcessResult runActivity()
00202                 {
00203                         return ProcessRun;
00204                 }
00205                 virtual bool haveActivity() const
00206                 {
00207                         return false;
00208                 }
00209 
00211 
00212         };
00213 }
00214 
00215 #endif