Add infos into target window
[ryzomcore.git] / ryzom / server / src / entities_game_service / fame_pd.cpp
blob3fc10ee1237907bc0ba68a9fdbd39ba6187d6433
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2015-2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "stdpch.h"
22 #include "egs_pd.h"
24 namespace EGSPD
27 static const struct { const char* Name; CFameTrend::TFameTrend Value; } TFameTrendConvert[] =
29 { "FameUpward", CFameTrend::FameUpward },
30 { "FameDownward", CFameTrend::FameDownward },
31 { "FameSteady", CFameTrend::FameSteady },
33 /* -----------------------------------------
34 * Static Implementation of CFameTrend
35 * ----------------------------------------- */
36 void CFameTrend::init()
38 _StrTable.clear();
39 _ValueMap.clear();
40 _StrTable.resize(3);
41 uint i;
42 for (i=0; i<3; ++i)
44 _StrTable[TFameTrendConvert[i].Value] = TFameTrendConvert[i].Name;
45 _ValueMap[NLMISC::toLowerAscii(std::string(TFameTrendConvert[i].Name))] = TFameTrendConvert[i].Value;
47 _Initialised = true;
49 bool CFameTrend::_Initialised = false;
50 std::string CFameTrend::_UnknownString = "Unknown";
51 std::vector<std::string> CFameTrend::_StrTable;
52 std::map<std::string, CFameTrend::TFameTrend> CFameTrend::_ValueMap;
53 // End of static implementation of CFameTrend
55 /* -----------------------------------------
56 * Static Implementation of CFameContainerEntryPD
57 * ----------------------------------------- */
58 NLMISC::CSheetId CFameContainerEntryPD::getSheet() const
60 return _Sheet;
62 sint32 CFameContainerEntryPD::getFame() const
64 return _Fame;
66 void CFameContainerEntryPD::setFame(sint32 __v, bool forceWrite)
68 if ((_Fame != __v) || forceWrite)
70 PDSLib.set(0, __BaseRow, (RY_PDS::TColumnIndex)(1), __v);
72 _Fame = __v;
74 sint32 CFameContainerEntryPD::getFameMemory() const
76 return _FameMemory;
78 void CFameContainerEntryPD::setFameMemory(sint32 __v, bool forceWrite)
80 if ((_FameMemory != __v) || forceWrite)
82 PDSLib.set(0, __BaseRow, (RY_PDS::TColumnIndex)(2), __v);
84 _FameMemory = __v;
86 CFameTrend::TFameTrend CFameContainerEntryPD::getLastFameChangeTrend() const
88 return _LastFameChangeTrend;
90 void CFameContainerEntryPD::setLastFameChangeTrend(CFameTrend::TFameTrend __v, bool forceWrite)
92 nlassert(__v<CFameTrend::___TFameTrend_useSize);
93 if ((_LastFameChangeTrend != __v) || forceWrite)
95 PDSLib.set(0, __BaseRow, (RY_PDS::TColumnIndex)(3), (uint32)__v);
97 _LastFameChangeTrend = __v;
99 CFameContainerPD* CFameContainerEntryPD::getParent()
101 return _Parent;
103 const CFameContainerPD* CFameContainerEntryPD::getParent() const
105 return _Parent;
107 void CFameContainerEntryPD::clear()
109 _Fame = 0;
110 PDSLib.set(0, __BaseRow, (RY_PDS::TColumnIndex)(1), 0);
111 _FameMemory = 0;
112 PDSLib.set(0, __BaseRow, (RY_PDS::TColumnIndex)(2), 0);
113 _LastFameChangeTrend = (CFameTrend::TFameTrend)0;
114 PDSLib.set(0, __BaseRow, (RY_PDS::TColumnIndex)(3), (uint32)(CFameTrend::TFameTrend)0);
116 CFameContainerEntryPD* CFameContainerEntryPD::cast(RY_PDS::IPDBaseData* obj)
118 return (obj->getTable() == 0) ? static_cast<CFameContainerEntryPD*>(obj) : NULL;
120 const CFameContainerEntryPD* CFameContainerEntryPD::cast(const RY_PDS::IPDBaseData* obj)
122 return (obj->getTable() == 0) ? static_cast<const CFameContainerEntryPD*>(obj) : NULL;
124 void CFameContainerEntryPD::apply(CPersistentDataRecord &__pdr)
126 uint16 __Tok_MapKey = __pdr.addString("__Key__");
127 uint16 __Tok_MapVal = __pdr.addString("__Val__");
128 uint16 __Tok_ClassName = __pdr.addString("__Class__");
129 uint16 __TokSheet = __pdr.addString("Sheet");
130 uint16 __TokFame = __pdr.addString("Fame");
131 uint16 __TokFameMemory = __pdr.addString("FameMemory");
132 uint16 __TokLastFameChangeTrend = __pdr.addString("LastFameChangeTrend");
133 _Parent = NULL;
134 while (!__pdr.isEndOfStruct())
136 if (false) {}
137 else if (__pdr.peekNextToken() == __TokSheet)
139 __pdr.pop(__TokSheet, _Sheet);
141 else if (__pdr.peekNextToken() == __TokFame)
143 __pdr.pop(__TokFame, _Fame);
145 else if (__pdr.peekNextToken() == __TokFameMemory)
147 __pdr.pop(__TokFameMemory, _FameMemory);
149 else if (__pdr.peekNextToken() == __TokLastFameChangeTrend)
152 std::string valuename;
153 __pdr.pop(__TokLastFameChangeTrend, valuename);
154 _LastFameChangeTrend = CFameTrend::fromString(valuename);
157 else
159 nlwarning("Skipping unrecognised token: %s", __pdr.peekNextTokenName().c_str());
160 __pdr.skipData();
164 void CFameContainerEntryPD::store(CPersistentDataRecord &__pdr) const
166 uint16 __Tok_MapKey = __pdr.addString("__Key__");
167 uint16 __Tok_MapVal = __pdr.addString("__Val__");
168 uint16 __Tok_ClassName = __pdr.addString("__Class__");
169 uint16 __TokSheet = __pdr.addString("Sheet");
170 uint16 __TokFame = __pdr.addString("Fame");
171 uint16 __TokFameMemory = __pdr.addString("FameMemory");
172 uint16 __TokLastFameChangeTrend = __pdr.addString("LastFameChangeTrend");
173 __pdr.push(__TokSheet, _Sheet);
174 __pdr.push(__TokFame, _Fame);
175 __pdr.push(__TokFameMemory, _FameMemory);
177 std::string valuename = CFameTrend::toString(_LastFameChangeTrend);
178 __pdr.push(__TokLastFameChangeTrend, valuename);
181 void CFameContainerEntryPD::pds__init(const NLMISC::CSheetId &Sheet)
183 _Sheet = Sheet;
184 _Fame = 0;
185 _FameMemory = 0;
186 _LastFameChangeTrend = (CFameTrend::TFameTrend)0;
187 _Parent = NULL;
189 void CFameContainerEntryPD::pds__destroy()
192 void CFameContainerEntryPD::pds__fetch(RY_PDS::CPData &data)
194 data.serial(_Sheet);
195 data.serial(_Fame);
196 data.serial(_FameMemory);
197 data.serialEnum(_LastFameChangeTrend);
198 _Parent = NULL;
200 void CFameContainerEntryPD::pds__register()
202 __BaseRow = _IndexAllocator.allocate();
203 PDSLib.allocateRow(0, __BaseRow, 0);
204 pds__registerAttributes();
206 void CFameContainerEntryPD::pds__registerAttributes()
208 if (RY_PDS::PDVerbose) nldebug("CFameContainerEntryPD: registerAttributes %u:%u", 0, __BaseRow);
209 PDSLib.set(0, __BaseRow, (RY_PDS::TColumnIndex)(0), _Sheet);
211 void CFameContainerEntryPD::pds__unregister()
213 pds__unregisterAttributes();
214 PDSLib.deallocateRow(0, __BaseRow);
215 _IndexAllocator.deallocate(__BaseRow);
217 void CFameContainerEntryPD::pds__unregisterAttributes()
219 if (RY_PDS::PDVerbose) nldebug("CFameContainerEntryPD: unregisterAttributes %u:%u", 0, __BaseRow);
220 pds__setParent(NULL);
222 void CFameContainerEntryPD::pds__setParent(CFameContainerPD* __parent)
224 NLMISC::CEntityId prevId;
225 if (_Parent != NULL)
227 prevId = _Parent->_ContId;
229 _Parent = __parent;
230 PDSLib.setParent(0, getRow(), (RY_PDS::TColumnIndex)(4), (__parent != NULL ? RY_PDS::CObjectIndex(__parent->getTable(), __parent->getRow()) : RY_PDS::CObjectIndex::null()), (_Parent != NULL ? _Parent->getContId() : NLMISC::CEntityId::Unknown), prevId);
232 void CFameContainerEntryPD::pds__setParentUnnotified(CFameContainerPD* __parent)
234 _Parent = __parent;
236 void CFameContainerEntryPD::pds__notifyInit()
239 void CFameContainerEntryPD::pds__notifyRelease()
241 PDSLib.release(0, __BaseRow);
243 void CFameContainerEntryPD::pds_static__init()
245 PDSLib.setIndexAllocator(0, _IndexAllocator);
247 RY_PDS::CIndexAllocator CFameContainerEntryPD::_IndexAllocator;
248 // End of static implementation of CFameContainerEntryPD
250 /* -----------------------------------------
251 * Static Implementation of CFameContainerPD
252 * ----------------------------------------- */
253 NLMISC::CEntityId CFameContainerPD::getContId() const
255 return _ContId;
257 CFameContainerEntryPD* CFameContainerPD::getEntries(const NLMISC::CSheetId& __k)
259 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator _it = _Entries.find(__k);
260 return (_it==_Entries.end() ? NULL : &((*_it).second));
262 const CFameContainerEntryPD* CFameContainerPD::getEntries(const NLMISC::CSheetId& __k) const
264 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::const_iterator _it = _Entries.find(__k);
265 return (_it==_Entries.end() ? NULL : &((*_it).second));
267 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator CFameContainerPD::getEntriesBegin()
269 return _Entries.begin();
271 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator CFameContainerPD::getEntriesEnd()
273 return _Entries.end();
275 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::const_iterator CFameContainerPD::getEntriesBegin() const
277 return _Entries.begin();
279 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::const_iterator CFameContainerPD::getEntriesEnd() const
281 return _Entries.end();
283 const std::map<NLMISC::CSheetId, CFameContainerEntryPD> & CFameContainerPD::getEntries() const
285 return _Entries;
287 CFameContainerEntryPD* CFameContainerPD::addToEntries(const NLMISC::CSheetId &__k)
289 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __it = _Entries.find(__k);
290 if (__it == _Entries.end())
292 __it = _Entries.insert(std::map<NLMISC::CSheetId, CFameContainerEntryPD>::value_type(__k, CFameContainerEntryPD())).first;
293 CFameContainerEntryPD* __o = &((*__it).second);
294 __o->pds__init(__k);
295 __o->pds__register();
296 __o->pds__setParent(this);
298 return &((*__it).second);
300 void CFameContainerPD::deleteFromEntries(const NLMISC::CSheetId &__k)
302 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __it = _Entries.find(__k);
303 if (__it == _Entries.end()) return;
304 CFameContainerEntryPD& __o = (*__it).second;
305 __o.pds__unregister();
306 _Entries.erase(__it);
308 uint32 CFameContainerPD::getLastGuildStatusChange() const
310 return _LastGuildStatusChange;
312 void CFameContainerPD::setLastGuildStatusChange(uint32 __v, bool forceWrite)
314 if ((_LastGuildStatusChange != __v) || forceWrite)
316 PDSLib.set(__BaseTable, __BaseRow, (RY_PDS::TColumnIndex)(2), __v, _ContId);
318 _LastGuildStatusChange = __v;
320 uint32 CFameContainerPD::getLastFameChangeDate() const
322 return _LastFameChangeDate;
324 void CFameContainerPD::setLastFameChangeDate(uint32 __v, bool forceWrite)
326 if ((_LastFameChangeDate != __v) || forceWrite)
328 PDSLib.set(__BaseTable, __BaseRow, (RY_PDS::TColumnIndex)(3), __v, _ContId);
330 _LastFameChangeDate = __v;
332 void CFameContainerPD::clear()
334 for (std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __it=_Entries.begin(); __it!=_Entries.end(); )
336 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __itr=__it++;
337 CFameContainerEntryPD* __o = &((*__itr).second);
338 __o->pds__unregister();
339 __o->pds__destroy();
341 _Entries.clear();
342 _LastGuildStatusChange = 0;
343 PDSLib.set(__BaseTable, __BaseRow, (RY_PDS::TColumnIndex)(2), 0);
344 _LastFameChangeDate = 0;
345 PDSLib.set(__BaseTable, __BaseRow, (RY_PDS::TColumnIndex)(3), 0);
347 CFameContainerPD* CFameContainerPD::cast(RY_PDS::IPDBaseData* obj)
349 switch (obj->getTable())
351 case 1:
352 case 2:
353 return static_cast<CFameContainerPD*>(obj);
355 return NULL;
357 const CFameContainerPD* CFameContainerPD::cast(const RY_PDS::IPDBaseData* obj)
359 switch (obj->getTable())
361 case 1:
362 case 2:
363 return static_cast<const CFameContainerPD*>(obj);
365 return NULL;
367 CFameContainerPD* CFameContainerPD::create(const NLMISC::CEntityId &ContId)
369 CFameContainerPD *__o = static_cast<CFameContainerPD*>(pds_static__factory());
370 __o->pds__init(ContId);
371 __o->pds__register();
372 __o->pds__notifyInit();
373 return __o;
375 void CFameContainerPD::remove(const NLMISC::CEntityId& ContId)
377 std::map<NLMISC::CEntityId,CFameContainerPD*>::iterator it = _Map.find(ContId);
378 if (it != _Map.end())
380 CFameContainerPD* __o = (*it).second;
381 __o->pds__notifyRelease();
382 __o->pds__unregister();
383 __o->pds__destroy();
384 delete __o;
387 void CFameContainerPD::load(const NLMISC::CEntityId& ContId)
389 PDSLib.load(1, ContId.asUint64());
391 void CFameContainerPD::setLoadCallback(void (*callback)(const NLMISC::CEntityId& key, CFameContainerPD* object))
393 __pds__LoadCallback = callback;
395 void CFameContainerPD::unload(const NLMISC::CEntityId &ContId)
397 std::map<NLMISC::CEntityId,CFameContainerPD*>::iterator it = _Map.find(ContId);
398 if (it != _Map.end())
400 CFameContainerPD* __o = (*it).second;
401 __o->pds__notifyRelease();
402 __o->pds__destroy();
403 delete __o;
406 CFameContainerPD* CFameContainerPD::get(const NLMISC::CEntityId &ContId)
408 std::map<NLMISC::CEntityId, CFameContainerPD*>::iterator __it = _Map.find(ContId);
409 return (__it != _Map.end()) ? (*__it).second : NULL;
411 std::map<NLMISC::CEntityId, CFameContainerPD*>::iterator CFameContainerPD::begin()
413 return _Map.begin();
415 std::map<NLMISC::CEntityId, CFameContainerPD*>::iterator CFameContainerPD::end()
417 return _Map.end();
419 void CFameContainerPD::apply(CPersistentDataRecord &__pdr)
421 uint16 __Tok_MapKey = __pdr.addString("__Key__");
422 uint16 __Tok_MapVal = __pdr.addString("__Val__");
423 uint16 __Tok_ClassName = __pdr.addString("__Class__");
424 uint16 __TokContId = __pdr.addString("ContId");
425 uint16 __TokEntries = __pdr.addString("Entries");
426 uint16 __TokLastGuildStatusChange = __pdr.addString("LastGuildStatusChange");
427 uint16 __TokLastFameChangeDate = __pdr.addString("LastFameChangeDate");
428 while (!__pdr.isEndOfStruct())
430 if (false) {}
431 else if (__pdr.peekNextToken() == __TokContId)
433 __pdr.pop(__TokContId, _ContId);
435 // apply Entries
436 else if (__pdr.peekNextToken() == __TokEntries)
438 __pdr.popStructBegin(__TokEntries);
439 while (!__pdr.isEndOfStruct())
441 NLMISC::CSheetId key;
442 __pdr.pop(__Tok_MapKey, key);
443 __pdr.popStructBegin(__Tok_MapVal);
444 CFameContainerEntryPD& obj = _Entries[key];
445 obj.apply(__pdr);
446 obj.pds__setParentUnnotified(this);
447 __pdr.popStructEnd(__Tok_MapVal);
449 __pdr.popStructEnd(__TokEntries);
451 // end of apply Entries
452 else if (__pdr.peekNextToken() == __TokLastGuildStatusChange)
454 __pdr.pop(__TokLastGuildStatusChange, _LastGuildStatusChange);
456 else if (__pdr.peekNextToken() == __TokLastFameChangeDate)
458 __pdr.pop(__TokLastFameChangeDate, _LastFameChangeDate);
460 else
462 nlwarning("Skipping unrecognised token: %s", __pdr.peekNextTokenName().c_str());
463 __pdr.skipData();
466 pds__notifyInit();
468 void CFameContainerPD::store(CPersistentDataRecord &__pdr) const
470 uint16 __Tok_MapKey = __pdr.addString("__Key__");
471 uint16 __Tok_MapVal = __pdr.addString("__Val__");
472 uint16 __Tok_ClassName = __pdr.addString("__Class__");
473 uint16 __TokContId = __pdr.addString("ContId");
474 uint16 __TokEntries = __pdr.addString("Entries");
475 uint16 __TokLastGuildStatusChange = __pdr.addString("LastGuildStatusChange");
476 uint16 __TokLastFameChangeDate = __pdr.addString("LastFameChangeDate");
477 __pdr.push(__TokContId, _ContId);
478 // store Entries
479 __pdr.pushStructBegin(__TokEntries);
480 for (std::map<NLMISC::CSheetId, CFameContainerEntryPD>::const_iterator it=_Entries.begin(); it!=_Entries.end(); ++it)
482 NLMISC::CSheetId key = (*it).first;
483 __pdr.push(__Tok_MapKey, key);
484 __pdr.pushStructBegin(__Tok_MapVal);
485 (*it).second.store(__pdr);
486 __pdr.pushStructEnd(__Tok_MapVal);
488 __pdr.pushStructEnd(__TokEntries);
489 // end of store Entries
490 __pdr.push(__TokLastGuildStatusChange, _LastGuildStatusChange);
491 __pdr.push(__TokLastFameChangeDate, _LastFameChangeDate);
493 void CFameContainerPD::pds__init(const NLMISC::CEntityId &ContId)
495 _ContId = ContId;
496 _LastGuildStatusChange = 0;
497 _LastFameChangeDate = 0;
498 _Map[getContId()] = this;
500 void CFameContainerPD::pds__destroy()
502 for (std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __it=_Entries.begin(); __it!=_Entries.end(); )
504 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __itr=__it++;
505 ((*__itr).second).pds__destroy();
507 _Entries.clear();
508 _Map.erase(getContId());
510 void CFameContainerPD::pds__fetch(RY_PDS::CPData &data)
512 data.serial(_ContId);
513 RY_PDS::TTableIndex tableIndex;
514 RY_PDS::TRowIndex rowIndex;
517 // read table and row, create an object, affect to the ref, and fetch it
518 data.serial(tableIndex, rowIndex);
519 if (rowIndex == RY_PDS::INVALID_ROW_INDEX || tableIndex == RY_PDS::INVALID_TABLE_INDEX) break;
520 NLMISC::CSheetId __k;
521 data.serial(__k);
522 _Entries.insert(std::pair<NLMISC::CSheetId,CFameContainerEntryPD>(__k, CFameContainerEntryPD()));
523 CFameContainerEntryPD* __o = &(_Entries[__k]);
524 PDSLib.setRowIndex(rowIndex, __o);
525 __o->pds__fetch(data);
526 __o->pds__setParentUnnotified(this);
528 while (true);
529 data.serial(_LastGuildStatusChange);
530 data.serial(_LastFameChangeDate);
531 _Map[getContId()] = this;
533 void CFameContainerPD::pds__register()
535 __BaseRow = _IndexAllocator.allocate();
536 PDSLib.allocateRow(__BaseTable, __BaseRow, 0, _ContId);
537 pds__registerAttributes();
539 void CFameContainerPD::pds__registerAttributes()
541 if (RY_PDS::PDVerbose) nldebug("CFameContainerPD: registerAttributes %u:%u", __BaseTable, __BaseRow);
542 PDSLib.set(__BaseTable, __BaseRow, (RY_PDS::TColumnIndex)(0), _ContId);
544 void CFameContainerPD::pds__unregister()
546 pds__unregisterAttributes();
547 PDSLib.deallocateRow(__BaseTable, __BaseRow, _ContId);
548 _IndexAllocator.deallocate(__BaseRow);
550 void CFameContainerPD::pds__unregisterAttributes()
552 if (RY_PDS::PDVerbose) nldebug("CFameContainerPD: unregisterAttributes %u:%u", __BaseTable, __BaseRow);
553 for (std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __it=_Entries.begin(); __it!=_Entries.end(); )
555 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __itr=__it++;
556 CFameContainerEntryPD& __o = (*__itr).second;
557 __o.pds__unregister();
560 void CFameContainerPD::pds__notifyInit()
562 for (std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __it=_Entries.begin(); __it!=_Entries.end(); )
564 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __itr=__it++;
565 (*__itr).second.pds__notifyInit();
568 void CFameContainerPD::pds__notifyRelease()
570 PDSLib.release(__BaseTable, __BaseRow);
571 for (std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __it=_Entries.begin(); __it!=_Entries.end(); )
573 std::map<NLMISC::CSheetId, CFameContainerEntryPD>::iterator __itr=__it++;
574 (*__itr).second.pds__notifyRelease();
577 void CFameContainerPD::pds_static__init()
579 PDSLib.setIndexAllocator(1, _IndexAllocator);
580 pds_static__setFactory(pds_static__factory);
582 std::map<NLMISC::CEntityId,CFameContainerPD*> CFameContainerPD::_Map;
583 void CFameContainerPD::pds_static__setFactory(RY_PDS::TPDFactory userFactory)
585 if (!_FactoryInitialised)
587 PDSLib.registerClass(1, userFactory, pds_static__fetch, pds_static__notifyFailure);
588 _FactoryInitialised = true;
591 bool CFameContainerPD::_FactoryInitialised;
592 void CFameContainerPD::pds_static__notifyFailure(uint64 key)
594 if (__pds__LoadCallback != NULL)
596 __pds__LoadCallback((NLMISC::CEntityId)key, NULL);
599 void (*CFameContainerPD::__pds__LoadCallback)(const NLMISC::CEntityId& key, CFameContainerPD* object) = NULL;
600 RY_PDS::CIndexAllocator CFameContainerPD::_IndexAllocator;
601 RY_PDS::IPDBaseData* CFameContainerPD::pds_static__factory()
603 return new CFameContainerPD();
605 void CFameContainerPD::pds_static__fetch(RY_PDS::IPDBaseData *object, RY_PDS::CPData &data)
607 CFameContainerPD *__o = static_cast<CFameContainerPD*>(object);
608 __o->pds__fetch(data);
609 if (__pds__LoadCallback != NULL)
611 __pds__LoadCallback(__o->getContId(), __o);
613 __o->pds__notifyInit();
615 // End of static implementation of CFameContainerPD
617 /* -----------------------------------------
618 * Static Implementation of CGuildFameContainerPD
619 * ----------------------------------------- */
620 CGuildPD* CGuildFameContainerPD::getParent()
622 return _Parent;
624 const CGuildPD* CGuildFameContainerPD::getParent() const
626 return _Parent;
628 void CGuildFameContainerPD::clear()
630 CFameContainerPD::clear();
632 CGuildFameContainerPD* CGuildFameContainerPD::cast(RY_PDS::IPDBaseData* obj)
634 return (obj->getTable() == 2) ? static_cast<CGuildFameContainerPD*>(obj) : NULL;
636 const CGuildFameContainerPD* CGuildFameContainerPD::cast(const RY_PDS::IPDBaseData* obj)
638 return (obj->getTable() == 2) ? static_cast<const CGuildFameContainerPD*>(obj) : NULL;
640 CGuildFameContainerPD* CGuildFameContainerPD::create(const NLMISC::CEntityId &ContId)
642 CGuildFameContainerPD *__o = static_cast<CGuildFameContainerPD*>(pds_static__factory());
643 __o->pds__init(ContId);
644 __o->pds__register();
645 __o->pds__notifyInit();
646 return __o;
648 void CGuildFameContainerPD::apply(CPersistentDataRecord &__pdr)
650 uint16 __Tok_MapKey = __pdr.addString("__Key__");
651 uint16 __Tok_MapVal = __pdr.addString("__Val__");
652 uint16 __Tok_ClassName = __pdr.addString("__Class__");
653 uint16 __Tok_Parent = __pdr.addString("__Parent__");
654 _Parent = NULL;
655 while (!__pdr.isEndOfStruct())
657 if (false) {}
658 else if (__pdr.peekNextToken() == __Tok_Parent)
660 __pdr.popStructBegin(__Tok_Parent);
661 CFameContainerPD::apply(__pdr);
662 __pdr.popStructEnd(__Tok_Parent);
664 else
666 nlwarning("Skipping unrecognised token: %s", __pdr.peekNextTokenName().c_str());
667 __pdr.skipData();
671 void CGuildFameContainerPD::store(CPersistentDataRecord &__pdr) const
673 uint16 __Tok_MapKey = __pdr.addString("__Key__");
674 uint16 __Tok_MapVal = __pdr.addString("__Val__");
675 uint16 __Tok_ClassName = __pdr.addString("__Class__");
676 uint16 __Tok_Parent = __pdr.addString("__Parent__");
677 __pdr.pushStructBegin(__Tok_Parent);
678 CFameContainerPD::store(__pdr);
679 __pdr.pushStructEnd(__Tok_Parent);
681 void CGuildFameContainerPD::pds__init(const NLMISC::CEntityId &ContId)
683 CFameContainerPD::pds__init(ContId);
684 _Parent = NULL;
686 void CGuildFameContainerPD::pds__destroy()
688 CFameContainerPD::pds__destroy();
690 void CGuildFameContainerPD::pds__fetch(RY_PDS::CPData &data)
692 CFameContainerPD::pds__fetch(data);
693 _Parent = NULL;
695 void CGuildFameContainerPD::pds__register()
697 __BaseRow = _IndexAllocator.allocate();
698 PDSLib.allocateRow(__BaseTable, __BaseRow, 0, _ContId);
699 pds__registerAttributes();
701 void CGuildFameContainerPD::pds__registerAttributes()
703 if (RY_PDS::PDVerbose) nldebug("CGuildFameContainerPD: registerAttributes %u:%u", __BaseTable, __BaseRow);
704 CFameContainerPD::pds__registerAttributes();
706 void CGuildFameContainerPD::pds__unregister()
708 pds__unregisterAttributes();
709 PDSLib.deallocateRow(__BaseTable, __BaseRow, _ContId);
710 _IndexAllocator.deallocate(__BaseRow);
712 void CGuildFameContainerPD::pds__unregisterAttributes()
714 if (RY_PDS::PDVerbose) nldebug("CGuildFameContainerPD: unregisterAttributes %u:%u", __BaseTable, __BaseRow);
715 CFameContainerPD::pds__unregisterAttributes();
716 pds__setParent(NULL);
718 void CGuildFameContainerPD::pds__setParent(CGuildPD* __parent)
720 if (_Parent != NULL)
722 _Parent->pds__unlinkFameContainer(_ContId);
724 _Parent = __parent;
725 PDSLib.setParent(__BaseTable, getRow(), (RY_PDS::TColumnIndex)(4), (__parent != NULL ? RY_PDS::CObjectIndex(4, __parent->getRow()) : RY_PDS::CObjectIndex::null()), _ContId);
727 void CGuildFameContainerPD::pds__setParentUnnotified(CGuildPD* __parent)
729 _Parent = __parent;
731 void CGuildFameContainerPD::pds__notifyInit()
733 CFameContainerPD::pds__notifyInit();
735 void CGuildFameContainerPD::pds__notifyRelease()
737 CFameContainerPD::pds__notifyRelease();
739 void CGuildFameContainerPD::pds_static__init()
741 PDSLib.setIndexAllocator(2, _IndexAllocator);
742 pds_static__setFactory(pds_static__factory);
744 void CGuildFameContainerPD::pds_static__setFactory(RY_PDS::TPDFactory userFactory)
746 if (!_FactoryInitialised)
748 PDSLib.registerClass(2, userFactory, pds_static__fetch, NULL);
749 _FactoryInitialised = true;
752 bool CGuildFameContainerPD::_FactoryInitialised;
753 RY_PDS::CIndexAllocator CGuildFameContainerPD::_IndexAllocator;
754 RY_PDS::IPDBaseData* CGuildFameContainerPD::pds_static__factory()
756 return new CGuildFameContainerPD();
758 // End of static implementation of CGuildFameContainerPD
761 } // End of EGSPD