Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / server / src / shard_unifier_service / database_mapping.h
blobe96676fefed6c8f863488bbd61a18fb1384f84c0
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2021 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/>.
17 /////////////////////////////////////////////////////////////////
18 // WARNING : this is a generated file, don't change it !
19 /////////////////////////////////////////////////////////////////
21 #ifndef DATABASE_MAPPING
22 #define DATABASE_MAPPING
23 #include "nel/misc/types_nl.h"
24 #include <memory>
25 #include "nel/misc/hierarchical_timer.h"
26 #include "nel/misc/string_conversion.h"
27 #include "nel/net/message.h"
28 #include "nel/net/module.h"
29 #include "nel/net/module_builder_parts.h"
30 #include "nel/net/module_message.h"
31 #include "nel/net/module_gateway.h"
33 #include "nel/misc/string_common.h"
34 #include "server_share/mysql_wrapper.h"
36 #include "ring_session_manager.h"
38 #include "game_share/ring_session_manager_itf.h"
40 #include "game_share/character_sync_itf.h"
42 namespace RSMGR
45 class CKnownUser;
47 class CKnownUserPtr;
48 class CSessionParticipant;
50 class CSessionParticipantPtr;
51 class CCharacter;
53 class CCharacterPtr;
54 class CRingUser;
56 class CRingUserPtr;
57 class CSession;
59 class CSessionPtr;
60 class CShard;
62 class CShardPtr;
63 class CGuild;
65 class CGuildPtr;
66 class CGuildInvite;
68 class CGuildInvitePtr;
69 class CPlayerRating;
71 class CPlayerRatingPtr;
72 class CJournalEntry;
74 class CJournalEntryPtr;
75 class CFolder;
77 class CFolderPtr;
78 class CFolderAccess;
80 class CFolderAccessPtr;
81 class CScenario;
83 class CScenarioPtr;
84 class CSessionLog;
86 class CSessionLogPtr;
87 class CGmStatus;
89 class CGmStatusPtr;
93 class CKnownUserPtr
95 friend class CKnownUser;
97 const char *_FileName;
98 uint32 _LineNum;
100 // linked list of smart ptr
101 CKnownUserPtr *_NextPtr;
102 CKnownUserPtr *_PrevPtr;
104 CKnownUser *_Ptr;
106 void linkPtr();
108 void unlinkPtr();
110 public:
111 CKnownUserPtr()
112 : _FileName(NULL),
113 _LineNum(0),
114 _Ptr(NULL),
115 _NextPtr(NULL),
116 _PrevPtr(NULL)
120 CKnownUserPtr(const CKnownUserPtr &other, const char *filename, uint32 lineNum)
121 : _FileName(filename),
122 _LineNum(lineNum),
123 _NextPtr(NULL),
124 _PrevPtr(NULL)
126 // point the same object
127 _Ptr = other._Ptr;
128 // insert the pointer in the list
129 linkPtr();
132 CKnownUserPtr(const CKnownUserPtr &other)
133 : _FileName(other._FileName),
134 _LineNum(other._LineNum),
135 _NextPtr(NULL),
136 _PrevPtr(NULL)
138 // point the same object
139 _Ptr = other._Ptr;
140 // insert the pointer in the list
141 linkPtr();
144 CKnownUserPtr(CKnownUser *objectPtr, const char *filename, uint32 lineNum)
145 : _FileName(filename),
146 _LineNum(lineNum),
147 _NextPtr(NULL),
148 _PrevPtr(NULL)
150 _Ptr = objectPtr;
152 linkPtr();
155 CKnownUserPtr &assign(const CKnownUserPtr &other, const char *filename, uint32 lineNum)
157 _FileName = filename;
158 _LineNum = lineNum;
160 unlinkPtr();
161 _Ptr = other._Ptr;
162 linkPtr();
164 return *this;
167 ~CKnownUserPtr()
169 unlinkPtr();
172 CKnownUserPtr &assign(CKnownUser *objectPtr, const char *filename, uint32 lineNum)
174 _FileName = filename;
175 _LineNum = lineNum;
177 unlinkPtr();
178 _Ptr = objectPtr;
179 linkPtr();
181 return *this;
184 CKnownUserPtr &operator =(const CKnownUserPtr &other)
186 return assign(other, __FILE__, __LINE__);
189 CKnownUser *operator ->()
191 return _Ptr;
193 const CKnownUser *operator ->() const
195 return _Ptr;
198 bool operator == (const CKnownUserPtr &other) const
200 return _Ptr == other._Ptr;
202 bool operator != (const CKnownUserPtr &other) const
204 return !operator ==(other);
207 bool operator == (const CKnownUser *object) const
209 return _Ptr == object;
211 bool operator != (const CKnownUser *object) const
213 return !operator ==(object);
216 /// Less then comparator : comparison on pointer object address
217 bool operator < (const CKnownUserPtr &other) const
219 return _Ptr < other._Ptr;
222 /// Used to walk thrue the linked list of pointer
223 CKnownUserPtr *getNextPtr()
225 return _NextPtr;
233 class CSessionParticipantPtr
235 friend class CSessionParticipant;
237 const char *_FileName;
238 uint32 _LineNum;
240 // linked list of smart ptr
241 CSessionParticipantPtr *_NextPtr;
242 CSessionParticipantPtr *_PrevPtr;
244 CSessionParticipant *_Ptr;
246 void linkPtr();
248 void unlinkPtr();
250 public:
251 CSessionParticipantPtr()
252 : _FileName(NULL),
253 _LineNum(0),
254 _Ptr(NULL),
255 _NextPtr(NULL),
256 _PrevPtr(NULL)
260 CSessionParticipantPtr(const CSessionParticipantPtr &other, const char *filename, uint32 lineNum)
261 : _FileName(filename),
262 _LineNum(lineNum),
263 _NextPtr(NULL),
264 _PrevPtr(NULL)
266 // point the same object
267 _Ptr = other._Ptr;
268 // insert the pointer in the list
269 linkPtr();
272 CSessionParticipantPtr(const CSessionParticipantPtr &other)
273 : _FileName(other._FileName),
274 _LineNum(other._LineNum),
275 _NextPtr(NULL),
276 _PrevPtr(NULL)
278 // point the same object
279 _Ptr = other._Ptr;
280 // insert the pointer in the list
281 linkPtr();
284 CSessionParticipantPtr(CSessionParticipant *objectPtr, const char *filename, uint32 lineNum)
285 : _FileName(filename),
286 _LineNum(lineNum),
287 _NextPtr(NULL),
288 _PrevPtr(NULL)
290 _Ptr = objectPtr;
292 linkPtr();
295 CSessionParticipantPtr &assign(const CSessionParticipantPtr &other, const char *filename, uint32 lineNum)
297 _FileName = filename;
298 _LineNum = lineNum;
300 unlinkPtr();
301 _Ptr = other._Ptr;
302 linkPtr();
304 return *this;
307 ~CSessionParticipantPtr()
309 unlinkPtr();
312 CSessionParticipantPtr &assign(CSessionParticipant *objectPtr, const char *filename, uint32 lineNum)
314 _FileName = filename;
315 _LineNum = lineNum;
317 unlinkPtr();
318 _Ptr = objectPtr;
319 linkPtr();
321 return *this;
324 CSessionParticipantPtr &operator =(const CSessionParticipantPtr &other)
326 return assign(other, __FILE__, __LINE__);
329 CSessionParticipant *operator ->()
331 return _Ptr;
333 const CSessionParticipant *operator ->() const
335 return _Ptr;
338 bool operator == (const CSessionParticipantPtr &other) const
340 return _Ptr == other._Ptr;
342 bool operator != (const CSessionParticipantPtr &other) const
344 return !operator ==(other);
347 bool operator == (const CSessionParticipant *object) const
349 return _Ptr == object;
351 bool operator != (const CSessionParticipant *object) const
353 return !operator ==(object);
356 /// Less then comparator : comparison on pointer object address
357 bool operator < (const CSessionParticipantPtr &other) const
359 return _Ptr < other._Ptr;
362 /// Used to walk thrue the linked list of pointer
363 CSessionParticipantPtr *getNextPtr()
365 return _NextPtr;
373 class CCharacterPtr
375 friend class CCharacter;
377 const char *_FileName;
378 uint32 _LineNum;
380 // linked list of smart ptr
381 CCharacterPtr *_NextPtr;
382 CCharacterPtr *_PrevPtr;
384 CCharacter *_Ptr;
386 void linkPtr();
388 void unlinkPtr();
390 public:
391 CCharacterPtr()
392 : _FileName(NULL),
393 _LineNum(0),
394 _Ptr(NULL),
395 _NextPtr(NULL),
396 _PrevPtr(NULL)
400 CCharacterPtr(const CCharacterPtr &other, const char *filename, uint32 lineNum)
401 : _FileName(filename),
402 _LineNum(lineNum),
403 _NextPtr(NULL),
404 _PrevPtr(NULL)
406 // point the same object
407 _Ptr = other._Ptr;
408 // insert the pointer in the list
409 linkPtr();
412 CCharacterPtr(const CCharacterPtr &other)
413 : _FileName(other._FileName),
414 _LineNum(other._LineNum),
415 _NextPtr(NULL),
416 _PrevPtr(NULL)
418 // point the same object
419 _Ptr = other._Ptr;
420 // insert the pointer in the list
421 linkPtr();
424 CCharacterPtr(CCharacter *objectPtr, const char *filename, uint32 lineNum)
425 : _FileName(filename),
426 _LineNum(lineNum),
427 _NextPtr(NULL),
428 _PrevPtr(NULL)
430 _Ptr = objectPtr;
432 linkPtr();
435 CCharacterPtr &assign(const CCharacterPtr &other, const char *filename, uint32 lineNum)
437 _FileName = filename;
438 _LineNum = lineNum;
440 unlinkPtr();
441 _Ptr = other._Ptr;
442 linkPtr();
444 return *this;
447 ~CCharacterPtr()
449 unlinkPtr();
452 CCharacterPtr &assign(CCharacter *objectPtr, const char *filename, uint32 lineNum)
454 _FileName = filename;
455 _LineNum = lineNum;
457 unlinkPtr();
458 _Ptr = objectPtr;
459 linkPtr();
461 return *this;
464 CCharacterPtr &operator =(const CCharacterPtr &other)
466 return assign(other, __FILE__, __LINE__);
469 CCharacter *operator ->()
471 return _Ptr;
473 const CCharacter *operator ->() const
475 return _Ptr;
478 bool operator == (const CCharacterPtr &other) const
480 return _Ptr == other._Ptr;
482 bool operator != (const CCharacterPtr &other) const
484 return !operator ==(other);
487 bool operator == (const CCharacter *object) const
489 return _Ptr == object;
491 bool operator != (const CCharacter *object) const
493 return !operator ==(object);
496 /// Less then comparator : comparison on pointer object address
497 bool operator < (const CCharacterPtr &other) const
499 return _Ptr < other._Ptr;
502 /// Used to walk thrue the linked list of pointer
503 CCharacterPtr *getNextPtr()
505 return _NextPtr;
513 class CRingUserPtr
515 friend class CRingUser;
517 const char *_FileName;
518 uint32 _LineNum;
520 // linked list of smart ptr
521 CRingUserPtr *_NextPtr;
522 CRingUserPtr *_PrevPtr;
524 CRingUser *_Ptr;
526 void linkPtr();
528 void unlinkPtr();
530 public:
531 CRingUserPtr()
532 : _FileName(NULL),
533 _LineNum(0),
534 _Ptr(NULL),
535 _NextPtr(NULL),
536 _PrevPtr(NULL)
540 CRingUserPtr(const CRingUserPtr &other, const char *filename, uint32 lineNum)
541 : _FileName(filename),
542 _LineNum(lineNum),
543 _NextPtr(NULL),
544 _PrevPtr(NULL)
546 // point the same object
547 _Ptr = other._Ptr;
548 // insert the pointer in the list
549 linkPtr();
552 CRingUserPtr(const CRingUserPtr &other)
553 : _FileName(other._FileName),
554 _LineNum(other._LineNum),
555 _NextPtr(NULL),
556 _PrevPtr(NULL)
558 // point the same object
559 _Ptr = other._Ptr;
560 // insert the pointer in the list
561 linkPtr();
564 CRingUserPtr(CRingUser *objectPtr, const char *filename, uint32 lineNum)
565 : _FileName(filename),
566 _LineNum(lineNum),
567 _NextPtr(NULL),
568 _PrevPtr(NULL)
570 _Ptr = objectPtr;
572 linkPtr();
575 CRingUserPtr &assign(const CRingUserPtr &other, const char *filename, uint32 lineNum)
577 _FileName = filename;
578 _LineNum = lineNum;
580 unlinkPtr();
581 _Ptr = other._Ptr;
582 linkPtr();
584 return *this;
587 ~CRingUserPtr()
589 unlinkPtr();
592 CRingUserPtr &assign(CRingUser *objectPtr, const char *filename, uint32 lineNum)
594 _FileName = filename;
595 _LineNum = lineNum;
597 unlinkPtr();
598 _Ptr = objectPtr;
599 linkPtr();
601 return *this;
604 CRingUserPtr &operator =(const CRingUserPtr &other)
606 return assign(other, __FILE__, __LINE__);
609 CRingUser *operator ->()
611 return _Ptr;
613 const CRingUser *operator ->() const
615 return _Ptr;
618 bool operator == (const CRingUserPtr &other) const
620 return _Ptr == other._Ptr;
622 bool operator != (const CRingUserPtr &other) const
624 return !operator ==(other);
627 bool operator == (const CRingUser *object) const
629 return _Ptr == object;
631 bool operator != (const CRingUser *object) const
633 return !operator ==(object);
636 /// Less then comparator : comparison on pointer object address
637 bool operator < (const CRingUserPtr &other) const
639 return _Ptr < other._Ptr;
642 /// Used to walk thrue the linked list of pointer
643 CRingUserPtr *getNextPtr()
645 return _NextPtr;
653 class CSessionPtr
655 friend class CSession;
657 const char *_FileName;
658 uint32 _LineNum;
660 // linked list of smart ptr
661 CSessionPtr *_NextPtr;
662 CSessionPtr *_PrevPtr;
664 CSession *_Ptr;
666 void linkPtr();
668 void unlinkPtr();
670 public:
671 CSessionPtr()
672 : _FileName(NULL),
673 _LineNum(0),
674 _Ptr(NULL),
675 _NextPtr(NULL),
676 _PrevPtr(NULL)
680 CSessionPtr(const CSessionPtr &other, const char *filename, uint32 lineNum)
681 : _FileName(filename),
682 _LineNum(lineNum),
683 _NextPtr(NULL),
684 _PrevPtr(NULL)
686 // point the same object
687 _Ptr = other._Ptr;
688 // insert the pointer in the list
689 linkPtr();
692 CSessionPtr(const CSessionPtr &other)
693 : _FileName(other._FileName),
694 _LineNum(other._LineNum),
695 _NextPtr(NULL),
696 _PrevPtr(NULL)
698 // point the same object
699 _Ptr = other._Ptr;
700 // insert the pointer in the list
701 linkPtr();
704 CSessionPtr(CSession *objectPtr, const char *filename, uint32 lineNum)
705 : _FileName(filename),
706 _LineNum(lineNum),
707 _NextPtr(NULL),
708 _PrevPtr(NULL)
710 _Ptr = objectPtr;
712 linkPtr();
715 CSessionPtr &assign(const CSessionPtr &other, const char *filename, uint32 lineNum)
717 _FileName = filename;
718 _LineNum = lineNum;
720 unlinkPtr();
721 _Ptr = other._Ptr;
722 linkPtr();
724 return *this;
727 ~CSessionPtr()
729 unlinkPtr();
732 CSessionPtr &assign(CSession *objectPtr, const char *filename, uint32 lineNum)
734 _FileName = filename;
735 _LineNum = lineNum;
737 unlinkPtr();
738 _Ptr = objectPtr;
739 linkPtr();
741 return *this;
744 CSessionPtr &operator =(const CSessionPtr &other)
746 return assign(other, __FILE__, __LINE__);
749 CSession *operator ->()
751 return _Ptr;
753 const CSession *operator ->() const
755 return _Ptr;
758 bool operator == (const CSessionPtr &other) const
760 return _Ptr == other._Ptr;
762 bool operator != (const CSessionPtr &other) const
764 return !operator ==(other);
767 bool operator == (const CSession *object) const
769 return _Ptr == object;
771 bool operator != (const CSession *object) const
773 return !operator ==(object);
776 /// Less then comparator : comparison on pointer object address
777 bool operator < (const CSessionPtr &other) const
779 return _Ptr < other._Ptr;
782 /// Used to walk thrue the linked list of pointer
783 CSessionPtr *getNextPtr()
785 return _NextPtr;
793 class CShardPtr
795 friend class CShard;
797 const char *_FileName;
798 uint32 _LineNum;
800 // linked list of smart ptr
801 CShardPtr *_NextPtr;
802 CShardPtr *_PrevPtr;
804 CShard *_Ptr;
806 void linkPtr();
808 void unlinkPtr();
810 public:
811 CShardPtr()
812 : _FileName(NULL),
813 _LineNum(0),
814 _Ptr(NULL),
815 _NextPtr(NULL),
816 _PrevPtr(NULL)
820 CShardPtr(const CShardPtr &other, const char *filename, uint32 lineNum)
821 : _FileName(filename),
822 _LineNum(lineNum),
823 _NextPtr(NULL),
824 _PrevPtr(NULL)
826 // point the same object
827 _Ptr = other._Ptr;
828 // insert the pointer in the list
829 linkPtr();
832 CShardPtr(const CShardPtr &other)
833 : _FileName(other._FileName),
834 _LineNum(other._LineNum),
835 _NextPtr(NULL),
836 _PrevPtr(NULL)
838 // point the same object
839 _Ptr = other._Ptr;
840 // insert the pointer in the list
841 linkPtr();
844 CShardPtr(CShard *objectPtr, const char *filename, uint32 lineNum)
845 : _FileName(filename),
846 _LineNum(lineNum),
847 _NextPtr(NULL),
848 _PrevPtr(NULL)
850 _Ptr = objectPtr;
852 linkPtr();
855 CShardPtr &assign(const CShardPtr &other, const char *filename, uint32 lineNum)
857 _FileName = filename;
858 _LineNum = lineNum;
860 unlinkPtr();
861 _Ptr = other._Ptr;
862 linkPtr();
864 return *this;
867 ~CShardPtr()
869 unlinkPtr();
872 CShardPtr &assign(CShard *objectPtr, const char *filename, uint32 lineNum)
874 _FileName = filename;
875 _LineNum = lineNum;
877 unlinkPtr();
878 _Ptr = objectPtr;
879 linkPtr();
881 return *this;
884 CShardPtr &operator =(const CShardPtr &other)
886 return assign(other, __FILE__, __LINE__);
889 CShard *operator ->()
891 return _Ptr;
893 const CShard *operator ->() const
895 return _Ptr;
898 bool operator == (const CShardPtr &other) const
900 return _Ptr == other._Ptr;
902 bool operator != (const CShardPtr &other) const
904 return !operator ==(other);
907 bool operator == (const CShard *object) const
909 return _Ptr == object;
911 bool operator != (const CShard *object) const
913 return !operator ==(object);
916 /// Less then comparator : comparison on pointer object address
917 bool operator < (const CShardPtr &other) const
919 return _Ptr < other._Ptr;
922 /// Used to walk thrue the linked list of pointer
923 CShardPtr *getNextPtr()
925 return _NextPtr;
933 class CGuildPtr
935 friend class CGuild;
937 const char *_FileName;
938 uint32 _LineNum;
940 // linked list of smart ptr
941 CGuildPtr *_NextPtr;
942 CGuildPtr *_PrevPtr;
944 CGuild *_Ptr;
946 void linkPtr();
948 void unlinkPtr();
950 public:
951 CGuildPtr()
952 : _FileName(NULL),
953 _LineNum(0),
954 _Ptr(NULL),
955 _NextPtr(NULL),
956 _PrevPtr(NULL)
960 CGuildPtr(const CGuildPtr &other, const char *filename, uint32 lineNum)
961 : _FileName(filename),
962 _LineNum(lineNum),
963 _NextPtr(NULL),
964 _PrevPtr(NULL)
966 // point the same object
967 _Ptr = other._Ptr;
968 // insert the pointer in the list
969 linkPtr();
972 CGuildPtr(const CGuildPtr &other)
973 : _FileName(other._FileName),
974 _LineNum(other._LineNum),
975 _NextPtr(NULL),
976 _PrevPtr(NULL)
978 // point the same object
979 _Ptr = other._Ptr;
980 // insert the pointer in the list
981 linkPtr();
984 CGuildPtr(CGuild *objectPtr, const char *filename, uint32 lineNum)
985 : _FileName(filename),
986 _LineNum(lineNum),
987 _NextPtr(NULL),
988 _PrevPtr(NULL)
990 _Ptr = objectPtr;
992 linkPtr();
995 CGuildPtr &assign(const CGuildPtr &other, const char *filename, uint32 lineNum)
997 _FileName = filename;
998 _LineNum = lineNum;
1000 unlinkPtr();
1001 _Ptr = other._Ptr;
1002 linkPtr();
1004 return *this;
1007 ~CGuildPtr()
1009 unlinkPtr();
1012 CGuildPtr &assign(CGuild *objectPtr, const char *filename, uint32 lineNum)
1014 _FileName = filename;
1015 _LineNum = lineNum;
1017 unlinkPtr();
1018 _Ptr = objectPtr;
1019 linkPtr();
1021 return *this;
1024 CGuildPtr &operator =(const CGuildPtr &other)
1026 return assign(other, __FILE__, __LINE__);
1029 CGuild *operator ->()
1031 return _Ptr;
1033 const CGuild *operator ->() const
1035 return _Ptr;
1038 bool operator == (const CGuildPtr &other) const
1040 return _Ptr == other._Ptr;
1042 bool operator != (const CGuildPtr &other) const
1044 return !operator ==(other);
1047 bool operator == (const CGuild *object) const
1049 return _Ptr == object;
1051 bool operator != (const CGuild *object) const
1053 return !operator ==(object);
1056 /// Less then comparator : comparison on pointer object address
1057 bool operator < (const CGuildPtr &other) const
1059 return _Ptr < other._Ptr;
1062 /// Used to walk thrue the linked list of pointer
1063 CGuildPtr *getNextPtr()
1065 return _NextPtr;
1073 class CGuildInvitePtr
1075 friend class CGuildInvite;
1077 const char *_FileName;
1078 uint32 _LineNum;
1080 // linked list of smart ptr
1081 CGuildInvitePtr *_NextPtr;
1082 CGuildInvitePtr *_PrevPtr;
1084 CGuildInvite *_Ptr;
1086 void linkPtr();
1088 void unlinkPtr();
1090 public:
1091 CGuildInvitePtr()
1092 : _FileName(NULL),
1093 _LineNum(0),
1094 _Ptr(NULL),
1095 _NextPtr(NULL),
1096 _PrevPtr(NULL)
1100 CGuildInvitePtr(const CGuildInvitePtr &other, const char *filename, uint32 lineNum)
1101 : _FileName(filename),
1102 _LineNum(lineNum),
1103 _NextPtr(NULL),
1104 _PrevPtr(NULL)
1106 // point the same object
1107 _Ptr = other._Ptr;
1108 // insert the pointer in the list
1109 linkPtr();
1112 CGuildInvitePtr(const CGuildInvitePtr &other)
1113 : _FileName(other._FileName),
1114 _LineNum(other._LineNum),
1115 _NextPtr(NULL),
1116 _PrevPtr(NULL)
1118 // point the same object
1119 _Ptr = other._Ptr;
1120 // insert the pointer in the list
1121 linkPtr();
1124 CGuildInvitePtr(CGuildInvite *objectPtr, const char *filename, uint32 lineNum)
1125 : _FileName(filename),
1126 _LineNum(lineNum),
1127 _NextPtr(NULL),
1128 _PrevPtr(NULL)
1130 _Ptr = objectPtr;
1132 linkPtr();
1135 CGuildInvitePtr &assign(const CGuildInvitePtr &other, const char *filename, uint32 lineNum)
1137 _FileName = filename;
1138 _LineNum = lineNum;
1140 unlinkPtr();
1141 _Ptr = other._Ptr;
1142 linkPtr();
1144 return *this;
1147 ~CGuildInvitePtr()
1149 unlinkPtr();
1152 CGuildInvitePtr &assign(CGuildInvite *objectPtr, const char *filename, uint32 lineNum)
1154 _FileName = filename;
1155 _LineNum = lineNum;
1157 unlinkPtr();
1158 _Ptr = objectPtr;
1159 linkPtr();
1161 return *this;
1164 CGuildInvitePtr &operator =(const CGuildInvitePtr &other)
1166 return assign(other, __FILE__, __LINE__);
1169 CGuildInvite *operator ->()
1171 return _Ptr;
1173 const CGuildInvite *operator ->() const
1175 return _Ptr;
1178 bool operator == (const CGuildInvitePtr &other) const
1180 return _Ptr == other._Ptr;
1182 bool operator != (const CGuildInvitePtr &other) const
1184 return !operator ==(other);
1187 bool operator == (const CGuildInvite *object) const
1189 return _Ptr == object;
1191 bool operator != (const CGuildInvite *object) const
1193 return !operator ==(object);
1196 /// Less then comparator : comparison on pointer object address
1197 bool operator < (const CGuildInvitePtr &other) const
1199 return _Ptr < other._Ptr;
1202 /// Used to walk thrue the linked list of pointer
1203 CGuildInvitePtr *getNextPtr()
1205 return _NextPtr;
1213 class CPlayerRatingPtr
1215 friend class CPlayerRating;
1217 const char *_FileName;
1218 uint32 _LineNum;
1220 // linked list of smart ptr
1221 CPlayerRatingPtr *_NextPtr;
1222 CPlayerRatingPtr *_PrevPtr;
1224 CPlayerRating *_Ptr;
1226 void linkPtr();
1228 void unlinkPtr();
1230 public:
1231 CPlayerRatingPtr()
1232 : _FileName(NULL),
1233 _LineNum(0),
1234 _Ptr(NULL),
1235 _NextPtr(NULL),
1236 _PrevPtr(NULL)
1240 CPlayerRatingPtr(const CPlayerRatingPtr &other, const char *filename, uint32 lineNum)
1241 : _FileName(filename),
1242 _LineNum(lineNum),
1243 _NextPtr(NULL),
1244 _PrevPtr(NULL)
1246 // point the same object
1247 _Ptr = other._Ptr;
1248 // insert the pointer in the list
1249 linkPtr();
1252 CPlayerRatingPtr(const CPlayerRatingPtr &other)
1253 : _FileName(other._FileName),
1254 _LineNum(other._LineNum),
1255 _NextPtr(NULL),
1256 _PrevPtr(NULL)
1258 // point the same object
1259 _Ptr = other._Ptr;
1260 // insert the pointer in the list
1261 linkPtr();
1264 CPlayerRatingPtr(CPlayerRating *objectPtr, const char *filename, uint32 lineNum)
1265 : _FileName(filename),
1266 _LineNum(lineNum),
1267 _NextPtr(NULL),
1268 _PrevPtr(NULL)
1270 _Ptr = objectPtr;
1272 linkPtr();
1275 CPlayerRatingPtr &assign(const CPlayerRatingPtr &other, const char *filename, uint32 lineNum)
1277 _FileName = filename;
1278 _LineNum = lineNum;
1280 unlinkPtr();
1281 _Ptr = other._Ptr;
1282 linkPtr();
1284 return *this;
1287 ~CPlayerRatingPtr()
1289 unlinkPtr();
1292 CPlayerRatingPtr &assign(CPlayerRating *objectPtr, const char *filename, uint32 lineNum)
1294 _FileName = filename;
1295 _LineNum = lineNum;
1297 unlinkPtr();
1298 _Ptr = objectPtr;
1299 linkPtr();
1301 return *this;
1304 CPlayerRatingPtr &operator =(const CPlayerRatingPtr &other)
1306 return assign(other, __FILE__, __LINE__);
1309 CPlayerRating *operator ->()
1311 return _Ptr;
1313 const CPlayerRating *operator ->() const
1315 return _Ptr;
1318 bool operator == (const CPlayerRatingPtr &other) const
1320 return _Ptr == other._Ptr;
1322 bool operator != (const CPlayerRatingPtr &other) const
1324 return !operator ==(other);
1327 bool operator == (const CPlayerRating *object) const
1329 return _Ptr == object;
1331 bool operator != (const CPlayerRating *object) const
1333 return !operator ==(object);
1336 /// Less then comparator : comparison on pointer object address
1337 bool operator < (const CPlayerRatingPtr &other) const
1339 return _Ptr < other._Ptr;
1342 /// Used to walk thrue the linked list of pointer
1343 CPlayerRatingPtr *getNextPtr()
1345 return _NextPtr;
1353 class CJournalEntryPtr
1355 friend class CJournalEntry;
1357 const char *_FileName;
1358 uint32 _LineNum;
1360 // linked list of smart ptr
1361 CJournalEntryPtr *_NextPtr;
1362 CJournalEntryPtr *_PrevPtr;
1364 CJournalEntry *_Ptr;
1366 void linkPtr();
1368 void unlinkPtr();
1370 public:
1371 CJournalEntryPtr()
1372 : _FileName(NULL),
1373 _LineNum(0),
1374 _Ptr(NULL),
1375 _NextPtr(NULL),
1376 _PrevPtr(NULL)
1380 CJournalEntryPtr(const CJournalEntryPtr &other, const char *filename, uint32 lineNum)
1381 : _FileName(filename),
1382 _LineNum(lineNum),
1383 _NextPtr(NULL),
1384 _PrevPtr(NULL)
1386 // point the same object
1387 _Ptr = other._Ptr;
1388 // insert the pointer in the list
1389 linkPtr();
1392 CJournalEntryPtr(const CJournalEntryPtr &other)
1393 : _FileName(other._FileName),
1394 _LineNum(other._LineNum),
1395 _NextPtr(NULL),
1396 _PrevPtr(NULL)
1398 // point the same object
1399 _Ptr = other._Ptr;
1400 // insert the pointer in the list
1401 linkPtr();
1404 CJournalEntryPtr(CJournalEntry *objectPtr, const char *filename, uint32 lineNum)
1405 : _FileName(filename),
1406 _LineNum(lineNum),
1407 _NextPtr(NULL),
1408 _PrevPtr(NULL)
1410 _Ptr = objectPtr;
1412 linkPtr();
1415 CJournalEntryPtr &assign(const CJournalEntryPtr &other, const char *filename, uint32 lineNum)
1417 _FileName = filename;
1418 _LineNum = lineNum;
1420 unlinkPtr();
1421 _Ptr = other._Ptr;
1422 linkPtr();
1424 return *this;
1427 ~CJournalEntryPtr()
1429 unlinkPtr();
1432 CJournalEntryPtr &assign(CJournalEntry *objectPtr, const char *filename, uint32 lineNum)
1434 _FileName = filename;
1435 _LineNum = lineNum;
1437 unlinkPtr();
1438 _Ptr = objectPtr;
1439 linkPtr();
1441 return *this;
1444 CJournalEntryPtr &operator =(const CJournalEntryPtr &other)
1446 return assign(other, __FILE__, __LINE__);
1449 CJournalEntry *operator ->()
1451 return _Ptr;
1453 const CJournalEntry *operator ->() const
1455 return _Ptr;
1458 bool operator == (const CJournalEntryPtr &other) const
1460 return _Ptr == other._Ptr;
1462 bool operator != (const CJournalEntryPtr &other) const
1464 return !operator ==(other);
1467 bool operator == (const CJournalEntry *object) const
1469 return _Ptr == object;
1471 bool operator != (const CJournalEntry *object) const
1473 return !operator ==(object);
1476 /// Less then comparator : comparison on pointer object address
1477 bool operator < (const CJournalEntryPtr &other) const
1479 return _Ptr < other._Ptr;
1482 /// Used to walk thrue the linked list of pointer
1483 CJournalEntryPtr *getNextPtr()
1485 return _NextPtr;
1493 class CFolderPtr
1495 friend class CFolder;
1497 const char *_FileName;
1498 uint32 _LineNum;
1500 // linked list of smart ptr
1501 CFolderPtr *_NextPtr;
1502 CFolderPtr *_PrevPtr;
1504 CFolder *_Ptr;
1506 void linkPtr();
1508 void unlinkPtr();
1510 public:
1511 CFolderPtr()
1512 : _FileName(NULL),
1513 _LineNum(0),
1514 _Ptr(NULL),
1515 _NextPtr(NULL),
1516 _PrevPtr(NULL)
1520 CFolderPtr(const CFolderPtr &other, const char *filename, uint32 lineNum)
1521 : _FileName(filename),
1522 _LineNum(lineNum),
1523 _NextPtr(NULL),
1524 _PrevPtr(NULL)
1526 // point the same object
1527 _Ptr = other._Ptr;
1528 // insert the pointer in the list
1529 linkPtr();
1532 CFolderPtr(const CFolderPtr &other)
1533 : _FileName(other._FileName),
1534 _LineNum(other._LineNum),
1535 _NextPtr(NULL),
1536 _PrevPtr(NULL)
1538 // point the same object
1539 _Ptr = other._Ptr;
1540 // insert the pointer in the list
1541 linkPtr();
1544 CFolderPtr(CFolder *objectPtr, const char *filename, uint32 lineNum)
1545 : _FileName(filename),
1546 _LineNum(lineNum),
1547 _NextPtr(NULL),
1548 _PrevPtr(NULL)
1550 _Ptr = objectPtr;
1552 linkPtr();
1555 CFolderPtr &assign(const CFolderPtr &other, const char *filename, uint32 lineNum)
1557 _FileName = filename;
1558 _LineNum = lineNum;
1560 unlinkPtr();
1561 _Ptr = other._Ptr;
1562 linkPtr();
1564 return *this;
1567 ~CFolderPtr()
1569 unlinkPtr();
1572 CFolderPtr &assign(CFolder *objectPtr, const char *filename, uint32 lineNum)
1574 _FileName = filename;
1575 _LineNum = lineNum;
1577 unlinkPtr();
1578 _Ptr = objectPtr;
1579 linkPtr();
1581 return *this;
1584 CFolderPtr &operator =(const CFolderPtr &other)
1586 return assign(other, __FILE__, __LINE__);
1589 CFolder *operator ->()
1591 return _Ptr;
1593 const CFolder *operator ->() const
1595 return _Ptr;
1598 bool operator == (const CFolderPtr &other) const
1600 return _Ptr == other._Ptr;
1602 bool operator != (const CFolderPtr &other) const
1604 return !operator ==(other);
1607 bool operator == (const CFolder *object) const
1609 return _Ptr == object;
1611 bool operator != (const CFolder *object) const
1613 return !operator ==(object);
1616 /// Less then comparator : comparison on pointer object address
1617 bool operator < (const CFolderPtr &other) const
1619 return _Ptr < other._Ptr;
1622 /// Used to walk thrue the linked list of pointer
1623 CFolderPtr *getNextPtr()
1625 return _NextPtr;
1633 class CFolderAccessPtr
1635 friend class CFolderAccess;
1637 const char *_FileName;
1638 uint32 _LineNum;
1640 // linked list of smart ptr
1641 CFolderAccessPtr *_NextPtr;
1642 CFolderAccessPtr *_PrevPtr;
1644 CFolderAccess *_Ptr;
1646 void linkPtr();
1648 void unlinkPtr();
1650 public:
1651 CFolderAccessPtr()
1652 : _FileName(NULL),
1653 _LineNum(0),
1654 _Ptr(NULL),
1655 _NextPtr(NULL),
1656 _PrevPtr(NULL)
1660 CFolderAccessPtr(const CFolderAccessPtr &other, const char *filename, uint32 lineNum)
1661 : _FileName(filename),
1662 _LineNum(lineNum),
1663 _NextPtr(NULL),
1664 _PrevPtr(NULL)
1666 // point the same object
1667 _Ptr = other._Ptr;
1668 // insert the pointer in the list
1669 linkPtr();
1672 CFolderAccessPtr(const CFolderAccessPtr &other)
1673 : _FileName(other._FileName),
1674 _LineNum(other._LineNum),
1675 _NextPtr(NULL),
1676 _PrevPtr(NULL)
1678 // point the same object
1679 _Ptr = other._Ptr;
1680 // insert the pointer in the list
1681 linkPtr();
1684 CFolderAccessPtr(CFolderAccess *objectPtr, const char *filename, uint32 lineNum)
1685 : _FileName(filename),
1686 _LineNum(lineNum),
1687 _NextPtr(NULL),
1688 _PrevPtr(NULL)
1690 _Ptr = objectPtr;
1692 linkPtr();
1695 CFolderAccessPtr &assign(const CFolderAccessPtr &other, const char *filename, uint32 lineNum)
1697 _FileName = filename;
1698 _LineNum = lineNum;
1700 unlinkPtr();
1701 _Ptr = other._Ptr;
1702 linkPtr();
1704 return *this;
1707 ~CFolderAccessPtr()
1709 unlinkPtr();
1712 CFolderAccessPtr &assign(CFolderAccess *objectPtr, const char *filename, uint32 lineNum)
1714 _FileName = filename;
1715 _LineNum = lineNum;
1717 unlinkPtr();
1718 _Ptr = objectPtr;
1719 linkPtr();
1721 return *this;
1724 CFolderAccessPtr &operator =(const CFolderAccessPtr &other)
1726 return assign(other, __FILE__, __LINE__);
1729 CFolderAccess *operator ->()
1731 return _Ptr;
1733 const CFolderAccess *operator ->() const
1735 return _Ptr;
1738 bool operator == (const CFolderAccessPtr &other) const
1740 return _Ptr == other._Ptr;
1742 bool operator != (const CFolderAccessPtr &other) const
1744 return !operator ==(other);
1747 bool operator == (const CFolderAccess *object) const
1749 return _Ptr == object;
1751 bool operator != (const CFolderAccess *object) const
1753 return !operator ==(object);
1756 /// Less then comparator : comparison on pointer object address
1757 bool operator < (const CFolderAccessPtr &other) const
1759 return _Ptr < other._Ptr;
1762 /// Used to walk thrue the linked list of pointer
1763 CFolderAccessPtr *getNextPtr()
1765 return _NextPtr;
1773 class CScenarioPtr
1775 friend class CScenario;
1777 const char *_FileName;
1778 uint32 _LineNum;
1780 // linked list of smart ptr
1781 CScenarioPtr *_NextPtr;
1782 CScenarioPtr *_PrevPtr;
1784 CScenario *_Ptr;
1786 void linkPtr();
1788 void unlinkPtr();
1790 public:
1791 CScenarioPtr()
1792 : _FileName(NULL),
1793 _LineNum(0),
1794 _Ptr(NULL),
1795 _NextPtr(NULL),
1796 _PrevPtr(NULL)
1800 CScenarioPtr(const CScenarioPtr &other, const char *filename, uint32 lineNum)
1801 : _FileName(filename),
1802 _LineNum(lineNum),
1803 _NextPtr(NULL),
1804 _PrevPtr(NULL)
1806 // point the same object
1807 _Ptr = other._Ptr;
1808 // insert the pointer in the list
1809 linkPtr();
1812 CScenarioPtr(const CScenarioPtr &other)
1813 : _FileName(other._FileName),
1814 _LineNum(other._LineNum),
1815 _NextPtr(NULL),
1816 _PrevPtr(NULL)
1818 // point the same object
1819 _Ptr = other._Ptr;
1820 // insert the pointer in the list
1821 linkPtr();
1824 CScenarioPtr(CScenario *objectPtr, const char *filename, uint32 lineNum)
1825 : _FileName(filename),
1826 _LineNum(lineNum),
1827 _NextPtr(NULL),
1828 _PrevPtr(NULL)
1830 _Ptr = objectPtr;
1832 linkPtr();
1835 CScenarioPtr &assign(const CScenarioPtr &other, const char *filename, uint32 lineNum)
1837 _FileName = filename;
1838 _LineNum = lineNum;
1840 unlinkPtr();
1841 _Ptr = other._Ptr;
1842 linkPtr();
1844 return *this;
1847 ~CScenarioPtr()
1849 unlinkPtr();
1852 CScenarioPtr &assign(CScenario *objectPtr, const char *filename, uint32 lineNum)
1854 _FileName = filename;
1855 _LineNum = lineNum;
1857 unlinkPtr();
1858 _Ptr = objectPtr;
1859 linkPtr();
1861 return *this;
1864 CScenarioPtr &operator =(const CScenarioPtr &other)
1866 return assign(other, __FILE__, __LINE__);
1869 CScenario *operator ->()
1871 return _Ptr;
1873 const CScenario *operator ->() const
1875 return _Ptr;
1878 bool operator == (const CScenarioPtr &other) const
1880 return _Ptr == other._Ptr;
1882 bool operator != (const CScenarioPtr &other) const
1884 return !operator ==(other);
1887 bool operator == (const CScenario *object) const
1889 return _Ptr == object;
1891 bool operator != (const CScenario *object) const
1893 return !operator ==(object);
1896 /// Less then comparator : comparison on pointer object address
1897 bool operator < (const CScenarioPtr &other) const
1899 return _Ptr < other._Ptr;
1902 /// Used to walk thrue the linked list of pointer
1903 CScenarioPtr *getNextPtr()
1905 return _NextPtr;
1913 class CSessionLogPtr
1915 friend class CSessionLog;
1917 const char *_FileName;
1918 uint32 _LineNum;
1920 // linked list of smart ptr
1921 CSessionLogPtr *_NextPtr;
1922 CSessionLogPtr *_PrevPtr;
1924 CSessionLog *_Ptr;
1926 void linkPtr();
1928 void unlinkPtr();
1930 public:
1931 CSessionLogPtr()
1932 : _FileName(NULL),
1933 _LineNum(0),
1934 _Ptr(NULL),
1935 _NextPtr(NULL),
1936 _PrevPtr(NULL)
1940 CSessionLogPtr(const CSessionLogPtr &other, const char *filename, uint32 lineNum)
1941 : _FileName(filename),
1942 _LineNum(lineNum),
1943 _NextPtr(NULL),
1944 _PrevPtr(NULL)
1946 // point the same object
1947 _Ptr = other._Ptr;
1948 // insert the pointer in the list
1949 linkPtr();
1952 CSessionLogPtr(const CSessionLogPtr &other)
1953 : _FileName(other._FileName),
1954 _LineNum(other._LineNum),
1955 _NextPtr(NULL),
1956 _PrevPtr(NULL)
1958 // point the same object
1959 _Ptr = other._Ptr;
1960 // insert the pointer in the list
1961 linkPtr();
1964 CSessionLogPtr(CSessionLog *objectPtr, const char *filename, uint32 lineNum)
1965 : _FileName(filename),
1966 _LineNum(lineNum),
1967 _NextPtr(NULL),
1968 _PrevPtr(NULL)
1970 _Ptr = objectPtr;
1972 linkPtr();
1975 CSessionLogPtr &assign(const CSessionLogPtr &other, const char *filename, uint32 lineNum)
1977 _FileName = filename;
1978 _LineNum = lineNum;
1980 unlinkPtr();
1981 _Ptr = other._Ptr;
1982 linkPtr();
1984 return *this;
1987 ~CSessionLogPtr()
1989 unlinkPtr();
1992 CSessionLogPtr &assign(CSessionLog *objectPtr, const char *filename, uint32 lineNum)
1994 _FileName = filename;
1995 _LineNum = lineNum;
1997 unlinkPtr();
1998 _Ptr = objectPtr;
1999 linkPtr();
2001 return *this;
2004 CSessionLogPtr &operator =(const CSessionLogPtr &other)
2006 return assign(other, __FILE__, __LINE__);
2009 CSessionLog *operator ->()
2011 return _Ptr;
2013 const CSessionLog *operator ->() const
2015 return _Ptr;
2018 bool operator == (const CSessionLogPtr &other) const
2020 return _Ptr == other._Ptr;
2022 bool operator != (const CSessionLogPtr &other) const
2024 return !operator ==(other);
2027 bool operator == (const CSessionLog *object) const
2029 return _Ptr == object;
2031 bool operator != (const CSessionLog *object) const
2033 return !operator ==(object);
2036 /// Less then comparator : comparison on pointer object address
2037 bool operator < (const CSessionLogPtr &other) const
2039 return _Ptr < other._Ptr;
2042 /// Used to walk thrue the linked list of pointer
2043 CSessionLogPtr *getNextPtr()
2045 return _NextPtr;
2053 class CGmStatusPtr
2055 friend class CGmStatus;
2057 const char *_FileName;
2058 uint32 _LineNum;
2060 // linked list of smart ptr
2061 CGmStatusPtr *_NextPtr;
2062 CGmStatusPtr *_PrevPtr;
2064 CGmStatus *_Ptr;
2066 void linkPtr();
2068 void unlinkPtr();
2070 public:
2071 CGmStatusPtr()
2072 : _FileName(NULL),
2073 _LineNum(0),
2074 _Ptr(NULL),
2075 _NextPtr(NULL),
2076 _PrevPtr(NULL)
2080 CGmStatusPtr(const CGmStatusPtr &other, const char *filename, uint32 lineNum)
2081 : _FileName(filename),
2082 _LineNum(lineNum),
2083 _NextPtr(NULL),
2084 _PrevPtr(NULL)
2086 // point the same object
2087 _Ptr = other._Ptr;
2088 // insert the pointer in the list
2089 linkPtr();
2092 CGmStatusPtr(const CGmStatusPtr &other)
2093 : _FileName(other._FileName),
2094 _LineNum(other._LineNum),
2095 _NextPtr(NULL),
2096 _PrevPtr(NULL)
2098 // point the same object
2099 _Ptr = other._Ptr;
2100 // insert the pointer in the list
2101 linkPtr();
2104 CGmStatusPtr(CGmStatus *objectPtr, const char *filename, uint32 lineNum)
2105 : _FileName(filename),
2106 _LineNum(lineNum),
2107 _NextPtr(NULL),
2108 _PrevPtr(NULL)
2110 _Ptr = objectPtr;
2112 linkPtr();
2115 CGmStatusPtr &assign(const CGmStatusPtr &other, const char *filename, uint32 lineNum)
2117 _FileName = filename;
2118 _LineNum = lineNum;
2120 unlinkPtr();
2121 _Ptr = other._Ptr;
2122 linkPtr();
2124 return *this;
2127 ~CGmStatusPtr()
2129 unlinkPtr();
2132 CGmStatusPtr &assign(CGmStatus *objectPtr, const char *filename, uint32 lineNum)
2134 _FileName = filename;
2135 _LineNum = lineNum;
2137 unlinkPtr();
2138 _Ptr = objectPtr;
2139 linkPtr();
2141 return *this;
2144 CGmStatusPtr &operator =(const CGmStatusPtr &other)
2146 return assign(other, __FILE__, __LINE__);
2149 CGmStatus *operator ->()
2151 return _Ptr;
2153 const CGmStatus *operator ->() const
2155 return _Ptr;
2158 bool operator == (const CGmStatusPtr &other) const
2160 return _Ptr == other._Ptr;
2162 bool operator != (const CGmStatusPtr &other) const
2164 return !operator ==(other);
2167 bool operator == (const CGmStatus *object) const
2169 return _Ptr == object;
2171 bool operator != (const CGmStatus *object) const
2173 return !operator ==(object);
2176 /// Less then comparator : comparison on pointer object address
2177 bool operator < (const CGmStatusPtr &other) const
2179 return _Ptr < other._Ptr;
2182 /// Used to walk thrue the linked list of pointer
2183 CGmStatusPtr *getNextPtr()
2185 return _NextPtr;
2192 struct TUserType
2194 enum TValues
2196 ut_character = 1,
2197 ut_pioneer,
2198 /// the highest valid value in the enum
2199 last_enum_item = ut_pioneer,
2200 /// a value equal to the last enum item +1
2201 end_of_enum,
2203 invalid_val,
2205 /// Number of enumerated values
2206 nb_enum_items = 2
2209 /// Index table to convert enum value to linear index table
2210 const std::map<TValues, uint32> &getIndexTable() const
2212 static std::map<TValues, uint32> indexTable;
2213 static bool init = false;
2214 if (!init)
2216 // fill the index table
2217 indexTable.insert(std::make_pair(ut_character, 0));
2218 indexTable.insert(std::make_pair(ut_pioneer, 1));
2220 init = true;
2223 return indexTable;
2227 static const NLMISC::CStringConversion<TValues> &getConversionTable()
2229 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
2230 NL_STRING_CONVERSION_TABLE_ENTRY(ut_character)
2231 NL_STRING_CONVERSION_TABLE_ENTRY(ut_pioneer)
2232 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
2234 static NLMISC::CStringConversion<TValues>
2235 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
2236 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
2238 return conversionTable;
2241 TValues _Value;
2243 public:
2244 TUserType()
2245 : _Value(invalid_val)
2248 TUserType(TValues value)
2249 : _Value(value)
2253 TUserType(const std::string &str)
2255 _Value = getConversionTable().fromString(str);
2258 void serial(NLMISC::IStream &s)
2260 s.serialEnum(_Value);
2263 bool operator == (const TUserType &other) const
2265 return _Value == other._Value;
2267 bool operator != (const TUserType &other) const
2269 return ! (_Value == other._Value);
2271 bool operator < (const TUserType &other) const
2273 return _Value < other._Value;
2276 bool operator <= (const TUserType &other) const
2278 return _Value <= other._Value;
2281 bool operator > (const TUserType &other) const
2283 return !(_Value <= other._Value);
2285 bool operator >= (const TUserType &other) const
2287 return !(_Value < other._Value);
2290 const std::string &toString() const
2292 return getConversionTable().toString(_Value);
2294 static const std::string &toString(TValues value)
2296 return getConversionTable().toString(value);
2299 TValues getValue() const
2301 return _Value;
2304 // return true if the actual value of the enum is valid, otherwise false
2305 bool isValid()
2307 if (_Value == invalid_val)
2308 return false;
2310 // not invalid, check other enum value
2311 return getConversionTable().isValid(_Value);
2315 uint32 asIndex()
2317 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
2318 nlassert(it != getIndexTable().end());
2319 return it->second;
2325 struct TKnownUserRelation
2327 enum TValues
2329 rt_friend = 1,
2330 rt_banned,
2331 rt_friend_dm,
2332 /// the highest valid value in the enum
2333 last_enum_item = rt_friend_dm,
2334 /// a value equal to the last enum item +1
2335 end_of_enum,
2337 invalid_val,
2339 /// Number of enumerated values
2340 nb_enum_items = 3
2343 /// Index table to convert enum value to linear index table
2344 const std::map<TValues, uint32> &getIndexTable() const
2346 static std::map<TValues, uint32> indexTable;
2347 static bool init = false;
2348 if (!init)
2350 // fill the index table
2351 indexTable.insert(std::make_pair(rt_friend, 0));
2352 indexTable.insert(std::make_pair(rt_banned, 1));
2353 indexTable.insert(std::make_pair(rt_friend_dm, 2));
2355 init = true;
2358 return indexTable;
2362 static const NLMISC::CStringConversion<TValues> &getConversionTable()
2364 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
2365 NL_STRING_CONVERSION_TABLE_ENTRY(rt_friend)
2366 NL_STRING_CONVERSION_TABLE_ENTRY(rt_banned)
2367 NL_STRING_CONVERSION_TABLE_ENTRY(rt_friend_dm)
2368 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
2370 static NLMISC::CStringConversion<TValues>
2371 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
2372 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
2374 return conversionTable;
2377 TValues _Value;
2379 public:
2380 TKnownUserRelation()
2381 : _Value(invalid_val)
2384 TKnownUserRelation(TValues value)
2385 : _Value(value)
2389 TKnownUserRelation(const std::string &str)
2391 _Value = getConversionTable().fromString(str);
2394 void serial(NLMISC::IStream &s)
2396 s.serialEnum(_Value);
2399 bool operator == (const TKnownUserRelation &other) const
2401 return _Value == other._Value;
2403 bool operator != (const TKnownUserRelation &other) const
2405 return ! (_Value == other._Value);
2407 bool operator < (const TKnownUserRelation &other) const
2409 return _Value < other._Value;
2412 bool operator <= (const TKnownUserRelation &other) const
2414 return _Value <= other._Value;
2417 bool operator > (const TKnownUserRelation &other) const
2419 return !(_Value <= other._Value);
2421 bool operator >= (const TKnownUserRelation &other) const
2423 return !(_Value < other._Value);
2426 const std::string &toString() const
2428 return getConversionTable().toString(_Value);
2430 static const std::string &toString(TValues value)
2432 return getConversionTable().toString(value);
2435 TValues getValue() const
2437 return _Value;
2440 // return true if the actual value of the enum is valid, otherwise false
2441 bool isValid()
2443 if (_Value == invalid_val)
2444 return false;
2446 // not invalid, check other enum value
2447 return getConversionTable().isValid(_Value);
2451 uint32 asIndex()
2453 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
2454 nlassert(it != getIndexTable().end());
2455 return it->second;
2459 /////////////////////////////////////////////////////////////////
2460 // WARNING : this is a generated file, don't change it !
2461 /////////////////////////////////////////////////////////////////
2462 class CKnownUser
2464 protected:
2466 uint32 _RelationId;
2468 uint32 _OwnerId;
2470 uint32 _TargetUser;
2472 uint32 _TargetCharacter;
2474 TKnownUserRelation _Relation;
2476 std::string _Comments;
2477 public:
2479 uint32 getOwnerId() const
2481 return _OwnerId;
2484 void setOwnerId(uint32 value)
2487 if (_OwnerId != value)
2489 if (getPersistentState() != NOPE::os_transient)
2490 setPersistentState(NOPE::os_dirty);
2492 _OwnerId = value;
2498 uint32 getTargetUser() const
2500 return _TargetUser;
2503 void setTargetUser(uint32 value)
2506 if (_TargetUser != value)
2508 if (getPersistentState() != NOPE::os_transient)
2509 setPersistentState(NOPE::os_dirty);
2511 _TargetUser = value;
2517 uint32 getTargetCharacter() const
2519 return _TargetCharacter;
2522 void setTargetCharacter(uint32 value)
2525 if (_TargetCharacter != value)
2527 if (getPersistentState() != NOPE::os_transient)
2528 setPersistentState(NOPE::os_dirty);
2530 _TargetCharacter = value;
2536 TKnownUserRelation getRelation() const
2538 return _Relation;
2541 void setRelation(TKnownUserRelation value)
2544 if (_Relation != value)
2546 if (getPersistentState() != NOPE::os_transient)
2547 setPersistentState(NOPE::os_dirty);
2549 _Relation = value;
2555 const std::string &getComments() const
2557 return _Comments;
2562 void setComments(const std::string &value)
2565 if (_Comments != value)
2567 if (getPersistentState() != NOPE::os_transient)
2568 setPersistentState(NOPE::os_dirty);
2571 _Comments = value;
2578 bool operator == (const CKnownUser &other) const
2580 return _RelationId == other._RelationId
2581 && _OwnerId == other._OwnerId
2582 && _TargetUser == other._TargetUser
2583 && _TargetCharacter == other._TargetCharacter
2584 && _Relation == other._Relation
2585 && _Comments == other._Comments;
2589 private:
2590 // private constructor, you must use 'createTransient' to get an instance
2591 CKnownUser()
2592 : _PtrList(NULL),
2593 _ObjectState(NOPE::os_transient),
2594 _RelationId(NOPE::INVALID_OBJECT_ID)
2597 // register the cache for this class (if not already done)
2598 registerUpdatable();
2601 // Destructor, delete any children
2602 ~CKnownUser();
2604 /// utility func to remove this object from the released object container
2605 void removeFromReleased();
2608 public:
2609 /// Create a new instance in the transient space
2610 static CKnownUserPtr createTransient(const char *filename, uint32 lineNum)
2612 return CKnownUserPtr(new CKnownUser(), filename, lineNum);
2615 /** Create a new object in the database from the current object data.
2616 * The object MUST be in transient state (i.e, it must be a new
2617 * object created by user and not comming from the databse).
2618 * If identifier is autogenerated, the generated id can be read after
2619 * this call.
2621 bool create(MSW::CConnection &connection);
2622 /** Update the database with the current object state.
2623 * The object MUST be either in clean or dirty state.
2624 * Return true if the object has been effectively stored
2625 * in the database.
2626 * After this call, the object is in 'clean' state.
2628 bool update(MSW::CConnection &connection);
2629 /** Remove the current object from the persistent storage.
2630 * The object must be in clean or dirty state.
2631 * Return true if the object has been correctly
2632 * updated in the database.
2633 * After the call, the object is in 'clean' state.
2635 bool remove(MSW::CConnection &connection);
2636 /** Remove an object from the persistent storage by specifying
2637 * the id to remove.
2638 * Return true if an entry as been effectively removed from
2639 * the database.
2640 * After the call, the object is in 'removed' state and should
2641 * no more be used. A good pratice should be to delete
2642 * the transient object just after the remove call.
2644 static bool removeById(MSW::CConnection &connection, uint32 id);
2646 /** Load an instance from the database.
2647 * This call allocate a new object and load the property value
2648 * from the database.
2649 * Return NULL if the object id is not found.
2651 static CKnownUserPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
2654 /** Load all objects children of CRingUser and
2655 * return them by using the specified output iterator.
2658 static bool loadChildrenOfCRingUser(MSW::CConnection &connection, uint32 parentId, std::vector < CKnownUserPtr > &children, const char *filename, uint32 lineNum);
2660 /** Load all objects children of CCharacter and
2661 * return them by using the specified output iterator.
2664 static bool loadChildrenOfCCharacter(MSW::CConnection &connection, uint32 parentId, std::vector < CKnownUserPtr > &children, const char *filename, uint32 lineNum);
2667 private:
2669 private:
2670 friend class CPersistentCache;
2671 friend class CKnownUserPtr;
2673 typedef std::map<uint32, CKnownUser*> TObjectCache;
2674 typedef std::set<CKnownUser*> TObjectSet;
2675 typedef std::map<time_t, TObjectSet> TReleasedObject;
2677 /// The complete set of object currently in memory (either active or released) excluding transient instance
2678 static TObjectCache _ObjectCache;
2679 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
2680 static TReleasedObject _ReleasedObject;
2682 /// The current object state
2683 NOPE::TObjectState _ObjectState;
2685 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
2686 time_t _ReleaseDate;
2688 /// The linked list of pointer on this object
2689 CKnownUserPtr *_PtrList;
2691 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
2692 static CKnownUser *loadFromCache(uint32 objectId, bool unrelease);
2694 // Receive and execute command from the cache manager.
2695 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
2697 static void dump();
2699 static void updateCache();
2701 public:
2702 static void clearCache();
2703 private:
2704 void registerUpdatable();
2706 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
2707 void setFirstPtr(CKnownUserPtr *ptr);
2709 // return the first pointer of the pointer list (can be null)
2710 CKnownUserPtr *getFirstPtr()
2712 return _PtrList;
2715 public:
2717 /** Return the object identifier (witch is unique)
2718 * You can only call this method on a persistent instance.
2719 * (because transient instance can have invalid id)
2721 uint32 getObjectId() const
2724 nlassert(getPersistentState() != NOPE::os_transient);
2725 return _RelationId;
2728 /** Set the object unique ID.
2729 * You can only set the object id on a transient object
2730 * having a non autogenerated unique id.
2731 * Furthermore, you MUST set the id before calling create()
2732 * if the id is not autogenerated.
2734 void setObjectId(uint32 objectId)
2736 // can only be set when in transient state
2737 nlassert(getPersistentState() == NOPE::os_transient);
2738 // can only be set once
2739 nlassert(_RelationId == NOPE::INVALID_OBJECT_ID);
2740 _RelationId = objectId;
2743 /** Return the current persistent state of the object.*/
2744 NOPE::TObjectState getPersistentState() const
2746 return _ObjectState;
2749 private:
2750 // Set the persistent state of the object and do some house keeping
2751 void setPersistentState(NOPE::TObjectState state);
2758 /////////////////////////////////////////////////////////////////
2759 // WARNING : this is a generated file, don't change it !
2760 /////////////////////////////////////////////////////////////////
2761 class CSessionParticipant
2763 protected:
2765 uint32 _Id;
2767 TSessionId _SessionId;
2769 uint32 _CharId;
2771 TSessionPartStatus _Status;
2773 bool _Kicked;
2774 public:
2776 TSessionId getSessionId() const
2778 return _SessionId;
2781 void setSessionId(TSessionId value)
2784 if (_SessionId != value)
2786 if (getPersistentState() != NOPE::os_transient)
2787 setPersistentState(NOPE::os_dirty);
2789 _SessionId = value;
2795 uint32 getCharId() const
2797 return _CharId;
2800 void setCharId(uint32 value)
2803 if (_CharId != value)
2805 if (getPersistentState() != NOPE::os_transient)
2806 setPersistentState(NOPE::os_dirty);
2808 _CharId = value;
2814 TSessionPartStatus getStatus() const
2816 return _Status;
2819 void setStatus(TSessionPartStatus value)
2822 if (_Status != value)
2824 if (getPersistentState() != NOPE::os_transient)
2825 setPersistentState(NOPE::os_dirty);
2827 _Status = value;
2833 bool getKicked() const
2835 return _Kicked;
2838 void setKicked(bool value)
2841 if (_Kicked != value)
2843 if (getPersistentState() != NOPE::os_transient)
2844 setPersistentState(NOPE::os_dirty);
2846 _Kicked = value;
2852 bool operator == (const CSessionParticipant &other) const
2854 return _Id == other._Id
2855 && _SessionId == other._SessionId
2856 && _CharId == other._CharId
2857 && _Status == other._Status
2858 && _Kicked == other._Kicked;
2862 private:
2863 // private constructor, you must use 'createTransient' to get an instance
2864 CSessionParticipant()
2865 : _PtrList(NULL),
2866 _ObjectState(NOPE::os_transient),
2867 _Id(NOPE::INVALID_OBJECT_ID)
2869 // Default initialisation
2870 _Kicked = false;
2872 // register the cache for this class (if not already done)
2873 registerUpdatable();
2876 // Destructor, delete any children
2877 ~CSessionParticipant();
2879 /// utility func to remove this object from the released object container
2880 void removeFromReleased();
2883 public:
2884 /// Create a new instance in the transient space
2885 static CSessionParticipantPtr createTransient(const char *filename, uint32 lineNum)
2887 return CSessionParticipantPtr(new CSessionParticipant(), filename, lineNum);
2890 /** Create a new object in the database from the current object data.
2891 * The object MUST be in transient state (i.e, it must be a new
2892 * object created by user and not comming from the databse).
2893 * If identifier is autogenerated, the generated id can be read after
2894 * this call.
2896 bool create(MSW::CConnection &connection);
2897 /** Update the database with the current object state.
2898 * The object MUST be either in clean or dirty state.
2899 * Return true if the object has been effectively stored
2900 * in the database.
2901 * After this call, the object is in 'clean' state.
2903 bool update(MSW::CConnection &connection);
2904 /** Remove the current object from the persistent storage.
2905 * The object must be in clean or dirty state.
2906 * Return true if the object has been correctly
2907 * updated in the database.
2908 * After the call, the object is in 'clean' state.
2910 bool remove(MSW::CConnection &connection);
2911 /** Remove an object from the persistent storage by specifying
2912 * the id to remove.
2913 * Return true if an entry as been effectively removed from
2914 * the database.
2915 * After the call, the object is in 'removed' state and should
2916 * no more be used. A good pratice should be to delete
2917 * the transient object just after the remove call.
2919 static bool removeById(MSW::CConnection &connection, uint32 id);
2921 /** Load an instance from the database.
2922 * This call allocate a new object and load the property value
2923 * from the database.
2924 * Return NULL if the object id is not found.
2926 static CSessionParticipantPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
2929 /** Load all objects children of CCharacter and
2930 * return them by using the specified output iterator.
2933 static bool loadChildrenOfCCharacter(MSW::CConnection &connection, uint32 parentId, std::vector < CSessionParticipantPtr > &children, const char *filename, uint32 lineNum);
2935 /** Load all objects children of CSession and
2936 * return them by using the specified output iterator.
2939 static bool loadChildrenOfCSession(MSW::CConnection &connection, uint32 parentId, std::vector < CSessionParticipantPtr > &children, const char *filename, uint32 lineNum);
2942 private:
2944 private:
2945 friend class CPersistentCache;
2946 friend class CSessionParticipantPtr;
2948 typedef std::map<uint32, CSessionParticipant*> TObjectCache;
2949 typedef std::set<CSessionParticipant*> TObjectSet;
2950 typedef std::map<time_t, TObjectSet> TReleasedObject;
2952 /// The complete set of object currently in memory (either active or released) excluding transient instance
2953 static TObjectCache _ObjectCache;
2954 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
2955 static TReleasedObject _ReleasedObject;
2957 /// The current object state
2958 NOPE::TObjectState _ObjectState;
2960 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
2961 time_t _ReleaseDate;
2963 /// The linked list of pointer on this object
2964 CSessionParticipantPtr *_PtrList;
2966 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
2967 static CSessionParticipant *loadFromCache(uint32 objectId, bool unrelease);
2969 // Receive and execute command from the cache manager.
2970 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
2972 static void dump();
2974 static void updateCache();
2976 public:
2977 static void clearCache();
2978 private:
2979 void registerUpdatable();
2981 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
2982 void setFirstPtr(CSessionParticipantPtr *ptr);
2984 // return the first pointer of the pointer list (can be null)
2985 CSessionParticipantPtr *getFirstPtr()
2987 return _PtrList;
2990 public:
2992 /** Return the object identifier (witch is unique)
2993 * You can only call this method on a persistent instance.
2994 * (because transient instance can have invalid id)
2996 uint32 getObjectId() const
2999 nlassert(getPersistentState() != NOPE::os_transient);
3000 return _Id;
3003 /** Set the object unique ID.
3004 * You can only set the object id on a transient object
3005 * having a non autogenerated unique id.
3006 * Furthermore, you MUST set the id before calling create()
3007 * if the id is not autogenerated.
3009 void setObjectId(uint32 objectId)
3011 // can only be set when in transient state
3012 nlassert(getPersistentState() == NOPE::os_transient);
3013 // can only be set once
3014 nlassert(_Id == NOPE::INVALID_OBJECT_ID);
3015 _Id = objectId;
3018 /** Return the current persistent state of the object.*/
3019 NOPE::TObjectState getPersistentState() const
3021 return _ObjectState;
3024 private:
3025 // Set the persistent state of the object and do some house keeping
3026 void setPersistentState(NOPE::TObjectState state);
3033 /////////////////////////////////////////////////////////////////
3034 // WARNING : this is a generated file, don't change it !
3035 /////////////////////////////////////////////////////////////////
3036 class CCharacter
3038 protected:
3040 uint32 _CharId;
3042 std::string _CharName;
3044 uint32 _UserId;
3046 uint32 _GuildId;
3048 uint32 _BestCombatLevel;
3050 uint32 _HomeMainlandSessionId;
3052 std::string _RingAccess;
3054 CHARSYNC::TRace _Race;
3056 CHARSYNC::TCivilisation _Civilisation;
3058 CHARSYNC::TCult _Cult;
3060 uint32 _CurrentSession;
3062 uint32 _RRPAM;
3064 uint32 _RRPMasterless;
3066 uint32 _RRPAuthor;
3068 bool _Newcomer;
3070 uint32 _CreationDate;
3072 uint32 _LastPlayedDate;
3074 friend class CSession;
3076 std::vector < CSessionPtr > *_Sessions;
3078 friend class CSessionParticipant;
3080 std::vector < CSessionParticipantPtr > *_SessionParticipants;
3082 friend class CKnownUser;
3084 std::vector < CKnownUserPtr > *_KnownBy;
3086 friend class CPlayerRating;
3088 std::vector < CPlayerRatingPtr > *_PlayerRatings;
3089 public:
3091 const std::string &getCharName() const
3093 return _CharName;
3098 void setCharName(const std::string &value)
3101 if (_CharName != value)
3103 if (getPersistentState() != NOPE::os_transient)
3104 setPersistentState(NOPE::os_dirty);
3107 _CharName = value;
3114 uint32 getUserId() const
3116 return _UserId;
3119 void setUserId(uint32 value)
3122 if (_UserId != value)
3124 if (getPersistentState() != NOPE::os_transient)
3125 setPersistentState(NOPE::os_dirty);
3127 _UserId = value;
3133 uint32 getGuildId() const
3135 return _GuildId;
3138 void setGuildId(uint32 value)
3141 if (_GuildId != value)
3143 if (getPersistentState() != NOPE::os_transient)
3144 setPersistentState(NOPE::os_dirty);
3146 _GuildId = value;
3152 uint32 getBestCombatLevel() const
3154 return _BestCombatLevel;
3157 void setBestCombatLevel(uint32 value)
3160 if (_BestCombatLevel != value)
3162 if (getPersistentState() != NOPE::os_transient)
3163 setPersistentState(NOPE::os_dirty);
3165 _BestCombatLevel = value;
3171 uint32 getHomeMainlandSessionId() const
3173 return _HomeMainlandSessionId;
3176 void setHomeMainlandSessionId(uint32 value)
3179 if (_HomeMainlandSessionId != value)
3181 if (getPersistentState() != NOPE::os_transient)
3182 setPersistentState(NOPE::os_dirty);
3184 _HomeMainlandSessionId = value;
3190 const std::string &getRingAccess() const
3192 return _RingAccess;
3197 void setRingAccess(const std::string &value)
3200 if (_RingAccess != value)
3202 if (getPersistentState() != NOPE::os_transient)
3203 setPersistentState(NOPE::os_dirty);
3206 _RingAccess = value;
3213 CHARSYNC::TRace getRace() const
3215 return _Race;
3218 void setRace(CHARSYNC::TRace value)
3221 if (_Race != value)
3223 if (getPersistentState() != NOPE::os_transient)
3224 setPersistentState(NOPE::os_dirty);
3226 _Race = value;
3232 CHARSYNC::TCivilisation getCivilisation() const
3234 return _Civilisation;
3237 void setCivilisation(CHARSYNC::TCivilisation value)
3240 if (_Civilisation != value)
3242 if (getPersistentState() != NOPE::os_transient)
3243 setPersistentState(NOPE::os_dirty);
3245 _Civilisation = value;
3251 CHARSYNC::TCult getCult() const
3253 return _Cult;
3256 void setCult(CHARSYNC::TCult value)
3259 if (_Cult != value)
3261 if (getPersistentState() != NOPE::os_transient)
3262 setPersistentState(NOPE::os_dirty);
3264 _Cult = value;
3270 uint32 getCurrentSession() const
3272 return _CurrentSession;
3275 void setCurrentSession(uint32 value)
3278 if (_CurrentSession != value)
3280 if (getPersistentState() != NOPE::os_transient)
3281 setPersistentState(NOPE::os_dirty);
3283 _CurrentSession = value;
3289 uint32 getRRPAM() const
3291 return _RRPAM;
3294 void setRRPAM(uint32 value)
3297 if (_RRPAM != value)
3299 if (getPersistentState() != NOPE::os_transient)
3300 setPersistentState(NOPE::os_dirty);
3302 _RRPAM = value;
3308 uint32 getRRPMasterless() const
3310 return _RRPMasterless;
3313 void setRRPMasterless(uint32 value)
3316 if (_RRPMasterless != value)
3318 if (getPersistentState() != NOPE::os_transient)
3319 setPersistentState(NOPE::os_dirty);
3321 _RRPMasterless = value;
3327 uint32 getRRPAuthor() const
3329 return _RRPAuthor;
3332 void setRRPAuthor(uint32 value)
3335 if (_RRPAuthor != value)
3337 if (getPersistentState() != NOPE::os_transient)
3338 setPersistentState(NOPE::os_dirty);
3340 _RRPAuthor = value;
3346 bool getNewcomer() const
3348 return _Newcomer;
3351 void setNewcomer(bool value)
3354 if (_Newcomer != value)
3356 if (getPersistentState() != NOPE::os_transient)
3357 setPersistentState(NOPE::os_dirty);
3359 _Newcomer = value;
3365 uint32 getCreationDate() const
3367 return _CreationDate;
3370 void setCreationDate(uint32 value)
3373 if (_CreationDate != value)
3375 if (getPersistentState() != NOPE::os_transient)
3376 setPersistentState(NOPE::os_dirty);
3378 _CreationDate = value;
3384 uint32 getLastPlayedDate() const
3386 return _LastPlayedDate;
3389 void setLastPlayedDate(uint32 value)
3392 if (_LastPlayedDate != value)
3394 if (getPersistentState() != NOPE::os_transient)
3395 setPersistentState(NOPE::os_dirty);
3397 _LastPlayedDate = value;
3403 /** Return a const reference to the vector of child.
3404 * If you want to modify the element inside, you need to
3405 * use on of the two following methods who return non const pointer
3406 * on contained elements.
3408 const std::vector<CSessionPtr> &getSessions() const;
3409 /** Return the ith element of the child vector
3410 * index must be valid (ie less than size of the vector)
3412 CSessionPtr &getSessionsByIndex(uint32 index) const;
3413 /** Return the identified element by looking in the vector
3414 * If no element match the id, NULL pointer is returned
3416 CSessionPtr &getSessionsById(uint32 id) const;
3419 /** Return a const reference to the vector of child.
3420 * If you want to modify the element inside, you need to
3421 * use on of the two following methods who return non const pointer
3422 * on contained elements.
3424 const std::vector<CSessionParticipantPtr> &getSessionParticipants() const;
3425 /** Return the ith element of the child vector
3426 * index must be valid (ie less than size of the vector)
3428 CSessionParticipantPtr &getSessionParticipantsByIndex(uint32 index) const;
3429 /** Return the identified element by looking in the vector
3430 * If no element match the id, NULL pointer is returned
3432 CSessionParticipantPtr &getSessionParticipantsById(uint32 id) const;
3435 /** Return a const reference to the vector of child.
3436 * If you want to modify the element inside, you need to
3437 * use on of the two following methods who return non const pointer
3438 * on contained elements.
3440 const std::vector<CKnownUserPtr> &getKnownBy() const;
3441 /** Return the ith element of the child vector
3442 * index must be valid (ie less than size of the vector)
3444 CKnownUserPtr &getKnownByByIndex(uint32 index) const;
3445 /** Return the identified element by looking in the vector
3446 * If no element match the id, NULL pointer is returned
3448 CKnownUserPtr &getKnownByById(uint32 id) const;
3451 /** Return a const reference to the vector of child.
3452 * If you want to modify the element inside, you need to
3453 * use on of the two following methods who return non const pointer
3454 * on contained elements.
3456 const std::vector<CPlayerRatingPtr> &getPlayerRatings() const;
3457 /** Return the ith element of the child vector
3458 * index must be valid (ie less than size of the vector)
3460 CPlayerRatingPtr &getPlayerRatingsByIndex(uint32 index) const;
3461 /** Return the identified element by looking in the vector
3462 * If no element match the id, NULL pointer is returned
3464 CPlayerRatingPtr &getPlayerRatingsById(uint32 id) const;
3467 bool operator == (const CCharacter &other) const
3469 return _CharId == other._CharId
3470 && _CharName == other._CharName
3471 && _UserId == other._UserId
3472 && _GuildId == other._GuildId
3473 && _BestCombatLevel == other._BestCombatLevel
3474 && _HomeMainlandSessionId == other._HomeMainlandSessionId
3475 && _RingAccess == other._RingAccess
3476 && _Race == other._Race
3477 && _Civilisation == other._Civilisation
3478 && _Cult == other._Cult
3479 && _CurrentSession == other._CurrentSession
3480 && _RRPAM == other._RRPAM
3481 && _RRPMasterless == other._RRPMasterless
3482 && _RRPAuthor == other._RRPAuthor
3483 && _Newcomer == other._Newcomer
3484 && _CreationDate == other._CreationDate
3485 && _LastPlayedDate == other._LastPlayedDate;
3489 private:
3490 // private constructor, you must use 'createTransient' to get an instance
3491 CCharacter()
3492 : _PtrList(NULL),
3493 _ObjectState(NOPE::os_transient),
3494 _CharId(NOPE::INVALID_OBJECT_ID)
3496 // Default initialisation
3497 _GuildId = 0;
3498 _BestCombatLevel = 0;
3499 _HomeMainlandSessionId = 0;
3500 _CurrentSession = 0;
3501 _RRPAM = 0;
3502 _RRPMasterless = 0;
3503 _RRPAuthor = 0;
3504 _Newcomer = 1;
3505 _LastPlayedDate = 0;
3506 _Sessions = NULL;
3507 _SessionParticipants = NULL;
3508 _KnownBy = NULL;
3509 _PlayerRatings = NULL;
3511 // register the cache for this class (if not already done)
3512 registerUpdatable();
3515 // Destructor, delete any children
3516 ~CCharacter();
3518 /// utility func to remove this object from the released object container
3519 void removeFromReleased();
3522 public:
3523 /// Create a new instance in the transient space
3524 static CCharacterPtr createTransient(const char *filename, uint32 lineNum)
3526 return CCharacterPtr(new CCharacter(), filename, lineNum);
3529 /** Create a new object in the database from the current object data.
3530 * The object MUST be in transient state (i.e, it must be a new
3531 * object created by user and not comming from the databse).
3532 * If identifier is autogenerated, the generated id can be read after
3533 * this call.
3535 bool create(MSW::CConnection &connection);
3536 /** Update the database with the current object state.
3537 * The object MUST be either in clean or dirty state.
3538 * Return true if the object has been effectively stored
3539 * in the database.
3540 * After this call, the object is in 'clean' state.
3542 bool update(MSW::CConnection &connection);
3543 /** Remove the current object from the persistent storage.
3544 * The object must be in clean or dirty state.
3545 * Return true if the object has been correctly
3546 * updated in the database.
3547 * After the call, the object is in 'clean' state.
3549 bool remove(MSW::CConnection &connection);
3550 /** Remove an object from the persistent storage by specifying
3551 * the id to remove.
3552 * Return true if an entry as been effectively removed from
3553 * the database.
3554 * After the call, the object is in 'removed' state and should
3555 * no more be used. A good pratice should be to delete
3556 * the transient object just after the remove call.
3558 static bool removeById(MSW::CConnection &connection, uint32 id);
3560 /** Load an instance from the database.
3561 * This call allocate a new object and load the property value
3562 * from the database.
3563 * Return NULL if the object id is not found.
3565 static CCharacterPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
3568 /** Load all objects children of CRingUser and
3569 * return them by using the specified output iterator.
3572 static bool loadChildrenOfCRingUser(MSW::CConnection &connection, uint32 parentId, std::map < uint32, CCharacterPtr > &children, const char *filename, uint32 lineNum);
3574 /** Load all objects children of CGuild and
3575 * return them by using the specified output iterator.
3578 static bool loadChildrenOfCGuild(MSW::CConnection &connection, uint32 parentId, std::vector < CCharacterPtr > &children, const char *filename, uint32 lineNum);
3580 /// Load Sessions child(ren) object(s).
3581 bool loadSessions(MSW::CConnection &connection, const char *filename, uint32 lineNum);
3583 /// Load SessionParticipants child(ren) object(s).
3584 bool loadSessionParticipants(MSW::CConnection &connection, const char *filename, uint32 lineNum);
3586 /// Load KnownBy child(ren) object(s).
3587 bool loadKnownBy(MSW::CConnection &connection, const char *filename, uint32 lineNum);
3589 /// Load PlayerRatings child(ren) object(s).
3590 bool loadPlayerRatings(MSW::CConnection &connection, const char *filename, uint32 lineNum);
3593 private:
3595 private:
3596 friend class CPersistentCache;
3597 friend class CCharacterPtr;
3599 typedef std::map<uint32, CCharacter*> TObjectCache;
3600 typedef std::set<CCharacter*> TObjectSet;
3601 typedef std::map<time_t, TObjectSet> TReleasedObject;
3603 /// The complete set of object currently in memory (either active or released) excluding transient instance
3604 static TObjectCache _ObjectCache;
3605 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
3606 static TReleasedObject _ReleasedObject;
3608 /// The current object state
3609 NOPE::TObjectState _ObjectState;
3611 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
3612 time_t _ReleaseDate;
3614 /// The linked list of pointer on this object
3615 CCharacterPtr *_PtrList;
3617 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
3618 static CCharacter *loadFromCache(uint32 objectId, bool unrelease);
3620 // Receive and execute command from the cache manager.
3621 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
3623 static void dump();
3625 static void updateCache();
3627 public:
3628 static void clearCache();
3629 private:
3630 void registerUpdatable();
3632 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
3633 void setFirstPtr(CCharacterPtr *ptr);
3635 // return the first pointer of the pointer list (can be null)
3636 CCharacterPtr *getFirstPtr()
3638 return _PtrList;
3641 public:
3643 /** Return the object identifier (witch is unique)
3644 * You can only call this method on a persistent instance.
3645 * (because transient instance can have invalid id)
3647 uint32 getObjectId() const
3650 return _CharId;
3653 /** Set the object unique ID.
3654 * You can only set the object id on a transient object
3655 * having a non autogenerated unique id.
3656 * Furthermore, you MUST set the id before calling create()
3657 * if the id is not autogenerated.
3659 void setObjectId(uint32 objectId)
3661 // can only be set when in transient state
3662 nlassert(getPersistentState() == NOPE::os_transient);
3663 // can only be set once
3664 nlassert(_CharId == NOPE::INVALID_OBJECT_ID);
3665 _CharId = objectId;
3668 /** Return the current persistent state of the object.*/
3669 NOPE::TObjectState getPersistentState() const
3671 return _ObjectState;
3674 private:
3675 // Set the persistent state of the object and do some house keeping
3676 void setPersistentState(NOPE::TObjectState state);
3685 struct TCurrentActivity
3687 enum TValues
3689 ca_none = 1,
3690 ca_play,
3691 ca_edit,
3692 ca_anim,
3693 /// the highest valid value in the enum
3694 last_enum_item = ca_anim,
3695 /// a value equal to the last enum item +1
3696 end_of_enum,
3698 invalid_val,
3700 /// Number of enumerated values
3701 nb_enum_items = 4
3704 /// Index table to convert enum value to linear index table
3705 const std::map<TValues, uint32> &getIndexTable() const
3707 static std::map<TValues, uint32> indexTable;
3708 static bool init = false;
3709 if (!init)
3711 // fill the index table
3712 indexTable.insert(std::make_pair(ca_none, 0));
3713 indexTable.insert(std::make_pair(ca_play, 1));
3714 indexTable.insert(std::make_pair(ca_edit, 2));
3715 indexTable.insert(std::make_pair(ca_anim, 3));
3717 init = true;
3720 return indexTable;
3724 static const NLMISC::CStringConversion<TValues> &getConversionTable()
3726 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
3727 NL_STRING_CONVERSION_TABLE_ENTRY(ca_none)
3728 NL_STRING_CONVERSION_TABLE_ENTRY(ca_play)
3729 NL_STRING_CONVERSION_TABLE_ENTRY(ca_edit)
3730 NL_STRING_CONVERSION_TABLE_ENTRY(ca_anim)
3731 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
3733 static NLMISC::CStringConversion<TValues>
3734 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
3735 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
3737 return conversionTable;
3740 TValues _Value;
3742 public:
3743 TCurrentActivity()
3744 : _Value(invalid_val)
3747 TCurrentActivity(TValues value)
3748 : _Value(value)
3752 TCurrentActivity(const std::string &str)
3754 _Value = getConversionTable().fromString(str);
3757 void serial(NLMISC::IStream &s)
3759 s.serialEnum(_Value);
3762 bool operator == (const TCurrentActivity &other) const
3764 return _Value == other._Value;
3766 bool operator != (const TCurrentActivity &other) const
3768 return ! (_Value == other._Value);
3770 bool operator < (const TCurrentActivity &other) const
3772 return _Value < other._Value;
3775 bool operator <= (const TCurrentActivity &other) const
3777 return _Value <= other._Value;
3780 bool operator > (const TCurrentActivity &other) const
3782 return !(_Value <= other._Value);
3784 bool operator >= (const TCurrentActivity &other) const
3786 return !(_Value < other._Value);
3789 const std::string &toString() const
3791 return getConversionTable().toString(_Value);
3793 static const std::string &toString(TValues value)
3795 return getConversionTable().toString(value);
3798 TValues getValue() const
3800 return _Value;
3803 // return true if the actual value of the enum is valid, otherwise false
3804 bool isValid()
3806 if (_Value == invalid_val)
3807 return false;
3809 // not invalid, check other enum value
3810 return getConversionTable().isValid(_Value);
3814 uint32 asIndex()
3816 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
3817 nlassert(it != getIndexTable().end());
3818 return it->second;
3824 struct TCurrentStatus
3826 enum TValues
3828 cs_offline = 1,
3829 cs_logged,
3830 cs_online,
3831 /// the highest valid value in the enum
3832 last_enum_item = cs_online,
3833 /// a value equal to the last enum item +1
3834 end_of_enum,
3836 invalid_val,
3838 /// Number of enumerated values
3839 nb_enum_items = 3
3842 /// Index table to convert enum value to linear index table
3843 const std::map<TValues, uint32> &getIndexTable() const
3845 static std::map<TValues, uint32> indexTable;
3846 static bool init = false;
3847 if (!init)
3849 // fill the index table
3850 indexTable.insert(std::make_pair(cs_offline, 0));
3851 indexTable.insert(std::make_pair(cs_logged, 1));
3852 indexTable.insert(std::make_pair(cs_online, 2));
3854 init = true;
3857 return indexTable;
3861 static const NLMISC::CStringConversion<TValues> &getConversionTable()
3863 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
3864 NL_STRING_CONVERSION_TABLE_ENTRY(cs_offline)
3865 NL_STRING_CONVERSION_TABLE_ENTRY(cs_logged)
3866 NL_STRING_CONVERSION_TABLE_ENTRY(cs_online)
3867 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
3869 static NLMISC::CStringConversion<TValues>
3870 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
3871 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
3873 return conversionTable;
3876 TValues _Value;
3878 public:
3879 TCurrentStatus()
3880 : _Value(invalid_val)
3883 TCurrentStatus(TValues value)
3884 : _Value(value)
3888 TCurrentStatus(const std::string &str)
3890 _Value = getConversionTable().fromString(str);
3893 void serial(NLMISC::IStream &s)
3895 s.serialEnum(_Value);
3898 bool operator == (const TCurrentStatus &other) const
3900 return _Value == other._Value;
3902 bool operator != (const TCurrentStatus &other) const
3904 return ! (_Value == other._Value);
3906 bool operator < (const TCurrentStatus &other) const
3908 return _Value < other._Value;
3911 bool operator <= (const TCurrentStatus &other) const
3913 return _Value <= other._Value;
3916 bool operator > (const TCurrentStatus &other) const
3918 return !(_Value <= other._Value);
3920 bool operator >= (const TCurrentStatus &other) const
3922 return !(_Value < other._Value);
3925 const std::string &toString() const
3927 return getConversionTable().toString(_Value);
3929 static const std::string &toString(TValues value)
3931 return getConversionTable().toString(value);
3934 TValues getValue() const
3936 return _Value;
3939 // return true if the actual value of the enum is valid, otherwise false
3940 bool isValid()
3942 if (_Value == invalid_val)
3943 return false;
3945 // not invalid, check other enum value
3946 return getConversionTable().isValid(_Value);
3950 uint32 asIndex()
3952 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
3953 nlassert(it != getIndexTable().end());
3954 return it->second;
3960 struct TPublicLevel
3962 enum TValues
3964 ul_none = 1,
3965 ul_public,
3966 /// the highest valid value in the enum
3967 last_enum_item = ul_public,
3968 /// a value equal to the last enum item +1
3969 end_of_enum,
3971 invalid_val,
3973 /// Number of enumerated values
3974 nb_enum_items = 2
3977 /// Index table to convert enum value to linear index table
3978 const std::map<TValues, uint32> &getIndexTable() const
3980 static std::map<TValues, uint32> indexTable;
3981 static bool init = false;
3982 if (!init)
3984 // fill the index table
3985 indexTable.insert(std::make_pair(ul_none, 0));
3986 indexTable.insert(std::make_pair(ul_public, 1));
3988 init = true;
3991 return indexTable;
3995 static const NLMISC::CStringConversion<TValues> &getConversionTable()
3997 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
3998 NL_STRING_CONVERSION_TABLE_ENTRY(ul_none)
3999 NL_STRING_CONVERSION_TABLE_ENTRY(ul_public)
4000 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
4002 static NLMISC::CStringConversion<TValues>
4003 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
4004 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
4006 return conversionTable;
4009 TValues _Value;
4011 public:
4012 TPublicLevel()
4013 : _Value(invalid_val)
4016 TPublicLevel(TValues value)
4017 : _Value(value)
4021 TPublicLevel(const std::string &str)
4023 _Value = getConversionTable().fromString(str);
4026 void serial(NLMISC::IStream &s)
4028 s.serialEnum(_Value);
4031 bool operator == (const TPublicLevel &other) const
4033 return _Value == other._Value;
4035 bool operator != (const TPublicLevel &other) const
4037 return ! (_Value == other._Value);
4039 bool operator < (const TPublicLevel &other) const
4041 return _Value < other._Value;
4044 bool operator <= (const TPublicLevel &other) const
4046 return _Value <= other._Value;
4049 bool operator > (const TPublicLevel &other) const
4051 return !(_Value <= other._Value);
4053 bool operator >= (const TPublicLevel &other) const
4055 return !(_Value < other._Value);
4058 const std::string &toString() const
4060 return getConversionTable().toString(_Value);
4062 static const std::string &toString(TValues value)
4064 return getConversionTable().toString(value);
4067 TValues getValue() const
4069 return _Value;
4072 // return true if the actual value of the enum is valid, otherwise false
4073 bool isValid()
4075 if (_Value == invalid_val)
4076 return false;
4078 // not invalid, check other enum value
4079 return getConversionTable().isValid(_Value);
4083 uint32 asIndex()
4085 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
4086 nlassert(it != getIndexTable().end());
4087 return it->second;
4093 struct TAccountType
4095 enum TValues
4097 at_normal = 1,
4098 at_gold,
4099 /// the highest valid value in the enum
4100 last_enum_item = at_gold,
4101 /// a value equal to the last enum item +1
4102 end_of_enum,
4104 invalid_val,
4106 /// Number of enumerated values
4107 nb_enum_items = 2
4110 /// Index table to convert enum value to linear index table
4111 const std::map<TValues, uint32> &getIndexTable() const
4113 static std::map<TValues, uint32> indexTable;
4114 static bool init = false;
4115 if (!init)
4117 // fill the index table
4118 indexTable.insert(std::make_pair(at_normal, 0));
4119 indexTable.insert(std::make_pair(at_gold, 1));
4121 init = true;
4124 return indexTable;
4128 static const NLMISC::CStringConversion<TValues> &getConversionTable()
4130 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
4131 NL_STRING_CONVERSION_TABLE_ENTRY(at_normal)
4132 NL_STRING_CONVERSION_TABLE_ENTRY(at_gold)
4133 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
4135 static NLMISC::CStringConversion<TValues>
4136 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
4137 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
4139 return conversionTable;
4142 TValues _Value;
4144 public:
4145 TAccountType()
4146 : _Value(invalid_val)
4149 TAccountType(TValues value)
4150 : _Value(value)
4154 TAccountType(const std::string &str)
4156 _Value = getConversionTable().fromString(str);
4159 void serial(NLMISC::IStream &s)
4161 s.serialEnum(_Value);
4164 bool operator == (const TAccountType &other) const
4166 return _Value == other._Value;
4168 bool operator != (const TAccountType &other) const
4170 return ! (_Value == other._Value);
4172 bool operator < (const TAccountType &other) const
4174 return _Value < other._Value;
4177 bool operator <= (const TAccountType &other) const
4179 return _Value <= other._Value;
4182 bool operator > (const TAccountType &other) const
4184 return !(_Value <= other._Value);
4186 bool operator >= (const TAccountType &other) const
4188 return !(_Value < other._Value);
4191 const std::string &toString() const
4193 return getConversionTable().toString(_Value);
4195 static const std::string &toString(TValues value)
4197 return getConversionTable().toString(value);
4200 TValues getValue() const
4202 return _Value;
4205 // return true if the actual value of the enum is valid, otherwise false
4206 bool isValid()
4208 if (_Value == invalid_val)
4209 return false;
4211 // not invalid, check other enum value
4212 return getConversionTable().isValid(_Value);
4216 uint32 asIndex()
4218 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
4219 nlassert(it != getIndexTable().end());
4220 return it->second;
4226 struct TLanguage
4228 enum TValues
4230 lang_en = 1,
4231 lang_fr,
4232 lang_de,
4233 lang_other,
4234 /// the highest valid value in the enum
4235 last_enum_item = lang_other,
4236 /// a value equal to the last enum item +1
4237 end_of_enum,
4239 invalid_val,
4241 /// Number of enumerated values
4242 nb_enum_items = 4
4245 /// Index table to convert enum value to linear index table
4246 const std::map<TValues, uint32> &getIndexTable() const
4248 static std::map<TValues, uint32> indexTable;
4249 static bool init = false;
4250 if (!init)
4252 // fill the index table
4253 indexTable.insert(std::make_pair(lang_en, 0));
4254 indexTable.insert(std::make_pair(lang_fr, 1));
4255 indexTable.insert(std::make_pair(lang_de, 2));
4256 indexTable.insert(std::make_pair(lang_other, 3));
4258 init = true;
4261 return indexTable;
4265 static const NLMISC::CStringConversion<TValues> &getConversionTable()
4267 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
4268 NL_STRING_CONVERSION_TABLE_ENTRY(lang_en)
4269 NL_STRING_CONVERSION_TABLE_ENTRY(lang_fr)
4270 NL_STRING_CONVERSION_TABLE_ENTRY(lang_de)
4271 NL_STRING_CONVERSION_TABLE_ENTRY(lang_other)
4272 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
4274 static NLMISC::CStringConversion<TValues>
4275 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
4276 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
4278 return conversionTable;
4281 TValues _Value;
4283 public:
4284 TLanguage()
4285 : _Value(invalid_val)
4288 TLanguage(TValues value)
4289 : _Value(value)
4293 TLanguage(const std::string &str)
4295 _Value = getConversionTable().fromString(str);
4298 void serial(NLMISC::IStream &s)
4300 s.serialEnum(_Value);
4303 bool operator == (const TLanguage &other) const
4305 return _Value == other._Value;
4307 bool operator != (const TLanguage &other) const
4309 return ! (_Value == other._Value);
4311 bool operator < (const TLanguage &other) const
4313 return _Value < other._Value;
4316 bool operator <= (const TLanguage &other) const
4318 return _Value <= other._Value;
4321 bool operator > (const TLanguage &other) const
4323 return !(_Value <= other._Value);
4325 bool operator >= (const TLanguage &other) const
4327 return !(_Value < other._Value);
4330 const std::string &toString() const
4332 return getConversionTable().toString(_Value);
4334 static const std::string &toString(TValues value)
4336 return getConversionTable().toString(value);
4339 TValues getValue() const
4341 return _Value;
4344 // return true if the actual value of the enum is valid, otherwise false
4345 bool isValid()
4347 if (_Value == invalid_val)
4348 return false;
4350 // not invalid, check other enum value
4351 return getConversionTable().isValid(_Value);
4355 uint32 asIndex()
4357 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
4358 nlassert(it != getIndexTable().end());
4359 return it->second;
4363 /////////////////////////////////////////////////////////////////
4364 // WARNING : this is a generated file, don't change it !
4365 /////////////////////////////////////////////////////////////////
4366 class CRingUser
4368 protected:
4370 uint32 _UserId;
4372 std::string _UserName;
4374 uint32 _CurrentCharacter;
4376 uint32 _CurrentSession;
4378 TCurrentActivity _CurrentActivity;
4380 TCurrentStatus _CurrentStatus;
4382 TPublicLevel _PublicLevel;
4384 TAccountType _AccountType;
4386 std::string _ContentAccessLevel;
4388 std::string _Description;
4390 TLanguage _Lang;
4392 std::string _Cookie;
4394 sint32 _CurrentDomainId;
4396 std::string _AddedPrivileges;
4398 friend class CKnownUser;
4400 std::vector < CKnownUserPtr > *_KnownUsers;
4402 friend class CCharacter;
4404 std::map < uint32, CCharacterPtr > *_Characters;
4406 friend class CFolder;
4408 std::vector < CFolderPtr > *_Folders;
4410 friend class CFolderAccess;
4412 std::vector < CFolderAccessPtr > *_FolderAccess;
4413 friend class CGmStatus;
4414 bool _GMStatusLoaded;
4415 CGmStatusPtr _GMStatus;
4416 public:
4418 const std::string &getUserName() const
4420 return _UserName;
4425 void setUserName(const std::string &value)
4428 if (_UserName != value)
4430 if (getPersistentState() != NOPE::os_transient)
4431 setPersistentState(NOPE::os_dirty);
4434 _UserName = value;
4441 uint32 getCurrentCharacter() const
4443 return _CurrentCharacter;
4446 void setCurrentCharacter(uint32 value)
4449 if (_CurrentCharacter != value)
4451 if (getPersistentState() != NOPE::os_transient)
4452 setPersistentState(NOPE::os_dirty);
4454 _CurrentCharacter = value;
4460 uint32 getCurrentSession() const
4462 return _CurrentSession;
4465 void setCurrentSession(uint32 value)
4468 if (_CurrentSession != value)
4470 if (getPersistentState() != NOPE::os_transient)
4471 setPersistentState(NOPE::os_dirty);
4473 _CurrentSession = value;
4479 TCurrentActivity getCurrentActivity() const
4481 return _CurrentActivity;
4484 void setCurrentActivity(TCurrentActivity value)
4487 if (_CurrentActivity != value)
4489 if (getPersistentState() != NOPE::os_transient)
4490 setPersistentState(NOPE::os_dirty);
4492 _CurrentActivity = value;
4498 TCurrentStatus getCurrentStatus() const
4500 return _CurrentStatus;
4503 void setCurrentStatus(TCurrentStatus value)
4506 if (_CurrentStatus != value)
4508 if (getPersistentState() != NOPE::os_transient)
4509 setPersistentState(NOPE::os_dirty);
4511 _CurrentStatus = value;
4517 TPublicLevel getPublicLevel() const
4519 return _PublicLevel;
4522 void setPublicLevel(TPublicLevel value)
4525 if (_PublicLevel != value)
4527 if (getPersistentState() != NOPE::os_transient)
4528 setPersistentState(NOPE::os_dirty);
4530 _PublicLevel = value;
4536 TAccountType getAccountType() const
4538 return _AccountType;
4541 void setAccountType(TAccountType value)
4544 if (_AccountType != value)
4546 if (getPersistentState() != NOPE::os_transient)
4547 setPersistentState(NOPE::os_dirty);
4549 _AccountType = value;
4555 const std::string &getContentAccessLevel() const
4557 return _ContentAccessLevel;
4562 void setContentAccessLevel(const std::string &value)
4565 if (_ContentAccessLevel != value)
4567 if (getPersistentState() != NOPE::os_transient)
4568 setPersistentState(NOPE::os_dirty);
4571 _ContentAccessLevel = value;
4578 const std::string &getDescription() const
4580 return _Description;
4585 void setDescription(const std::string &value)
4588 if (_Description != value)
4590 if (getPersistentState() != NOPE::os_transient)
4591 setPersistentState(NOPE::os_dirty);
4594 _Description = value;
4601 TLanguage getLang() const
4603 return _Lang;
4606 void setLang(TLanguage value)
4609 if (_Lang != value)
4611 if (getPersistentState() != NOPE::os_transient)
4612 setPersistentState(NOPE::os_dirty);
4614 _Lang = value;
4620 const std::string &getCookie() const
4622 return _Cookie;
4627 void setCookie(const std::string &value)
4630 if (_Cookie != value)
4632 if (getPersistentState() != NOPE::os_transient)
4633 setPersistentState(NOPE::os_dirty);
4636 _Cookie = value;
4643 sint32 getCurrentDomainId() const
4645 return _CurrentDomainId;
4648 void setCurrentDomainId(sint32 value)
4651 if (_CurrentDomainId != value)
4653 if (getPersistentState() != NOPE::os_transient)
4654 setPersistentState(NOPE::os_dirty);
4656 _CurrentDomainId = value;
4662 const std::string &getAddedPrivileges() const
4664 return _AddedPrivileges;
4669 void setAddedPrivileges(const std::string &value)
4672 if (_AddedPrivileges != value)
4674 if (getPersistentState() != NOPE::os_transient)
4675 setPersistentState(NOPE::os_dirty);
4678 _AddedPrivileges = value;
4685 /** Return a const reference to the vector of child.
4686 * If you want to modify the element inside, you need to
4687 * use on of the two following methods who return non const pointer
4688 * on contained elements.
4690 const std::vector<CKnownUserPtr> &getKnownUsers() const;
4691 /** Return the ith element of the child vector
4692 * index must be valid (ie less than size of the vector)
4694 CKnownUserPtr &getKnownUsersByIndex(uint32 index) const;
4695 /** Return the identified element by looking in the vector
4696 * If no element match the id, NULL pointer is returned
4698 CKnownUserPtr &getKnownUsersById(uint32 id) const;
4701 /** Return a const reference to the map of child.
4702 * If you want to modify the element inside, you need to
4703 * use on of the two following method who return non const pointer
4704 * on contained elements.
4706 const std::map<uint32, CCharacterPtr> &getCharacters() const;
4707 /** Return the identified element by looking in the map
4708 * If no element match the id, NULL pointer is returned
4710 CCharacterPtr &getCharactersById(uint32 id) const;
4713 /** Return a const reference to the vector of child.
4714 * If you want to modify the element inside, you need to
4715 * use on of the two following methods who return non const pointer
4716 * on contained elements.
4718 const std::vector<CFolderPtr> &getFolders() const;
4719 /** Return the ith element of the child vector
4720 * index must be valid (ie less than size of the vector)
4722 CFolderPtr &getFoldersByIndex(uint32 index) const;
4723 /** Return the identified element by looking in the vector
4724 * If no element match the id, NULL pointer is returned
4726 CFolderPtr &getFoldersById(uint32 id) const;
4729 /** Return a const reference to the vector of child.
4730 * If you want to modify the element inside, you need to
4731 * use on of the two following methods who return non const pointer
4732 * on contained elements.
4734 const std::vector<CFolderAccessPtr> &getFolderAccess() const;
4735 /** Return the ith element of the child vector
4736 * index must be valid (ie less than size of the vector)
4738 CFolderAccessPtr &getFolderAccessByIndex(uint32 index) const;
4739 /** Return the identified element by looking in the vector
4740 * If no element match the id, NULL pointer is returned
4742 CFolderAccessPtr &getFolderAccessById(uint32 id) const;
4745 /** Return the one child object (or null if not) */
4746 CGmStatusPtr getGMStatus();
4748 bool operator == (const CRingUser &other) const
4750 return _UserId == other._UserId
4751 && _UserName == other._UserName
4752 && _CurrentCharacter == other._CurrentCharacter
4753 && _CurrentSession == other._CurrentSession
4754 && _CurrentActivity == other._CurrentActivity
4755 && _CurrentStatus == other._CurrentStatus
4756 && _PublicLevel == other._PublicLevel
4757 && _AccountType == other._AccountType
4758 && _ContentAccessLevel == other._ContentAccessLevel
4759 && _Description == other._Description
4760 && _Lang == other._Lang
4761 && _Cookie == other._Cookie
4762 && _CurrentDomainId == other._CurrentDomainId
4763 && _AddedPrivileges == other._AddedPrivileges;
4767 private:
4768 // private constructor, you must use 'createTransient' to get an instance
4769 CRingUser()
4770 : _PtrList(NULL),
4771 _ObjectState(NOPE::os_transient),
4772 _UserId(NOPE::INVALID_OBJECT_ID)
4774 _KnownUsers = NULL;
4775 _Characters = NULL;
4776 _Folders = NULL;
4777 _FolderAccess = NULL;
4778 _GMStatusLoaded = false;
4780 // register the cache for this class (if not already done)
4781 registerUpdatable();
4784 // Destructor, delete any children
4785 ~CRingUser();
4787 /// utility func to remove this object from the released object container
4788 void removeFromReleased();
4791 public:
4792 /// Create a new instance in the transient space
4793 static CRingUserPtr createTransient(const char *filename, uint32 lineNum)
4795 return CRingUserPtr(new CRingUser(), filename, lineNum);
4798 /** Create a new object in the database from the current object data.
4799 * The object MUST be in transient state (i.e, it must be a new
4800 * object created by user and not comming from the databse).
4801 * If identifier is autogenerated, the generated id can be read after
4802 * this call.
4804 bool create(MSW::CConnection &connection);
4805 /** Update the database with the current object state.
4806 * The object MUST be either in clean or dirty state.
4807 * Return true if the object has been effectively stored
4808 * in the database.
4809 * After this call, the object is in 'clean' state.
4811 bool update(MSW::CConnection &connection);
4812 /** Remove the current object from the persistent storage.
4813 * The object must be in clean or dirty state.
4814 * Return true if the object has been correctly
4815 * updated in the database.
4816 * After the call, the object is in 'clean' state.
4818 bool remove(MSW::CConnection &connection);
4819 /** Remove an object from the persistent storage by specifying
4820 * the id to remove.
4821 * Return true if an entry as been effectively removed from
4822 * the database.
4823 * After the call, the object is in 'removed' state and should
4824 * no more be used. A good pratice should be to delete
4825 * the transient object just after the remove call.
4827 static bool removeById(MSW::CConnection &connection, uint32 id);
4829 /** Load an instance from the database.
4830 * This call allocate a new object and load the property value
4831 * from the database.
4832 * Return NULL if the object id is not found.
4834 static CRingUserPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
4837 /// Load KnownUsers child(ren) object(s).
4838 bool loadKnownUsers(MSW::CConnection &connection, const char *filename, uint32 lineNum);
4840 /// Load Characters child(ren) object(s).
4841 bool loadCharacters(MSW::CConnection &connection, const char *filename, uint32 lineNum);
4843 /// Load Folders child(ren) object(s).
4844 bool loadFolders(MSW::CConnection &connection, const char *filename, uint32 lineNum);
4846 /// Load FolderAccess child(ren) object(s).
4847 bool loadFolderAccess(MSW::CConnection &connection, const char *filename, uint32 lineNum);
4849 /// Load GMStatus child(ren) object(s).
4850 bool loadGMStatus(MSW::CConnection &connection, const char *filename, uint32 lineNum);
4853 private:
4855 private:
4856 friend class CPersistentCache;
4857 friend class CRingUserPtr;
4859 typedef std::map<uint32, CRingUser*> TObjectCache;
4860 typedef std::set<CRingUser*> TObjectSet;
4861 typedef std::map<time_t, TObjectSet> TReleasedObject;
4863 /// The complete set of object currently in memory (either active or released) excluding transient instance
4864 static TObjectCache _ObjectCache;
4865 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
4866 static TReleasedObject _ReleasedObject;
4868 /// The current object state
4869 NOPE::TObjectState _ObjectState;
4871 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
4872 time_t _ReleaseDate;
4874 /// The linked list of pointer on this object
4875 CRingUserPtr *_PtrList;
4877 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
4878 static CRingUser *loadFromCache(uint32 objectId, bool unrelease);
4880 // Receive and execute command from the cache manager.
4881 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
4883 static void dump();
4885 static void updateCache();
4887 public:
4888 static void clearCache();
4889 private:
4890 void registerUpdatable();
4892 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
4893 void setFirstPtr(CRingUserPtr *ptr);
4895 // return the first pointer of the pointer list (can be null)
4896 CRingUserPtr *getFirstPtr()
4898 return _PtrList;
4901 public:
4903 /** Return the object identifier (witch is unique)
4904 * You can only call this method on a persistent instance.
4905 * (because transient instance can have invalid id)
4907 uint32 getObjectId() const
4910 return _UserId;
4913 /** Set the object unique ID.
4914 * You can only set the object id on a transient object
4915 * having a non autogenerated unique id.
4916 * Furthermore, you MUST set the id before calling create()
4917 * if the id is not autogenerated.
4919 void setObjectId(uint32 objectId)
4921 // can only be set when in transient state
4922 nlassert(getPersistentState() == NOPE::os_transient);
4923 // can only be set once
4924 nlassert(_UserId == NOPE::INVALID_OBJECT_ID);
4925 _UserId = objectId;
4928 /** Return the current persistent state of the object.*/
4929 NOPE::TObjectState getPersistentState() const
4931 return _ObjectState;
4934 private:
4935 // Set the persistent state of the object and do some house keeping
4936 void setPersistentState(NOPE::TObjectState state);
4945 struct TRelationToParent
4947 enum TValues
4949 rtp_same = 1,
4950 rtp_variant,
4951 rtp_different,
4952 /// the highest valid value in the enum
4953 last_enum_item = rtp_different,
4954 /// a value equal to the last enum item +1
4955 end_of_enum,
4957 invalid_val,
4959 /// Number of enumerated values
4960 nb_enum_items = 3
4963 /// Index table to convert enum value to linear index table
4964 const std::map<TValues, uint32> &getIndexTable() const
4966 static std::map<TValues, uint32> indexTable;
4967 static bool init = false;
4968 if (!init)
4970 // fill the index table
4971 indexTable.insert(std::make_pair(rtp_same, 0));
4972 indexTable.insert(std::make_pair(rtp_variant, 1));
4973 indexTable.insert(std::make_pair(rtp_different, 2));
4975 init = true;
4978 return indexTable;
4982 static const NLMISC::CStringConversion<TValues> &getConversionTable()
4984 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
4985 NL_STRING_CONVERSION_TABLE_ENTRY(rtp_same)
4986 NL_STRING_CONVERSION_TABLE_ENTRY(rtp_variant)
4987 NL_STRING_CONVERSION_TABLE_ENTRY(rtp_different)
4988 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
4990 static NLMISC::CStringConversion<TValues>
4991 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
4992 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
4994 return conversionTable;
4997 TValues _Value;
4999 public:
5000 TRelationToParent()
5001 : _Value(invalid_val)
5004 TRelationToParent(TValues value)
5005 : _Value(value)
5009 TRelationToParent(const std::string &str)
5011 _Value = getConversionTable().fromString(str);
5014 void serial(NLMISC::IStream &s)
5016 s.serialEnum(_Value);
5019 bool operator == (const TRelationToParent &other) const
5021 return _Value == other._Value;
5023 bool operator != (const TRelationToParent &other) const
5025 return ! (_Value == other._Value);
5027 bool operator < (const TRelationToParent &other) const
5029 return _Value < other._Value;
5032 bool operator <= (const TRelationToParent &other) const
5034 return _Value <= other._Value;
5037 bool operator > (const TRelationToParent &other) const
5039 return !(_Value <= other._Value);
5041 bool operator >= (const TRelationToParent &other) const
5043 return !(_Value < other._Value);
5046 const std::string &toString() const
5048 return getConversionTable().toString(_Value);
5050 static const std::string &toString(TValues value)
5052 return getConversionTable().toString(value);
5055 TValues getValue() const
5057 return _Value;
5060 // return true if the actual value of the enum is valid, otherwise false
5061 bool isValid()
5063 if (_Value == invalid_val)
5064 return false;
5066 // not invalid, check other enum value
5067 return getConversionTable().isValid(_Value);
5071 uint32 asIndex()
5073 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
5074 nlassert(it != getIndexTable().end());
5075 return it->second;
5081 struct TPlayType
5083 enum TValues
5085 pt_rp = 1,
5086 pt_pvp,
5087 /// the highest valid value in the enum
5088 last_enum_item = pt_pvp,
5089 /// a value equal to the last enum item +1
5090 end_of_enum,
5092 invalid_val,
5094 /// Number of enumerated values
5095 nb_enum_items = 2
5098 /// Index table to convert enum value to linear index table
5099 const std::map<TValues, uint32> &getIndexTable() const
5101 static std::map<TValues, uint32> indexTable;
5102 static bool init = false;
5103 if (!init)
5105 // fill the index table
5106 indexTable.insert(std::make_pair(pt_rp, 0));
5107 indexTable.insert(std::make_pair(pt_pvp, 1));
5109 init = true;
5112 return indexTable;
5116 static const NLMISC::CStringConversion<TValues> &getConversionTable()
5118 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
5119 NL_STRING_CONVERSION_TABLE_ENTRY(pt_rp)
5120 NL_STRING_CONVERSION_TABLE_ENTRY(pt_pvp)
5121 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
5123 static NLMISC::CStringConversion<TValues>
5124 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
5125 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
5127 return conversionTable;
5130 TValues _Value;
5132 public:
5133 TPlayType()
5134 : _Value(invalid_val)
5137 TPlayType(TValues value)
5138 : _Value(value)
5142 TPlayType(const std::string &str)
5144 _Value = getConversionTable().fromString(str);
5147 void serial(NLMISC::IStream &s)
5149 s.serialEnum(_Value);
5152 bool operator == (const TPlayType &other) const
5154 return _Value == other._Value;
5156 bool operator != (const TPlayType &other) const
5158 return ! (_Value == other._Value);
5160 bool operator < (const TPlayType &other) const
5162 return _Value < other._Value;
5165 bool operator <= (const TPlayType &other) const
5167 return _Value <= other._Value;
5170 bool operator > (const TPlayType &other) const
5172 return !(_Value <= other._Value);
5174 bool operator >= (const TPlayType &other) const
5176 return !(_Value < other._Value);
5179 const std::string &toString() const
5181 return getConversionTable().toString(_Value);
5183 static const std::string &toString(TValues value)
5185 return getConversionTable().toString(value);
5188 TValues getValue() const
5190 return _Value;
5193 // return true if the actual value of the enum is valid, otherwise false
5194 bool isValid()
5196 if (_Value == invalid_val)
5197 return false;
5199 // not invalid, check other enum value
5200 return getConversionTable().isValid(_Value);
5204 uint32 asIndex()
5206 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
5207 nlassert(it != getIndexTable().end());
5208 return it->second;
5212 /////////////////////////////////////////////////////////////////
5213 // WARNING : this is a generated file, don't change it !
5214 /////////////////////////////////////////////////////////////////
5215 class CSession
5217 protected:
5219 TSessionId _SessionId;
5221 TSessionType _SessionType;
5223 std::string _Title;
5225 uint32 _OwnerId;
5227 uint32 _PlanDate;
5229 uint32 _StartDate;
5231 std::string _Description;
5233 TSessionOrientation _Orientation;
5235 R2::TSessionLevel _Level;
5237 TRuleType _RuleType;
5239 TAccessType _AccessType;
5241 TSessionState _State;
5243 uint32 _HostShardId;
5245 uint32 _SubscriptionSlots;
5247 uint32 _ReservedSlots;
5249 TEstimatedDuration _EstimatedDuration;
5251 uint32 _FinalDuration;
5253 uint32 _FolderId;
5255 std::string _Lang;
5257 std::string _Icone;
5259 TAnimMode _AnimMode;
5261 TRaceFilter _RaceFilter;
5263 TReligionFilter _ReligionFilter;
5265 TGuildFilter _GuildFilter;
5267 TShardFilter _ShardFilter;
5269 TLevelFilter _LevelFilter;
5271 bool _SubscriptionClosed;
5273 bool _Newcomer;
5275 friend class CSessionParticipant;
5277 std::vector < CSessionParticipantPtr > *_SessionParticipants;
5279 friend class CGuildInvite;
5281 std::vector < CGuildInvitePtr > *_GuildInvites;
5283 friend class CJournalEntry;
5285 std::vector < CJournalEntryPtr > *_JournalEntries;
5286 public:
5288 TSessionType getSessionType() const
5290 return _SessionType;
5293 void setSessionType(TSessionType value)
5296 if (_SessionType != value)
5298 if (getPersistentState() != NOPE::os_transient)
5299 setPersistentState(NOPE::os_dirty);
5301 _SessionType = value;
5307 const std::string &getTitle() const
5309 return _Title;
5314 void setTitle(const std::string &value)
5317 if (_Title != value)
5319 if (getPersistentState() != NOPE::os_transient)
5320 setPersistentState(NOPE::os_dirty);
5323 _Title = value;
5330 uint32 getOwnerId() const
5332 return _OwnerId;
5335 void setOwnerId(uint32 value)
5338 if (_OwnerId != value)
5340 if (getPersistentState() != NOPE::os_transient)
5341 setPersistentState(NOPE::os_dirty);
5343 _OwnerId = value;
5349 uint32 getPlanDate() const
5351 return _PlanDate;
5354 void setPlanDate(uint32 value)
5357 if (_PlanDate != value)
5359 if (getPersistentState() != NOPE::os_transient)
5360 setPersistentState(NOPE::os_dirty);
5362 _PlanDate = value;
5368 uint32 getStartDate() const
5370 return _StartDate;
5373 void setStartDate(uint32 value)
5376 if (_StartDate != value)
5378 if (getPersistentState() != NOPE::os_transient)
5379 setPersistentState(NOPE::os_dirty);
5381 _StartDate = value;
5387 const std::string &getDescription() const
5389 return _Description;
5394 void setDescription(const std::string &value)
5397 if (_Description != value)
5399 if (getPersistentState() != NOPE::os_transient)
5400 setPersistentState(NOPE::os_dirty);
5403 _Description = value;
5410 TSessionOrientation getOrientation() const
5412 return _Orientation;
5415 void setOrientation(TSessionOrientation value)
5418 if (_Orientation != value)
5420 if (getPersistentState() != NOPE::os_transient)
5421 setPersistentState(NOPE::os_dirty);
5423 _Orientation = value;
5429 R2::TSessionLevel getLevel() const
5431 return _Level;
5434 void setLevel(R2::TSessionLevel value)
5437 if (_Level != value)
5439 if (getPersistentState() != NOPE::os_transient)
5440 setPersistentState(NOPE::os_dirty);
5442 _Level = value;
5448 TRuleType getRuleType() const
5450 return _RuleType;
5453 void setRuleType(TRuleType value)
5456 if (_RuleType != value)
5458 if (getPersistentState() != NOPE::os_transient)
5459 setPersistentState(NOPE::os_dirty);
5461 _RuleType = value;
5467 TAccessType getAccessType() const
5469 return _AccessType;
5472 void setAccessType(TAccessType value)
5475 if (_AccessType != value)
5477 if (getPersistentState() != NOPE::os_transient)
5478 setPersistentState(NOPE::os_dirty);
5480 _AccessType = value;
5486 TSessionState getState() const
5488 return _State;
5491 void setState(TSessionState value)
5494 if (_State != value)
5496 if (getPersistentState() != NOPE::os_transient)
5497 setPersistentState(NOPE::os_dirty);
5499 _State = value;
5505 uint32 getHostShardId() const
5507 return _HostShardId;
5510 void setHostShardId(uint32 value)
5513 if (_HostShardId != value)
5515 if (getPersistentState() != NOPE::os_transient)
5516 setPersistentState(NOPE::os_dirty);
5518 _HostShardId = value;
5524 uint32 getSubscriptionSlots() const
5526 return _SubscriptionSlots;
5529 void setSubscriptionSlots(uint32 value)
5532 if (_SubscriptionSlots != value)
5534 if (getPersistentState() != NOPE::os_transient)
5535 setPersistentState(NOPE::os_dirty);
5537 _SubscriptionSlots = value;
5543 uint32 getReservedSlots() const
5545 return _ReservedSlots;
5548 void setReservedSlots(uint32 value)
5551 if (_ReservedSlots != value)
5553 if (getPersistentState() != NOPE::os_transient)
5554 setPersistentState(NOPE::os_dirty);
5556 _ReservedSlots = value;
5562 TEstimatedDuration getEstimatedDuration() const
5564 return _EstimatedDuration;
5567 void setEstimatedDuration(TEstimatedDuration value)
5570 if (_EstimatedDuration != value)
5572 if (getPersistentState() != NOPE::os_transient)
5573 setPersistentState(NOPE::os_dirty);
5575 _EstimatedDuration = value;
5581 uint32 getFinalDuration() const
5583 return _FinalDuration;
5586 void setFinalDuration(uint32 value)
5589 if (_FinalDuration != value)
5591 if (getPersistentState() != NOPE::os_transient)
5592 setPersistentState(NOPE::os_dirty);
5594 _FinalDuration = value;
5600 uint32 getFolderId() const
5602 return _FolderId;
5605 void setFolderId(uint32 value)
5608 if (_FolderId != value)
5610 if (getPersistentState() != NOPE::os_transient)
5611 setPersistentState(NOPE::os_dirty);
5613 _FolderId = value;
5619 const std::string &getLang() const
5621 return _Lang;
5626 void setLang(const std::string &value)
5629 if (_Lang != value)
5631 if (getPersistentState() != NOPE::os_transient)
5632 setPersistentState(NOPE::os_dirty);
5635 _Lang = value;
5642 const std::string &getIcone() const
5644 return _Icone;
5649 void setIcone(const std::string &value)
5652 if (_Icone != value)
5654 if (getPersistentState() != NOPE::os_transient)
5655 setPersistentState(NOPE::os_dirty);
5658 _Icone = value;
5665 TAnimMode getAnimMode() const
5667 return _AnimMode;
5670 void setAnimMode(TAnimMode value)
5673 if (_AnimMode != value)
5675 if (getPersistentState() != NOPE::os_transient)
5676 setPersistentState(NOPE::os_dirty);
5678 _AnimMode = value;
5684 TRaceFilter getRaceFilter() const
5686 return _RaceFilter;
5689 void setRaceFilter(TRaceFilter value)
5692 if (_RaceFilter != value)
5694 if (getPersistentState() != NOPE::os_transient)
5695 setPersistentState(NOPE::os_dirty);
5697 _RaceFilter = value;
5703 TReligionFilter getReligionFilter() const
5705 return _ReligionFilter;
5708 void setReligionFilter(TReligionFilter value)
5711 if (_ReligionFilter != value)
5713 if (getPersistentState() != NOPE::os_transient)
5714 setPersistentState(NOPE::os_dirty);
5716 _ReligionFilter = value;
5722 TGuildFilter getGuildFilter() const
5724 return _GuildFilter;
5727 void setGuildFilter(TGuildFilter value)
5730 if (_GuildFilter != value)
5732 if (getPersistentState() != NOPE::os_transient)
5733 setPersistentState(NOPE::os_dirty);
5735 _GuildFilter = value;
5741 TShardFilter getShardFilter() const
5743 return _ShardFilter;
5746 void setShardFilter(TShardFilter value)
5749 if (_ShardFilter != value)
5751 if (getPersistentState() != NOPE::os_transient)
5752 setPersistentState(NOPE::os_dirty);
5754 _ShardFilter = value;
5760 TLevelFilter getLevelFilter() const
5762 return _LevelFilter;
5765 void setLevelFilter(TLevelFilter value)
5768 if (_LevelFilter != value)
5770 if (getPersistentState() != NOPE::os_transient)
5771 setPersistentState(NOPE::os_dirty);
5773 _LevelFilter = value;
5779 bool getSubscriptionClosed() const
5781 return _SubscriptionClosed;
5784 void setSubscriptionClosed(bool value)
5787 if (_SubscriptionClosed != value)
5789 if (getPersistentState() != NOPE::os_transient)
5790 setPersistentState(NOPE::os_dirty);
5792 _SubscriptionClosed = value;
5798 bool getNewcomer() const
5800 return _Newcomer;
5803 void setNewcomer(bool value)
5806 if (_Newcomer != value)
5808 if (getPersistentState() != NOPE::os_transient)
5809 setPersistentState(NOPE::os_dirty);
5811 _Newcomer = value;
5817 /** Return a const reference to the vector of child.
5818 * If you want to modify the element inside, you need to
5819 * use on of the two following methods who return non const pointer
5820 * on contained elements.
5822 const std::vector<CSessionParticipantPtr> &getSessionParticipants() const;
5823 /** Return the ith element of the child vector
5824 * index must be valid (ie less than size of the vector)
5826 CSessionParticipantPtr &getSessionParticipantsByIndex(uint32 index) const;
5827 /** Return the identified element by looking in the vector
5828 * If no element match the id, NULL pointer is returned
5830 CSessionParticipantPtr &getSessionParticipantsById(uint32 id) const;
5833 /** Return a const reference to the vector of child.
5834 * If you want to modify the element inside, you need to
5835 * use on of the two following methods who return non const pointer
5836 * on contained elements.
5838 const std::vector<CGuildInvitePtr> &getGuildInvites() const;
5839 /** Return the ith element of the child vector
5840 * index must be valid (ie less than size of the vector)
5842 CGuildInvitePtr &getGuildInvitesByIndex(uint32 index) const;
5843 /** Return the identified element by looking in the vector
5844 * If no element match the id, NULL pointer is returned
5846 CGuildInvitePtr &getGuildInvitesById(uint32 id) const;
5849 /** Return a const reference to the vector of child.
5850 * If you want to modify the element inside, you need to
5851 * use on of the two following methods who return non const pointer
5852 * on contained elements.
5854 const std::vector<CJournalEntryPtr> &getJournalEntries() const;
5855 /** Return the ith element of the child vector
5856 * index must be valid (ie less than size of the vector)
5858 CJournalEntryPtr &getJournalEntriesByIndex(uint32 index) const;
5859 /** Return the identified element by looking in the vector
5860 * If no element match the id, NULL pointer is returned
5862 CJournalEntryPtr &getJournalEntriesById(uint32 id) const;
5865 bool operator == (const CSession &other) const
5867 return _SessionId == other._SessionId
5868 && _SessionType == other._SessionType
5869 && _Title == other._Title
5870 && _OwnerId == other._OwnerId
5871 && _PlanDate == other._PlanDate
5872 && _StartDate == other._StartDate
5873 && _Description == other._Description
5874 && _Orientation == other._Orientation
5875 && _Level == other._Level
5876 && _RuleType == other._RuleType
5877 && _AccessType == other._AccessType
5878 && _State == other._State
5879 && _HostShardId == other._HostShardId
5880 && _SubscriptionSlots == other._SubscriptionSlots
5881 && _ReservedSlots == other._ReservedSlots
5882 && _EstimatedDuration == other._EstimatedDuration
5883 && _FinalDuration == other._FinalDuration
5884 && _FolderId == other._FolderId
5885 && _Lang == other._Lang
5886 && _Icone == other._Icone
5887 && _AnimMode == other._AnimMode
5888 && _RaceFilter == other._RaceFilter
5889 && _ReligionFilter == other._ReligionFilter
5890 && _GuildFilter == other._GuildFilter
5891 && _ShardFilter == other._ShardFilter
5892 && _LevelFilter == other._LevelFilter
5893 && _SubscriptionClosed == other._SubscriptionClosed
5894 && _Newcomer == other._Newcomer;
5898 private:
5899 // private constructor, you must use 'createTransient' to get an instance
5900 CSession()
5901 : _PtrList(NULL),
5902 _ObjectState(NOPE::os_transient),
5903 _SessionId(NOPE::INVALID_OBJECT_ID)
5905 // Default initialisation
5906 _AccessType = TAccessType::at_private;
5907 _Newcomer = 1;
5908 _SessionParticipants = NULL;
5909 _GuildInvites = NULL;
5910 _JournalEntries = NULL;
5912 // register the cache for this class (if not already done)
5913 registerUpdatable();
5916 // Destructor, delete any children
5917 ~CSession();
5919 /// utility func to remove this object from the released object container
5920 void removeFromReleased();
5923 public:
5924 /// Create a new instance in the transient space
5925 static CSessionPtr createTransient(const char *filename, uint32 lineNum)
5927 return CSessionPtr(new CSession(), filename, lineNum);
5930 /** Create a new object in the database from the current object data.
5931 * The object MUST be in transient state (i.e, it must be a new
5932 * object created by user and not comming from the databse).
5933 * If identifier is autogenerated, the generated id can be read after
5934 * this call.
5936 bool create(MSW::CConnection &connection);
5937 /** Update the database with the current object state.
5938 * The object MUST be either in clean or dirty state.
5939 * Return true if the object has been effectively stored
5940 * in the database.
5941 * After this call, the object is in 'clean' state.
5943 bool update(MSW::CConnection &connection);
5944 /** Remove the current object from the persistent storage.
5945 * The object must be in clean or dirty state.
5946 * Return true if the object has been correctly
5947 * updated in the database.
5948 * After the call, the object is in 'clean' state.
5950 bool remove(MSW::CConnection &connection);
5951 /** Remove an object from the persistent storage by specifying
5952 * the id to remove.
5953 * Return true if an entry as been effectively removed from
5954 * the database.
5955 * After the call, the object is in 'removed' state and should
5956 * no more be used. A good pratice should be to delete
5957 * the transient object just after the remove call.
5959 static bool removeById(MSW::CConnection &connection, uint32 id);
5961 /** Load an instance from the database.
5962 * This call allocate a new object and load the property value
5963 * from the database.
5964 * Return NULL if the object id is not found.
5966 static CSessionPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
5969 /** Load all objects children of CCharacter and
5970 * return them by using the specified output iterator.
5973 static bool loadChildrenOfCCharacter(MSW::CConnection &connection, uint32 parentId, std::vector < CSessionPtr > &children, const char *filename, uint32 lineNum);
5975 /** Load all objects children of CFolder and
5976 * return them by using the specified output iterator.
5979 static bool loadChildrenOfCFolder(MSW::CConnection &connection, uint32 parentId, std::vector < CSessionPtr > &children, const char *filename, uint32 lineNum);
5981 /// Load SessionParticipants child(ren) object(s).
5982 bool loadSessionParticipants(MSW::CConnection &connection, const char *filename, uint32 lineNum);
5984 /// Load GuildInvites child(ren) object(s).
5985 bool loadGuildInvites(MSW::CConnection &connection, const char *filename, uint32 lineNum);
5987 /// Load JournalEntries child(ren) object(s).
5988 bool loadJournalEntries(MSW::CConnection &connection, const char *filename, uint32 lineNum);
5991 private:
5993 private:
5994 friend class CPersistentCache;
5995 friend class CSessionPtr;
5997 typedef std::map<uint32, CSession*> TObjectCache;
5998 typedef std::set<CSession*> TObjectSet;
5999 typedef std::map<time_t, TObjectSet> TReleasedObject;
6001 /// The complete set of object currently in memory (either active or released) excluding transient instance
6002 static TObjectCache _ObjectCache;
6003 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
6004 static TReleasedObject _ReleasedObject;
6006 /// The current object state
6007 NOPE::TObjectState _ObjectState;
6009 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
6010 time_t _ReleaseDate;
6012 /// The linked list of pointer on this object
6013 CSessionPtr *_PtrList;
6015 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
6016 static CSession *loadFromCache(uint32 objectId, bool unrelease);
6018 // Receive and execute command from the cache manager.
6019 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
6021 static void dump();
6023 static void updateCache();
6025 public:
6026 static void clearCache();
6027 private:
6028 void registerUpdatable();
6030 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
6031 void setFirstPtr(CSessionPtr *ptr);
6033 // return the first pointer of the pointer list (can be null)
6034 CSessionPtr *getFirstPtr()
6036 return _PtrList;
6039 public:
6041 /** Return the object identifier (witch is unique)
6042 * You can only call this method on a persistent instance.
6043 * (because transient instance can have invalid id)
6045 uint32 getObjectId() const
6048 nlassert(getPersistentState() != NOPE::os_transient);
6049 return _SessionId;
6052 /** Set the object unique ID.
6053 * You can only set the object id on a transient object
6054 * having a non autogenerated unique id.
6055 * Furthermore, you MUST set the id before calling create()
6056 * if the id is not autogenerated.
6058 void setObjectId(uint32 objectId)
6060 // can only be set when in transient state
6061 nlassert(getPersistentState() == NOPE::os_transient);
6062 // can only be set once
6063 nlassert(_SessionId == NOPE::INVALID_OBJECT_ID);
6064 _SessionId = objectId;
6067 /** Return the current persistent state of the object.*/
6068 NOPE::TObjectState getPersistentState() const
6070 return _ObjectState;
6073 private:
6074 // Set the persistent state of the object and do some house keeping
6075 void setPersistentState(NOPE::TObjectState state);
6084 struct TAccessLevel
6086 enum TValues
6088 ds_close,
6089 ds_dev,
6090 ds_restricted,
6091 ds_open,
6092 /// the highest valid value in the enum
6093 last_enum_item = ds_open,
6094 /// a value equal to the last enum item +1
6095 end_of_enum,
6097 invalid_val,
6099 /// Number of enumerated values
6100 nb_enum_items = 4
6103 /// Index table to convert enum value to linear index table
6104 const std::map<TValues, uint32> &getIndexTable() const
6106 static std::map<TValues, uint32> indexTable;
6107 static bool init = false;
6108 if (!init)
6110 // fill the index table
6111 indexTable.insert(std::make_pair(ds_close, 0));
6112 indexTable.insert(std::make_pair(ds_dev, 1));
6113 indexTable.insert(std::make_pair(ds_restricted, 2));
6114 indexTable.insert(std::make_pair(ds_open, 3));
6116 init = true;
6119 return indexTable;
6123 static const NLMISC::CStringConversion<TValues> &getConversionTable()
6125 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
6126 NL_STRING_CONVERSION_TABLE_ENTRY(ds_close)
6127 NL_STRING_CONVERSION_TABLE_ENTRY(ds_dev)
6128 NL_STRING_CONVERSION_TABLE_ENTRY(ds_restricted)
6129 NL_STRING_CONVERSION_TABLE_ENTRY(ds_open)
6130 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
6132 static NLMISC::CStringConversion<TValues>
6133 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
6134 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
6136 return conversionTable;
6139 TValues _Value;
6141 public:
6142 TAccessLevel()
6143 : _Value(invalid_val)
6146 TAccessLevel(TValues value)
6147 : _Value(value)
6151 TAccessLevel(const std::string &str)
6153 _Value = getConversionTable().fromString(str);
6156 void serial(NLMISC::IStream &s)
6158 s.serialEnum(_Value);
6161 bool operator == (const TAccessLevel &other) const
6163 return _Value == other._Value;
6165 bool operator != (const TAccessLevel &other) const
6167 return ! (_Value == other._Value);
6169 bool operator < (const TAccessLevel &other) const
6171 return _Value < other._Value;
6174 bool operator <= (const TAccessLevel &other) const
6176 return _Value <= other._Value;
6179 bool operator > (const TAccessLevel &other) const
6181 return !(_Value <= other._Value);
6183 bool operator >= (const TAccessLevel &other) const
6185 return !(_Value < other._Value);
6188 const std::string &toString() const
6190 return getConversionTable().toString(_Value);
6192 static const std::string &toString(TValues value)
6194 return getConversionTable().toString(value);
6197 TValues getValue() const
6199 return _Value;
6202 // return true if the actual value of the enum is valid, otherwise false
6203 bool isValid()
6205 if (_Value == invalid_val)
6206 return false;
6208 // not invalid, check other enum value
6209 return getConversionTable().isValid(_Value);
6213 uint32 asIndex()
6215 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
6216 nlassert(it != getIndexTable().end());
6217 return it->second;
6221 /////////////////////////////////////////////////////////////////
6222 // WARNING : this is a generated file, don't change it !
6223 /////////////////////////////////////////////////////////////////
6224 class CShard
6226 protected:
6228 uint32 _ShardId;
6230 bool _WSOnline;
6232 TAccessLevel _RequiredState;
6234 std::string _MOTD;
6236 friend class CGuild;
6238 std::map < uint32, CGuildPtr > *_Guilds;
6239 public:
6241 bool getWSOnline() const
6243 return _WSOnline;
6246 void setWSOnline(bool value)
6249 if (_WSOnline != value)
6251 if (getPersistentState() != NOPE::os_transient)
6252 setPersistentState(NOPE::os_dirty);
6254 _WSOnline = value;
6260 const TAccessLevel &getRequiredState() const
6262 return _RequiredState;
6267 void setRequiredState(const TAccessLevel &value)
6270 if (_RequiredState != value)
6272 if (getPersistentState() != NOPE::os_transient)
6273 setPersistentState(NOPE::os_dirty);
6276 _RequiredState = value;
6283 const std::string &getMOTD() const
6285 return _MOTD;
6290 void setMOTD(const std::string &value)
6293 if (_MOTD != value)
6295 if (getPersistentState() != NOPE::os_transient)
6296 setPersistentState(NOPE::os_dirty);
6299 _MOTD = value;
6306 /** Return a const reference to the map of child.
6307 * If you want to modify the element inside, you need to
6308 * use on of the two following method who return non const pointer
6309 * on contained elements.
6311 const std::map<uint32, CGuildPtr> &getGuilds() const;
6312 /** Return the identified element by looking in the map
6313 * If no element match the id, NULL pointer is returned
6315 CGuildPtr &getGuildsById(uint32 id) const;
6318 bool operator == (const CShard &other) const
6320 return _ShardId == other._ShardId
6321 && _WSOnline == other._WSOnline
6322 && _RequiredState == other._RequiredState
6323 && _MOTD == other._MOTD;
6327 private:
6328 // private constructor, you must use 'createTransient' to get an instance
6329 CShard()
6330 : _PtrList(NULL),
6331 _ObjectState(NOPE::os_transient),
6332 _ShardId(NOPE::INVALID_OBJECT_ID)
6334 // Default initialisation
6335 _WSOnline = false;
6336 _Guilds = NULL;
6338 // register the cache for this class (if not already done)
6339 registerUpdatable();
6342 // Destructor, delete any children
6343 ~CShard();
6345 /// utility func to remove this object from the released object container
6346 void removeFromReleased();
6349 public:
6350 /// Create a new instance in the transient space
6351 static CShardPtr createTransient(const char *filename, uint32 lineNum)
6353 return CShardPtr(new CShard(), filename, lineNum);
6356 /** Create a new object in the database from the current object data.
6357 * The object MUST be in transient state (i.e, it must be a new
6358 * object created by user and not comming from the databse).
6359 * If identifier is autogenerated, the generated id can be read after
6360 * this call.
6362 bool create(MSW::CConnection &connection);
6363 /** Update the database with the current object state.
6364 * The object MUST be either in clean or dirty state.
6365 * Return true if the object has been effectively stored
6366 * in the database.
6367 * After this call, the object is in 'clean' state.
6369 bool update(MSW::CConnection &connection);
6370 /** Remove the current object from the persistent storage.
6371 * The object must be in clean or dirty state.
6372 * Return true if the object has been correctly
6373 * updated in the database.
6374 * After the call, the object is in 'clean' state.
6376 bool remove(MSW::CConnection &connection);
6377 /** Remove an object from the persistent storage by specifying
6378 * the id to remove.
6379 * Return true if an entry as been effectively removed from
6380 * the database.
6381 * After the call, the object is in 'removed' state and should
6382 * no more be used. A good pratice should be to delete
6383 * the transient object just after the remove call.
6385 static bool removeById(MSW::CConnection &connection, uint32 id);
6387 /** Load an instance from the database.
6388 * This call allocate a new object and load the property value
6389 * from the database.
6390 * Return NULL if the object id is not found.
6392 static CShardPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
6395 /// Load Guilds child(ren) object(s).
6396 bool loadGuilds(MSW::CConnection &connection, const char *filename, uint32 lineNum);
6399 private:
6401 private:
6402 friend class CPersistentCache;
6403 friend class CShardPtr;
6405 typedef std::map<uint32, CShard*> TObjectCache;
6406 typedef std::set<CShard*> TObjectSet;
6407 typedef std::map<time_t, TObjectSet> TReleasedObject;
6409 /// The complete set of object currently in memory (either active or released) excluding transient instance
6410 static TObjectCache _ObjectCache;
6411 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
6412 static TReleasedObject _ReleasedObject;
6414 /// The current object state
6415 NOPE::TObjectState _ObjectState;
6417 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
6418 time_t _ReleaseDate;
6420 /// The linked list of pointer on this object
6421 CShardPtr *_PtrList;
6423 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
6424 static CShard *loadFromCache(uint32 objectId, bool unrelease);
6426 // Receive and execute command from the cache manager.
6427 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
6429 static void dump();
6431 static void updateCache();
6433 public:
6434 static void clearCache();
6435 private:
6436 void registerUpdatable();
6438 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
6439 void setFirstPtr(CShardPtr *ptr);
6441 // return the first pointer of the pointer list (can be null)
6442 CShardPtr *getFirstPtr()
6444 return _PtrList;
6447 public:
6449 /** Return the object identifier (witch is unique)
6450 * You can only call this method on a persistent instance.
6451 * (because transient instance can have invalid id)
6453 uint32 getObjectId() const
6456 return _ShardId;
6459 /** Set the object unique ID.
6460 * You can only set the object id on a transient object
6461 * having a non autogenerated unique id.
6462 * Furthermore, you MUST set the id before calling create()
6463 * if the id is not autogenerated.
6465 void setObjectId(uint32 objectId)
6467 // can only be set when in transient state
6468 nlassert(getPersistentState() == NOPE::os_transient);
6469 // can only be set once
6470 nlassert(_ShardId == NOPE::INVALID_OBJECT_ID);
6471 _ShardId = objectId;
6474 /** Return the current persistent state of the object.*/
6475 NOPE::TObjectState getPersistentState() const
6477 return _ObjectState;
6480 private:
6481 // Set the persistent state of the object and do some house keeping
6482 void setPersistentState(NOPE::TObjectState state);
6489 /////////////////////////////////////////////////////////////////
6490 // WARNING : this is a generated file, don't change it !
6491 /////////////////////////////////////////////////////////////////
6492 class CGuild
6494 protected:
6496 uint32 _GuildId;
6498 std::string _GuildName;
6500 uint32 _ShardId;
6502 friend class CCharacter;
6504 std::vector < CCharacterPtr > *_Characters;
6506 friend class CGuildInvite;
6508 std::vector < CGuildInvitePtr > *_Invites;
6509 public:
6511 const std::string &getGuildName() const
6513 return _GuildName;
6518 void setGuildName(const std::string &value)
6521 if (_GuildName != value)
6523 if (getPersistentState() != NOPE::os_transient)
6524 setPersistentState(NOPE::os_dirty);
6527 _GuildName = value;
6534 uint32 getShardId() const
6536 return _ShardId;
6539 void setShardId(uint32 value)
6542 if (_ShardId != value)
6544 if (getPersistentState() != NOPE::os_transient)
6545 setPersistentState(NOPE::os_dirty);
6547 _ShardId = value;
6553 /** Return a const reference to the vector of child.
6554 * If you want to modify the element inside, you need to
6555 * use on of the two following methods who return non const pointer
6556 * on contained elements.
6558 const std::vector<CCharacterPtr> &getCharacters() const;
6559 /** Return the ith element of the child vector
6560 * index must be valid (ie less than size of the vector)
6562 CCharacterPtr &getCharactersByIndex(uint32 index) const;
6563 /** Return the identified element by looking in the vector
6564 * If no element match the id, NULL pointer is returned
6566 CCharacterPtr &getCharactersById(uint32 id) const;
6569 /** Return a const reference to the vector of child.
6570 * If you want to modify the element inside, you need to
6571 * use on of the two following methods who return non const pointer
6572 * on contained elements.
6574 const std::vector<CGuildInvitePtr> &getInvites() const;
6575 /** Return the ith element of the child vector
6576 * index must be valid (ie less than size of the vector)
6578 CGuildInvitePtr &getInvitesByIndex(uint32 index) const;
6579 /** Return the identified element by looking in the vector
6580 * If no element match the id, NULL pointer is returned
6582 CGuildInvitePtr &getInvitesById(uint32 id) const;
6585 bool operator == (const CGuild &other) const
6587 return _GuildId == other._GuildId
6588 && _GuildName == other._GuildName
6589 && _ShardId == other._ShardId;
6593 private:
6594 // private constructor, you must use 'createTransient' to get an instance
6595 CGuild()
6596 : _PtrList(NULL),
6597 _ObjectState(NOPE::os_transient),
6598 _GuildId(NOPE::INVALID_OBJECT_ID)
6600 _Characters = NULL;
6601 _Invites = NULL;
6603 // register the cache for this class (if not already done)
6604 registerUpdatable();
6607 // Destructor, delete any children
6608 ~CGuild();
6610 /// utility func to remove this object from the released object container
6611 void removeFromReleased();
6614 public:
6615 /// Create a new instance in the transient space
6616 static CGuildPtr createTransient(const char *filename, uint32 lineNum)
6618 return CGuildPtr(new CGuild(), filename, lineNum);
6621 /** Create a new object in the database from the current object data.
6622 * The object MUST be in transient state (i.e, it must be a new
6623 * object created by user and not comming from the databse).
6624 * If identifier is autogenerated, the generated id can be read after
6625 * this call.
6627 bool create(MSW::CConnection &connection);
6628 /** Update the database with the current object state.
6629 * The object MUST be either in clean or dirty state.
6630 * Return true if the object has been effectively stored
6631 * in the database.
6632 * After this call, the object is in 'clean' state.
6634 bool update(MSW::CConnection &connection);
6635 /** Remove the current object from the persistent storage.
6636 * The object must be in clean or dirty state.
6637 * Return true if the object has been correctly
6638 * updated in the database.
6639 * After the call, the object is in 'clean' state.
6641 bool remove(MSW::CConnection &connection);
6642 /** Remove an object from the persistent storage by specifying
6643 * the id to remove.
6644 * Return true if an entry as been effectively removed from
6645 * the database.
6646 * After the call, the object is in 'removed' state and should
6647 * no more be used. A good pratice should be to delete
6648 * the transient object just after the remove call.
6650 static bool removeById(MSW::CConnection &connection, uint32 id);
6652 /** Load an instance from the database.
6653 * This call allocate a new object and load the property value
6654 * from the database.
6655 * Return NULL if the object id is not found.
6657 static CGuildPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
6660 /** Load all objects children of CShard and
6661 * return them by using the specified output iterator.
6664 static bool loadChildrenOfCShard(MSW::CConnection &connection, uint32 parentId, std::map < uint32, CGuildPtr > &children, const char *filename, uint32 lineNum);
6666 /// Load Characters child(ren) object(s).
6667 bool loadCharacters(MSW::CConnection &connection, const char *filename, uint32 lineNum);
6669 /// Load Invites child(ren) object(s).
6670 bool loadInvites(MSW::CConnection &connection, const char *filename, uint32 lineNum);
6673 private:
6675 private:
6676 friend class CPersistentCache;
6677 friend class CGuildPtr;
6679 typedef std::map<uint32, CGuild*> TObjectCache;
6680 typedef std::set<CGuild*> TObjectSet;
6681 typedef std::map<time_t, TObjectSet> TReleasedObject;
6683 /// The complete set of object currently in memory (either active or released) excluding transient instance
6684 static TObjectCache _ObjectCache;
6685 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
6686 static TReleasedObject _ReleasedObject;
6688 /// The current object state
6689 NOPE::TObjectState _ObjectState;
6691 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
6692 time_t _ReleaseDate;
6694 /// The linked list of pointer on this object
6695 CGuildPtr *_PtrList;
6697 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
6698 static CGuild *loadFromCache(uint32 objectId, bool unrelease);
6700 // Receive and execute command from the cache manager.
6701 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
6703 static void dump();
6705 static void updateCache();
6707 public:
6708 static void clearCache();
6709 private:
6710 void registerUpdatable();
6712 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
6713 void setFirstPtr(CGuildPtr *ptr);
6715 // return the first pointer of the pointer list (can be null)
6716 CGuildPtr *getFirstPtr()
6718 return _PtrList;
6721 public:
6723 /** Return the object identifier (witch is unique)
6724 * You can only call this method on a persistent instance.
6725 * (because transient instance can have invalid id)
6727 uint32 getObjectId() const
6730 return _GuildId;
6733 /** Set the object unique ID.
6734 * You can only set the object id on a transient object
6735 * having a non autogenerated unique id.
6736 * Furthermore, you MUST set the id before calling create()
6737 * if the id is not autogenerated.
6739 void setObjectId(uint32 objectId)
6741 // can only be set when in transient state
6742 nlassert(getPersistentState() == NOPE::os_transient);
6743 // can only be set once
6744 nlassert(_GuildId == NOPE::INVALID_OBJECT_ID);
6745 _GuildId = objectId;
6748 /** Return the current persistent state of the object.*/
6749 NOPE::TObjectState getPersistentState() const
6751 return _ObjectState;
6754 private:
6755 // Set the persistent state of the object and do some house keeping
6756 void setPersistentState(NOPE::TObjectState state);
6763 /////////////////////////////////////////////////////////////////
6764 // WARNING : this is a generated file, don't change it !
6765 /////////////////////////////////////////////////////////////////
6766 class CGuildInvite
6768 protected:
6770 uint32 _Id;
6772 uint32 _GuildId;
6774 TSessionId _SessionId;
6775 public:
6777 uint32 getGuildId() const
6779 return _GuildId;
6782 void setGuildId(uint32 value)
6785 if (_GuildId != value)
6787 if (getPersistentState() != NOPE::os_transient)
6788 setPersistentState(NOPE::os_dirty);
6790 _GuildId = value;
6796 TSessionId getSessionId() const
6798 return _SessionId;
6801 void setSessionId(TSessionId value)
6804 if (_SessionId != value)
6806 if (getPersistentState() != NOPE::os_transient)
6807 setPersistentState(NOPE::os_dirty);
6809 _SessionId = value;
6815 bool operator == (const CGuildInvite &other) const
6817 return _Id == other._Id
6818 && _GuildId == other._GuildId
6819 && _SessionId == other._SessionId;
6823 private:
6824 // private constructor, you must use 'createTransient' to get an instance
6825 CGuildInvite()
6826 : _PtrList(NULL),
6827 _ObjectState(NOPE::os_transient),
6828 _Id(NOPE::INVALID_OBJECT_ID)
6831 // register the cache for this class (if not already done)
6832 registerUpdatable();
6835 // Destructor, delete any children
6836 ~CGuildInvite();
6838 /// utility func to remove this object from the released object container
6839 void removeFromReleased();
6842 public:
6843 /// Create a new instance in the transient space
6844 static CGuildInvitePtr createTransient(const char *filename, uint32 lineNum)
6846 return CGuildInvitePtr(new CGuildInvite(), filename, lineNum);
6849 /** Create a new object in the database from the current object data.
6850 * The object MUST be in transient state (i.e, it must be a new
6851 * object created by user and not comming from the databse).
6852 * If identifier is autogenerated, the generated id can be read after
6853 * this call.
6855 bool create(MSW::CConnection &connection);
6856 /** Update the database with the current object state.
6857 * The object MUST be either in clean or dirty state.
6858 * Return true if the object has been effectively stored
6859 * in the database.
6860 * After this call, the object is in 'clean' state.
6862 bool update(MSW::CConnection &connection);
6863 /** Remove the current object from the persistent storage.
6864 * The object must be in clean or dirty state.
6865 * Return true if the object has been correctly
6866 * updated in the database.
6867 * After the call, the object is in 'clean' state.
6869 bool remove(MSW::CConnection &connection);
6870 /** Remove an object from the persistent storage by specifying
6871 * the id to remove.
6872 * Return true if an entry as been effectively removed from
6873 * the database.
6874 * After the call, the object is in 'removed' state and should
6875 * no more be used. A good pratice should be to delete
6876 * the transient object just after the remove call.
6878 static bool removeById(MSW::CConnection &connection, uint32 id);
6880 /** Load an instance from the database.
6881 * This call allocate a new object and load the property value
6882 * from the database.
6883 * Return NULL if the object id is not found.
6885 static CGuildInvitePtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
6888 /** Load all objects children of CGuild and
6889 * return them by using the specified output iterator.
6892 static bool loadChildrenOfCGuild(MSW::CConnection &connection, uint32 parentId, std::vector < CGuildInvitePtr > &children, const char *filename, uint32 lineNum);
6894 /** Load all objects children of CSession and
6895 * return them by using the specified output iterator.
6898 static bool loadChildrenOfCSession(MSW::CConnection &connection, uint32 parentId, std::vector < CGuildInvitePtr > &children, const char *filename, uint32 lineNum);
6901 private:
6903 private:
6904 friend class CPersistentCache;
6905 friend class CGuildInvitePtr;
6907 typedef std::map<uint32, CGuildInvite*> TObjectCache;
6908 typedef std::set<CGuildInvite*> TObjectSet;
6909 typedef std::map<time_t, TObjectSet> TReleasedObject;
6911 /// The complete set of object currently in memory (either active or released) excluding transient instance
6912 static TObjectCache _ObjectCache;
6913 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
6914 static TReleasedObject _ReleasedObject;
6916 /// The current object state
6917 NOPE::TObjectState _ObjectState;
6919 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
6920 time_t _ReleaseDate;
6922 /// The linked list of pointer on this object
6923 CGuildInvitePtr *_PtrList;
6925 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
6926 static CGuildInvite *loadFromCache(uint32 objectId, bool unrelease);
6928 // Receive and execute command from the cache manager.
6929 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
6931 static void dump();
6933 static void updateCache();
6935 public:
6936 static void clearCache();
6937 private:
6938 void registerUpdatable();
6940 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
6941 void setFirstPtr(CGuildInvitePtr *ptr);
6943 // return the first pointer of the pointer list (can be null)
6944 CGuildInvitePtr *getFirstPtr()
6946 return _PtrList;
6949 public:
6951 /** Return the object identifier (witch is unique)
6952 * You can only call this method on a persistent instance.
6953 * (because transient instance can have invalid id)
6955 uint32 getObjectId() const
6958 nlassert(getPersistentState() != NOPE::os_transient);
6959 return _Id;
6962 /** Set the object unique ID.
6963 * You can only set the object id on a transient object
6964 * having a non autogenerated unique id.
6965 * Furthermore, you MUST set the id before calling create()
6966 * if the id is not autogenerated.
6968 void setObjectId(uint32 objectId)
6970 // can only be set when in transient state
6971 nlassert(getPersistentState() == NOPE::os_transient);
6972 // can only be set once
6973 nlassert(_Id == NOPE::INVALID_OBJECT_ID);
6974 _Id = objectId;
6977 /** Return the current persistent state of the object.*/
6978 NOPE::TObjectState getPersistentState() const
6980 return _ObjectState;
6983 private:
6984 // Set the persistent state of the object and do some house keeping
6985 void setPersistentState(NOPE::TObjectState state);
6992 /////////////////////////////////////////////////////////////////
6993 // WARNING : this is a generated file, don't change it !
6994 /////////////////////////////////////////////////////////////////
6995 class CPlayerRating
6997 protected:
6999 uint32 _Id;
7001 uint32 _ScenarioId;
7003 uint32 _Author;
7005 uint32 _RateFun;
7007 uint32 _RateDifficulty;
7009 uint32 _RateAccessibility;
7011 uint32 _RateOriginality;
7013 uint32 _RateDirection;
7014 public:
7016 uint32 getScenarioId() const
7018 return _ScenarioId;
7021 void setScenarioId(uint32 value)
7024 if (_ScenarioId != value)
7026 if (getPersistentState() != NOPE::os_transient)
7027 setPersistentState(NOPE::os_dirty);
7029 _ScenarioId = value;
7035 uint32 getAuthor() const
7037 return _Author;
7040 void setAuthor(uint32 value)
7043 if (_Author != value)
7045 if (getPersistentState() != NOPE::os_transient)
7046 setPersistentState(NOPE::os_dirty);
7048 _Author = value;
7054 uint32 getRateFun() const
7056 return _RateFun;
7059 void setRateFun(uint32 value)
7062 if (_RateFun != value)
7064 if (getPersistentState() != NOPE::os_transient)
7065 setPersistentState(NOPE::os_dirty);
7067 _RateFun = value;
7073 uint32 getRateDifficulty() const
7075 return _RateDifficulty;
7078 void setRateDifficulty(uint32 value)
7081 if (_RateDifficulty != value)
7083 if (getPersistentState() != NOPE::os_transient)
7084 setPersistentState(NOPE::os_dirty);
7086 _RateDifficulty = value;
7092 uint32 getRateAccessibility() const
7094 return _RateAccessibility;
7097 void setRateAccessibility(uint32 value)
7100 if (_RateAccessibility != value)
7102 if (getPersistentState() != NOPE::os_transient)
7103 setPersistentState(NOPE::os_dirty);
7105 _RateAccessibility = value;
7111 uint32 getRateOriginality() const
7113 return _RateOriginality;
7116 void setRateOriginality(uint32 value)
7119 if (_RateOriginality != value)
7121 if (getPersistentState() != NOPE::os_transient)
7122 setPersistentState(NOPE::os_dirty);
7124 _RateOriginality = value;
7130 uint32 getRateDirection() const
7132 return _RateDirection;
7135 void setRateDirection(uint32 value)
7138 if (_RateDirection != value)
7140 if (getPersistentState() != NOPE::os_transient)
7141 setPersistentState(NOPE::os_dirty);
7143 _RateDirection = value;
7149 bool operator == (const CPlayerRating &other) const
7151 return _Id == other._Id
7152 && _ScenarioId == other._ScenarioId
7153 && _Author == other._Author
7154 && _RateFun == other._RateFun
7155 && _RateDifficulty == other._RateDifficulty
7156 && _RateAccessibility == other._RateAccessibility
7157 && _RateOriginality == other._RateOriginality
7158 && _RateDirection == other._RateDirection;
7162 private:
7163 // private constructor, you must use 'createTransient' to get an instance
7164 CPlayerRating()
7165 : _PtrList(NULL),
7166 _ObjectState(NOPE::os_transient),
7167 _Id(NOPE::INVALID_OBJECT_ID)
7170 // register the cache for this class (if not already done)
7171 registerUpdatable();
7174 // Destructor, delete any children
7175 ~CPlayerRating();
7177 /// utility func to remove this object from the released object container
7178 void removeFromReleased();
7181 public:
7182 /// Create a new instance in the transient space
7183 static CPlayerRatingPtr createTransient(const char *filename, uint32 lineNum)
7185 return CPlayerRatingPtr(new CPlayerRating(), filename, lineNum);
7188 /** Create a new object in the database from the current object data.
7189 * The object MUST be in transient state (i.e, it must be a new
7190 * object created by user and not comming from the databse).
7191 * If identifier is autogenerated, the generated id can be read after
7192 * this call.
7194 bool create(MSW::CConnection &connection);
7195 /** Update the database with the current object state.
7196 * The object MUST be either in clean or dirty state.
7197 * Return true if the object has been effectively stored
7198 * in the database.
7199 * After this call, the object is in 'clean' state.
7201 bool update(MSW::CConnection &connection);
7202 /** Remove the current object from the persistent storage.
7203 * The object must be in clean or dirty state.
7204 * Return true if the object has been correctly
7205 * updated in the database.
7206 * After the call, the object is in 'clean' state.
7208 bool remove(MSW::CConnection &connection);
7209 /** Remove an object from the persistent storage by specifying
7210 * the id to remove.
7211 * Return true if an entry as been effectively removed from
7212 * the database.
7213 * After the call, the object is in 'removed' state and should
7214 * no more be used. A good pratice should be to delete
7215 * the transient object just after the remove call.
7217 static bool removeById(MSW::CConnection &connection, uint32 id);
7219 /** Load an instance from the database.
7220 * This call allocate a new object and load the property value
7221 * from the database.
7222 * Return NULL if the object id is not found.
7224 static CPlayerRatingPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
7227 /** Load all objects children of CScenario and
7228 * return them by using the specified output iterator.
7231 static bool loadChildrenOfCScenario(MSW::CConnection &connection, uint32 parentId, std::vector < CPlayerRatingPtr > &children, const char *filename, uint32 lineNum);
7233 /** Load all objects children of CCharacter and
7234 * return them by using the specified output iterator.
7237 static bool loadChildrenOfCCharacter(MSW::CConnection &connection, uint32 parentId, std::vector < CPlayerRatingPtr > &children, const char *filename, uint32 lineNum);
7240 private:
7242 private:
7243 friend class CPersistentCache;
7244 friend class CPlayerRatingPtr;
7246 typedef std::map<uint32, CPlayerRating*> TObjectCache;
7247 typedef std::set<CPlayerRating*> TObjectSet;
7248 typedef std::map<time_t, TObjectSet> TReleasedObject;
7250 /// The complete set of object currently in memory (either active or released) excluding transient instance
7251 static TObjectCache _ObjectCache;
7252 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
7253 static TReleasedObject _ReleasedObject;
7255 /// The current object state
7256 NOPE::TObjectState _ObjectState;
7258 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
7259 time_t _ReleaseDate;
7261 /// The linked list of pointer on this object
7262 CPlayerRatingPtr *_PtrList;
7264 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
7265 static CPlayerRating *loadFromCache(uint32 objectId, bool unrelease);
7267 // Receive and execute command from the cache manager.
7268 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
7270 static void dump();
7272 static void updateCache();
7274 public:
7275 static void clearCache();
7276 private:
7277 void registerUpdatable();
7279 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
7280 void setFirstPtr(CPlayerRatingPtr *ptr);
7282 // return the first pointer of the pointer list (can be null)
7283 CPlayerRatingPtr *getFirstPtr()
7285 return _PtrList;
7288 public:
7290 /** Return the object identifier (witch is unique)
7291 * You can only call this method on a persistent instance.
7292 * (because transient instance can have invalid id)
7294 uint32 getObjectId() const
7297 nlassert(getPersistentState() != NOPE::os_transient);
7298 return _Id;
7301 /** Set the object unique ID.
7302 * You can only set the object id on a transient object
7303 * having a non autogenerated unique id.
7304 * Furthermore, you MUST set the id before calling create()
7305 * if the id is not autogenerated.
7307 void setObjectId(uint32 objectId)
7309 // can only be set when in transient state
7310 nlassert(getPersistentState() == NOPE::os_transient);
7311 // can only be set once
7312 nlassert(_Id == NOPE::INVALID_OBJECT_ID);
7313 _Id = objectId;
7316 /** Return the current persistent state of the object.*/
7317 NOPE::TObjectState getPersistentState() const
7319 return _ObjectState;
7322 private:
7323 // Set the persistent state of the object and do some house keeping
7324 void setPersistentState(NOPE::TObjectState state);
7333 struct TJournalEntryType
7335 enum TValues
7337 jet_credits = 1,
7338 jet_notes,
7339 /// the highest valid value in the enum
7340 last_enum_item = jet_notes,
7341 /// a value equal to the last enum item +1
7342 end_of_enum,
7344 invalid_val,
7346 /// Number of enumerated values
7347 nb_enum_items = 2
7350 /// Index table to convert enum value to linear index table
7351 const std::map<TValues, uint32> &getIndexTable() const
7353 static std::map<TValues, uint32> indexTable;
7354 static bool init = false;
7355 if (!init)
7357 // fill the index table
7358 indexTable.insert(std::make_pair(jet_credits, 0));
7359 indexTable.insert(std::make_pair(jet_notes, 1));
7361 init = true;
7364 return indexTable;
7368 static const NLMISC::CStringConversion<TValues> &getConversionTable()
7370 NL_BEGIN_STRING_CONVERSION_TABLE(TValues)
7371 NL_STRING_CONVERSION_TABLE_ENTRY(jet_credits)
7372 NL_STRING_CONVERSION_TABLE_ENTRY(jet_notes)
7373 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val)
7375 static NLMISC::CStringConversion<TValues>
7376 conversionTable(TValues_nl_string_conversion_table, sizeof(TValues_nl_string_conversion_table)
7377 / sizeof(TValues_nl_string_conversion_table[0]), invalid_val);
7379 return conversionTable;
7382 TValues _Value;
7384 public:
7385 TJournalEntryType()
7386 : _Value(invalid_val)
7389 TJournalEntryType(TValues value)
7390 : _Value(value)
7394 TJournalEntryType(const std::string &str)
7396 _Value = getConversionTable().fromString(str);
7399 void serial(NLMISC::IStream &s)
7401 s.serialEnum(_Value);
7404 bool operator == (const TJournalEntryType &other) const
7406 return _Value == other._Value;
7408 bool operator != (const TJournalEntryType &other) const
7410 return ! (_Value == other._Value);
7412 bool operator < (const TJournalEntryType &other) const
7414 return _Value < other._Value;
7417 bool operator <= (const TJournalEntryType &other) const
7419 return _Value <= other._Value;
7422 bool operator > (const TJournalEntryType &other) const
7424 return !(_Value <= other._Value);
7426 bool operator >= (const TJournalEntryType &other) const
7428 return !(_Value < other._Value);
7431 const std::string &toString() const
7433 return getConversionTable().toString(_Value);
7435 static const std::string &toString(TValues value)
7437 return getConversionTable().toString(value);
7440 TValues getValue() const
7442 return _Value;
7445 // return true if the actual value of the enum is valid, otherwise false
7446 bool isValid()
7448 if (_Value == invalid_val)
7449 return false;
7451 // not invalid, check other enum value
7452 return getConversionTable().isValid(_Value);
7456 uint32 asIndex()
7458 std::map<TValues, uint32>::const_iterator it(getIndexTable().find(_Value));
7459 nlassert(it != getIndexTable().end());
7460 return it->second;
7464 /////////////////////////////////////////////////////////////////
7465 // WARNING : this is a generated file, don't change it !
7466 /////////////////////////////////////////////////////////////////
7467 class CJournalEntry
7469 protected:
7471 uint32 _Id;
7473 TSessionId _SessionId;
7475 uint32 _Author;
7477 TJournalEntryType _Type;
7479 std::string _Text;
7481 uint32 _TimeStamp;
7482 public:
7484 TSessionId getSessionId() const
7486 return _SessionId;
7489 void setSessionId(TSessionId value)
7492 if (_SessionId != value)
7494 if (getPersistentState() != NOPE::os_transient)
7495 setPersistentState(NOPE::os_dirty);
7497 _SessionId = value;
7503 uint32 getAuthor() const
7505 return _Author;
7508 void setAuthor(uint32 value)
7511 if (_Author != value)
7513 if (getPersistentState() != NOPE::os_transient)
7514 setPersistentState(NOPE::os_dirty);
7516 _Author = value;
7522 TJournalEntryType getType() const
7524 return _Type;
7527 void setType(TJournalEntryType value)
7530 if (_Type != value)
7532 if (getPersistentState() != NOPE::os_transient)
7533 setPersistentState(NOPE::os_dirty);
7535 _Type = value;
7541 const std::string &getText() const
7543 return _Text;
7548 void setText(const std::string &value)
7551 if (_Text != value)
7553 if (getPersistentState() != NOPE::os_transient)
7554 setPersistentState(NOPE::os_dirty);
7557 _Text = value;
7564 uint32 getTimeStamp() const
7566 return _TimeStamp;
7569 void setTimeStamp(uint32 value)
7572 if (_TimeStamp != value)
7574 if (getPersistentState() != NOPE::os_transient)
7575 setPersistentState(NOPE::os_dirty);
7577 _TimeStamp = value;
7583 bool operator == (const CJournalEntry &other) const
7585 return _Id == other._Id
7586 && _SessionId == other._SessionId
7587 && _Author == other._Author
7588 && _Type == other._Type
7589 && _Text == other._Text
7590 && _TimeStamp == other._TimeStamp;
7594 private:
7595 // private constructor, you must use 'createTransient' to get an instance
7596 CJournalEntry()
7597 : _PtrList(NULL),
7598 _ObjectState(NOPE::os_transient),
7599 _Id(NOPE::INVALID_OBJECT_ID)
7602 // register the cache for this class (if not already done)
7603 registerUpdatable();
7606 // Destructor, delete any children
7607 ~CJournalEntry();
7609 /// utility func to remove this object from the released object container
7610 void removeFromReleased();
7613 public:
7614 /// Create a new instance in the transient space
7615 static CJournalEntryPtr createTransient(const char *filename, uint32 lineNum)
7617 return CJournalEntryPtr(new CJournalEntry(), filename, lineNum);
7620 /** Create a new object in the database from the current object data.
7621 * The object MUST be in transient state (i.e, it must be a new
7622 * object created by user and not comming from the databse).
7623 * If identifier is autogenerated, the generated id can be read after
7624 * this call.
7626 bool create(MSW::CConnection &connection);
7627 /** Update the database with the current object state.
7628 * The object MUST be either in clean or dirty state.
7629 * Return true if the object has been effectively stored
7630 * in the database.
7631 * After this call, the object is in 'clean' state.
7633 bool update(MSW::CConnection &connection);
7634 /** Remove the current object from the persistent storage.
7635 * The object must be in clean or dirty state.
7636 * Return true if the object has been correctly
7637 * updated in the database.
7638 * After the call, the object is in 'clean' state.
7640 bool remove(MSW::CConnection &connection);
7641 /** Remove an object from the persistent storage by specifying
7642 * the id to remove.
7643 * Return true if an entry as been effectively removed from
7644 * the database.
7645 * After the call, the object is in 'removed' state and should
7646 * no more be used. A good pratice should be to delete
7647 * the transient object just after the remove call.
7649 static bool removeById(MSW::CConnection &connection, uint32 id);
7651 /** Load an instance from the database.
7652 * This call allocate a new object and load the property value
7653 * from the database.
7654 * Return NULL if the object id is not found.
7656 static CJournalEntryPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
7659 /** Load all objects children of CSession and
7660 * return them by using the specified output iterator.
7663 static bool loadChildrenOfCSession(MSW::CConnection &connection, uint32 parentId, std::vector < CJournalEntryPtr > &children, const char *filename, uint32 lineNum);
7666 private:
7668 private:
7669 friend class CPersistentCache;
7670 friend class CJournalEntryPtr;
7672 typedef std::map<uint32, CJournalEntry*> TObjectCache;
7673 typedef std::set<CJournalEntry*> TObjectSet;
7674 typedef std::map<time_t, TObjectSet> TReleasedObject;
7676 /// The complete set of object currently in memory (either active or released) excluding transient instance
7677 static TObjectCache _ObjectCache;
7678 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
7679 static TReleasedObject _ReleasedObject;
7681 /// The current object state
7682 NOPE::TObjectState _ObjectState;
7684 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
7685 time_t _ReleaseDate;
7687 /// The linked list of pointer on this object
7688 CJournalEntryPtr *_PtrList;
7690 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
7691 static CJournalEntry *loadFromCache(uint32 objectId, bool unrelease);
7693 // Receive and execute command from the cache manager.
7694 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
7696 static void dump();
7698 static void updateCache();
7700 public:
7701 static void clearCache();
7702 private:
7703 void registerUpdatable();
7705 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
7706 void setFirstPtr(CJournalEntryPtr *ptr);
7708 // return the first pointer of the pointer list (can be null)
7709 CJournalEntryPtr *getFirstPtr()
7711 return _PtrList;
7714 public:
7716 /** Return the object identifier (witch is unique)
7717 * You can only call this method on a persistent instance.
7718 * (because transient instance can have invalid id)
7720 uint32 getObjectId() const
7723 nlassert(getPersistentState() != NOPE::os_transient);
7724 return _Id;
7727 /** Set the object unique ID.
7728 * You can only set the object id on a transient object
7729 * having a non autogenerated unique id.
7730 * Furthermore, you MUST set the id before calling create()
7731 * if the id is not autogenerated.
7733 void setObjectId(uint32 objectId)
7735 // can only be set when in transient state
7736 nlassert(getPersistentState() == NOPE::os_transient);
7737 // can only be set once
7738 nlassert(_Id == NOPE::INVALID_OBJECT_ID);
7739 _Id = objectId;
7742 /** Return the current persistent state of the object.*/
7743 NOPE::TObjectState getPersistentState() const
7745 return _ObjectState;
7748 private:
7749 // Set the persistent state of the object and do some house keeping
7750 void setPersistentState(NOPE::TObjectState state);
7757 /////////////////////////////////////////////////////////////////
7758 // WARNING : this is a generated file, don't change it !
7759 /////////////////////////////////////////////////////////////////
7760 class CFolder
7762 protected:
7764 uint32 _Id;
7766 uint32 _Author;
7768 std::string _Title;
7770 std::string _Comments;
7772 friend class CFolderAccess;
7774 std::vector < CFolderAccessPtr > *_FolderAccess;
7776 friend class CSession;
7778 std::vector < CSessionPtr > *_Sessions;
7779 public:
7781 uint32 getAuthor() const
7783 return _Author;
7786 void setAuthor(uint32 value)
7789 if (_Author != value)
7791 if (getPersistentState() != NOPE::os_transient)
7792 setPersistentState(NOPE::os_dirty);
7794 _Author = value;
7800 const std::string &getTitle() const
7802 return _Title;
7807 void setTitle(const std::string &value)
7810 if (_Title != value)
7812 if (getPersistentState() != NOPE::os_transient)
7813 setPersistentState(NOPE::os_dirty);
7816 _Title = value;
7823 const std::string &getComments() const
7825 return _Comments;
7830 void setComments(const std::string &value)
7833 if (_Comments != value)
7835 if (getPersistentState() != NOPE::os_transient)
7836 setPersistentState(NOPE::os_dirty);
7839 _Comments = value;
7846 /** Return a const reference to the vector of child.
7847 * If you want to modify the element inside, you need to
7848 * use on of the two following methods who return non const pointer
7849 * on contained elements.
7851 const std::vector<CFolderAccessPtr> &getFolderAccess() const;
7852 /** Return the ith element of the child vector
7853 * index must be valid (ie less than size of the vector)
7855 CFolderAccessPtr &getFolderAccessByIndex(uint32 index) const;
7856 /** Return the identified element by looking in the vector
7857 * If no element match the id, NULL pointer is returned
7859 CFolderAccessPtr &getFolderAccessById(uint32 id) const;
7862 /** Return a const reference to the vector of child.
7863 * If you want to modify the element inside, you need to
7864 * use on of the two following methods who return non const pointer
7865 * on contained elements.
7867 const std::vector<CSessionPtr> &getSessions() const;
7868 /** Return the ith element of the child vector
7869 * index must be valid (ie less than size of the vector)
7871 CSessionPtr &getSessionsByIndex(uint32 index) const;
7872 /** Return the identified element by looking in the vector
7873 * If no element match the id, NULL pointer is returned
7875 CSessionPtr &getSessionsById(uint32 id) const;
7878 bool operator == (const CFolder &other) const
7880 return _Id == other._Id
7881 && _Author == other._Author
7882 && _Title == other._Title
7883 && _Comments == other._Comments;
7887 private:
7888 // private constructor, you must use 'createTransient' to get an instance
7889 CFolder()
7890 : _PtrList(NULL),
7891 _ObjectState(NOPE::os_transient),
7892 _Id(NOPE::INVALID_OBJECT_ID)
7894 _FolderAccess = NULL;
7895 _Sessions = NULL;
7897 // register the cache for this class (if not already done)
7898 registerUpdatable();
7901 // Destructor, delete any children
7902 ~CFolder();
7904 /// utility func to remove this object from the released object container
7905 void removeFromReleased();
7908 public:
7909 /// Create a new instance in the transient space
7910 static CFolderPtr createTransient(const char *filename, uint32 lineNum)
7912 return CFolderPtr(new CFolder(), filename, lineNum);
7915 /** Create a new object in the database from the current object data.
7916 * The object MUST be in transient state (i.e, it must be a new
7917 * object created by user and not comming from the databse).
7918 * If identifier is autogenerated, the generated id can be read after
7919 * this call.
7921 bool create(MSW::CConnection &connection);
7922 /** Update the database with the current object state.
7923 * The object MUST be either in clean or dirty state.
7924 * Return true if the object has been effectively stored
7925 * in the database.
7926 * After this call, the object is in 'clean' state.
7928 bool update(MSW::CConnection &connection);
7929 /** Remove the current object from the persistent storage.
7930 * The object must be in clean or dirty state.
7931 * Return true if the object has been correctly
7932 * updated in the database.
7933 * After the call, the object is in 'clean' state.
7935 bool remove(MSW::CConnection &connection);
7936 /** Remove an object from the persistent storage by specifying
7937 * the id to remove.
7938 * Return true if an entry as been effectively removed from
7939 * the database.
7940 * After the call, the object is in 'removed' state and should
7941 * no more be used. A good pratice should be to delete
7942 * the transient object just after the remove call.
7944 static bool removeById(MSW::CConnection &connection, uint32 id);
7946 /** Load an instance from the database.
7947 * This call allocate a new object and load the property value
7948 * from the database.
7949 * Return NULL if the object id is not found.
7951 static CFolderPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
7954 /** Load all objects children of CRingUser and
7955 * return them by using the specified output iterator.
7958 static bool loadChildrenOfCRingUser(MSW::CConnection &connection, uint32 parentId, std::vector < CFolderPtr > &children, const char *filename, uint32 lineNum);
7960 /// Load FolderAccess child(ren) object(s).
7961 bool loadFolderAccess(MSW::CConnection &connection, const char *filename, uint32 lineNum);
7963 /// Load Sessions child(ren) object(s).
7964 bool loadSessions(MSW::CConnection &connection, const char *filename, uint32 lineNum);
7967 private:
7969 private:
7970 friend class CPersistentCache;
7971 friend class CFolderPtr;
7973 typedef std::map<uint32, CFolder*> TObjectCache;
7974 typedef std::set<CFolder*> TObjectSet;
7975 typedef std::map<time_t, TObjectSet> TReleasedObject;
7977 /// The complete set of object currently in memory (either active or released) excluding transient instance
7978 static TObjectCache _ObjectCache;
7979 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
7980 static TReleasedObject _ReleasedObject;
7982 /// The current object state
7983 NOPE::TObjectState _ObjectState;
7985 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
7986 time_t _ReleaseDate;
7988 /// The linked list of pointer on this object
7989 CFolderPtr *_PtrList;
7991 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
7992 static CFolder *loadFromCache(uint32 objectId, bool unrelease);
7994 // Receive and execute command from the cache manager.
7995 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
7997 static void dump();
7999 static void updateCache();
8001 public:
8002 static void clearCache();
8003 private:
8004 void registerUpdatable();
8006 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
8007 void setFirstPtr(CFolderPtr *ptr);
8009 // return the first pointer of the pointer list (can be null)
8010 CFolderPtr *getFirstPtr()
8012 return _PtrList;
8015 public:
8017 /** Return the object identifier (witch is unique)
8018 * You can only call this method on a persistent instance.
8019 * (because transient instance can have invalid id)
8021 uint32 getObjectId() const
8024 nlassert(getPersistentState() != NOPE::os_transient);
8025 return _Id;
8028 /** Set the object unique ID.
8029 * You can only set the object id on a transient object
8030 * having a non autogenerated unique id.
8031 * Furthermore, you MUST set the id before calling create()
8032 * if the id is not autogenerated.
8034 void setObjectId(uint32 objectId)
8036 // can only be set when in transient state
8037 nlassert(getPersistentState() == NOPE::os_transient);
8038 // can only be set once
8039 nlassert(_Id == NOPE::INVALID_OBJECT_ID);
8040 _Id = objectId;
8043 /** Return the current persistent state of the object.*/
8044 NOPE::TObjectState getPersistentState() const
8046 return _ObjectState;
8049 private:
8050 // Set the persistent state of the object and do some house keeping
8051 void setPersistentState(NOPE::TObjectState state);
8058 /////////////////////////////////////////////////////////////////
8059 // WARNING : this is a generated file, don't change it !
8060 /////////////////////////////////////////////////////////////////
8061 class CFolderAccess
8063 protected:
8065 uint32 _Id;
8067 uint32 _FolderId;
8069 uint32 _UserId;
8070 public:
8072 uint32 getFolderId() const
8074 return _FolderId;
8077 void setFolderId(uint32 value)
8080 if (_FolderId != value)
8082 if (getPersistentState() != NOPE::os_transient)
8083 setPersistentState(NOPE::os_dirty);
8085 _FolderId = value;
8091 uint32 getUserId() const
8093 return _UserId;
8096 void setUserId(uint32 value)
8099 if (_UserId != value)
8101 if (getPersistentState() != NOPE::os_transient)
8102 setPersistentState(NOPE::os_dirty);
8104 _UserId = value;
8110 bool operator == (const CFolderAccess &other) const
8112 return _Id == other._Id
8113 && _FolderId == other._FolderId
8114 && _UserId == other._UserId;
8118 private:
8119 // private constructor, you must use 'createTransient' to get an instance
8120 CFolderAccess()
8121 : _PtrList(NULL),
8122 _ObjectState(NOPE::os_transient),
8123 _Id(NOPE::INVALID_OBJECT_ID)
8126 // register the cache for this class (if not already done)
8127 registerUpdatable();
8130 // Destructor, delete any children
8131 ~CFolderAccess();
8133 /// utility func to remove this object from the released object container
8134 void removeFromReleased();
8137 public:
8138 /// Create a new instance in the transient space
8139 static CFolderAccessPtr createTransient(const char *filename, uint32 lineNum)
8141 return CFolderAccessPtr(new CFolderAccess(), filename, lineNum);
8144 /** Create a new object in the database from the current object data.
8145 * The object MUST be in transient state (i.e, it must be a new
8146 * object created by user and not comming from the databse).
8147 * If identifier is autogenerated, the generated id can be read after
8148 * this call.
8150 bool create(MSW::CConnection &connection);
8151 /** Update the database with the current object state.
8152 * The object MUST be either in clean or dirty state.
8153 * Return true if the object has been effectively stored
8154 * in the database.
8155 * After this call, the object is in 'clean' state.
8157 bool update(MSW::CConnection &connection);
8158 /** Remove the current object from the persistent storage.
8159 * The object must be in clean or dirty state.
8160 * Return true if the object has been correctly
8161 * updated in the database.
8162 * After the call, the object is in 'clean' state.
8164 bool remove(MSW::CConnection &connection);
8165 /** Remove an object from the persistent storage by specifying
8166 * the id to remove.
8167 * Return true if an entry as been effectively removed from
8168 * the database.
8169 * After the call, the object is in 'removed' state and should
8170 * no more be used. A good pratice should be to delete
8171 * the transient object just after the remove call.
8173 static bool removeById(MSW::CConnection &connection, uint32 id);
8175 /** Load an instance from the database.
8176 * This call allocate a new object and load the property value
8177 * from the database.
8178 * Return NULL if the object id is not found.
8180 static CFolderAccessPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
8183 /** Load all objects children of CRingUser and
8184 * return them by using the specified output iterator.
8187 static bool loadChildrenOfCRingUser(MSW::CConnection &connection, uint32 parentId, std::vector < CFolderAccessPtr > &children, const char *filename, uint32 lineNum);
8189 /** Load all objects children of CFolder and
8190 * return them by using the specified output iterator.
8193 static bool loadChildrenOfCFolder(MSW::CConnection &connection, uint32 parentId, std::vector < CFolderAccessPtr > &children, const char *filename, uint32 lineNum);
8196 private:
8198 private:
8199 friend class CPersistentCache;
8200 friend class CFolderAccessPtr;
8202 typedef std::map<uint32, CFolderAccess*> TObjectCache;
8203 typedef std::set<CFolderAccess*> TObjectSet;
8204 typedef std::map<time_t, TObjectSet> TReleasedObject;
8206 /// The complete set of object currently in memory (either active or released) excluding transient instance
8207 static TObjectCache _ObjectCache;
8208 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
8209 static TReleasedObject _ReleasedObject;
8211 /// The current object state
8212 NOPE::TObjectState _ObjectState;
8214 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
8215 time_t _ReleaseDate;
8217 /// The linked list of pointer on this object
8218 CFolderAccessPtr *_PtrList;
8220 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
8221 static CFolderAccess *loadFromCache(uint32 objectId, bool unrelease);
8223 // Receive and execute command from the cache manager.
8224 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
8226 static void dump();
8228 static void updateCache();
8230 public:
8231 static void clearCache();
8232 private:
8233 void registerUpdatable();
8235 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
8236 void setFirstPtr(CFolderAccessPtr *ptr);
8238 // return the first pointer of the pointer list (can be null)
8239 CFolderAccessPtr *getFirstPtr()
8241 return _PtrList;
8244 public:
8246 /** Return the object identifier (witch is unique)
8247 * You can only call this method on a persistent instance.
8248 * (because transient instance can have invalid id)
8250 uint32 getObjectId() const
8253 nlassert(getPersistentState() != NOPE::os_transient);
8254 return _Id;
8257 /** Set the object unique ID.
8258 * You can only set the object id on a transient object
8259 * having a non autogenerated unique id.
8260 * Furthermore, you MUST set the id before calling create()
8261 * if the id is not autogenerated.
8263 void setObjectId(uint32 objectId)
8265 // can only be set when in transient state
8266 nlassert(getPersistentState() == NOPE::os_transient);
8267 // can only be set once
8268 nlassert(_Id == NOPE::INVALID_OBJECT_ID);
8269 _Id = objectId;
8272 /** Return the current persistent state of the object.*/
8273 NOPE::TObjectState getPersistentState() const
8275 return _ObjectState;
8278 private:
8279 // Set the persistent state of the object and do some house keeping
8280 void setPersistentState(NOPE::TObjectState state);
8287 /////////////////////////////////////////////////////////////////
8288 // WARNING : this is a generated file, don't change it !
8289 /////////////////////////////////////////////////////////////////
8290 class CScenario
8292 protected:
8294 uint32 _Id;
8296 NLMISC::CHashKeyMD5 _MD5;
8298 std::string _Title;
8300 std::string _Description;
8302 std::string _Author;
8304 uint32 _RRPTotal;
8306 TAnimMode _AnimMode;
8308 std::string _Language;
8310 TSessionOrientation _Orientation;
8312 R2::TSessionLevel _Level;
8314 bool _AllowFreeTrial;
8316 friend class CSessionLog;
8318 std::vector < CSessionLogPtr > *_SessionLogs;
8320 friend class CPlayerRating;
8322 std::vector < CPlayerRatingPtr > *_PlayerRatings;
8323 public:
8325 const NLMISC::CHashKeyMD5 &getMD5() const
8327 return _MD5;
8332 void setMD5(const NLMISC::CHashKeyMD5 &value)
8335 if (_MD5 != value)
8337 if (getPersistentState() != NOPE::os_transient)
8338 setPersistentState(NOPE::os_dirty);
8341 _MD5 = value;
8348 const std::string &getTitle() const
8350 return _Title;
8355 void setTitle(const std::string &value)
8358 if (_Title != value)
8360 if (getPersistentState() != NOPE::os_transient)
8361 setPersistentState(NOPE::os_dirty);
8364 _Title = value;
8371 const std::string &getDescription() const
8373 return _Description;
8378 void setDescription(const std::string &value)
8381 if (_Description != value)
8383 if (getPersistentState() != NOPE::os_transient)
8384 setPersistentState(NOPE::os_dirty);
8387 _Description = value;
8394 const std::string &getAuthor() const
8396 return _Author;
8401 void setAuthor(const std::string &value)
8404 if (_Author != value)
8406 if (getPersistentState() != NOPE::os_transient)
8407 setPersistentState(NOPE::os_dirty);
8410 _Author = value;
8417 uint32 getRRPTotal() const
8419 return _RRPTotal;
8422 void setRRPTotal(uint32 value)
8425 if (_RRPTotal != value)
8427 if (getPersistentState() != NOPE::os_transient)
8428 setPersistentState(NOPE::os_dirty);
8430 _RRPTotal = value;
8436 TAnimMode getAnimMode() const
8438 return _AnimMode;
8441 void setAnimMode(TAnimMode value)
8444 if (_AnimMode != value)
8446 if (getPersistentState() != NOPE::os_transient)
8447 setPersistentState(NOPE::os_dirty);
8449 _AnimMode = value;
8455 const std::string &getLanguage() const
8457 return _Language;
8462 void setLanguage(const std::string &value)
8465 if (_Language != value)
8467 if (getPersistentState() != NOPE::os_transient)
8468 setPersistentState(NOPE::os_dirty);
8471 _Language = value;
8478 TSessionOrientation getOrientation() const
8480 return _Orientation;
8483 void setOrientation(TSessionOrientation value)
8486 if (_Orientation != value)
8488 if (getPersistentState() != NOPE::os_transient)
8489 setPersistentState(NOPE::os_dirty);
8491 _Orientation = value;
8497 R2::TSessionLevel getLevel() const
8499 return _Level;
8502 void setLevel(R2::TSessionLevel value)
8505 if (_Level != value)
8507 if (getPersistentState() != NOPE::os_transient)
8508 setPersistentState(NOPE::os_dirty);
8510 _Level = value;
8516 bool getAllowFreeTrial() const
8518 return _AllowFreeTrial;
8521 void setAllowFreeTrial(bool value)
8524 if (_AllowFreeTrial != value)
8526 if (getPersistentState() != NOPE::os_transient)
8527 setPersistentState(NOPE::os_dirty);
8529 _AllowFreeTrial = value;
8535 /** Return a const reference to the vector of child.
8536 * If you want to modify the element inside, you need to
8537 * use on of the two following methods who return non const pointer
8538 * on contained elements.
8540 const std::vector<CSessionLogPtr> &getSessionLogs() const;
8541 /** Return the ith element of the child vector
8542 * index must be valid (ie less than size of the vector)
8544 CSessionLogPtr &getSessionLogsByIndex(uint32 index) const;
8545 /** Return the identified element by looking in the vector
8546 * If no element match the id, NULL pointer is returned
8548 CSessionLogPtr &getSessionLogsById(uint32 id) const;
8551 /** Return a const reference to the vector of child.
8552 * If you want to modify the element inside, you need to
8553 * use on of the two following methods who return non const pointer
8554 * on contained elements.
8556 const std::vector<CPlayerRatingPtr> &getPlayerRatings() const;
8557 /** Return the ith element of the child vector
8558 * index must be valid (ie less than size of the vector)
8560 CPlayerRatingPtr &getPlayerRatingsByIndex(uint32 index) const;
8561 /** Return the identified element by looking in the vector
8562 * If no element match the id, NULL pointer is returned
8564 CPlayerRatingPtr &getPlayerRatingsById(uint32 id) const;
8567 bool operator == (const CScenario &other) const
8569 return _Id == other._Id
8570 && _MD5 == other._MD5
8571 && _Title == other._Title
8572 && _Description == other._Description
8573 && _Author == other._Author
8574 && _RRPTotal == other._RRPTotal
8575 && _AnimMode == other._AnimMode
8576 && _Language == other._Language
8577 && _Orientation == other._Orientation
8578 && _Level == other._Level
8579 && _AllowFreeTrial == other._AllowFreeTrial;
8583 private:
8584 // private constructor, you must use 'createTransient' to get an instance
8585 CScenario()
8586 : _PtrList(NULL),
8587 _ObjectState(NOPE::os_transient),
8588 _Id(NOPE::INVALID_OBJECT_ID)
8590 // Default initialisation
8591 _RRPTotal = 0;
8592 _AllowFreeTrial = false;
8593 _SessionLogs = NULL;
8594 _PlayerRatings = NULL;
8596 // register the cache for this class (if not already done)
8597 registerUpdatable();
8600 // Destructor, delete any children
8601 ~CScenario();
8603 /// utility func to remove this object from the released object container
8604 void removeFromReleased();
8607 public:
8608 /// Create a new instance in the transient space
8609 static CScenarioPtr createTransient(const char *filename, uint32 lineNum)
8611 return CScenarioPtr(new CScenario(), filename, lineNum);
8614 /** Create a new object in the database from the current object data.
8615 * The object MUST be in transient state (i.e, it must be a new
8616 * object created by user and not comming from the databse).
8617 * If identifier is autogenerated, the generated id can be read after
8618 * this call.
8620 bool create(MSW::CConnection &connection);
8621 /** Update the database with the current object state.
8622 * The object MUST be either in clean or dirty state.
8623 * Return true if the object has been effectively stored
8624 * in the database.
8625 * After this call, the object is in 'clean' state.
8627 bool update(MSW::CConnection &connection);
8628 /** Remove the current object from the persistent storage.
8629 * The object must be in clean or dirty state.
8630 * Return true if the object has been correctly
8631 * updated in the database.
8632 * After the call, the object is in 'clean' state.
8634 bool remove(MSW::CConnection &connection);
8635 /** Remove an object from the persistent storage by specifying
8636 * the id to remove.
8637 * Return true if an entry as been effectively removed from
8638 * the database.
8639 * After the call, the object is in 'removed' state and should
8640 * no more be used. A good pratice should be to delete
8641 * the transient object just after the remove call.
8643 static bool removeById(MSW::CConnection &connection, uint32 id);
8645 /** Load an instance from the database.
8646 * This call allocate a new object and load the property value
8647 * from the database.
8648 * Return NULL if the object id is not found.
8650 static CScenarioPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
8653 /// Load SessionLogs child(ren) object(s).
8654 bool loadSessionLogs(MSW::CConnection &connection, const char *filename, uint32 lineNum);
8656 /// Load PlayerRatings child(ren) object(s).
8657 bool loadPlayerRatings(MSW::CConnection &connection, const char *filename, uint32 lineNum);
8660 private:
8662 private:
8663 friend class CPersistentCache;
8664 friend class CScenarioPtr;
8666 typedef std::map<uint32, CScenario*> TObjectCache;
8667 typedef std::set<CScenario*> TObjectSet;
8668 typedef std::map<time_t, TObjectSet> TReleasedObject;
8670 /// The complete set of object currently in memory (either active or released) excluding transient instance
8671 static TObjectCache _ObjectCache;
8672 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
8673 static TReleasedObject _ReleasedObject;
8675 /// The current object state
8676 NOPE::TObjectState _ObjectState;
8678 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
8679 time_t _ReleaseDate;
8681 /// The linked list of pointer on this object
8682 CScenarioPtr *_PtrList;
8684 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
8685 static CScenario *loadFromCache(uint32 objectId, bool unrelease);
8687 // Receive and execute command from the cache manager.
8688 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
8690 static void dump();
8692 static void updateCache();
8694 public:
8695 static void clearCache();
8696 private:
8697 void registerUpdatable();
8699 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
8700 void setFirstPtr(CScenarioPtr *ptr);
8702 // return the first pointer of the pointer list (can be null)
8703 CScenarioPtr *getFirstPtr()
8705 return _PtrList;
8708 public:
8710 /** Return the object identifier (witch is unique)
8711 * You can only call this method on a persistent instance.
8712 * (because transient instance can have invalid id)
8714 uint32 getObjectId() const
8717 nlassert(getPersistentState() != NOPE::os_transient);
8718 return _Id;
8721 /** Set the object unique ID.
8722 * You can only set the object id on a transient object
8723 * having a non autogenerated unique id.
8724 * Furthermore, you MUST set the id before calling create()
8725 * if the id is not autogenerated.
8727 void setObjectId(uint32 objectId)
8729 // can only be set when in transient state
8730 nlassert(getPersistentState() == NOPE::os_transient);
8731 // can only be set once
8732 nlassert(_Id == NOPE::INVALID_OBJECT_ID);
8733 _Id = objectId;
8736 /** Return the current persistent state of the object.*/
8737 NOPE::TObjectState getPersistentState() const
8739 return _ObjectState;
8742 private:
8743 // Set the persistent state of the object and do some house keeping
8744 void setPersistentState(NOPE::TObjectState state);
8751 /////////////////////////////////////////////////////////////////
8752 // WARNING : this is a generated file, don't change it !
8753 /////////////////////////////////////////////////////////////////
8754 class CSessionLog
8756 protected:
8758 uint32 _Id;
8760 uint32 _ScenarioId;
8762 uint32 _RRPScored;
8764 uint32 _ScenarioPointScored;
8766 uint32 _TimeTaken;
8768 std::string _Participants;
8770 uint32 _LaunchDate;
8772 std::string _Owner;
8774 std::string _GuildName;
8775 public:
8777 uint32 getScenarioId() const
8779 return _ScenarioId;
8782 void setScenarioId(uint32 value)
8785 if (_ScenarioId != value)
8787 if (getPersistentState() != NOPE::os_transient)
8788 setPersistentState(NOPE::os_dirty);
8790 _ScenarioId = value;
8796 uint32 getRRPScored() const
8798 return _RRPScored;
8801 void setRRPScored(uint32 value)
8804 if (_RRPScored != value)
8806 if (getPersistentState() != NOPE::os_transient)
8807 setPersistentState(NOPE::os_dirty);
8809 _RRPScored = value;
8815 uint32 getScenarioPointScored() const
8817 return _ScenarioPointScored;
8820 void setScenarioPointScored(uint32 value)
8823 if (_ScenarioPointScored != value)
8825 if (getPersistentState() != NOPE::os_transient)
8826 setPersistentState(NOPE::os_dirty);
8828 _ScenarioPointScored = value;
8834 uint32 getTimeTaken() const
8836 return _TimeTaken;
8839 void setTimeTaken(uint32 value)
8842 if (_TimeTaken != value)
8844 if (getPersistentState() != NOPE::os_transient)
8845 setPersistentState(NOPE::os_dirty);
8847 _TimeTaken = value;
8853 const std::string &getParticipants() const
8855 return _Participants;
8860 void setParticipants(const std::string &value)
8863 if (_Participants != value)
8865 if (getPersistentState() != NOPE::os_transient)
8866 setPersistentState(NOPE::os_dirty);
8869 _Participants = value;
8876 uint32 getLaunchDate() const
8878 return _LaunchDate;
8881 void setLaunchDate(uint32 value)
8884 if (_LaunchDate != value)
8886 if (getPersistentState() != NOPE::os_transient)
8887 setPersistentState(NOPE::os_dirty);
8889 _LaunchDate = value;
8895 const std::string &getOwner() const
8897 return _Owner;
8902 void setOwner(const std::string &value)
8905 if (_Owner != value)
8907 if (getPersistentState() != NOPE::os_transient)
8908 setPersistentState(NOPE::os_dirty);
8911 _Owner = value;
8918 const std::string &getGuildName() const
8920 return _GuildName;
8925 void setGuildName(const std::string &value)
8928 if (_GuildName != value)
8930 if (getPersistentState() != NOPE::os_transient)
8931 setPersistentState(NOPE::os_dirty);
8934 _GuildName = value;
8941 bool operator == (const CSessionLog &other) const
8943 return _Id == other._Id
8944 && _ScenarioId == other._ScenarioId
8945 && _RRPScored == other._RRPScored
8946 && _ScenarioPointScored == other._ScenarioPointScored
8947 && _TimeTaken == other._TimeTaken
8948 && _Participants == other._Participants
8949 && _LaunchDate == other._LaunchDate
8950 && _Owner == other._Owner
8951 && _GuildName == other._GuildName;
8955 private:
8956 // private constructor, you must use 'createTransient' to get an instance
8957 CSessionLog()
8958 : _PtrList(NULL),
8959 _ObjectState(NOPE::os_transient),
8960 _Id(NOPE::INVALID_OBJECT_ID)
8962 // Default initialisation
8963 _RRPScored = 0;
8964 _ScenarioPointScored = 0;
8965 _TimeTaken = 0;
8967 // register the cache for this class (if not already done)
8968 registerUpdatable();
8971 // Destructor, delete any children
8972 ~CSessionLog();
8974 /// utility func to remove this object from the released object container
8975 void removeFromReleased();
8978 public:
8979 /// Create a new instance in the transient space
8980 static CSessionLogPtr createTransient(const char *filename, uint32 lineNum)
8982 return CSessionLogPtr(new CSessionLog(), filename, lineNum);
8985 /** Create a new object in the database from the current object data.
8986 * The object MUST be in transient state (i.e, it must be a new
8987 * object created by user and not comming from the databse).
8988 * If identifier is autogenerated, the generated id can be read after
8989 * this call.
8991 bool create(MSW::CConnection &connection);
8992 /** Update the database with the current object state.
8993 * The object MUST be either in clean or dirty state.
8994 * Return true if the object has been effectively stored
8995 * in the database.
8996 * After this call, the object is in 'clean' state.
8998 bool update(MSW::CConnection &connection);
8999 /** Remove the current object from the persistent storage.
9000 * The object must be in clean or dirty state.
9001 * Return true if the object has been correctly
9002 * updated in the database.
9003 * After the call, the object is in 'clean' state.
9005 bool remove(MSW::CConnection &connection);
9006 /** Remove an object from the persistent storage by specifying
9007 * the id to remove.
9008 * Return true if an entry as been effectively removed from
9009 * the database.
9010 * After the call, the object is in 'removed' state and should
9011 * no more be used. A good pratice should be to delete
9012 * the transient object just after the remove call.
9014 static bool removeById(MSW::CConnection &connection, uint32 id);
9016 /** Load an instance from the database.
9017 * This call allocate a new object and load the property value
9018 * from the database.
9019 * Return NULL if the object id is not found.
9021 static CSessionLogPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
9024 /** Load all objects children of CScenario and
9025 * return them by using the specified output iterator.
9028 static bool loadChildrenOfCScenario(MSW::CConnection &connection, uint32 parentId, std::vector < CSessionLogPtr > &children, const char *filename, uint32 lineNum);
9031 private:
9033 private:
9034 friend class CPersistentCache;
9035 friend class CSessionLogPtr;
9037 typedef std::map<uint32, CSessionLog*> TObjectCache;
9038 typedef std::set<CSessionLog*> TObjectSet;
9039 typedef std::map<time_t, TObjectSet> TReleasedObject;
9041 /// The complete set of object currently in memory (either active or released) excluding transient instance
9042 static TObjectCache _ObjectCache;
9043 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
9044 static TReleasedObject _ReleasedObject;
9046 /// The current object state
9047 NOPE::TObjectState _ObjectState;
9049 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
9050 time_t _ReleaseDate;
9052 /// The linked list of pointer on this object
9053 CSessionLogPtr *_PtrList;
9055 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
9056 static CSessionLog *loadFromCache(uint32 objectId, bool unrelease);
9058 // Receive and execute command from the cache manager.
9059 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
9061 static void dump();
9063 static void updateCache();
9065 public:
9066 static void clearCache();
9067 private:
9068 void registerUpdatable();
9070 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
9071 void setFirstPtr(CSessionLogPtr *ptr);
9073 // return the first pointer of the pointer list (can be null)
9074 CSessionLogPtr *getFirstPtr()
9076 return _PtrList;
9079 public:
9081 /** Return the object identifier (witch is unique)
9082 * You can only call this method on a persistent instance.
9083 * (because transient instance can have invalid id)
9085 uint32 getObjectId() const
9088 return _Id;
9091 /** Set the object unique ID.
9092 * You can only set the object id on a transient object
9093 * having a non autogenerated unique id.
9094 * Furthermore, you MUST set the id before calling create()
9095 * if the id is not autogenerated.
9097 void setObjectId(uint32 objectId)
9099 // can only be set when in transient state
9100 nlassert(getPersistentState() == NOPE::os_transient);
9101 // can only be set once
9102 nlassert(_Id == NOPE::INVALID_OBJECT_ID);
9103 _Id = objectId;
9106 /** Return the current persistent state of the object.*/
9107 NOPE::TObjectState getPersistentState() const
9109 return _ObjectState;
9112 private:
9113 // Set the persistent state of the object and do some house keeping
9114 void setPersistentState(NOPE::TObjectState state);
9121 /////////////////////////////////////////////////////////////////
9122 // WARNING : this is a generated file, don't change it !
9123 /////////////////////////////////////////////////////////////////
9124 class CGmStatus
9126 protected:
9128 uint32 _UserId;
9130 bool _Available;
9131 public:
9133 bool getAvailable() const
9135 return _Available;
9138 void setAvailable(bool value)
9141 if (_Available != value)
9143 if (getPersistentState() != NOPE::os_transient)
9144 setPersistentState(NOPE::os_dirty);
9146 _Available = value;
9152 bool operator == (const CGmStatus &other) const
9154 return _UserId == other._UserId
9155 && _Available == other._Available;
9159 private:
9160 // private constructor, you must use 'createTransient' to get an instance
9161 CGmStatus()
9162 : _PtrList(NULL),
9163 _ObjectState(NOPE::os_transient),
9164 _UserId(NOPE::INVALID_OBJECT_ID)
9166 // Default initialisation
9167 _Available = 1;
9169 // register the cache for this class (if not already done)
9170 registerUpdatable();
9173 // Destructor, delete any children
9174 ~CGmStatus();
9176 /// utility func to remove this object from the released object container
9177 void removeFromReleased();
9180 public:
9181 /// Create a new instance in the transient space
9182 static CGmStatusPtr createTransient(const char *filename, uint32 lineNum)
9184 return CGmStatusPtr(new CGmStatus(), filename, lineNum);
9187 /** Create a new object in the database from the current object data.
9188 * The object MUST be in transient state (i.e, it must be a new
9189 * object created by user and not comming from the databse).
9190 * If identifier is autogenerated, the generated id can be read after
9191 * this call.
9193 bool create(MSW::CConnection &connection);
9194 /** Update the database with the current object state.
9195 * The object MUST be either in clean or dirty state.
9196 * Return true if the object has been effectively stored
9197 * in the database.
9198 * After this call, the object is in 'clean' state.
9200 bool update(MSW::CConnection &connection);
9201 /** Remove the current object from the persistent storage.
9202 * The object must be in clean or dirty state.
9203 * Return true if the object has been correctly
9204 * updated in the database.
9205 * After the call, the object is in 'clean' state.
9207 bool remove(MSW::CConnection &connection);
9208 /** Remove an object from the persistent storage by specifying
9209 * the id to remove.
9210 * Return true if an entry as been effectively removed from
9211 * the database.
9212 * After the call, the object is in 'removed' state and should
9213 * no more be used. A good pratice should be to delete
9214 * the transient object just after the remove call.
9216 static bool removeById(MSW::CConnection &connection, uint32 id);
9218 /** Load an instance from the database.
9219 * This call allocate a new object and load the property value
9220 * from the database.
9221 * Return NULL if the object id is not found.
9223 static CGmStatusPtr load(MSW::CConnection &connection, uint32 id, const char *filename, uint32 lineNum);
9226 /** Load the object child of CRingUser and
9227 * return true if no error, false in case of error (in SQL maybe).
9228 * If no such object is found, fill the child pointer with NULL.
9230 static bool loadChildOfCRingUser(MSW::CConnection &connection, uint32 parentId, CGmStatusPtr &childPtr, const char *filename, uint32 lineNum);
9233 private:
9235 private:
9236 friend class CPersistentCache;
9237 friend class CGmStatusPtr;
9239 typedef std::map<uint32, CGmStatus*> TObjectCache;
9240 typedef std::set<CGmStatus*> TObjectSet;
9241 typedef std::map<time_t, TObjectSet> TReleasedObject;
9243 /// The complete set of object currently in memory (either active or released) excluding transient instance
9244 static TObjectCache _ObjectCache;
9245 /// The set of object in memory ut released (no pointer on them) and waiting for decommit
9246 static TReleasedObject _ReleasedObject;
9248 /// The current object state
9249 NOPE::TObjectState _ObjectState;
9251 /// For object in released state, this is the release date (used to trigger deletion of the object from memory)
9252 time_t _ReleaseDate;
9254 /// The linked list of pointer on this object
9255 CGmStatusPtr *_PtrList;
9257 // Try to load the specified object from the memory cache, return NULL if the object is not in the cache
9258 static CGmStatus *loadFromCache(uint32 objectId, bool unrelease);
9260 // Receive and execute command from the cache manager.
9261 static uint32 cacheCmd(NOPE::TCacheCmd cmd);
9263 static void dump();
9265 static void updateCache();
9267 public:
9268 static void clearCache();
9269 private:
9270 void registerUpdatable();
9272 // set the pointer on the first pointer of the pointer list (set to null when there is no more pointer)
9273 void setFirstPtr(CGmStatusPtr *ptr);
9275 // return the first pointer of the pointer list (can be null)
9276 CGmStatusPtr *getFirstPtr()
9278 return _PtrList;
9281 public:
9283 /** Return the object identifier (witch is unique)
9284 * You can only call this method on a persistent instance.
9285 * (because transient instance can have invalid id)
9287 uint32 getObjectId() const
9290 return _UserId;
9293 /** Set the object unique ID.
9294 * You can only set the object id on a transient object
9295 * having a non autogenerated unique id.
9296 * Furthermore, you MUST set the id before calling create()
9297 * if the id is not autogenerated.
9299 void setObjectId(uint32 objectId)
9301 // can only be set when in transient state
9302 nlassert(getPersistentState() == NOPE::os_transient);
9303 // can only be set once
9304 nlassert(_UserId == NOPE::INVALID_OBJECT_ID);
9305 _UserId = objectId;
9308 /** Return the current persistent state of the object.*/
9309 NOPE::TObjectState getPersistentState() const
9311 return _ObjectState;
9314 private:
9315 // Set the persistent state of the object and do some house keeping
9316 void setPersistentState(NOPE::TObjectState state);
9326 #endif