# 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.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                         TLast
00044                 };
00045 
00046                 enum TTypeCheck{
00047                                 CheckAll,
00048                                 CheckCount,
00049                                 DoNotCheck
00050                         };
00052                 struct CMethodCall
00053                 {                       
00054 
00055                         CMethodCall(const char *name, int i,const IObjectIA *a,TTypeCheck checkArg,int argCount,IObjectIA *r): 
00056                                         MethodName (name),ArgType(a),ReturnValue(r)
00057                         {
00058                                 Index = i;
00059                                 CheckArgType = checkArg;
00060                                 ArgCount = argCount;
00061                         }
00062 
00063                         ~CMethodCall()
00064                         {
00065                                 if(ReturnValue) ReturnValue->release();                         
00066                         }
00068                         CStringVarName MethodName;
00070                         const IObjectIA *ArgType;
00072                         IObjectIA *ReturnValue;
00074                         TTypeCheck CheckArgType;                        
00076                         sint ArgCount;
00078                         sint32 Index;                           
00079                 };
00080                 static CMethodCall **StaticMethod;
00081 
00082                 static void initClass();
00083                 static void releaseClass();
00084 
00085         private:
00086                 CAgentNumber *_AgentRef;
00087         public:
00088                 CProxyAgentMail();
00089                 CProxyAgentMail(const CAgentNumber &agentRef);
00090                 CProxyAgentMail(const CProxyAgentMail &mailer);
00091                 ~CProxyAgentMail();
00092 
00094 
00095                 virtual void save(NLMISC::IStream &os)
00096                 {
00097                         _AgentRef->save(os);
00098                 }
00099 
00100                 virtual void load(NLMISC::IStream &is)
00101                 {
00102                         delete _AgentRef;
00103                         _AgentRef = new CAgentNumber (is);
00104                 }
00105 
00106                 virtual const NLAIC::CIdentType &getType() const
00107                 {
00108                         return IdProxyAgentMail;
00109                 }
00110 
00111                 virtual const NLAIC::IBasicType *newInstance() const
00112                 {                       
00113                         NLAIC::IBasicType *x = new CProxyAgentMail();
00114                         //incRef();
00115                         return x;
00116                 }
00117 
00118                 virtual const NLAIC::IBasicType *clone() const
00119                 {
00120                         //if(_HostAgent != NULL) _HostAgent->incRef();
00121                         if(_AgentRef != NULL) return new CProxyAgentMail(*_AgentRef);
00122                         else return new CProxyAgentMail();                      
00123                 }
00124 
00125                 virtual void getDebugString(char *t) const
00126                 {
00127                         if(_AgentRef != NULL)
00128                         {
00129                                 char text[200];
00130                                 _AgentRef->getDebugString(text);
00131                                 sprintf(t,"CProxyAgentMail for '%s' agents",text);
00132                         }
00133                         else sprintf(t,"CProxyAgentMail 'NILL' agents");
00134                 }
00136 
00138 
00139                 virtual const CProcessResult &run()
00140                 {
00141                         return IObjectIA::ProcessRun;
00142                 }
00143 
00144                 virtual bool isEqual(const IBasicObjectIA &a) const
00145                 {
00146                         const CProxyAgentMail &l = (const CProxyAgentMail &)a;
00147                         if(l._AgentRef != NULL && _AgentRef != NULL)
00148                         {
00149                                 return *l._AgentRef == *_AgentRef;
00150                         }
00151                         else
00152                         {
00153                                 return false;
00154                         }
00155                 }
00156 
00157                 virtual tQueue isMember(const IVarName *h,const IVarName *m,const IObjectIA &p) const;
00158                 virtual CProcessResult runMethodeMember(sint32 h, sint32 m, IObjectIA *p);
00159                 virtual CProcessResult runMethodeMember(sint32 m,IObjectIA *p);
00160                 virtual sint32 getMethodIndexSize() const;
00162 
00164 
00165                 virtual void onKill(IConnectIA *a);
00166                 virtual std::list<IBasicAgent *>::iterator addChild(IBasicAgent *p);
00167                 virtual void removeChild(const IBasicAgent *p);
00168                 virtual void removeChild(std::list<IBasicAgent *>::iterator &iter);
00169                 virtual void runChildren();
00170                 virtual void processMessages();
00171                 virtual IObjectIA::CProcessResult sendMessage(IObjectIA *msg);
00172                 virtual IObjectIA::CProcessResult runActivity()
00173                 {
00174                         return ProcessRun;
00175                 }
00176                 virtual bool haveActivity() const
00177                 {
00178                         return false;
00179                 }
00181 
00182         };
00183 }
00184 
00185 #endif