1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 /////////////////////////////////////////////////////////////////
18 // WARNING : this is a generated file, don't change it !
19 /////////////////////////////////////////////////////////////////
21 #ifndef LOGGER_SERVICE_ITF
22 #define LOGGER_SERVICE_ITF
23 #include "nel/misc/types_nl.h"
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/entity_id.h"
35 #include "nel/misc/sheet_id.h"
37 #include "game_share/inventories.h"
46 class TListParamValues
;
54 struct TSupportedParamType
66 /// the highest valid value in the enum
67 last_enum_item
= spt_itemId
,
68 /// a value equal to the last enum item +1
73 /// Number of enumerated values
77 /// Index table to convert enum value to linear index table
78 const std::map
<TValues
, uint32
> &getIndexTable() const
80 static std::map
<TValues
, uint32
> indexTable
;
81 static bool init
= false;
84 // fill the index table
85 indexTable
.insert(std::make_pair(spt_uint32
, 0));
86 indexTable
.insert(std::make_pair(spt_uint64
, 1));
87 indexTable
.insert(std::make_pair(spt_sint32
, 2));
88 indexTable
.insert(std::make_pair(spt_float
, 3));
89 indexTable
.insert(std::make_pair(spt_string
, 4));
90 indexTable
.insert(std::make_pair(spt_entityId
, 5));
91 indexTable
.insert(std::make_pair(spt_sheetId
, 6));
92 indexTable
.insert(std::make_pair(spt_itemId
, 7));
101 static const NLMISC::CStringConversion
<TValues
> &getConversionTable()
103 NL_BEGIN_STRING_CONVERSION_TABLE(TValues
)
104 NL_STRING_CONVERSION_TABLE_ENTRY(spt_uint32
)
105 NL_STRING_CONVERSION_TABLE_ENTRY(spt_uint64
)
106 NL_STRING_CONVERSION_TABLE_ENTRY(spt_sint32
)
107 NL_STRING_CONVERSION_TABLE_ENTRY(spt_float
)
108 NL_STRING_CONVERSION_TABLE_ENTRY(spt_string
)
109 NL_STRING_CONVERSION_TABLE_ENTRY(spt_entityId
)
110 NL_STRING_CONVERSION_TABLE_ENTRY(spt_sheetId
)
111 NL_STRING_CONVERSION_TABLE_ENTRY(spt_itemId
)
112 NL_STRING_CONVERSION_TABLE_ENTRY(invalid_val
)
114 static NLMISC::CStringConversion
<TValues
>
115 conversionTable(TValues_nl_string_conversion_table
, sizeof(TValues_nl_string_conversion_table
)
116 / sizeof(TValues_nl_string_conversion_table
[0]), invalid_val
);
118 return conversionTable
;
124 TSupportedParamType()
125 : _Value(invalid_val
)
128 TSupportedParamType(TValues value
)
133 TSupportedParamType(const std::string
&str
)
135 _Value
= getConversionTable().fromString(str
);
138 void serial(NLMISC::IStream
&s
)
140 s
.serialEnum(_Value
);
143 bool operator == (const TSupportedParamType
&other
) const
145 return _Value
== other
._Value
;
147 bool operator != (const TSupportedParamType
&other
) const
149 return ! (_Value
== other
._Value
);
151 bool operator < (const TSupportedParamType
&other
) const
153 return _Value
< other
._Value
;
156 bool operator <= (const TSupportedParamType
&other
) const
158 return _Value
<= other
._Value
;
161 bool operator > (const TSupportedParamType
&other
) const
163 return !(_Value
<= other
._Value
);
165 bool operator >= (const TSupportedParamType
&other
) const
167 return !(_Value
< other
._Value
);
170 const std::string
&toString() const
172 return getConversionTable().toString(_Value
);
174 static const std::string
&toString(TValues value
)
176 return getConversionTable().toString(value
);
179 TValues
getValue() const
184 // return true if the actual value of the enum is valid, otherwise false
187 if (_Value
== invalid_val
)
190 // not invalid, check other enum value
191 return getConversionTable().isValid(_Value
);
197 std::map
<TValues
, uint32
>::const_iterator
it(getIndexTable().find(_Value
));
198 nlassert(it
!= getIndexTable().end());
206 // template <class T> LGS::TSupportedParamType getParamType();
207 // template <class T> LGS::TSupportedParamType getParamType<uint32>() { return LGS::TSupportedParamType::spt_uint32;}
208 // template <class T> LGS::TSupportedParamType getParamType<uint64>() { return LGS::TSupportedParamType::spt_uint64;}
209 // template <class T> LGS::TSupportedParamType getParamType<sint32>() { return LGS::TSupportedParamType::spt_sint32;}
210 // template <class T> LGS::TSupportedParamType getParamType<float>() { return LGS::TSupportedParamType::spt_float;}
211 // template <class T> LGS::TSupportedParamType getParamType<std::string>() { return LGS::TSupportedParamType::spt_string;}
212 // template <class T> LGS::TSupportedParamType getParamType<NLMISC::CEntityId>() { return LGS::TSupportedParamType::spt_entityId;}
213 // template <class T> LGS::TSupportedParamType getParamType<NLMISC::CSheetId>() { return LGS::TSupportedParamType::spt_sheetId;}
214 // template <class T> LGS::TSupportedParamType getParamType<INVENTORIES::TItemId>() { return LGS::TSupportedParamType::spt_itemId;}
219 : _Type(TSupportedParamType::invalid_val
)
222 TParamValue(uint32 value
)
224 _Type
= TSupportedParamType::spt_uint32
;
228 TParamValue(uint64 value
)
230 _Type
= TSupportedParamType::spt_uint64
;
234 TParamValue(bool value
)
236 _Type
= TSupportedParamType::spt_uint32
;
237 _UInt32Val
= value
? 1 : 0;
240 TParamValue(sint32 value
)
242 _Type
= TSupportedParamType::spt_sint32
;
246 TParamValue(float value
)
248 _Type
= TSupportedParamType::spt_float
;
252 TParamValue(const std::string
&value
)
254 _Type
= TSupportedParamType::spt_string
;
258 TParamValue(const NLMISC::CEntityId
&value
)
260 _Type
= TSupportedParamType::spt_entityId
;
264 TParamValue(const NLMISC::CSheetId
&value
)
266 _Type
= TSupportedParamType::spt_sheetId
;
270 TParamValue(INVENTORIES::TItemId itemId
)
272 _Type
= TSupportedParamType::spt_itemId
;
276 TParamValue
&operator = (const TParamValue
&other
)
280 switch (_Type
.getValue())
282 case TSupportedParamType::spt_uint32
:
283 _UInt32Val
= other
._UInt32Val
;
285 case TSupportedParamType::spt_uint64
:
286 _UInt64Val
= other
._UInt64Val
;
288 case TSupportedParamType::spt_sint32
:
289 _SInt32Val
= other
._SInt32Val
;
291 case TSupportedParamType::spt_float
:
292 _FloatVal
= other
._FloatVal
;
294 case TSupportedParamType::spt_string
:
295 _StringVal
= other
._StringVal
;
297 case TSupportedParamType::spt_entityId
:
298 _EntityId
= other
._EntityId
;
300 case TSupportedParamType::spt_sheetId
:
301 _SheetId
= other
._SheetId
;
303 case TSupportedParamType::spt_itemId
:
304 _ItemId
= other
._ItemId
;
313 void serial(NLMISC::IStream
&s
)
319 switch (_Type
.getValue())
321 case TSupportedParamType::spt_uint32
:
322 s
.serial(_UInt32Val
);
324 case TSupportedParamType::spt_uint64
:
325 s
.serial(_UInt64Val
);
327 case TSupportedParamType::spt_sint32
:
328 s
.serial(_SInt32Val
);
330 case TSupportedParamType::spt_float
:
333 case TSupportedParamType::spt_string
:
334 s
.serial(_StringVal
);
336 case TSupportedParamType::spt_entityId
:
339 case TSupportedParamType::spt_sheetId
:
342 case TSupportedParamType::spt_itemId
:
350 std::string
toString() const
352 switch (_Type
.getValue())
354 case TSupportedParamType::spt_uint32
:
355 return NLMISC::toString(_UInt32Val
);
357 case TSupportedParamType::spt_uint64
:
358 return NLMISC::toString(_UInt64Val
);
360 case TSupportedParamType::spt_sint32
:
361 return NLMISC::toString(_SInt32Val
);
363 case TSupportedParamType::spt_float
:
364 return NLMISC::toString(_FloatVal
);
366 case TSupportedParamType::spt_string
:
369 case TSupportedParamType::spt_entityId
:
370 return _EntityId
.toString();
372 case TSupportedParamType::spt_sheetId
:
373 return _SheetId
.toString();
375 case TSupportedParamType::spt_itemId
:
376 return NLMISC::toString(_ItemId
);
385 TSupportedParamType
getType() const
390 uint32
get_uint32() const
392 nlassert(_Type
== TSupportedParamType::spt_uint32
);
395 uint64
get_uint64() const
397 nlassert(_Type
== TSupportedParamType::spt_uint64
);
400 sint32
get_sint32() const
402 nlassert(_Type
== TSupportedParamType::spt_sint32
);
405 float get_float() const
407 nlassert(_Type
== TSupportedParamType::spt_float
);
410 const std::string
&get_string() const
412 nlassert(_Type
== TSupportedParamType::spt_string
);
415 const NLMISC::CEntityId
&get_entityId() const
417 nlassert(_Type
== TSupportedParamType::spt_entityId
);
420 const NLMISC::CSheetId
&get_sheetId() const
422 nlassert(_Type
== TSupportedParamType::spt_sheetId
);
425 const INVENTORIES::TItemId
&get_itemId() const
427 nlassert(_Type
== TSupportedParamType::spt_itemId
);
432 const uint32
&get(const uint32
*typeTag
) const
434 nlassert(_Type
== TSupportedParamType::spt_uint32
);
438 const uint64
&get(const uint64
*typeTag
) const
440 nlassert(_Type
== TSupportedParamType::spt_uint64
);
444 const sint32
&get(const sint32
*typeTag
) const
446 nlassert(_Type
== TSupportedParamType::spt_sint32
);
450 const float &get(const float *typeTag
) const
452 nlassert(_Type
== TSupportedParamType::spt_float
);
456 const std::string
&get(const std::string
*typeTag
) const
458 nlassert(_Type
== TSupportedParamType::spt_string
);
462 const NLMISC::CEntityId
&get(const NLMISC::CEntityId
*typeTag
) const
464 nlassert(_Type
== TSupportedParamType::spt_entityId
);
468 const NLMISC::CSheetId
&get(const NLMISC::CSheetId
*typeTag
) const
470 nlassert(_Type
== TSupportedParamType::spt_sheetId
);
474 const INVENTORIES::TItemId
&get(const INVENTORIES::TItemId
*typeTag
) const
476 nlassert(_Type
== TSupportedParamType::spt_itemId
);
480 bool operator == (const TParamValue
&other
) const
482 if (_Type
!= other
._Type
)
485 switch (_Type
.getValue())
487 case TSupportedParamType::spt_uint32
:
488 return _UInt32Val
== other
._UInt32Val
;
490 case TSupportedParamType::spt_uint64
:
491 return _UInt64Val
== other
._UInt64Val
;
493 case TSupportedParamType::spt_sint32
:
494 return _SInt32Val
== other
._SInt32Val
;
496 case TSupportedParamType::spt_float
:
497 return _FloatVal
== other
._FloatVal
;
499 case TSupportedParamType::spt_string
:
500 return _StringVal
== other
._StringVal
;
502 case TSupportedParamType::spt_entityId
:
503 return _EntityId
== other
._EntityId
;
505 case TSupportedParamType::spt_sheetId
:
506 return _SheetId
== other
._SheetId
;
508 case TSupportedParamType::spt_itemId
:
509 return _ItemId
== other
._ItemId
;
516 bool operator < (const TParamValue
&other
) const
518 if (_Type
!= other
._Type
)
521 switch (_Type
.getValue())
523 case TSupportedParamType::spt_uint32
:
524 return _UInt32Val
< other
._UInt32Val
;
526 case TSupportedParamType::spt_uint64
:
527 return _UInt64Val
< other
._UInt64Val
;
529 case TSupportedParamType::spt_sint32
:
530 return _SInt32Val
< other
._SInt32Val
;
532 case TSupportedParamType::spt_float
:
533 return _FloatVal
< other
._FloatVal
;
535 case TSupportedParamType::spt_string
:
536 return _StringVal
< other
._StringVal
;
538 case TSupportedParamType::spt_entityId
:
539 return _EntityId
< other
._EntityId
;
541 case TSupportedParamType::spt_sheetId
:
542 return _SheetId
< other
._SheetId
;
544 case TSupportedParamType::spt_itemId
:
545 return _ItemId
< other
._ItemId
;
553 TSupportedParamType _Type
;
562 std::string _StringVal
;
563 NLMISC::CEntityId _EntityId
;
564 NLMISC::CSheetId _SheetId
;
565 INVENTORIES::TItemId _ItemId
;
569 // Describe a param for a log entry
570 /////////////////////////////////////////////////////////////////
571 // WARNING : this is a generated file, don't change it !
572 /////////////////////////////////////////////////////////////////
576 // Name of the parameter
578 // Type of the parameter
579 TSupportedParamType _Type
;
580 // Flag indicating that this parameter is a list
583 // Name of the parameter
584 const std::string
&getName() const
589 std::string
&getName()
595 void setName(const std::string
&value
)
603 // Type of the parameter
604 TSupportedParamType
getType() const
609 void setType(TSupportedParamType value
)
615 // Flag indicating that this parameter is a list
621 void setList(bool value
)
628 bool operator == (const TParamDesc
&other
) const
630 return _Name
== other
._Name
631 && _Type
== other
._Type
632 && _List
== other
._List
;
639 // Default initialisation
644 void serial(NLMISC::IStream
&s
)
659 // A vector of parameter value
660 /////////////////////////////////////////////////////////////////
661 // WARNING : this is a generated file, don't change it !
662 /////////////////////////////////////////////////////////////////
663 class TListParamValues
667 std::list
< TParamValue
> _Params
;
670 const std::list
< TParamValue
> &getParams() const
675 std::list
< TParamValue
> &getParams()
681 void setParams(const std::list
< TParamValue
> &value
)
690 bool operator == (const TListParamValues
&other
) const
692 return _Params
== other
._Params
;
702 void serial(NLMISC::IStream
&s
)
704 s
.serialCont(_Params
);
715 // Definition of a log entry
716 /////////////////////////////////////////////////////////////////
717 // WARNING : this is a generated file, don't change it !
718 /////////////////////////////////////////////////////////////////
722 // The name of the log, used to identify the log
723 std::string _LogName
;
724 // This log is a context log
726 // The textual content of the log, contains '__CLOSE_CONTEXT__' to close a log context
727 std::string _LogText
;
729 std::vector
< TParamDesc
> _Params
;
731 std::vector
< TParamDesc
> _ListParams
;
733 // The name of the log, used to identify the log
734 std::string
getLogName() const
739 void setLogName(std::string value
)
745 // This log is a context log
746 bool getContext() const
751 void setContext(bool value
)
757 // The textual content of the log, contains '__CLOSE_CONTEXT__' to close a log context
758 std::string
getLogText() const
763 void setLogText(std::string value
)
770 const std::vector
< TParamDesc
> &getParams() const
775 std::vector
< TParamDesc
> &getParams()
781 void setParams(const std::vector
< TParamDesc
> &value
)
790 const std::vector
< TParamDesc
> &getListParams() const
795 std::vector
< TParamDesc
> &getListParams()
801 void setListParams(const std::vector
< TParamDesc
> &value
)
810 bool operator == (const TLogDefinition
&other
) const
812 return _LogName
== other
._LogName
813 && _Context
== other
._Context
814 && _LogText
== other
._LogText
815 && _Params
== other
._Params
816 && _ListParams
== other
._ListParams
;
823 // Default initialisation
828 void serial(NLMISC::IStream
&s
)
833 s
.serialCont(_Params
);
834 s
.serialCont(_ListParams
);
845 // A log entry data. This contains the parameter of a log
846 // entry to be stored in the log archive
847 /////////////////////////////////////////////////////////////////
848 // WARNING : this is a generated file, don't change it !
849 /////////////////////////////////////////////////////////////////
854 std::string _LogName
;
858 std::vector
< TParamValue
> _Params
;
860 std::vector
< TListParamValues
> _ListParams
;
863 std::string
getLogName() const
868 void setLogName(std::string value
)
875 uint32
getTimeStamp() const
880 void setTimeStamp(uint32 value
)
887 const std::vector
< TParamValue
> &getParams() const
892 std::vector
< TParamValue
> &getParams()
898 void setParams(const std::vector
< TParamValue
> &value
)
907 const std::vector
< TListParamValues
> &getListParams() const
912 std::vector
< TListParamValues
> &getListParams()
918 void setListParams(const std::vector
< TListParamValues
> &value
)
927 bool operator == (const TLogInfo
&other
) const
929 return _LogName
== other
._LogName
930 && _TimeStamp
== other
._TimeStamp
931 && _Params
== other
._Params
932 && _ListParams
== other
._ListParams
;
942 void serial(NLMISC::IStream
&s
)
945 s
.serial(_TimeStamp
);
946 s
.serialCont(_Params
);
947 s
.serialCont(_ListParams
);
959 /////////////////////////////////////////////////////////////////
960 // WARNING : this is a generated file, don't change it !
961 /////////////////////////////////////////////////////////////////
962 class CLoggerServiceSkel
965 /// the interceptor type
966 typedef NLNET::CInterceptorForwarder
< CLoggerServiceSkel
> TInterceptor
;
970 // do early run time check for message table
971 getMessageHandlers();
973 virtual ~CLoggerServiceSkel()
977 void init(NLNET::IModule
*module
)
979 _Interceptor
.init(this, module
);
982 // unused interceptors
983 std::string
fwdBuildModuleManifest() const { return std::string(); }
984 void fwdOnModuleUp(NLNET::IModuleProxy
*moduleProxy
) {}
985 void fwdOnModuleDown(NLNET::IModuleProxy
*moduleProxy
) {}
986 void fwdOnModuleSecurityChange(NLNET::IModuleProxy
*moduleProxy
) {}
988 // process module message interceptor
989 bool fwdOnProcessModuleMessage(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&message
);
992 typedef void (CLoggerServiceSkel::*TMessageHandler
)(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&message
);
993 typedef std::map
<std::string
, TMessageHandler
> TMessageHandlerMap
;
995 const TMessageHandlerMap
&getMessageHandlers() const;
998 void registerClient_skel(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&__message
);
1000 void reportLog_skel(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&__message
);
1002 // declare one interceptor member of the skeleton
1003 TInterceptor _Interceptor
;
1005 // declare the interceptor forwarder as friend of this class
1006 friend class NLNET::CInterceptorForwarder
< CLoggerServiceSkel
>;
1008 /////////////////////////////////////////////////////////////////
1009 // WARNING : this is a generated file, don't change it !
1010 /////////////////////////////////////////////////////////////////
1012 // A logger client register itself wy providing it's definition of
1013 // the log content. It is mandatory that ALL client share
1014 // Exactly the same definition of log.
1015 virtual void registerClient(NLNET::IModuleProxy
*sender
, uint32 shardId
, const std::vector
< TLogDefinition
> &logDef
) =0;
1016 // A client send a log
1017 virtual void reportLog(NLNET::IModuleProxy
*sender
, const std::vector
< TLogInfo
> &logInfos
) =0;
1022 /////////////////////////////////////////////////////////////////
1023 // WARNING : this is a generated file, don't change it !
1024 /////////////////////////////////////////////////////////////////
1025 class CLoggerServiceProxy
1027 /// Smart pointer on the module proxy
1028 NLNET::TModuleProxyPtr _ModuleProxy
;
1030 // Pointer on the local module that implement the interface (if the proxy is for a local module)
1031 NLNET::TModulePtr _LocalModule
;
1032 // Direct pointer on the server implementation interface for collocated module
1033 CLoggerServiceSkel
*_LocalModuleSkel
;
1037 CLoggerServiceProxy(NLNET::IModuleProxy
*proxy
)
1039 nlassert(proxy
->getModuleClassName() == "LoggerService");
1040 _ModuleProxy
= proxy
;
1042 // initialize collocated servant interface
1043 if (proxy
->getModuleDistance() == 0)
1045 _LocalModule
= proxy
->getLocalModule();
1046 nlassert(_LocalModule
!= NULL
);
1047 CLoggerServiceSkel::TInterceptor
*interceptor
= NULL
;
1048 interceptor
= static_cast < NLNET::CModuleBase
* >(_LocalModule
.getPtr())->getInterceptor(interceptor
);
1049 nlassert(interceptor
!= NULL
);
1051 _LocalModuleSkel
= interceptor
->getParent();
1052 nlassert(_LocalModuleSkel
!= NULL
);
1055 _LocalModuleSkel
= 0;
1058 virtual ~CLoggerServiceProxy()
1062 NLNET::IModuleProxy
*getModuleProxy()
1064 return _ModuleProxy
;
1067 // A logger client register itself wy providing it's definition of
1068 // the log content. It is mandatory that ALL client share
1069 // Exactly the same definition of log.
1070 void registerClient(NLNET::IModule
*sender
, uint32 shardId
, const std::vector
< TLogDefinition
> &logDef
);
1071 // A client send a log
1072 void reportLog(NLNET::IModule
*sender
, const std::vector
< TLogInfo
> &logInfos
);
1074 // Message serializer. Return the message received in reference for easier integration
1075 static const NLNET::CMessage
&buildMessageFor_registerClient(NLNET::CMessage
&__message
, uint32 shardId
, const std::vector
< TLogDefinition
> &logDef
);
1077 // Message serializer. Return the message received in reference for easier integration
1078 static const NLNET::CMessage
&buildMessageFor_reportLog(NLNET::CMessage
&__message
, const std::vector
< TLogInfo
> &logInfos
);