# 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_proxy_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_SERVER_MAILER_H
00026 #define NL_AGENT_SERVER_MAILER_H
00027 #include "nel/ai/agent/agent_script.h"
00028 
00029 namespace NLAIAGENT
00030 {       
00031         class IMainAgent;
00032 
00033         class CProxyAgentMail: public IBasicAgent
00034         {
00035         public:
00036                 static const NLAIC::CIdentType IdProxyAgentMail;
00037         public:
00038                 static IMainAgent *MainAgent;
00039         public:
00040 
00041                 enum  TMethodNumDef {
00042                         TConstructor,
00043                         TLastM
00044                 };              
00045                 
00046                 static CAgentScript::CMethodCall **StaticMethod;
00047 
00048                 static void initClass();
00049                 static void releaseClass();
00050 
00051         private:
00052                 CAgentNumber *_AgentRef;
00053         public:
00054                 CProxyAgentMail();
00055                 CProxyAgentMail(const CAgentNumber &agentRef);
00056                 CProxyAgentMail(const CProxyAgentMail &mailer);
00057                 virtual ~CProxyAgentMail();
00058 
00060 
00061                 virtual void save(NLMISC::IStream &os)
00062                 {
00063                         _AgentRef->save(os);
00064                 }
00065 
00066                 virtual void load(NLMISC::IStream &is)
00067                 {
00068                         delete _AgentRef;
00069                         _AgentRef = new CAgentNumber (is);
00070                 }
00071 
00072                 virtual const NLAIC::CIdentType &getType() const
00073                 {
00074                         return IdProxyAgentMail;
00075                 }
00076 
00077                 virtual const NLAIC::IBasicType *newInstance() const
00078                 {                       
00079                         NLAIC::IBasicType *x = new CProxyAgentMail();
00080                         //incRef();
00081                         return x;
00082                 }
00083 
00084                 virtual const NLAIC::IBasicType *clone() const
00085                 {
00086                         //if(_HostAgent != NULL) _HostAgent->incRef();
00087                         if(_AgentRef != NULL) return new CProxyAgentMail(*_AgentRef);
00088                         else return new CProxyAgentMail();                      
00089                 }
00090 
00091                 virtual void getDebugString(std::string &t) const
00092                 {
00093                         if(_AgentRef != NULL)
00094                         {
00095                                 std::string text;
00096                                 _AgentRef->getDebugString(text);
00097                                 t = NLAIC::stringGetBuild("CProxyAgentMail for '%s' agents",text.c_str());
00098                         }
00099                         else t = "CProxyAgentMail 'NILL' agents";
00100                 }
00102 
00103 
00104                 virtual const CProcessResult &run()
00105                 {
00106                         return IObjectIA::ProcessRun;
00107                 }
00108 
00109                 virtual bool isEqual(const IBasicObjectIA &a) const
00110                 {
00111                         const CProxyAgentMail &l = (const CProxyAgentMail &)a;
00112                         if(l._AgentRef != NULL && _AgentRef != NULL)
00113                         {
00114                                 return *l._AgentRef == *_AgentRef;
00115                         }
00116                         else
00117                         {
00118                                 return false;
00119                         }
00120                 }
00121 
00122                 virtual tQueue isMember(const IVarName *h,const IVarName *m,const IObjectIA &p) const;
00123                 virtual CProcessResult runMethodeMember(sint32 h, sint32 m, IObjectIA *p);
00124                 virtual CProcessResult runMethodeMember(sint32 m,IObjectIA *p);
00125                 virtual sint32 getMethodIndexSize() const;
00127 
00129 
00130                 virtual void onKill(IConnectIA *a);
00131                 virtual std::list<IBasicAgent *>::iterator addChild(IBasicAgent *p);
00132                 virtual void removeChild(const IBasicAgent *p);
00133                 virtual void removeChild(std::list<IBasicAgent *>::iterator &iter);
00134                 virtual void runChildren();
00135                 virtual void processMessages();
00136                 virtual IObjectIA::CProcessResult sendMessage(IObjectIA *msg);
00137                 virtual IObjectIA::CProcessResult sendMessage(const IVarName &,IObjectIA *);
00138                 virtual IObjectIA::CProcessResult runActivity()
00139                 {
00140                         return ProcessRun;
00141                 }
00142                 virtual bool haveActivity() const
00143                 {
00144                         return false;
00145                 }
00147 
00148                 const CAgentNumber *getAgentRef() const
00149                 {                       
00150                         return _AgentRef;                       
00151                 }
00152 
00153 
00154         };
00155 }
00156 
00157 #endif