From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/msg_8cpp-source.html | 563 ++++++++++++++++++++++++++++++++++ 1 file changed, 563 insertions(+) create mode 100644 docs/doxygen/nel/msg_8cpp-source.html (limited to 'docs/doxygen/nel/msg_8cpp-source.html') diff --git a/docs/doxygen/nel/msg_8cpp-source.html b/docs/doxygen/nel/msg_8cpp-source.html new file mode 100644 index 00000000..3f7257a8 --- /dev/null +++ b/docs/doxygen/nel/msg_8cpp-source.html @@ -0,0 +1,563 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# 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.cpp

Go to the documentation of this file.
00001 
+00006 /* Copyright, 2000 Nevrax Ltd.
+00007  *
+00008  * This file is part of NEVRAX NEL.
+00009  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00010  * it under the terms of the GNU General Public License as published by
+00011  * the Free Software Foundation; either version 2, or (at your option)
+00012  * any later version.
+00013 
+00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00017  * General Public License for more details.
+00018 
+00019  * You should have received a copy of the GNU General Public License
+00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00022  * MA 02111-1307, USA.
+00023  */
+00024 #include "nel/ai/agent/agent.h"
+00025 #include "nel/ai/agent/agent_local_mailer.h"
+00026 #include "nel/ai/agent/agent_proxy_mailer.h"
+00027 #include "nel/ai/logic/boolval.h"
+00028 #include "nel/ai/agent/object_type.h"
+00029 #include "nel/ai/agent/agent_method_def.h"
+00030 #include "nel/ai/agent/agent_digital.h" 
+00031 
+00032 namespace NLAIAGENT
+00033 {
+00034 
+00035         const NLAIC::IBasicType *CMessageGroup::clone() const 
+00036         {
+00037                 NLAIC::IBasicType *x = new CMessageGroup( *this );
+00038 
+00039 #ifdef NL_DEBUG
+00040         static sint kaka = 0;
+00041 #endif
+00042                 return x;
+00043         }
+00044 
+00045         const NLAIC::IBasicType *CMessageGroup::newInstance() const 
+00046         {
+00047                 NLAIC::IBasicType *x = new CMessageGroup( *this );
+00048                 return x;
+00049         }
+00050 
+00051 
+00052         const static sint32 _TSender = 0;
+00053         const static sint32 _TReceiver = 1;
+00054         const static sint32 _TXchgReceiverIsSender = 2;
+00055         const static sint32 _TContinuation = 3; 
+00056         const static sint32 _TSetContinuation = 4;
+00057         const static sint32 _TSetSender = 5;
+00058         const static sint32 _TInitProtocol = 6; 
+00059         const static sint32 _TProtcetSender = 7;                
+00060         const static sint32 _MLastM = 8;
+00061 
+00062         IMessageBase::CMethodCall IMessageBase::_Method[] = 
+00063         {
+00064                 IMessageBase::CMethodCall(_SENDER_,_TSender),           
+00065                 IMessageBase::CMethodCall(_RECEIVER_,_TReceiver),               
+00066                 IMessageBase::CMethodCall(_CONTINUATION_,_TContinuation),
+00067                 IMessageBase::CMethodCall(_SETCONTINUATION_,_TSetContinuation),
+00068                 IMessageBase::CMethodCall("XChangeReceiverSender",_TXchgReceiverIsSender),
+00069                 IMessageBase::CMethodCall("ProtcetSender",_TProtcetSender),
+00070                 IMessageBase::CMethodCall("InitProtocol",_TInitProtocol),
+00071                 IMessageBase::CMethodCall("SetSender",_TSetSender)              
+00072                 
+00073         };
+00074 
+00075         /*IntegerType IMessageBase::IdExec = IntegerType(IMessageBase::PExec);
+00076         IntegerType IMessageBase::IdAchieve = IntegerType(IMessageBase::PAchieve);
+00077         IntegerType IMessageBase::IdAsk = IntegerType(IMessageBase::PAsk);
+00078         IntegerType IMessageBase::IdBreak = IntegerType(IMessageBase::PBreak);
+00079         IntegerType IMessageBase::IdTell = IntegerType(IMessageBase::PTell);
+00080         IntegerType IMessageBase::IdKill = IntegerType(IMessageBase::PKill);*/
+00081 
+00082         IMessageBase::IMessageBase():IListBasicManager(),_Sender(NULL),_MsgGroup(NULL)
+00083         {
+00084                 _ReservedMethodIndexVar = -1;
+00085                 _ReservedHeritanceIndexVar = 0;
+00086                 _Receiver = NULL;
+00087                 _Continuation = NULL;
+00088                 _Performatif = PUndefine;
+00089                 _comeFromC_PLUS = true;
+00090                 _Dispatch = false;
+00091                 _ProtectSender = false;
+00092                 _SenderIsVolatile = false;
+00093                 _ReceiverIsVolatile = false;            
+00094                 _ContinuationIsVolatile = false;
+00095         }
+00096         IMessageBase::IMessageBase(IObjectIA *sender,IBaseGroupType *g):IListBasicManager(g),_Sender(sender),_MsgGroup(NULL)
+00097         {
+00098                 _ReservedMethodIndexVar = -1;
+00099                 _ReservedHeritanceIndexVar = 0;
+00100                 _Receiver = NULL;
+00101                 _Continuation = NULL;
+00102                 _Performatif = PUndefine;
+00103                 _comeFromC_PLUS = true;
+00104                 _Dispatch = false;
+00105                 _ProtectSender = false;
+00106                 _SenderIsVolatile = false;
+00107                 _ReceiverIsVolatile = false;            
+00108                 _ContinuationIsVolatile = false;
+00109         }
+00110 
+00111         IMessageBase::IMessageBase(IObjectIA *sender, IBasicMessageGroup &msg_group,IBaseGroupType *g):
+00112                                                         IListBasicManager(g),_Sender(sender),_MsgGroup((IBasicMessageGroup *)msg_group.clone())
+00113         {
+00114                 _ReservedMethodIndexVar = -1;
+00115                 _ReservedHeritanceIndexVar = 0;
+00116                 _Receiver = NULL;
+00117                 _Continuation = NULL;
+00118                 _Performatif = PUndefine;
+00119                 _comeFromC_PLUS = true;
+00120                 _Dispatch = false;
+00121                 _ProtectSender = false;
+00122                 _SenderIsVolatile = false;
+00123                 _ReceiverIsVolatile = false;            
+00124                 _ContinuationIsVolatile = false;
+00125         }
+00126 
+00127         IMessageBase::IMessageBase(const IMessageBase &m):IListBasicManager(m._List != NULL ? (IBaseGroupType *)m._List->clone(): NULL)
+00128         {
+00129                 _Sender = m._Sender;
+00130                 _SenderIsVolatile = m._SenderIsVolatile;
+00131                 if(_SenderIsVolatile && _Sender != NULL) _Sender->incRef();
+00132                 _Receiver = m._Receiver;
+00133                 _ReceiverIsVolatile = m._ReceiverIsVolatile;
+00134                 if(_ReceiverIsVolatile && _Receiver != NULL) _Receiver->incRef();
+00135                 _Continuation = m._Continuation;
+00136                 _ContinuationIsVolatile = m._ContinuationIsVolatile;
+00137                 if(_ContinuationIsVolatile && _Continuation != NULL) _Continuation->incRef();
+00138 
+00139                 if(m._MsgGroup) _MsgGroup = (IBasicMessageGroup *)m._MsgGroup->clone();
+00140                 else _MsgGroup = NULL;
+00141                 //_Message = (IBaseGroupType *)m._Message->clone();                     
+00142                 _ReservedMethodIndexVar = m._ReservedMethodIndexVar;
+00143                 _ReservedHeritanceIndexVar = m._ReservedHeritanceIndexVar;                      
+00144                 _Performatif = m._Performatif;
+00145                 _comeFromC_PLUS = m._comeFromC_PLUS;
+00146                 _Dispatch = m._Dispatch;
+00147                 _ProtectSender = m._ProtectSender;
+00148         }
+00149 
+00150         IMessageBase::~IMessageBase()
+00151         {
+00152                 if(_MsgGroup != NULL) _MsgGroup->release();
+00153                 if(_SenderIsVolatile && _Sender != NULL) _Sender->release();
+00154                 if(_ReceiverIsVolatile && _Receiver != NULL) _Receiver->release();
+00155             if(_ContinuationIsVolatile && _Continuation != NULL) _Continuation->release();
+00156         }       
+00157 
+00158 
+00159         IObjectIA &IMessageBase::operator = (const IObjectIA &a)
+00160         {
+00161                 IMessageBase &b = (IMessageBase &)a;
+00162                 _Sender = b._Sender;
+00163                 if(_SenderIsVolatile && _Sender != NULL) _Sender->incRef();
+00164                 _Receiver = b._Receiver;
+00165                 if(_ReceiverIsVolatile && _Receiver != NULL) _Receiver->incRef();
+00166                 _Continuation = b._Continuation;
+00167                 if(_ContinuationIsVolatile && _Continuation != NULL) _Continuation->incRef();
+00168                 setGroup((IBasicMessageGroup &)b.getGroup());
+00169                 *_List = *b._List;
+00170                 return *this;
+00171         }
+00172 
+00173         void IMessageBase::setSender(IObjectIA *s, bool v)
+00174         {                                       
+00175                 if(_SenderIsVolatile) _Sender->release();
+00176                 _Sender = s;
+00177                 _SenderIsVolatile = v;
+00178         }
+00179 
+00180         void IMessageBase::setReceiver(IObjectIA *r, bool v)
+00181         {       
+00182                 if(_ReceiverIsVolatile) _Receiver->release();
+00183                 _Receiver = r;
+00184                 _ReceiverIsVolatile = v;
+00185         }
+00186 
+00187         void IMessageBase::setContinuation(IObjectIA *r, bool v)
+00188         {                                       
+00189                 if(_ContinuationIsVolatile) _Continuation->release();
+00190                 _Continuation = r;
+00191                 _ContinuationIsVolatile = v;
+00192         }
+00193 
+00194         bool IMessageBase::isEqual(const IBasicObjectIA &a) const
+00195         {
+00196                 IMessageBase &b = (IMessageBase &)a;                                            
+00197                 return _Sender->isEqual((const IBasicAgent &)b) && getGroup() == b.getGroup() && IListBasicManager::isEqual(a);
+00198         }       
+00199 
+00200         void IMessageBase::save(NLMISC::IStream &os)
+00201         {       
+00202                 IListBasicManager::save(os);
+00203                 if(_Sender != NULL)
+00204                 {
+00205                         bool t = true;
+00206                         os.serial(t);
+00207                         IWordNumRef &r = (IWordNumRef&)((const IWordNumRef&)*((IRefrence *)_Sender));
+00208                         ((CNumericIndex &)r.getNumIdent()).save(os);                    
+00209                 }
+00210                 else
+00211                 {
+00212                         bool t = false;
+00213                         os.serial(t);
+00214                 }
+00215 
+00216                 if(_Receiver != NULL)
+00217                 {
+00218                         bool t = true;
+00219                         os.serial(t);
+00220                         IWordNumRef &r = (IWordNumRef&)((const IWordNumRef&)*((IRefrence *)_Receiver));
+00221                         ((CNumericIndex &)r.getNumIdent()).save(os);                    
+00222                 }
+00223                 else
+00224                 {
+00225                         bool t = false;
+00226                         os.serial(t);
+00227                 }
+00228 
+00229                 if(_Continuation != NULL)
+00230                 {
+00231                         bool t = true;
+00232                         os.serial(t);
+00233                         IWordNumRef &r = (IWordNumRef&)((const IWordNumRef&)*((IRefrence *)_Continuation));
+00234                         ((CNumericIndex &)r.getNumIdent()).save(os);                    
+00235                 }
+00236                 else
+00237                 {
+00238                         bool t = false;
+00239                         os.serial(t);
+00240                 }
+00241                 os.serial( (NLAIC::CIdentType &) _MsgGroup->getType() );
+00242                 os.serial( *_MsgGroup );                
+00243 
+00244                 sint32 i = _Performatif;
+00245                 os.serial(i);
+00246                 os.serial(_comeFromC_PLUS);
+00247         }
+00248         
+00249         void IMessageBase::load(NLMISC::IStream &is)
+00250         {
+00251                 IListBasicManager::load(is);
+00252                 bool t;
+00253                 is.serial(t);           
+00254                 if(t)
+00255                 {
+00256                         CNumericIndex r(is);
+00257                         IRefrence *ref = CLocWordNumRef::getRef(r);
+00258                         if(ref != NULL)
+00259                         {
+00260                                 //if(_Sender) _Sender->release();
+00261                                 _Sender = ref;
+00262                                 //_Sender->incRef();
+00263                         }
+00264                         else
+00265                         {
+00266                                 //if(_Sender) _Sender->release();
+00267                                 setSender(new CProxyAgentMail(r.getId()) , true);
+00268                         }
+00269                         
+00270                 }
+00271                 else
+00272                 {                       
+00273                         _Sender = NULL;
+00274                 }
+00275                 
+00276                 is.serial(t);           
+00277                 if(t)
+00278                 {
+00279                         CNumericIndex r(is);
+00280                         IRefrence *ref = CLocWordNumRef::getRef(r);
+00281                         if(ref != NULL)
+00282                         {
+00283                                 //if(_Receiver) _Receiver->release();
+00284                                 _Receiver = ref;
+00285                                 //_Receiver->incRef();
+00286                         }
+00287                         else
+00288                         {
+00289                                 //if(_Receiver) _Receiver->release();
+00290                                 setReceiver(new CProxyAgentMail(r.getId()) , true);
+00291                         }
+00292                         
+00293                 }
+00294                 else
+00295                 {
+00296                         //if(_Receiver) _Receiver->release();
+00297                         _Receiver = NULL;
+00298                 }
+00299                 is.serial(t);           
+00300                 if(t)
+00301                 {
+00302                         CNumericIndex r(is);
+00303                         IRefrence *ref = CLocWordNumRef::getRef(r);
+00304                         if(ref != NULL)
+00305                         {
+00306                                 //if(_Continuation) _Continuation->release();
+00307                                 _Continuation = ref;
+00308                                 //_Continuation->incRef();
+00309                         }
+00310                         else
+00311                         {                               
+00312                                 //if(_Continuation) _Continuation->release();
+00313                                 setContinuation(new CProxyAgentMail(r.getId()) , true);
+00314                         }
+00315                         
+00316                 }
+00317                 else
+00318                 {
+00319                         //if(_Continuation) _Continuation->release();
+00320                         _Continuation = NULL;
+00321                 }
+00322 
+00323                 NLAIC::CIdentTypeAlloc id;
+00324                 is.serial( id );
+00325                 if(_MsgGroup) delete _MsgGroup;
+00326                 _MsgGroup = (IBasicMessageGroup *)id.allocClass();
+00327                 is.serial( (IBasicMessageGroup &)*_MsgGroup );                          
+00328                 sint32 i = _Performatif;
+00329                 is.serial(i);
+00330                 _Performatif = (TPerformatif)i;
+00331                 is.serial(_comeFromC_PLUS);
+00332         }
+00333 
+00334         void IMessageBase::getDebugString(std::string &t) const
+00335         {
+00336                 std::string a;
+00337                 if(_Sender != NULL) _Sender->getDebugString(a); 
+00338                 else a = "NULL";
+00339                 std::string b;
+00340                 IListBasicManager::getDebugString(b);
+00341                 std::string g;
+00342                 if(_MsgGroup != NULL) _MsgGroup->getDebugString(g);
+00343                 else g = "_MsgGroup = NULL";
+00344                 t += NLAIC::stringGetBuild("IMessageBase<%d>:\n_sender:'%s' _MsgGroup:'%s' Message:'%s' dispatch:%d",this,a.c_str(),g.c_str(),b.c_str(),_Dispatch);
+00345         }
+00346         
+00347 
+00348 
+00349         sint32 IMessageBase::getMethodIndexSize() const
+00350         {
+00351                 return IBaseGroupType::getMethodIndexSize() + _MLastM;
+00352         }       
+00353 
+00354         tQueue IMessageBase::isMember(const IVarName *className,const IVarName *methodName,const IObjectIA &p) const
+00355         {                       
+00356                 if(className == NULL)
+00357                 {
+00358                         tQueue a;
+00359                         for(int i = 0; i < _MLastM; i++)
+00360                         {
+00361                                 if( *methodName == IMessageBase::_Method[i].MethodName )
+00362                                 {                                       
+00363                                         CObjectType *c = new CObjectType(new NLAIC::CIdentType(*IAgent::IdAgent));
+00364                                         a.push( CIdMethod( IMessageBase::_Method[i].Index + IBaseGroupType::getMethodIndexSize(), 0.0, NULL, c) );                                      
+00365                                         break;
+00366                                 }
+00367                         }
+00368 
+00369                         if ( a.size() )
+00370                                 return a;
+00371                         else 
+00372                                 return IBaseGroupType::isMember( className, methodName, p);
+00373                 }
+00374                 return IListBasicManager::isMember(className,methodName,p);
+00375         }
+00376 
+00377         IObjectIA::CProcessResult IMessageBase::sendMessage(IObjectIA *m)
+00378         {
+00379                 return _Receiver->sendMessage(m);
+00380         }
+00381         
+00382         IObjectIA::CProcessResult IMessageBase::sendMessage(const IVarName &name,IObjectIA *m)
+00383         {
+00384                 return _Receiver->sendMessage(name,m);
+00385         }
+00386 
+00387         IObjectIA::CProcessResult IMessageBase::runMethodeMember(sint32 h, sint32 index,IObjectIA *p)
+00388         {
+00389                 return IBaseGroupType::runMethodeMember(h,index,p);
+00390         }
+00391 
+00392         IObjectIA::CProcessResult IMessageBase::runMethodeMember(sint32 index,IObjectIA *p)
+00393         {
+00394                 switch(index - IBaseGroupType::getMethodIndexSize())
+00395                 {
+00396                         case _TSender           :
+00397                                 {
+00398                                         IObjectIA::CProcessResult a;            
+00399                                         if ( _Sender != NULL )
+00400                                                 a.Result = new CLocalAgentMail( (IBasicAgent *) _Sender );                              
+00401                                         else
+00402                                         {
+00403                                                 a.Result = &DigitalType::NullOperator;
+00404                                                 a.Result->incRef();
+00405                                         }
+00406                                         return a;
+00407                                 }                       
+00408                                 break;
+00409 
+00410                         case _TReceiver :
+00411                                 {
+00412                                         IObjectIA::CProcessResult a;                            
+00413                                         if ( _Receiver != NULL )
+00414                                                 a.Result = new CLocalAgentMail( (IBasicAgent *) _Receiver );                            
+00415                                         else
+00416                                         {
+00417                                                 a.Result = &DigitalType::NullOperator;
+00418                                                 a.Result->incRef();
+00419                                         }
+00420                                         return a;
+00421                                 }       
+00422                                 break;
+00423 
+00424                         case _TContinuation     :
+00425                                 {
+00426                                         IObjectIA::CProcessResult a;                            
+00427                                         if ( _Continuation != NULL )
+00428                                                 a.Result = new CLocalAgentMail( (IBasicAgent *) _Continuation );                                
+00429                                         else
+00430                                         {
+00431                                                 a.Result = &DigitalType::NullOperator;
+00432                                                 a.Result->incRef();
+00433                                         }
+00434                                         return a;
+00435                                 }                       
+00436                                 break;
+00437                         
+00438                         case _TXchgReceiverIsSender     :
+00439                                 {
+00440                                         IObjectIA *t = _Sender;
+00441                                         _Sender = _Receiver;
+00442                                         _Receiver = t;
+00443                                         return IObjectIA::CProcessResult();
+00444                                 }
+00445                         case _TSetContinuation:
+00446                                 {
+00447                                         IObjectIA *o = (IObjectIA *)((IBaseGroupType *)p)->get();
+00448                                         //o->incRef();
+00449                                         setContinuation(o);
+00450                                         return IObjectIA::CProcessResult();
+00451                                 }
+00452 
+00453                         case _TSetSender:
+00454                                 {
+00455                                         IObjectIA *obj = (IObjectIA *) ((IBaseGroupType *)p)->get();                                    
+00456                                         CLocalAgentMail *o = dynamic_cast<CLocalAgentMail *>(obj);
+00457                                         if(o != NULL)
+00458                                                 setSender((IObjectIA *)o->getHost());
+00459                                         else
+00460                                                 setSender((IObjectIA *)obj);
+00461 
+00462                                         return IObjectIA::CProcessResult();
+00463                                 }                       
+00464 
+00465                         case _TInitProtocol:
+00466                                 {
+00467                                         _ReservedMethodIndexVar = -1;
+00468                                         _ReservedHeritanceIndexVar = 0;                                 
+00469                                         return IObjectIA::CProcessResult();                             
+00470                                 }
+00471                                 
+00472                         case _TProtcetSender:
+00473                                 {
+00474                                         setProtcetSender();                                     
+00475                                         return IObjectIA::CProcessResult();                             
+00476                                 }
+00477 
+00478                                 
+00479                         }
+00480                 return IBaseGroupType::runMethodeMember(index,p);
+00481         }
+00482 
+00483 
+00484         const NLAIC::CIdentType &CMessageList::getType() const
+00485         {
+00486                 return IdMessage;
+00487         }
+00488 
+00489         const NLAIC::CIdentType &CMessageVector::getType() const
+00490         {
+00491                 return IdMessageVector;
+00492         }
+00493 }
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1