00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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
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
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
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