# 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  

msg.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_MSG_H
00026 #define NL_MSG_H
00027  
00028 #include "nel/ai/agent/agentexport.h"
00029 #include "nel/ai/c/registry_class.h"
00030 #include "nel/ai/agent/agent_object.h"
00031 #include "nel/ai/agent/msg_group.h"
00032 #include "nel/ai/agent/msg_container.h"
00033 #include "nel/ai/agent/list_manager.h"
00034 
00035 namespace NLAIAGENT
00036 {       
00037         class CIdentType;
00038         class IBasicAgent;
00039         //class IListBasicManager;
00040         
00051         class IMessageBase: public IListBasicManager
00052         {
00053         public:
00054                 enum TPerformatif
00055                 {
00056                         PUndefine,
00057                         PExec,
00058                         PAchieve,
00059                         PAsk,
00060                         PBreak,
00061                         PTell,
00062                         PKill,
00063                         PError,                 
00064                         PEven,
00065                         PService
00066                 };
00067 
00068         private:
00069 
00070                 struct CMethodCall
00071                 {
00072                         CMethodCall(const char *name, int i): MethodName (name)
00073                         {                               
00074                                 Index = i;
00075                         }
00076                         CStringVarName MethodName;
00077                         sint32 Index;
00078                 };
00079 
00080 
00081                 static CMethodCall _Method[];
00082 
00083         private:
00084 
00086                 IObjectIA *_Sender;
00087                 bool _SenderIsVolatile;
00089                 IObjectIA *_Receiver;
00090                 bool _ReceiverIsVolatile;
00092                 IObjectIA *_Continuation;
00093                 bool _ContinuationIsVolatile;
00095                 IBasicMessageGroup *_MsgGroup;
00096                 /*
00098                 IBaseGroupType *_Message;
00099                 */
00101                 sint32 _ReservedMethodIndexVar;
00103                 sint32 _ReservedHeritanceIndexVar;
00105                 TPerformatif _Performatif;
00107                 bool _comeFromC_PLUS;
00109                 bool _Dispatch;
00110                 bool _ProtectSender;
00111 
00112         public:
00113                 void setMessageGroup(IBaseGroupType *g)
00114                 {
00115                         if(_List != NULL) _List->release();
00116                         _List = g;
00117                 }
00118 
00119                 const IBaseGroupType *getMessageGroup() const
00120                 {
00121                         return _List;
00122                 }
00123 
00124         public:
00125                 IMessageBase();
00126                 IMessageBase(IObjectIA *sender,IBaseGroupType *g);
00127                 IMessageBase(IObjectIA *sender, IBasicMessageGroup &msg_group,IBaseGroupType *g);
00128 
00129                 IMessageBase(const IMessageBase &m);
00130 
00131                 virtual ~IMessageBase();                
00132                                 
00133                 const IBasicMessageGroup &getGroup() const
00134                 {
00135                         if(_MsgGroup == NULL) throw NLAIE::CExceptionUnReference(std::string("_MsgGroup in the iMessage class is not corectly inistializ"));
00136                         return *_MsgGroup;
00137                 }
00138 
00140                 void setGroup(IBasicMessageGroup &grp)
00141                 {                       
00142                         if(_MsgGroup != NULL) _MsgGroup->release();
00143                         _MsgGroup = (IBasicMessageGroup *)grp.clone();
00144                 }
00145 
00146                 void setPerformatif(TPerformatif p)
00147                 {
00148                         _Performatif = p;
00149                 }
00150 
00151                 const TPerformatif &getPerformatif() const
00152                 {
00153                         return _Performatif;
00154                 }
00155 
00157 
00158                 void setSender(IObjectIA *s, bool v = false);
00159                 void setReceiver(IObjectIA *r, bool v = false);
00160                 void setContinuation(IObjectIA *r, bool v = false);             
00161 
00162                 void setDispatch(bool state = true)
00163                 {
00164                         _Dispatch = state;
00165                 }
00166 
00167                 bool getDispatch() const
00168                 {
00169                         return _Dispatch;
00170                 }
00171 
00172                 const IObjectIA *getSender() const
00173                 {                       
00174                         return _Sender;
00175                 }
00176 
00177                 const IObjectIA *getReceiver() const
00178                 {                       
00179                         return _Receiver;
00180                 }
00181 
00182                 const IObjectIA *getContinuation() const
00183                 {                       
00184                         return _Continuation;
00185                 }
00187                 
00189 
00190                 void setMethodIndex(sint32 h,sint32 n)
00191                 {
00192                         _ReservedMethodIndexVar = n;
00193                         _ReservedHeritanceIndexVar = h;
00194                 }
00195 
00196                 sint32 getMethodIndex() const
00197                 {
00198                         return _ReservedMethodIndexVar;
00199                 }
00200 
00201                 const sint32  getHeritanceIndex() const
00202                 {
00203                         return _ReservedHeritanceIndexVar;
00204                 }
00205 
00206                 void setProtcetSender()
00207                 {
00208                         _ProtectSender = true;
00209                 }
00210                 void UnsetProtcetSender()
00211                 {
00212                         _ProtectSender = false;
00213                 }
00214 
00215                 bool getProtcetSender() const
00216                 {
00217                         return _ProtectSender;
00218                 }
00219 
00221 
00222         public:
00223                 
00225 
00226                 /*virtual IObjetOp &operator += (const IObjetOp &a);
00227                 virtual IObjetOp &operator -= (const IObjetOp &a);              
00228 
00229                 virtual const IObjectIA *operator[] (sint32) const;
00230 
00231                 virtual void set(int i,IObjectIA *o)
00232                 {
00233                         _Message->set(i,o);
00234                 }
00235 
00236                 virtual bool isTrue() const;
00237 
00238                 virtual IObjetOp *operator ! () const;
00239                 virtual void push(const IObjectIA *o);
00240                 virtual void pushFront(const IObjectIA *o);
00241                 virtual CIteratorContener getIterator()
00242                 {
00243                         return _Message->getIterator();
00244                 }
00245                 virtual void cpy(const IObjectIA &o);
00246                 virtual const IObjectIA *pop();
00247                 virtual const IObjectIA *get() const;
00248                 virtual const IObjectIA *popFront();
00249                 virtual const IObjectIA *getFront() const;
00250                 virtual sint32 size() const;
00251                 virtual const IObjectIA *find(const IObjectIA &obj) const;
00252                 virtual void eraseFirst(const IObjectIA &obj);
00253                 virtual void eraseAll(const IObjectIA &obj); 
00254                 virtual void erase(const IObjectIA *o); 
00255                 virtual void erase(const IObjectIA &obj);
00256                 virtual void erase(std::list<const IObjectIA *> &l);
00257                 virtual void clear();*/
00258 
00259                 virtual IObjectIA &operator = (const IObjectIA &a);             
00260 
00261                 virtual sint32 getMethodIndexSize() const;
00262                 virtual tQueue isMember(const IVarName *className,const IVarName *methodName,const IObjectIA &p) const;
00263                 virtual IObjectIA::CProcessResult runMethodeMember(sint32, sint32,IObjectIA *);
00264                 virtual IObjectIA::CProcessResult runMethodeMember(sint32,IObjectIA *);
00265                 virtual bool isEqual(const IBasicObjectIA &a) const;
00266                 
00267                 virtual void save(NLMISC::IStream &os);
00268                 virtual void load(NLMISC::IStream &is);
00269                 virtual void getDebugString(std::string &t) const;      
00270                 
00271                 virtual CProcessResult sendMessage(IObjectIA *);
00272                 virtual CProcessResult sendMessage(const IVarName &,IObjectIA *);
00274         };
00275 
00284         class CMessageList: public IMessageBase
00285         {
00286         private:
00287                 
00288 
00289         public:
00290                 static const NLAIC::CIdentType IdMessage;
00291         public:
00292 
00293                 CMessageList()
00294                 {
00295                         CGroupType *x = new CGroupType();
00296                         setMessageGroup(x);
00297                 }
00298 
00299                 CMessageList(const CGroupType &m)
00300                 {
00301                         setMessageGroup((CGroupType *)m.clone());
00302                 }
00303 
00304                 CMessageList(const CGroupType &m,IObjectIA *sender): IMessageBase(sender,(CGroupType *)m.clone())
00305                 {
00306                 }
00307 
00308                 CMessageList(const CGroupType &m,IObjectIA *sender, IBasicMessageGroup &msg_group):IMessageBase(sender,msg_group,(CGroupType *)m.clone())
00309                 {
00310                 }
00311 
00312                 CMessageList(const CMessageList &m):IMessageBase(m)
00313                 {
00314                 }               
00315                 
00316 
00317                 virtual ~CMessageList()
00318                 {                       
00319                 }
00320 
00321         public:
00322 
00324 
00325                 virtual const NLAIC::CIdentType &getType() const;                                       
00326 
00327                 virtual const NLAIC::IBasicType *clone() const
00328                 {
00329                         NLAIC::IBasicInterface *c = (NLAIC::IBasicInterface *)new CMessageList(*this);
00330                         return c;
00331                 }               
00332 
00333                 virtual const NLAIC::IBasicType *newInstance() const
00334                 {                                                                       
00335                         CMessageList *instance = new CMessageList;
00336                         return instance;
00337                 }               
00339         
00340         };
00341 
00350         class CMessageVector: public IMessageBase
00351         {
00352         private:
00353                 
00354 
00355         public:
00356                 static const NLAIC::CIdentType IdMessageVector;
00357         public:
00358 
00359                 CMessageVector(int n)
00360                 {
00361                         CVectorGroupType *x = new CVectorGroupType(n);
00362                         setMessageGroup(x);
00363                 }
00364 
00365                 CMessageVector()
00366                 {
00367                         CVectorGroupType *x = new CVectorGroupType();
00368                         setMessageGroup(x);
00369                 }
00370 
00371                 CMessageVector(const CVectorGroupType &m)
00372                 {
00373                         setMessageGroup((CVectorGroupType *)m.clone());
00374                 }
00375 
00376                 CMessageVector(const CVectorGroupType &m,IObjectIA *sender): IMessageBase(sender,(CVectorGroupType *)m.clone())
00377                 {
00378                 }
00379 
00380                 CMessageVector(const CVectorGroupType &m,IObjectIA *sender, IBasicMessageGroup &msg_group):
00381                                 IMessageBase(sender,msg_group,(CVectorGroupType *)m.clone())
00382                 {
00383                 }
00384 
00385                 CMessageVector(const CMessageVector &m):IMessageBase(m)
00386                 {
00387                 }               
00388                 
00389 
00390                 virtual ~CMessageVector()
00391                 {                       
00392                 }
00393 
00394         public:
00395 
00397 
00398 
00399                 virtual const NLAIC::CIdentType &getType() const;                                       
00400 
00401                 virtual const NLAIC::IBasicType *clone() const
00402                 {
00403                         NLAIC::IBasicInterface *m = (NLAIC::IBasicInterface *)new CMessageVector(*this);
00404                         return m;
00405                 }               
00406 
00407                 virtual const NLAIC::IBasicType *newInstance() const
00408                 {                                                                       
00409                         return clone();
00410                 }               
00412         };
00413 }
00414 #endif