# 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(std::string &t) const
00101                 {
00102                         if(_HostAgent != NULL)  t += NLAIC::stringGetBuild("CLocalAgentMail for '%s' agents",(const char *)_HostAgent->getType());
00103                         else t += "CLocalAgentMail for 'NILL' agents";
00104                 }
00106 
00108 
00109 
00110                 virtual const CProcessResult &run()
00111                 {
00112                         return IObjectIA::ProcessRun;
00113                 }
00114 
00116 
00117                 virtual sint32 getStaticMemberSize() const
00118                 {
00119                         return _HostAgent->getStaticMemberSize();
00120                 }
00121 
00122                 virtual sint32 getStaticMemberIndex(const IVarName &m) const
00123                 {
00124                         return _HostAgent->getStaticMemberIndex(m);
00125                 }
00126 
00127                 virtual const IObjectIA *getStaticMember(sint32 i) const
00128                 {
00129                         return _HostAgent->getStaticMember(i);
00130                 }
00131 
00132                 virtual bool setStaticMember(sint32 i,IObjectIA *o)
00133                 {
00134                         return _HostAgent->setStaticMember(i,o);
00135                 }
00136 
00137                 virtual sint32 getMethodIndexSize() const
00138                 {
00139                         return _HostAgent->getMethodIndexSize();
00140                 }
00142 
00143                 virtual tQueue isMember(const IVarName *h,const IVarName *m,const IObjectIA &p) const;
00144                 
00145                 virtual sint32 isClassInheritedFrom(const IVarName &h) const
00146                 {
00147                         return _HostAgent->isClassInheritedFrom(h);
00148                 }
00149 
00150                 virtual CProcessResult runMethodeMember(sint32 h, sint32 m, IObjectIA *p)
00151                 {
00152                         return _HostAgent->runMethodeMember(h,m,p);
00153                 }
00154 
00155                 virtual CProcessResult runMethodeMember(sint32 m,IObjectIA *p)
00156                 {
00157                         return _HostAgent->runMethodeMember(m,p);
00158                 }               
00159 
00160                 virtual tQueue canProcessMessage(const IVarName &m)
00161                 {
00162                         return _HostAgent->canProcessMessage(m);
00163                 }
00165 
00167 
00168                 //Note that is equal if the hosts agents is equal.
00169                 virtual bool isEqual(const IBasicObjectIA &a) const
00170                 {
00171                         const CLocalAgentMail &l = (const CLocalAgentMail &)a;
00172                         if(l._HostAgent != NULL && _HostAgent != NULL)
00173                         {
00174                                 return _HostAgent->isEqual(*l._HostAgent);
00175                         }
00176                         else
00177                         {
00178                                 return false;
00179                         }
00180                 }
00182 
00184 
00185                 virtual void onKill(IConnectIA *a);
00186                 virtual std::list<IBasicAgent *>::iterator addChild(IBasicAgent *p)
00187                 {
00188                         return _HostAgent->addChild(p);
00189                 }
00190                 virtual void removeChild(const IBasicAgent *p)
00191                 {
00192                         _HostAgent->removeChild(p);
00193                 }
00194 
00195                 virtual void removeChild(std::list<IBasicAgent *>::iterator &iter)
00196                 {
00197                         _HostAgent->removeChild(iter);
00198                 }
00199 
00200                 virtual void runChildren();
00201                 virtual void processMessages();                 
00202                 virtual IObjectIA::CProcessResult sendMessage(IObjectIA *msg);          
00203                 //virtual IObjectIA::CProcessResult sendMessage(IMessageBase *msg, IBasicAgent &receiver);              
00204 
00206                 virtual IObjectIA::CProcessResult runActivity()
00207                 {
00208                         return ProcessRun;
00209                 }
00210                 virtual bool haveActivity() const
00211                 {
00212                         return false;
00213                 }       
00215 
00216         };
00217 }
00218 
00219 #endif