1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include <nel/misc/types_nl.h>
22 #include <nel/misc/debug.h>
23 #include <nel/misc/common.h>
24 #include <nel/misc/entity_id.h>
25 #include <nel/misc/sheet_id.h>
28 #include <pd_lib/pd_lib.h>
29 #include <game_share/persistent_data.h>
37 // Forward declarations
47 * defined at entities_game_service/pd_scripts/fame.pds:4
62 ___TFameTrend_useSize
= 3,
72 /// \name Conversion methods
76 * Use these methods to convert from enum value to string (and vice versa)
79 static const std::string
& toString(TFameTrend v
);
80 static CFameTrend::TFameTrend
fromString(const std::string
& v
);
87 /// \name Enum initialisation
91 static bool _Initialised
;
92 static std::string _UnknownString
;
93 static std::vector
<std::string
> _StrTable
;
94 static std::map
<std::string
, TFameTrend
> _ValueMap
;
100 /** CFameContainerEntryPD
101 * defined at entities_game_service/pd_scripts/fame.pds:11
103 class CFameContainerEntryPD
: public RY_PDS::IPDBaseData
108 /// \name Accessors and Mutators methods
112 * Use these methods to change a value, add or delete elements.
115 NLMISC::CSheetId
getSheet() const;
117 sint32
getFame() const;
118 void setFame(sint32 __v
, bool forceWrite
=false);
120 sint32
getFameMemory() const;
121 void setFameMemory(sint32 __v
, bool forceWrite
=false);
123 CFameTrend::TFameTrend
getLastFameChangeTrend() const;
124 void setLastFameChangeTrend(CFameTrend::TFameTrend __v
, bool forceWrite
=false);
126 CFameContainerPD
* getParent();
127 const CFameContainerPD
* getParent() const;
134 /// \name Public Management methods
138 * Use these methods to create, load, unload and get
139 * an object from database.
144 * Clear whole object content but key (delete subobjects if there are, key is left unmodified), default clear value is 0.
149 * Cast base object to CFameContainerEntryPD
151 static CFameContainerEntryPD
* cast(RY_PDS::IPDBaseData
* obj
);
154 * Cast base object to const CFameContainerEntryPD
156 static const CFameContainerEntryPD
* cast(const RY_PDS::IPDBaseData
* obj
);
163 /// \name Public constructor
167 * This constructor is public to allow direct instanciation of the class
170 CFameContainerEntryPD();
171 ~CFameContainerEntryPD();
178 /// \name Persistent methods declaration
181 void apply(CPersistentDataRecord
&__pdr
);
182 void store(CPersistentDataRecord
&__pdr
) const;
193 * Don't modify those value manually, use accessors and mutators above
196 NLMISC::CSheetId _Sheet
;
199 CFameTrend::TFameTrend _LastFameChangeTrend
;
200 CFameContainerPD
* _Parent
;
207 /// \name Internal Management methods
210 void pds__init(const NLMISC::CSheetId
&Sheet
);
212 void pds__fetch(RY_PDS::CPData
&data
);
213 void pds__register();
214 void pds__registerAttributes();
215 void pds__unregister();
216 void pds__unregisterAttributes();
217 void pds__setParent(CFameContainerPD
* __parent
);
218 void pds__setParentUnnotified(CFameContainerPD
* __parent
);
219 void pds__notifyInit();
220 void pds__notifyRelease();
221 static void pds_static__init();
228 /// \name Default Factory and Fetch methods
231 static RY_PDS::CIndexAllocator _IndexAllocator
;
238 friend class CFameContainerPD
;
239 friend class RY_PDS::CPDSLib
;
240 friend void EGSPD::init(uint32
);
244 * defined at entities_game_service/pd_scripts/fame.pds:20
246 class CFameContainerPD
: public RY_PDS::IPDBaseData
251 /// \name Accessors and Mutators methods
255 * Use these methods to change a value, add or delete elements.
258 NLMISC::CEntityId
getContId() const;
260 CFameContainerEntryPD
* getEntries(const NLMISC::CSheetId
& __k
);
261 const CFameContainerEntryPD
* getEntries(const NLMISC::CSheetId
& __k
) const;
262 std::map
<NLMISC::CSheetId
, CFameContainerEntryPD
>::iterator
getEntriesBegin();
263 std::map
<NLMISC::CSheetId
, CFameContainerEntryPD
>::iterator
getEntriesEnd();
264 std::map
<NLMISC::CSheetId
, CFameContainerEntryPD
>::const_iterator
getEntriesBegin() const;
265 std::map
<NLMISC::CSheetId
, CFameContainerEntryPD
>::const_iterator
getEntriesEnd() const;
266 const std::map
<NLMISC::CSheetId
, CFameContainerEntryPD
> & getEntries() const;
267 CFameContainerEntryPD
* addToEntries(const NLMISC::CSheetId
&__k
);
268 void deleteFromEntries(const NLMISC::CSheetId
&__k
);
270 uint32
getLastGuildStatusChange() const;
271 void setLastGuildStatusChange(uint32 __v
, bool forceWrite
=false);
273 uint32
getLastFameChangeDate() const;
274 void setLastFameChangeDate(uint32 __v
, bool forceWrite
=false);
281 /// \name Public Management methods
285 * Use these methods to create, load, unload and get
286 * an object from database.
291 * Clear whole object content but key (delete subobjects if there are, key is left unmodified), default clear value is 0.
293 virtual void clear();
296 * Cast base object to CFameContainerPD
298 static CFameContainerPD
* cast(RY_PDS::IPDBaseData
* obj
);
301 * Cast base object to const CFameContainerPD
303 static const CFameContainerPD
* cast(const RY_PDS::IPDBaseData
* obj
);
306 * Create an object of the CFameContainerPD class, and declare it to the PDS.
308 static CFameContainerPD
* create(const NLMISC::CEntityId
&ContId
);
311 * Destroy an object from the PDS. Caution! Object will no longer exist in database.
312 * Also children (that is objects that belong to this object) are also destroyed.
314 static void remove(const NLMISC::CEntityId
& ContId
);
317 * Retrieve an object from the database.
318 * Data are sent asynchronously, so the load callback is called when data are ready.
319 * Use get() to access to the loaded object.
321 static void load(const NLMISC::CEntityId
& ContId
);
324 * Setup load callback so client is warned that load succeded or failed.
326 static void setLoadCallback(void (*callback
)(const NLMISC::CEntityId
& key
, CFameContainerPD
* object
));
329 * Unload an object from the client memory. Object still exists in database and can be retrieved again using load.
331 static void unload(const NLMISC::CEntityId
&ContId
);
334 * Get an object in client. Object must have been previously loaded from database with a load.
336 static CFameContainerPD
* get(const NLMISC::CEntityId
&ContId
);
339 * Return the begin iterator of the global map of CFameContainerPD
341 static std::map
<NLMISC::CEntityId
, CFameContainerPD
*>::iterator
begin();
344 * Return the end iterator of the global map of CFameContainerPD
346 static std::map
<NLMISC::CEntityId
, CFameContainerPD
*>::iterator
end();
353 /// \name Public constructor
357 * This constructor is public to allow direct instanciation of the class
361 virtual ~CFameContainerPD();
368 /// \name Persistent methods declaration
371 virtual void apply(CPersistentDataRecord
&__pdr
);
372 virtual void store(CPersistentDataRecord
&__pdr
) const;
383 * Don't modify those value manually, use accessors and mutators above
386 NLMISC::CEntityId _ContId
;
387 std::map
<NLMISC::CSheetId
, CFameContainerEntryPD
> _Entries
;
388 uint32 _LastGuildStatusChange
;
389 uint32 _LastFameChangeDate
;
396 /// \name Internal Management methods
399 virtual void pds__init(const NLMISC::CEntityId
&ContId
);
400 virtual void pds__destroy();
401 virtual void pds__fetch(RY_PDS::CPData
&data
);
402 virtual void pds__register();
403 virtual void pds__registerAttributes();
404 virtual void pds__unregister();
405 virtual void pds__unregisterAttributes();
406 virtual void pds__notifyInit();
407 virtual void pds__notifyRelease();
408 static void pds_static__init();
415 static std::map
<NLMISC::CEntityId
,CFameContainerPD
*> _Map
;
419 /// \name Default Factory and Fetch methods
422 static void pds_static__setFactory(RY_PDS::TPDFactory userFactory
);
423 static bool _FactoryInitialised
;
424 static void pds_static__notifyFailure(uint64 key
);
425 static void (*__pds__LoadCallback
)(const NLMISC::CEntityId
& key
, CFameContainerPD
* object
);
426 static RY_PDS::CIndexAllocator _IndexAllocator
;
427 static RY_PDS::IPDBaseData
* pds_static__factory();
428 static void pds_static__fetch(RY_PDS::IPDBaseData
*object
, RY_PDS::CPData
&data
);
435 friend class CFameContainerEntryPD
;
436 friend class RY_PDS::CPDSLib
;
437 friend void EGSPD::init(uint32
);
440 /** CGuildFameContainerPD
441 * defined at entities_game_service/pd_scripts/fame.pds:30
443 class CGuildFameContainerPD
: public CFameContainerPD
448 /// \name Accessors and Mutators methods
452 * Use these methods to change a value, add or delete elements.
455 CGuildPD
* getParent();
456 const CGuildPD
* getParent() const;
463 /// \name Public Management methods
467 * Use these methods to create, load, unload and get
468 * an object from database.
473 * Clear whole object content but key (delete subobjects if there are, key is left unmodified), default clear value is 0.
475 virtual void clear();
478 * Cast base object to CGuildFameContainerPD
480 static CGuildFameContainerPD
* cast(RY_PDS::IPDBaseData
* obj
);
483 * Cast base object to const CGuildFameContainerPD
485 static const CGuildFameContainerPD
* cast(const RY_PDS::IPDBaseData
* obj
);
488 * Create an object of the CGuildFameContainerPD class, and declare it to the PDS.
490 static CGuildFameContainerPD
* create(const NLMISC::CEntityId
&ContId
);
497 /// \name Public constructor
501 * This constructor is public to allow direct instanciation of the class
504 CGuildFameContainerPD();
505 virtual ~CGuildFameContainerPD();
512 /// \name Persistent methods declaration
515 virtual void apply(CPersistentDataRecord
&__pdr
);
516 virtual void store(CPersistentDataRecord
&__pdr
) const;
527 * Don't modify those value manually, use accessors and mutators above
537 /// \name Internal Management methods
540 virtual void pds__init(const NLMISC::CEntityId
&ContId
);
541 virtual void pds__destroy();
542 virtual void pds__fetch(RY_PDS::CPData
&data
);
543 virtual void pds__register();
544 virtual void pds__registerAttributes();
545 virtual void pds__unregister();
546 virtual void pds__unregisterAttributes();
547 void pds__setParent(CGuildPD
* __parent
);
548 void pds__setParentUnnotified(CGuildPD
* __parent
);
549 virtual void pds__notifyInit();
550 virtual void pds__notifyRelease();
551 static void pds_static__init();
558 /// \name Default Factory and Fetch methods
561 static void pds_static__setFactory(RY_PDS::TPDFactory userFactory
);
562 static bool _FactoryInitialised
;
563 static RY_PDS::CIndexAllocator _IndexAllocator
;
564 static RY_PDS::IPDBaseData
* pds_static__factory();
571 friend class CGuildContainerPD
;
572 friend class CGuildPD
;
573 friend class RY_PDS::CPDSLib
;
574 friend void EGSPD::init(uint32
);