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/group__type_8cpp-source.html | 1201 +++++++++++++++++++++++++ 1 file changed, 1201 insertions(+) create mode 100644 docs/doxygen/nel/group__type_8cpp-source.html (limited to 'docs/doxygen/nel/group__type_8cpp-source.html') diff --git a/docs/doxygen/nel/group__type_8cpp-source.html b/docs/doxygen/nel/group__type_8cpp-source.html new file mode 100644 index 00000000..a78893b9 --- /dev/null +++ b/docs/doxygen/nel/group__type_8cpp-source.html @@ -0,0 +1,1201 @@ + + + + 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  
+

group_type.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_object.h"
+00026 #include "nel/ai/agent/agent_digital.h"
+00027 #include "nel/ai/logic/boolval.h"
+00028 #include "nel/ai/agent/object_type.h"
+00029 #include "nel/ai/script/interpret_methodes.h"
+00030 #include "nel/ai/agent/agent_method_def.h"
+00031 
+00032 namespace NLAIAGENT
+00033 {
+00034         const static sint32 _Const = 0;
+00035         const static sint32 _Push = 1;
+00036         const static sint32 _PushFront = 2;
+00037         const static sint32 _Pop = 3;
+00038         const static sint32 _PopFront = 4;
+00039         const static sint32 _Back = 5;
+00040         const static sint32 _Front = 6;
+00041         const static sint32 _Get = 7;
+00042         const static sint32 _Set = 8;
+00043         const static sint32 _Size = 9;
+00044         const static sint32 _LastM = 10;
+00045 
+00046         IBaseGroupType::CMethodCall IBaseGroupType::_Method[] = 
+00047         {
+00048                 IBaseGroupType::CMethodCall(_CONSTRUCTOR_,_Const),
+00049                 IBaseGroupType::CMethodCall("Push",_Push),
+00050                 IBaseGroupType::CMethodCall("PushFront",_PushFront),
+00051                 IBaseGroupType::CMethodCall("Pop",_Pop),
+00052                 IBaseGroupType::CMethodCall("PopFront",_PopFront),
+00053                 IBaseGroupType::CMethodCall("Back",_Back),
+00054                 IBaseGroupType::CMethodCall("Front",_Front),            
+00055                 IBaseGroupType::CMethodCall("Get",_Get),
+00056                 IBaseGroupType::CMethodCall("Set",_Set),
+00057                 IBaseGroupType::CMethodCall("Size",_Size)
+00058         };      
+00059       
+00060         IBaseGroupType::IBaseGroupType()
+00061         {
+00062         }
+00063 
+00064         IBaseGroupType::~IBaseGroupType()
+00065         {
+00066         }
+00067 
+00068         IObjetOp &IBaseGroupType::operator += (const IObjetOp &a)
+00069         {
+00070                 cpy(a);
+00071                 return *this;
+00072         }
+00073 
+00074         IObjetOp &IBaseGroupType::operator -= (const IObjetOp &a)
+00075         {
+00076                 erase(a);
+00077                 return *this;
+00078         }
+00079 
+00080         IObjetOp &IBaseGroupType::operator += (IObjetOp *a)
+00081         {
+00082                 push(a);
+00083                 return *this;
+00084         }
+00085 
+00086         IObjetOp &IBaseGroupType::operator -= (IObjetOp *a)
+00087         {
+00088                 erase(a);
+00089                 return *this;
+00090         }
+00091 
+00092         sint32 IBaseGroupType::getMethodIndexSize() const
+00093         {
+00094                 return IObjetOp::getMethodIndexSize() + _LastM;
+00095         }
+00096 
+00097         tQueue IBaseGroupType::isMember(const IVarName *className,const IVarName *methodName,const IObjectIA &p) const
+00098         {
+00099                 tQueue a;
+00100                 NLAISCRIPT::CParam methodParam;
+00101                 
+00102                 if(className == NULL)
+00103                 {
+00104                         for(int i = 0; i < _LastM; i++)
+00105                         {
+00106 
+00107 #ifdef NL_DEBUG
+00108                 std::string s;
+00109                 methodName->getDebugString(s);
+00110                 if(s == "Get")
+00111                 {
+00112                         s = s;
+00113                 }
+00114 #endif
+00115                                 if(*methodName == IBaseGroupType::_Method[i].MethodName)
+00116                                 {                                                                               
+00117                                         switch(_Method[i].Index)
+00118                                         {
+00119                                         case _Const:
+00120                                         case _Push:
+00121                                         case _PushFront:
+00122                                         case _Set:              
+00123                                                 {
+00124                                                         CObjectType *c = new CObjectType(new NLAIC::CIdentType(NLAIC::CIdentType::VoidType));
+00125                                                         a.push(CIdMethod(IBaseGroupType::_Method[i].Index + IObjetOp::getMethodIndexSize(),0.0,NULL,c));
+00126                                                 }
+00127                                                 return a;
+00128                                         case _Size:
+00129                                                 {
+00130                                                         CObjectType *c = new CObjectType(new NLAIC::CIdentType(DigitalType::IdDigitalType));
+00131                                                         a.push(CIdMethod(IBaseGroupType::_Method[i].Index + IObjetOp::getMethodIndexSize(),0.0,NULL,c));
+00132                                                 }
+00133                                                 return a;
+00134                                         default:
+00135                                                 {
+00136                                                         CObjectType *c = new CObjectType(new NLAIC::CIdentType(*IAgent::IdAgent));
+00137                                                         a.push(CIdMethod(IBaseGroupType::_Method[i].Index + IObjetOp::getMethodIndexSize(),0.0,NULL,c));
+00138                                                 }
+00139                                                 return a;                                       
+00140                                         }
+00141                                 }
+00142                         }
+00143                 }
+00144                 return IObjetOp::isMember(className,methodName,p);
+00145         }
+00146 
+00147         IObjectIA::CProcessResult IBaseGroupType::runMethodeMember(sint32, sint32, IObjectIA *)
+00148         {
+00149                 return IObjectIA::CProcessResult();
+00150         }
+00151         IObjectIA::CProcessResult IBaseGroupType::runMethodeMember(sint32 index,IObjectIA *p)
+00152         {
+00153                 IBaseGroupType *param = (IBaseGroupType *)p;
+00154 
+00155                 switch(index - IObjetOp::getMethodIndexSize())
+00156                 {
+00157                 case _Const:
+00158                         return IObjectIA::CProcessResult();
+00159                 case _Push:     
+00160                         {
+00161                                 CIteratorContener i = param->getIterator();
+00162                                 while(!i.isInEnd())
+00163                                 {
+00164                                         IObjectIA *a = (IObjectIA *)i++;
+00165                                         a->incRef();
+00166                                         push(a);
+00167                                 }       
+00168                         }
+00169                         return IObjectIA::CProcessResult();
+00170                 case _PushFront:
+00171                         {
+00172                                 CIteratorContener i = param->getIterator();
+00173                                 while(!i.isInEnd())
+00174                                 {
+00175                                         IObjectIA *a = (IObjectIA *)i++;
+00176                                         a->incRef();
+00177                                         pushFront(a);
+00178                                 }       
+00179                         }
+00180                         return IObjectIA::CProcessResult();
+00181                         
+00182                 
+00183                 case _Pop:
+00184                         {
+00185                                 IObjectIA::CProcessResult c;
+00186                                 IObjectIA *a = (IObjectIA *)pop();                              
+00187                                 c.Result = a;
+00188                                 c.ResultState = IObjectIA::ProcessIdle;
+00189                                 return c;
+00190                         }
+00191 
+00192                 case _PopFront: 
+00193                         {
+00194                                 IObjectIA::CProcessResult c;
+00195                                 IObjectIA *a = (IObjectIA *)popFront();                         
+00196                                 c.Result = a;
+00197                                 c.ResultState = IObjectIA::ProcessIdle;
+00198                                 return c;
+00199                         }
+00200 
+00201                 case _Back:
+00202                         {
+00203                                 IObjectIA::CProcessResult c;
+00204                                 IObjectIA *a = (IObjectIA *)get();
+00205                                 a->incRef();
+00206                                 c.Result = a;
+00207                                 c.ResultState = IObjectIA::ProcessIdle;
+00208                                 return c;
+00209                         }
+00210 
+00211                 case _Front:    
+00212                         {
+00213                                 IObjectIA::CProcessResult c;
+00214                                 IObjectIA *a = (IObjectIA *)getFront();
+00215                                 a->incRef();
+00216                                 c.Result = a;
+00217                                 c.ResultState = IObjectIA::ProcessIdle;
+00218                                 return c;
+00219                         }
+00220 
+00221                 case _Get:
+00222                         {
+00223                                 IObjectIA::CProcessResult c;
+00224                                 const INombreDefine *f = (const INombreDefine *)param->get();
+00225                                 IObjectIA *a = (IObjectIA *)(*this)[(sint32)f->getNumber()];
+00226                                 a->incRef();
+00227                                 c.Result = a;
+00228                                 c.ResultState = IObjectIA::ProcessIdle;
+00229                                 return c;
+00230                         }
+00231 
+00232                 case _Set:
+00233                         {
+00234                                 CIteratorContener i = param->getIterator();
+00235                                 const DigitalType *f = (const DigitalType *)i ++;
+00236                                 IObjectIA *n = (IObjectIA *)i++;                                
+00237                                 
+00238 
+00239                                 set((sint32)f->getValue(),n);
+00240                                 n->incRef();
+00241                                 return IObjectIA::CProcessResult();
+00242                         }
+00243                 case _Size:
+00244                         {
+00245                                 DigitalType *f = new DigitalType((float)size());
+00246                                 IObjectIA::CProcessResult c;
+00247                                 c.Result = f;
+00248                                 c.ResultState = IObjectIA::ProcessIdle;
+00249                                 return c;
+00250                         }
+00251                 }
+00252 
+00253                 return IObjectIA::runMethodeMember(index,p);
+00254         }
+00255 
+00256         sint32 IBaseGroupType::isClassInheritedFrom(const IVarName &) const
+00257         {
+00258                 return -1;
+00259         }
+00260 
+00261         bool IBaseGroupType::isTrue() const
+00262         {
+00263                 return IObjetOp::isTrue();
+00264         }
+00265 
+00268 
+00269         IObjetOp *CGroupType::operator + (IObjetOp *a)
+00270         {
+00271                 CGroupType *o = new CGroupType();
+00272                 tListType::const_iterator i = _List.begin();
+00273                 while(i != _List.end())
+00274                 {
+00275                         o->_List.push_back(*i);
+00276                         ((IObjetOp*)(*i))->incRef();
+00277                         i ++;
+00278                 }
+00279                 
+00280                 *o += a;
+00281                 a->incRef();
+00282                 return o;
+00283         }
+00284         IObjetOp *CGroupType::operator - (IObjetOp *a)
+00285         {
+00286                 CGroupType *o = new CGroupType();
+00287                 tListType::const_iterator i = _List.begin();
+00288                 while(i != _List.end())
+00289                 {
+00290                         o->_List.push_back(*i);
+00291                         ((IObjetOp*)(*i))->incRef();
+00292                         i ++;
+00293                 }
+00294 
+00295                 *o -= a;
+00296                 a->release();
+00297                 return o;
+00298         }
+00299 
+00300         IObjetOp *CGroupType::operator + (const IObjetOp &a)
+00301         {
+00302                 CGroupType *o = new CGroupType();
+00303                 tListType::const_iterator i = _List.begin();
+00304                 while(i != _List.end())
+00305                 {
+00306                         o->_List.push_back(*i);
+00307                         ((IObjetOp*)(*i))->incRef();
+00308                         i ++;
+00309                 }
+00310                 
+00311                 *o += a;
+00312                 return o;
+00313         }
+00314         IObjetOp *CGroupType::operator - (const IObjetOp &a)
+00315         {
+00316                 CGroupType *o = new CGroupType();
+00317                 tListType::const_iterator i = _List.begin();
+00318                 while(i != _List.end())
+00319                 {
+00320                         o->_List.push_back(*i);
+00321                         ((IObjetOp*)(*i))->incRef();
+00322                         i ++;
+00323                 }
+00324 
+00325                 *o -= a;
+00326                 return o;
+00327         }
+00328         
+00329 
+00330         IObjetOp *CGroupType::operator ! () const
+00331         {               
+00332                 NLAILOGIC::CBoolType *x = new NLAILOGIC::CBoolType(!size());
+00333                 return x;
+00334         }
+00335 
+00336         IObjectIA &CGroupType::operator = (const IObjectIA &a)
+00337         {               
+00338                 clear();
+00339                 if((uint)(((const NLAIC::CTypeOfObject &)a.getType()) & NLAIC::CTypeOfObject::tList))
+00340                 {
+00341                         const CGroupType &g= (const CGroupType &)a;
+00342                         tListType::const_iterator i = g._List.begin();
+00343                         while(i != g._List.end())
+00344                         {
+00345                                 _List.push_back((const IObjectIA *)(*i++)->clone());
+00346                         }
+00347                 }       
+00348                 else _List.push_back((const IObjectIA *)a.clone());
+00349                 return *this;
+00350         }
+00351 
+00352         const IObjectIA *CGroupType::operator[] (sint32 index) const
+00353         {
+00354                 if ( index >= (sint32) _List.size() )
+00355                 {
+00356                         //TODO: throw Exc::CExceptionIndexError
+00357                 }
+00358 
+00359                 tListType::const_iterator it_l = _List.begin();
+00360                 for (sint32 i = 0; i < index; i++)
+00361                         it_l++;
+00362 
+00363                 return *it_l;
+00364         }
+00365 
+00366         void CGroupType::set(int index,IObjectIA *o)
+00367         {
+00368                 tListType::iterator it_l = _List.begin();
+00369                 for (sint32 i = 0; i < index; i++)
+00370                         it_l++;
+00371                 ((IObjectIA *)(*it_l))->release();
+00372                 (*it_l) = o;
+00373         }
+00374 
+00375         const NLAIC::CIdentType &CGroupType::getType() const            
+00376         {               
+00377                 return IdGroupType;
+00378         }
+00379 
+00380         const IObjectIA::CProcessResult &CGroupType::run()
+00381         {
+00382                 tListType::iterator i = _List.begin();
+00383                 while(i != _List.end())
+00384                 {
+00385                         ((IObjectIA *)(*i++))->run();
+00386                 }
+00387                 return IObjectIA::ProcessRun;  
+00388         }
+00389 
+00390         CGroupType::tListType &CGroupType::getList() 
+00391         {
+00392                 return _List;
+00393         }
+00394 
+00395         CGroupType::CGroupType()
+00396         {                                               
+00397         }
+00398 
+00399         CGroupType::CGroupType(const CGroupType &g)
+00400         {
+00401                 tListType::const_iterator i = g._List.begin();
+00402                 while(i != g._List.end())
+00403                 {
+00404                         _List.push_back((const IObjectIA *)(*i++)->clone());
+00405                 }
+00406         }                       
+00407                                                                                                                                                         
+00408         void CGroupType::getDebugString(std::string &text) const
+00409         {                                               
+00410                 text += "[";
+00411                 std::list<const IObjectIA *>::const_iterator i = _List.begin();
+00412                 while(i != _List.end())
+00413                 {
+00414                         std::string temp;
+00415                         (*i++)->getDebugString(temp);                           
+00416                         text += temp;
+00417                         if(i != _List.end()) text += " ";
+00418                 }
+00419                 text += "]";
+00420         }       
+00421 
+00422 //      IObjetOp *CGroupType::operator ! () const;
+00423 
+00424         void CGroupType::push(const IObjectIA *o)
+00425         {
+00426                 _List.push_back(o);
+00427         }
+00428 
+00429         void CGroupType::pushFront(const IObjectIA *o)
+00430         {
+00431                 _List.push_front(o);
+00432         }
+00433 
+00434         void CGroupType::cpy(const IObjectIA &o) 
+00435         {
+00436                 const IObjectIA *t = (const IObjectIA *)o.clone();      
+00437                 _List.push_back(t);
+00438         }
+00439 
+00440         const IObjectIA *CGroupType::pop() 
+00441         {
+00442                 const IObjectIA *Obj = _List.back();
+00443                 _List.pop_back();
+00444                 return Obj;
+00445         }
+00446 
+00447         const IObjectIA *CGroupType::get() const
+00448         {
+00449                 return _List.back();                    
+00450         }
+00451 
+00452         const IObjectIA *CGroupType::popFront() 
+00453         {
+00454                 const IObjectIA *Obj = _List.front();
+00455                 _List.pop_front();
+00456                 return Obj;
+00457         }
+00458 
+00459         const IObjectIA *CGroupType::getFront() const
+00460         {
+00461                 return _List.front();                   
+00462         }       
+00463 
+00464         sint32 CGroupType::size() const
+00465         {
+00466                 return _List.size();
+00467         }
+00468 
+00469         CGroupType::tListType CGroupType::findList(const IObjectIA &obj) const
+00470         {
+00471                 tListType l;                    
+00472                 tListType::const_iterator i = _List.begin();
+00473                 while(i != _List.end())
+00474                 {
+00475                         const IObjectIA *o = *i++;
+00476                         if( *o == obj) l.push_back();
+00477                 }
+00478                 return l;
+00479 
+00480         }
+00481 
+00482         CGroupType::tListType::const_iterator CGroupType::getBegin() const
+00483         {
+00484                 return _List.begin();
+00485         }
+00486 
+00487         CGroupType::tListType::const_iterator CGroupType::getEnd() const
+00488         {
+00489                 return _List.end();
+00490         }               
+00491 
+00492         CGroupType::tListType::iterator CGroupType::getBegin()
+00493         {
+00494                 return _List.begin();
+00495         }
+00496 
+00497         CGroupType::tListType::iterator CGroupType::getEnd()
+00498         {
+00499                 return _List.end();
+00500         }               
+00501 
+00502         const IObjectIA *CGroupType::find(const IObjectIA &obj) const
+00503         {                       
+00504                 tListType::const_iterator i = _List.begin();
+00505                 while(i != _List.end())
+00506                 {
+00507                         const IObjectIA *o = *i++;
+00508                         if( *o == obj) return o;
+00509                 }
+00510                 return NULL;
+00511         }
+00512 
+00513         /*void CGroupType::eraseFirst(const IObjectIA &obj) 
+00514         {                               
+00515                 tListType::iterator i = _List.begin();
+00516                 while(i != _List.end())
+00517                 {
+00518                         IObjectIA *o= (IObjectIA *)*i;
+00519                         if( *o == obj)
+00520                         {                                       
+00521                                 _List.erase(i);
+00522                                 o->release();
+00523                                 return;
+00524                         }
+00525                         i++;
+00526                 }                       
+00527         }*/
+00528 
+00529         void CGroupType::eraseAll(const IObjectIA &obj) 
+00530         {                       
+00531                 tListType::iterator i = _List.begin();
+00532                 while(i != _List.end())
+00533                 {
+00534                         tListType::iterator j = i++;
+00535                         IObjectIA *o= (IObjectIA *)*j;
+00536                         if( *o == obj)
+00537                         {                                       
+00538                                 _List.erase(j);
+00539                                 o->release();
+00540                                 return;
+00541                         }
+00542                 }
+00543         }
+00544 
+00545         void CGroupType::erase(const IObjectIA *o) 
+00546         {       
+00547                 tListType::iterator i = _List.begin();
+00548                 while(i != _List.end())
+00549                 {
+00550                         tListType::iterator j = i++;
+00551                         if( *j == o)
+00552                         {
+00553                                 IObjectIA *o = (IObjectIA *)*j;
+00554                                 _List.erase(j);
+00555                                 o->release();
+00556                                 return;
+00557                         }                               
+00558                 }
+00559         }
+00560 
+00561         void CGroupType::erase(const IObjectIA &obj) 
+00562         {       
+00563                 tListType::iterator i = _List.begin();
+00564                 while(i != _List.end())
+00565                 {
+00566                         tListType::iterator j = i++;
+00567                         if( *(*j) == obj)
+00568                         {
+00569                                 IObjectIA *o = (IObjectIA *)*j;
+00570                                 _List.erase(j);
+00571                                 o->release();
+00572                                 return;
+00573                         }                               
+00574                 }
+00575         }
+00576 
+00577         void CGroupType::erase(std::list<const IObjectIA *> &l) 
+00578         {                       
+00579                 tListType::iterator i = l.begin();
+00580                 while(i != l.end())
+00581                 {
+00582                         erase(*i++);                                                            
+00583                 }
+00584         }
+00585 
+00586         bool CGroupType::isEqual(const IBasicObjectIA &a) const
+00587         {
+00588                 const CGroupType &b = (const CGroupType &)a;                    
+00589                 if(size() != b.size()) return false;
+00590 
+00591                 tListType::const_iterator i = _List.begin();
+00592                 tListType::const_iterator j = b._List.begin();
+00593                 
+00594                 while(i != _List.end())
+00595                 {
+00596                         const IObjectIA *a1 = *i;
+00597                         const IObjectIA *a2 = *j;
+00598                         if( a1 != a2)
+00599                                 if(!(*a1 == *a2)) return false;
+00600                         i ++;
+00601                         j ++;
+00602                 }
+00603                 return true;
+00604         }
+00605 
+00606         const NLAIC::IBasicType *CGroupType::clone() const
+00607         {
+00608                 NLAIC::IBasicInterface *m = new CGroupType(*this);
+00609                 return m;
+00610         }
+00611 
+00612         const NLAIC::IBasicType *CGroupType::newInstance() const
+00613         {
+00614                 NLAIC::IBasicInterface *m = new CGroupType();
+00615                 return m;
+00616         }       
+00617 
+00618         void CGroupType::save(NLMISC::IStream &os)
+00619         {       
+00620                 sint32 size = _List.size();
+00621                 os.serial(size);
+00622                 std::list<const IObjectIA *>::const_iterator i = _List.begin();
+00623                 while(i != _List.end())
+00624                 {
+00625                         IObjectIA *o= (IObjectIA *)*i++;
+00626                         os.serial( (NLAIC::CIdentType &) o->getType() );
+00627                         o->save(os);
+00628                 }                       
+00629         }
+00630 
+00631         IObjetOp &CGroupType::neg()
+00632         {
+00633                 tListType::iterator i = _List.begin();
+00634                 while(i != _List.end())
+00635                 {
+00636                         const NLAIC::CTypeOfOperator &op = (const NLAIC::CTypeOfOperator &)(*i)->getType();
+00637                         if((uint32)(op & NLAIC::CTypeOfOperator::opNeg)) ((IObjetOp *)(*i))->neg();
+00638                         i++;
+00639                 }
+00640                 return *this;   
+00641         }
+00642 
+00643         void CGroupType::load(NLMISC::IStream &is)
+00644         {                       
+00645                 sint32 i;
+00646                 while(_List.size())
+00647                 {
+00648                         NLAIC::IBasicInterface * o = (NLAIC::IBasicInterface *)_List.front();
+00649                         o->release();
+00650                         _List.pop_front();
+00651                 }
+00652                 is.serial( i );
+00653                 NLAIC::CIdentTypeAlloc id;
+00654                 while(i--)
+00655                 {                               
+00656                         is.serial( id );
+00657                         NLAIC::IBasicInterface *o = (NLAIC::IBasicInterface *)id.allocClass();                          
+00658                         o->load(is);
+00659                         _List.push_back((const IObjectIA *)o);
+00660                                 
+00661                 }                       
+00662         }
+00663 
+00664         void CGroupType::clear()
+00665         {
+00666                 while(_List.size())
+00667                 {
+00668                         NLAIC::IBasicInterface * o = (NLAIC::IBasicInterface *)_List.front();
+00669                         o->release();
+00670                         _List.pop_front();
+00671                 }
+00672                 _List.clear();
+00673         }
+00674 
+00675         CGroupType::~CGroupType()
+00676         {                       
+00677                 clear();
+00678         }
+00679 
+00682 
+00683         IObjetOp *CVectorGroupType::operator + (IObjetOp *a)
+00684         {
+00685                 CVectorGroupType *o = new CVectorGroupType();
+00686                 tVectorType::const_iterator i = _Vector.begin();
+00687                 while(i != _Vector.end())
+00688                 {
+00689                         o->_Vector.push_back(*i);
+00690                         ((IObjetOp*)(*i))->incRef();
+00691                         i ++;
+00692                 }
+00693                 
+00694                 *o += a;
+00695                 a->incRef();
+00696                 return o;
+00697         }
+00698         IObjetOp *CVectorGroupType::operator - (IObjetOp *a)
+00699         {
+00700                 CVectorGroupType *o = new CVectorGroupType();
+00701                 tVectorType::const_iterator i = _Vector.begin();
+00702                 while(i != _Vector.end())
+00703                 {
+00704                         o->_Vector.push_back(*i);
+00705                         ((IObjetOp*)(*i))->incRef();
+00706                         i ++;
+00707                 }
+00708                 
+00709                 *o -= a;                
+00710                 a->release();
+00711                 return o;
+00712         }
+00713 
+00714         IObjetOp *CVectorGroupType::operator + (const IObjetOp &a)
+00715         {
+00716                 CVectorGroupType *o = new CVectorGroupType();
+00717                 tVectorType::const_iterator i = _Vector.begin();
+00718                 while(i != _Vector.end())
+00719                 {
+00720                         o->_Vector.push_back(*i);
+00721                         ((IObjetOp*)(*i))->incRef();
+00722                         i ++;
+00723                 }
+00724                 
+00725                 *o += a;
+00726                 
+00727                 return o;
+00728         }
+00729         IObjetOp *CVectorGroupType::operator - (const IObjetOp &a)
+00730         {
+00731                 CVectorGroupType *o = new CVectorGroupType();
+00732                 tVectorType::const_iterator i = _Vector.begin();
+00733                 while(i != _Vector.end())
+00734                 {
+00735                         o->_Vector.push_back(*i);
+00736                         ((IObjetOp*)(*i))->incRef();
+00737                         i ++;
+00738                 }
+00739                 
+00740                 *o -= a;                
+00741                 return o;
+00742         }
+00743         
+00744 
+00745         IObjetOp *CVectorGroupType::operator ! () const
+00746         {               
+00747                 NLAILOGIC::CBoolType *x = new NLAILOGIC::CBoolType(!size());
+00748                 return x;
+00749         }
+00750 
+00751         IObjectIA &CVectorGroupType::operator = (const IObjectIA &a)
+00752         {               
+00753                 clear();
+00754                 if((uint)(((const NLAIC::CTypeOfObject &)a.getType()) & NLAIC::CTypeOfObject::tList))
+00755                 {
+00756                         const CVectorGroupType &g= (const CVectorGroupType &)a;
+00757                         tVectorType::const_iterator i = g._Vector.begin();
+00758                         while(i != g._Vector.end())
+00759                         {
+00760                                 _Vector.push_back((const IObjectIA *)(*i++)->clone());
+00761                         }
+00762                 }       
+00763                 else 
+00764                         _Vector.push_back((const IObjectIA *)a.clone());
+00765                 return *this;
+00766         }
+00767 
+00768         const NLAIC::CIdentType &CVectorGroupType::getType() const              
+00769         {               
+00770                 return IdVectorGroupType;
+00771         }
+00772 
+00773         const IObjectIA::CProcessResult &CVectorGroupType::run()
+00774         {
+00775                 tVectorType::iterator i = _Vector.begin();
+00776                 while(i != _Vector.end())
+00777                 {
+00778                         ((IObjectIA *)(*i++))->run();
+00779                 }
+00780                 return IObjectIA::ProcessRun; 
+00781         }
+00782 
+00783         CVectorGroupType::tVectorType &CVectorGroupType::getVector() 
+00784         {
+00785                 return _Vector;
+00786         }
+00787 
+00788 
+00789         CVectorGroupType::CVectorGroupType(sint32 i): _Vector(i)
+00790         {
+00791         }
+00792 
+00793         CVectorGroupType::CVectorGroupType()
+00794         {                                               
+00795         }
+00796 
+00797         CVectorGroupType::CVectorGroupType(const CVectorGroupType &g)
+00798         {
+00799                 _Vector = g._Vector;
+00800                 tVectorType::const_iterator i = _Vector.begin();
+00801                 while(i != _Vector.end())
+00802                 {
+00803                         ((IObjectIA *)(*i++))->incRef();
+00804                 }
+00805         }                       
+00806 
+00807         void CVectorGroupType::getDebugString(std::string &text) const
+00808         {               
+00809                 
+00810                 if(_Vector.size())
+00811                 {                       
+00812                         text += "[";
+00813                         std::vector<const IObjectIA *>::const_iterator i = _Vector.begin();
+00814                         while(i != _Vector.end())
+00815                         {
+00816                                 std::string temp;
+00817                                 const IObjectIA *o = *i++;
+00818                                 o->getDebugString(temp);                                
+00819                                 text += temp;
+00820                                 if(i != _Vector.end()) text += " ";
+00821                         }
+00822                         text += "]";
+00823 
+00824                 }
+00825                 else
+00826                 {
+00827                         text += NLAIC::stringGetBuild("CVectorGroupType<%04x>: <empty>",this);
+00828                 }               
+00829         }       
+00830 
+00831 //      IObjetOp *CVectorGroupType::operator ! () const;
+00832 
+00833         void CVectorGroupType::push(const IObjectIA *o)
+00834         {
+00835                 _Vector.push_back(o);
+00836         }
+00837 
+00838         void CVectorGroupType::pushFront(const IObjectIA *o)
+00839         {
+00840                 _Vector.push_back(o);
+00841                 for(sint32 i = (sint32)_Vector.back() - 2; i == 0; i -- )
+00842                 {                       
+00843                         _Vector[i + 1] = _Vector[i];
+00844                 }
+00845                 _Vector[0] = o;
+00846 
+00847         }
+00848 
+00849         void CVectorGroupType::cpy(const IObjectIA &o) 
+00850         {
+00851                 _Vector.push_back((const IObjectIA *)o.clone());
+00852         }
+00853 
+00854         const IObjectIA *CVectorGroupType::pop() 
+00855         {
+00856                 const IObjectIA *Obj = _Vector.back();
+00857                 _Vector.erase( _Vector.end() );
+00858                 return Obj;
+00859         }
+00860 
+00861         const IObjectIA *CVectorGroupType::get() const
+00862         {
+00863                 return _Vector.back();                  
+00864         }
+00865 
+00866         const IObjectIA *CVectorGroupType::popFront() 
+00867         {
+00868                 const IObjectIA *Obj = _Vector.front();
+00869                 _Vector.erase( _Vector.begin() );
+00870                 return Obj;
+00871         }
+00872 
+00873         const IObjectIA *CVectorGroupType::getFront() const
+00874         {
+00875                 return _Vector.front();                 
+00876         }       
+00877 
+00878         sint32 CVectorGroupType::size() const
+00879         {
+00880                 return _Vector.size();
+00881         }
+00882 
+00883         CVectorGroupType::tVectorType CVectorGroupType::findList(const IObjectIA &obj) const
+00884         {
+00885                 tVectorType l;                  
+00886                 tVectorType::const_iterator i = _Vector.begin();
+00887                 while(i != _Vector.end())
+00888                 {
+00889                         const IObjectIA *o = *i++;
+00890                         if( *o == obj) 
+00891                                 l.push_back( o );
+00892                 }
+00893                 return l;
+00894         }
+00895 
+00896         const IObjectIA *CVectorGroupType::operator[] (sint32 index) const
+00897         {
+00898 #ifdef _DEGUG
+00899                 if ( index >= (sint32) _Vector.size() )
+00900                 {
+00901                         //TODO: throw Exc::CExceptionIndexError
+00902                 }
+00903 #endif
+00904 
+00905                 return _Vector[ index ];
+00906         }
+00907 
+00908         void CVectorGroupType::set(int index,IObjectIA *o)
+00909         {
+00910                 if((IObjectIA *)_Vector[ index ] != NULL) ((IObjectIA *)_Vector[ index ])->release();
+00911                 _Vector[ index ] = o;
+00912         }
+00913 
+00914 
+00915         CVectorGroupType::tVectorType::const_iterator CVectorGroupType::getBegin() const
+00916         {
+00917                 return _Vector.begin();
+00918         }
+00919 
+00920         CVectorGroupType::tVectorType::const_iterator CVectorGroupType::getEnd() const
+00921         {
+00922                 return _Vector.end();
+00923         }
+00924 
+00925         CVectorGroupType::tVectorType::iterator CVectorGroupType::getBegin()
+00926         {
+00927                 return _Vector.begin();
+00928         }
+00929 
+00930         CVectorGroupType::tVectorType::iterator CVectorGroupType::getEnd()
+00931         {
+00932                 return _Vector.end();
+00933         }               
+00934 
+00935         const IObjectIA *CVectorGroupType::find(const IObjectIA &obj) const
+00936         {                       
+00937                 tVectorType::const_iterator i = _Vector.begin();
+00938                 while(i != _Vector.end())
+00939                 {
+00940                         const IObjectIA *o = *i++;
+00941                         if( *o == obj) return o;
+00942                 }
+00943                 return NULL;
+00944         }       
+00945 
+00946         void CVectorGroupType::eraseAll(const IObjectIA &obj) 
+00947         {                       
+00948                 tVectorType::iterator i = _Vector.begin();
+00949                 while(i != _Vector.end())
+00950                 {
+00951                         tVectorType::iterator j = i++;
+00952                         IObjectIA *o= (IObjectIA *)*j;
+00953                         if( *o == obj)
+00954                         {                                       
+00955                                 _Vector.erase(j);
+00956                                 o->release();
+00957                                 return;
+00958                         }
+00959                 }
+00960         }
+00961 
+00962         void CVectorGroupType::erase(const IObjectIA *o) 
+00963         {       
+00964                 tVectorType::iterator i = _Vector.begin();
+00965                 while(i != _Vector.end())
+00966                 {
+00967                         tVectorType::iterator j = i++;
+00968                         if( *j == o)
+00969                         {
+00970                                 IObjectIA *o = (IObjectIA *)*j;
+00971                                 _Vector.erase(j);
+00972                                 o->release();
+00973                                 return;
+00974                         }                               
+00975                 }
+00976         }
+00977 
+00978         void CVectorGroupType::erase(const IObjectIA &obj) 
+00979         {       
+00980                 tVectorType::iterator i = _Vector.begin();
+00981                 while(i != _Vector.end())
+00982                 {
+00983                         tVectorType::iterator j = i++;
+00984                         if ( *(*j) == obj )
+00985                         {
+00986                                 IObjectIA *o = (IObjectIA *)*j;
+00987                                 _Vector.erase(j);
+00988                                 o->release();
+00989                                 return;
+00990                         }                               
+00991                 }
+00992         }
+00993 
+00994         void CVectorGroupType::erase(std::list<const IObjectIA *> &l) 
+00995         {                       
+00996                 std::list<const IObjectIA *>::iterator i = l.begin();
+00997                 while(i != l.end())
+00998                 {
+00999                         erase(*i++);                                                            
+01000                 }
+01001         }
+01002 
+01003         bool CVectorGroupType::isEqual(const IBasicObjectIA &a) const
+01004         {
+01005                 const CVectorGroupType &b = (const CVectorGroupType &)a;                        
+01006                 if(size() != b.size()) return false;
+01007 
+01008                 tVectorType::const_iterator i = _Vector.begin();
+01009                 tVectorType::const_iterator j = _Vector.begin();
+01010                 
+01011                 while(i != _Vector.end())
+01012                 {
+01013                         if(!(*i++)->isEqual(*(*j++))) return false;
+01014                 }
+01015                 return true;
+01016         }
+01017 
+01018         const NLAIC::IBasicType *CVectorGroupType::clone() const
+01019         {
+01020                 NLAIC::IBasicInterface *m = new CVectorGroupType(*this);
+01021                 return m;
+01022         }
+01023 
+01024         const NLAIC::IBasicType *CVectorGroupType::newInstance() const
+01025         {
+01026                 NLAIC::IBasicInterface *m = new CVectorGroupType();
+01027                 return m;
+01028         }       
+01029 
+01030         void CVectorGroupType::save(NLMISC::IStream &os)
+01031         {       
+01032                 sint32 size = _Vector.size();
+01033                 os.serial( size );
+01034                 std::vector<const IObjectIA *>::const_iterator i = _Vector.begin();
+01035                 while(i != _Vector.end())
+01036                 {
+01037                         IObjectIA *o= (IObjectIA *)*i++;
+01038                         os.serial( (NLAIC::CIdentType &) o->getType() );
+01039                         o->save(os);
+01040                 }                       
+01041         }
+01042 
+01043         IObjetOp &CVectorGroupType::neg()
+01044         {
+01045                 tVectorType::iterator i = _Vector.begin();
+01046                 while(i != _Vector.end())
+01047                 {
+01048                         const NLAIC::CTypeOfOperator &op = (const NLAIC::CTypeOfOperator &)(*i)->getType();
+01049                         if((uint32)(op & NLAIC::CTypeOfOperator::opNeg)) ((IObjetOp *)(*i))->neg();
+01050                         i++;
+01051                 }
+01052                 return *this;   
+01053         }
+01054 
+01055         void CVectorGroupType::load(NLMISC::IStream &is)
+01056         {                       
+01057                 sint32 i;
+01058                 while(_Vector.size())
+01059                 {
+01060                         NLAIC::IBasicInterface * o = (NLAIC::IBasicInterface *)_Vector.front();
+01061                         o->release();
+01062                         _Vector.erase( _Vector.begin() );
+01063                 }
+01064                 is.serial( i );
+01065                 NLAIC::CIdentTypeAlloc id;
+01066                 while(i--)
+01067                 {                               
+01068                         is.serial( id );
+01069                         NLAIC::IBasicInterface *o = (NLAIC::IBasicInterface *)id.allocClass();                          
+01070                         o->load(is);
+01071                         _Vector.push_back((const IObjectIA *)o);
+01072                                 
+01073                 }                       
+01074         }
+01075 
+01076         void CVectorGroupType::clear()  
+01077         {
+01078                 while(_Vector.size())
+01079                 {
+01080                         NLAIC::IBasicInterface * o = (NLAIC::IBasicInterface *)_Vector.front();                 
+01081                         o->release();
+01082                         _Vector.erase( _Vector.begin() );
+01083                 }
+01084         }
+01085 
+01086         tQueue CVectorGroupType::isMember(const IVarName *className,const IVarName *methodName,const IObjectIA &p) const
+01087         {
+01088                 tQueue a;
+01089                 NLAISCRIPT::CParam methodParam;
+01090                 NLAISCRIPT::CParam &param = (NLAISCRIPT::CParam &)p;
+01091                 
+01092                 if(param.size() != 1) return IBaseGroupType::isMember(className,methodName,p);
+01093 
+01094                 if(className == NULL)
+01095                 {                       
+01096                         if(*methodName == IBaseGroupType::_Method[0].MethodName)
+01097                         {                               
+01098                                 CObjectType *c = new CObjectType(new NLAIC::CIdentType(NLAIC::CIdentType::VoidType));
+01099                                 a.push(CIdMethod(_Const + IBaseGroupType::getMethodIndexSize(),0.0,NULL,c));                            
+01100                         }
+01101                         else
+01102                         {
+01103                                 return IBaseGroupType::isMember(className,methodName,p);
+01104                         }
+01105                         
+01106                 }
+01107                 return a;
+01108         }
+01109 
+01110         sint32 CVectorGroupType::getMethodIndexSize() const
+01111         {
+01112                 return IBaseGroupType::getMethodIndexSize() + 1;
+01113         }
+01114 
+01115         IObjectIA::CProcessResult CVectorGroupType::runMethodeMember(sint32, sint32, IObjectIA *)
+01116         {
+01117                 return IObjectIA::CProcessResult();
+01118         }
+01119         IObjectIA::CProcessResult CVectorGroupType::runMethodeMember(sint32 index,IObjectIA *p)
+01120         {
+01121                 sint32 i= index - IBaseGroupType::getMethodIndexSize();
+01122                 if(i == _Const)
+01123                 {
+01124                         IBaseGroupType *param = (IBaseGroupType *)p;
+01125                         const DigitalType *f = (const DigitalType *)param->get();
+01126                         _Vector.reserve((int)f->getValue());
+01127                 }
+01128                 return IBaseGroupType::runMethodeMember(index,p);
+01129         }       
+01130 
+01131         CVectorGroupType::~CVectorGroupType()
+01132         {                       
+01133                 clear();
+01134         }
+01135 }
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1