# 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  

mailbox.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_MAIL_BOX_H
00026 #define NL_MAIL_BOX_H
00027 
00028 #include "nel/ai/agent/msg.h"
00029 #include "nel/ai/agent/baseai.h"
00030 
00031 namespace NLAIAGENT
00032 {       
00033         class IMailBox:public IConnectIA
00034         {
00035         public:
00036                 typedef std::list<const IMessageBase *> tListMessage;
00037                 typedef std::list<IMailBox *> tListMailBox;
00038                 
00039         public:
00040                 
00041                 IMailBox(const IWordNumRef *parent);
00042                 IMailBox(const IMailBox &A);
00043                 IMailBox (NLMISC::IStream &is);
00044 
00045                 virtual void save(NLMISC::IStream &os) = 0;     
00046                 virtual void load(NLMISC::IStream &is) = 0;
00047                 
00048                 virtual ~IMailBox();
00049 
00050                 virtual void addMessage(IMessageBase *msg) = 0;
00051 
00052                 virtual void addMailBox(IMailBox *) = 0;
00053                 virtual void removeMailBox(IMailBox *) = 0;
00054 
00055                 virtual const IMessageBase &getMessage() = 0;
00056                 virtual void shareMessage() = 0;
00057                 virtual void popMessage() = 0;
00058                 virtual sint32  getMessageCount() const = 0;
00059                 virtual bool isEmpty() const = 0;
00060                 virtual sint size() const = 0;
00061 
00062                 virtual std::list<const IMessageBase *> *pumpMessages(/*IBasicMessageGroup &*/) const= 0;
00063 
00064                 virtual const tListMessage &getMesseageListe() const = 0;
00065 
00066                 /*virtual void addGroup(IBasicMessageGroup &) = 0;
00067                 virtual void removeGroup(IBasicMessageGroup &) = 0;
00068                 virtual std::list<IBasicMessageGroup *> &getGroups() = 0;*/
00069 
00070         };
00071 
00072         inline void IMailBox::save(NLMISC::IStream &os)
00073         {                               
00074                 IConnectIA::save(os);
00075         }
00076 
00077         inline void IMailBox::load(NLMISC::IStream &is)
00078         {                       
00079                 IConnectIA::load(is);
00080         }
00081 
00082         class CSimpleLocalMailBox:public IMailBox
00083         {
00084         protected:
00085                 IMailBox::tListMessage _ListMessage;
00086                 IObjectIA::CProcessResult       _RunState;
00087                 std::list<IBasicMessageGroup *> _Msg_grps;
00088                 sint _Size;
00089 
00090         public:
00091                 static const NLAIC::CIdentType IdSimpleLocalMailBox;
00092         public:
00093                 CSimpleLocalMailBox (const IWordNumRef *parent);
00094                 CSimpleLocalMailBox (NLMISC::IStream &is);
00095                 CSimpleLocalMailBox (const CSimpleLocalMailBox &a);
00096                 virtual ~CSimpleLocalMailBox();
00097                 virtual void addMessage(IMessageBase *msg);
00098                 virtual void addMailBox(IMailBox *);
00099                 virtual void removeMailBox(IMailBox *);
00100                 virtual void shareMessage() {}
00101                 virtual const IMessageBase &getMessage();
00102                 virtual void popMessage();
00103                 virtual sint32  getMessageCount() const;                
00104                 virtual bool isEmpty() const;
00105                 virtual std::list<const IMessageBase *> *pumpMessages(/*IBasicMessageGroup &*/) const;          
00106                 virtual const CProcessResult &getState() const;
00107                 virtual void setState(TProcessStatement state, IObjectIA *result);
00108                 virtual const IObjectIA::CProcessResult &run();
00109 //              virtual void fillMailBox();
00110                 virtual bool isEqual(const IBasicObjectIA &a) const;
00111                 virtual const NLAIC::IBasicType *clone() const;
00112                 virtual const NLAIC::IBasicType *newInstance() const;
00113                 virtual const NLAIC::CIdentType &getType() const;
00114                 virtual void getDebugString(std::string &t) const;
00115                 virtual void save(NLMISC::IStream &os);
00116                 virtual void load(NLMISC::IStream &is);
00117                 virtual void onKill(IConnectIA *);
00118                 virtual IObjectIA::CProcessResult sendMessage(IMessageBase *);
00119                 virtual const tListMessage &getMesseageListe() const 
00120                 {
00121                         return _ListMessage;
00122                 }
00123 
00124                 virtual sint size() const
00125                 {
00126                         return _Size;
00127                 }
00128         private:
00129                         virtual IConnectIA &getConnection(IConnectIA &r);
00130         };
00131 
00132         
00133         class CLocalMailBox:public IMailBox
00134         {
00135                 public:
00136                         static const NLAIC::CIdentType IdLocalMailBox;
00137                 public:                 
00138                         typedef std::list<const IMessageBase *>::iterator tListMessageIter;
00139                         typedef std::list<const IMessageBase *>::const_iterator tListMessageCstIter;
00140                         
00141                         typedef std::list<IMailBox *>::iterator tListMailBoxIter;
00142                         typedef std::list<IMailBox *>::const_iterator tListMailBoxCstIter;
00143 
00144                 private:                                                
00145                         IObjectIA::CProcessResult       _RunState;
00146                         tListMessage _ListMessageIn;
00147                         tListMessage _ListSharedMessage;
00148                         tListMailBox _ListMailBox;
00149                         sint _Size;
00150                         
00151                 public:
00152         
00153                         CLocalMailBox (const IWordNumRef *parent);
00154                         CLocalMailBox (NLMISC::IStream &is);
00155                         CLocalMailBox (const CLocalMailBox &A);
00156                         virtual ~CLocalMailBox();
00157                         virtual const IMessageBase &getMessage();
00158                         virtual void shareMessage();
00159                         virtual void popMessage();
00160                         virtual sint32  getMessageCount() const;
00161                         virtual bool isEmpty() const;
00162                         //virtual void sendMessage(const IBasicAgent &,const IBaseGroupType &);
00163                         virtual IObjectIA::CProcessResult sendMessage(IMessageBase *);
00164                         virtual void addMessage(IMessageBase *msg);
00165                         // Ajoute une boite aux lettre dans la liste des boites aux lettres "source" (les bals à consulter).
00166                         virtual void addMailBox(IMailBox *mail);
00167                         // Supprime une boite aux lettre dans la liste des boites aux lettres "source" (les bals à consulter).
00168                         virtual void removeMailBox(IMailBox *mail);
00169                         virtual void setName(const IVarName &);
00170                         virtual const NLAIC::IBasicType *clone() const;
00171                         virtual const NLAIC::IBasicType *newInstance() const;
00172                         virtual const NLAIC::CIdentType &getType() const;
00173                         virtual void onKill(IConnectIA *a);
00174                         virtual bool isEqual(const IBasicObjectIA &a) const;
00175                         virtual void save(NLMISC::IStream &os);
00176                         virtual void load(NLMISC::IStream &is);
00177                         virtual const CProcessResult &getState() const ;
00178                         virtual void setState(TProcessStatement state, IObjectIA *result);
00179                         virtual std::list<const IMessageBase *> *pumpMessages(/*IBasicMessageGroup &grp*/) const;
00180                         virtual const IObjectIA::CProcessResult &run();
00181                         virtual void getDebugString(std::string &t) const;
00182                         virtual const tListMessage &getMesseageListe() const 
00183                         {
00184                                 return _ListMessageIn;
00185                         }
00186                         virtual sint size() const
00187                         {
00188                                 return _Size;
00189                         }
00190                         /*virtual void addGroup(IBasicMessageGroup &grp);
00191                         virtual std::list<IBasicMessageGroup *> &getGroups() ;
00192                         virtual void removeGroup(IBasicMessageGroup &grp);*/
00193                 private:
00194                         void fillMailBox();
00195 
00196         };
00197 
00198         class CScriptMailBox : public CSimpleLocalMailBox
00199         {
00200         private:
00201                 sint32 _CIndex;
00202                 const IMessageBase *translateMsg(const IMessageBase *);
00203         public:
00204                 static const NLAIC::CIdentType IdScriptMailBox;
00205 
00206         public:
00207                         CScriptMailBox (const IWordNumRef *parent);
00208                         CScriptMailBox (NLMISC::IStream &is);
00209                         CScriptMailBox (const CScriptMailBox &A);
00210                         virtual ~CScriptMailBox();
00211                         virtual const IObjectIA::CProcessResult &run();
00212                         virtual void fillMailBox();
00213 
00214                         void setIndex(sint32);
00215                         sint32 getIndex();
00216 
00217                         virtual const NLAIC::IBasicType *clone() const;
00218                         virtual const NLAIC::IBasicType *newInstance() const;
00219                         virtual const NLAIC::CIdentType &getType() const;
00220 
00221         };      
00222 }
00223 #endif