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(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
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