00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "nel/ai/agent/agent.h"
00026 #include "nel/ai/agent/agent_object.h"
00027 #include "nel/ai/agent/list_manager.h"
00028
00029 namespace NLAIAGENT
00030 {
00031
00032
00033
00034
00035
00036
00037 IListBasicManager::IListBasicManager():_List(NULL)
00038 {
00039 }
00040 IListBasicManager::IListBasicManager(IBaseGroupType *l):_List(l)
00041 {
00042
00043 }
00044
00045 IListBasicManager::IListBasicManager(const IListBasicManager &l):_List(l._List)
00046 {
00047 l._List->incRef();
00048 }
00049
00050 IListBasicManager::~IListBasicManager()
00051 {
00052 if(_List != NULL) _List->release();
00053 }
00054
00055 void IListBasicManager::save(NLMISC::IStream &os)
00056 {
00057 os.serial( (NLAIC::CIdentType &) _List->getType() );
00058 os.serial( *_List );
00059 }
00060
00061 void IListBasicManager::load(NLMISC::IStream &is)
00062 {
00063 NLAIC::CIdentTypeAlloc id;
00064 is.serial( id );
00065 if(_List != NULL) _List->release();
00066 _List = (IBaseGroupType *)id.allocClass();
00067 is .serial( *_List );
00068 }
00069
00070 void IListBasicManager::getDebugString(std::string &t) const
00071 {
00072 std::string b;
00073 _List->getDebugString(b);
00074 t += NLAIC::stringGetBuild("IListBasicManager<%4x>: _List:'%s'",this,b.c_str());
00075 }
00076
00077 IObjectIA &IListBasicManager::operator = (const IObjectIA &b)
00078 {
00079 IListBasicManager &a = (IListBasicManager &)b;
00080 *_List = *a._List;
00081 return *this;
00082 }
00083
00084 IObjetOp &IListBasicManager::operator += (const IObjetOp &a)
00085 {
00086 _List->cpy(a);
00087 return *this;
00088 }
00089
00090 IObjetOp &IListBasicManager::operator -= (const IObjetOp &a)
00091 {
00092 _List->erase(a);
00093 return *this;
00094 }
00095
00096
00097 const IObjectIA *IListBasicManager::operator[] (sint32 index) const
00098 {
00099 #ifdef NL_DEBUG
00100 sint s = _List->size();
00101 #endif
00102 return (*_List)[index];
00103 }
00104
00105 bool IListBasicManager::isTrue() const
00106 {
00107 return _List->isTrue();
00108 }
00109 IObjetOp *IListBasicManager::operator ! () const
00110 {
00111 return !(*_List);
00112 }
00113 void IListBasicManager::push(const IObjectIA *o)
00114 {
00115 _List->push(o);
00116 }
00117
00118 void IListBasicManager::pushFront(const IObjectIA *o)
00119 {
00120 _List->pushFront(o);
00121 }
00122
00123 void IListBasicManager::cpy(const IObjectIA &o)
00124 {
00125 _List->cpy(o);
00126 }
00127 const IObjectIA *IListBasicManager::pop()
00128 {
00129 return _List->pop();
00130 }
00131 const IObjectIA *IListBasicManager::get() const
00132 {
00133 return _List->get();
00134 }
00135 const IObjectIA *IListBasicManager::popFront()
00136 {
00137 return _List->popFront();
00138 }
00139 const IObjectIA *IListBasicManager::getFront() const
00140 {
00141 return _List->getFront();
00142 }
00143 sint32 IListBasicManager::size() const
00144 {
00145 return _List->size();
00146 }
00147
00148 const IObjectIA *IListBasicManager::find(const IObjectIA &obj) const
00149 {
00150 return _List->find(obj);
00151 }
00152 void IListBasicManager::eraseFirst(const IObjectIA &obj)
00153 {
00154 _List->erase(obj);
00155 }
00156 void IListBasicManager::eraseAll(const IObjectIA &obj)
00157 {
00158 _List->eraseAll(obj);
00159 }
00160 void IListBasicManager::erase(const IObjectIA *o)
00161 {
00162 _List->erase(o);
00163 }
00164 void IListBasicManager::erase(const IObjectIA &obj)
00165 {
00166 _List->erase(obj);
00167 }
00168
00169 void IListBasicManager::erase(std::list<const IObjectIA *> &l)
00170 {
00171 _List->erase(l);
00172 }
00173 void IListBasicManager::clear()
00174 {
00175 _List->clear();
00176 }
00177
00178 bool IListBasicManager::isEqual(const IBasicObjectIA &b) const
00179 {
00180 IListBasicManager &a = (IListBasicManager &)b;
00181 return _List->isEqual(*a._List);
00182 }
00183
00184 sint32 IListBasicManager::getMethodIndexSize() const
00185 {
00186 return IBaseGroupType::getMethodIndexSize() + 0;
00187 }
00188
00189 tQueue IListBasicManager::isMember(const IVarName *className,const IVarName *methodName,const IObjectIA &p) const
00190 {
00191 return IBaseGroupType::isMember(className,methodName,p);
00192 }
00193
00194 IObjectIA::CProcessResult IListBasicManager::runMethodeMember(sint32 h, sint32 m,IObjectIA *p)
00195 {
00196 return IBaseGroupType::runMethodeMember(h,m,p);
00197 }
00198
00199 IObjectIA::CProcessResult IListBasicManager::runMethodeMember(sint32 m,IObjectIA *p)
00200 {
00201 return IBaseGroupType::runMethodeMember(m,p);
00202 }
00203
00204
00205
00206
00207
00208
00209 IListManager::IListManager(IBaseGroupType *l):IListBasicManager(l)
00210 {
00211
00212 }
00213
00214 IListManager::IListManager(const IListManager &l):IListBasicManager(l._List)
00215 {
00216 l._List->incRef();
00217 }
00218
00219 IListManager::~IListManager()
00220 {
00221 }
00222
00223 bool IListManager::isEqual(const IBasicObjectIA &a) const
00224 {
00225 const IListManager &l = (const IListManager &)a;
00226 return l._List == _List;
00227 }
00228
00229 IObjectIA::CProcessResult IListManager::sendMessage(IObjectIA *msg)
00230 {
00231 CIteratorContener itr = _List->getIterator();
00232
00233 if(itr.isInEnd())
00234 {
00235 msg->release();
00236 }
00237 else
00238 {
00239 while(!itr.isInEnd())
00240 {
00241 IObjectIA *obj = (IObjectIA *)(itr++);
00242 obj->sendMessage(msg);
00243 if(!itr.isInEnd()) msg->incRef();
00244 }
00245 }
00246 return IObjectIA::CProcessResult();
00247 }
00248
00249
00250
00251
00252
00253
00254 CVectorGroupManager::CVectorGroupManager(sint32 i):IListManager(new CVectorGroupType(i))
00255 {
00256 }
00257
00258 CVectorGroupManager::CVectorGroupManager():IListManager(new CVectorGroupType())
00259 {
00260 }
00261
00262 CVectorGroupManager::CVectorGroupManager(const CVectorGroupManager &l):IListManager(l)
00263 {
00264 }
00265
00266 CVectorGroupManager::~CVectorGroupManager()
00267 {
00268 }
00269
00270 const NLAIC::CIdentType &CVectorGroupManager::getType() const
00271 {
00272 return IdVectorGroupManager;
00273 }
00274
00275 const NLAIC::IBasicType *CVectorGroupManager::clone() const
00276 {
00277 NLAIC::IBasicType *x = new CVectorGroupManager(*this);
00278 return x;
00279 }
00280
00281 const NLAIC::IBasicType *CVectorGroupManager::newInstance() const
00282 {
00283 return new CVectorGroupManager();
00284 }
00285
00286 void CVectorGroupManager::trie()
00287 {
00288
00289 throw;
00290 }
00291
00292 const IObjectIA *CVectorGroupManager::getObject(const CObjectIdent &) const
00293 {
00294
00295 throw;
00296 return NULL;
00297 }
00298
00299
00300
00301
00302
00303
00304 CListGroupManager::CListGroupManager():IListManager(new CGroupType())
00305 {
00306 }
00307
00308 CListGroupManager::CListGroupManager(const CListGroupManager &l):IListManager(l)
00309 {
00310 }
00311
00312 CListGroupManager::~CListGroupManager()
00313 {
00314 }
00315
00316 const NLAIC::CIdentType &CListGroupManager::getType() const
00317 {
00318 return IdListGroupManager;
00319 }
00320
00321 const NLAIC::IBasicType *CListGroupManager::clone() const
00322 {
00323 return new CListGroupManager(*this);
00324 }
00325
00326 const NLAIC::IBasicType *CListGroupManager::newInstance() const
00327 {
00328 return new CListGroupManager();
00329 }
00330
00331 void CListGroupManager::trie()
00332 {
00333
00334 throw;
00335 }
00336
00337 const IObjectIA *CListGroupManager::getObject(const CObjectIdent &) const
00338 {
00339
00340 throw;
00341 return NULL;
00342 }
00343 }