00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00090 return x;
00091 }
00092
00093 virtual const NLAIC::IBasicType *clone() const
00094 {
00095
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
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
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