Add infos into target window
[ryzomcore.git] / ryzom / server / src / entities_game_service / fame_pd.h
blobb390ea86d841707e62dacf7672d0379f10e0edcf
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
8 //
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/>.
18 #ifndef FAME_PD_H
19 #define FAME_PD_H
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>
26 #include <vector>
27 #include <map>
28 #include <pd_lib/pd_lib.h>
29 #include <game_share/persistent_data.h>
31 // User #includes
33 namespace EGSPD
37 // Forward declarations
43 // Typedefs & Enums
46 /** TFameTrend
47 * defined at entities_game_service/pd_scripts/fame.pds:4
49 class CFameTrend
52 public:
54 /// \name Enum values
55 // @{
57 enum TFameTrend
59 FameUpward = 0,
60 FameDownward = 1,
61 FameSteady = 2,
62 ___TFameTrend_useSize = 3,
63 Unknown = 3,
64 EndFameTrend = 3,
67 // @}
70 public:
72 /// \name Conversion methods
73 // @{
75 /**
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);
82 // @}
85 private:
87 /// \name Enum initialisation
88 // @{
90 static void init();
91 static bool _Initialised;
92 static std::string _UnknownString;
93 static std::vector<std::string> _StrTable;
94 static std::map<std::string, TFameTrend> _ValueMap;
96 // @}
100 /** CFameContainerEntryPD
101 * defined at entities_game_service/pd_scripts/fame.pds:11
103 class CFameContainerEntryPD : public RY_PDS::IPDBaseData
106 public:
108 /// \name Accessors and Mutators methods
109 // @{
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;
129 // @}
132 public:
134 /// \name Public Management methods
135 // @{
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.
146 void clear();
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);
158 // @}
161 public:
163 /// \name Public constructor
164 // @{
167 * This constructor is public to allow direct instanciation of the class
170 CFameContainerEntryPD();
171 ~CFameContainerEntryPD();
173 // @}
176 public:
178 /// \name Persistent methods declaration
179 // @{
181 void apply(CPersistentDataRecord &__pdr);
182 void store(CPersistentDataRecord &__pdr) const;
184 // @}
187 protected:
189 /// \name Attributes
190 // @{
193 * Don't modify those value manually, use accessors and mutators above
196 NLMISC::CSheetId _Sheet;
197 sint32 _Fame;
198 sint32 _FameMemory;
199 CFameTrend::TFameTrend _LastFameChangeTrend;
200 CFameContainerPD* _Parent;
202 // @}
205 protected:
207 /// \name Internal Management methods
208 // @{
210 void pds__init(const NLMISC::CSheetId &Sheet);
211 void pds__destroy();
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();
223 // @}
226 protected:
228 /// \name Default Factory and Fetch methods
229 // @{
231 static RY_PDS::CIndexAllocator _IndexAllocator;
233 // @}
236 protected:
238 friend class CFameContainerPD;
239 friend class RY_PDS::CPDSLib;
240 friend void EGSPD::init(uint32);
243 /** CFameContainerPD
244 * defined at entities_game_service/pd_scripts/fame.pds:20
246 class CFameContainerPD : public RY_PDS::IPDBaseData
249 public:
251 /// \name Accessors and Mutators methods
252 // @{
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);
276 // @}
279 public:
281 /// \name Public Management methods
282 // @{
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();
348 // @}
351 public:
353 /// \name Public constructor
354 // @{
357 * This constructor is public to allow direct instanciation of the class
360 CFameContainerPD();
361 virtual ~CFameContainerPD();
363 // @}
366 public:
368 /// \name Persistent methods declaration
369 // @{
371 virtual void apply(CPersistentDataRecord &__pdr);
372 virtual void store(CPersistentDataRecord &__pdr) const;
374 // @}
377 protected:
379 /// \name Attributes
380 // @{
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;
391 // @}
394 protected:
396 /// \name Internal Management methods
397 // @{
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();
410 // @}
413 protected:
415 static std::map<NLMISC::CEntityId,CFameContainerPD*> _Map;
417 protected:
419 /// \name Default Factory and Fetch methods
420 // @{
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);
430 // @}
433 protected:
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
446 public:
448 /// \name Accessors and Mutators methods
449 // @{
452 * Use these methods to change a value, add or delete elements.
455 CGuildPD* getParent();
456 const CGuildPD* getParent() const;
458 // @}
461 public:
463 /// \name Public Management methods
464 // @{
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);
492 // @}
495 public:
497 /// \name Public constructor
498 // @{
501 * This constructor is public to allow direct instanciation of the class
504 CGuildFameContainerPD();
505 virtual ~CGuildFameContainerPD();
507 // @}
510 public:
512 /// \name Persistent methods declaration
513 // @{
515 virtual void apply(CPersistentDataRecord &__pdr);
516 virtual void store(CPersistentDataRecord &__pdr) const;
518 // @}
521 protected:
523 /// \name Attributes
524 // @{
527 * Don't modify those value manually, use accessors and mutators above
530 CGuildPD* _Parent;
532 // @}
535 protected:
537 /// \name Internal Management methods
538 // @{
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();
553 // @}
556 protected:
558 /// \name Default Factory and Fetch methods
559 // @{
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();
566 // @}
569 protected:
571 friend class CGuildContainerPD;
572 friend class CGuildPD;
573 friend class RY_PDS::CPDSLib;
574 friend void EGSPD::init(uint32);
578 } // End of EGSPD
580 #endif