40 | | //! level of details that will be logged to a logger |
41 | | // DULEZITE TODO - zde musi respektovat aktualne ulozene hodnoty, tj. nacist je, pak pridat |
42 | | // ty co se maji v tomto kroku ulozit a pak vse ulozit.. protoze to delame kompozici a ne dedenim DODELAT |
43 | | // ALE HOUBY, TAKHLE TO NEJDE, musime nechat jako samostatny objekt, kazda uroven tedy zvlast, |
44 | | // jednoznacne jmeno atd.. |
45 | | // |
46 | | //! information about connection to a logger |
47 | | template<class T> class logged_options { |
| 40 | //! This class stores a details that will be logged to a logger |
| 41 | template<class T> class log_level_template { |
66 | | bool operator [] (const enum T::possible_options &option ) const |
67 | | { |
68 | | return values[option]; |
69 | | } |
70 | | |
71 | | bitset<32>::reference operator [] (const enum T::possible_options &option ) |
72 | | { |
73 | | return values[option]; |
| 74 | //! read only operator for testing individual fields of log_level |
| 75 | //! |
| 76 | //! it is necessary to acces it with a proper enumeration type, thus this approach is type-safe |
| 77 | bool operator [] (const enum T::log_level_enums &log_level ) const |
| 78 | { |
| 79 | return values[log_level]; |
| 80 | } |
| 81 | |
| 82 | //! operator for setting an individual field of log_level |
| 83 | //! |
| 84 | //! it is necessary to acces it with a proper enumeration type, thus this approach is type-safe |
| 85 | bitset<32>::reference operator [] (const enum T::log_level_enums &log_level ) |
| 86 | { |
| 87 | return values[log_level]; |
77 | | // MUZEME INTERNE POUZIVAT ENUMY, A KLIDNE MENIT JEJICH PORADI, DIKY TOMUHLE MAKRU SE VZDY NAMAPUJI NA TY SPRAVNE STRINGY |
78 | | #define LOG_LEVEL(CLASSNAME,...) private: friend class logged_options<CLASSNAME>; static const Array<string> &option_names() { static const Array<string> option_names( "{"#__VA_ARGS__" }" ); return option_names; }; public: enum possible_options { __VA_ARGS__ }; logged_options<CLASSNAME> log_level; |
| 91 | /*! |
| 92 | \def LOG_LEVEL(classname,...) |
| 93 | \brief Macro for defining a log_level attribute with a specific set of enumerations related to a specific class |
| 94 | |
| 95 | This macro has to be called within a class declaration. Its argument \a classname has to correspond to that wrapping class. |
| 96 | This macro defines a log_level instance which can be modified either directly or by the means of #UI class. |
| 97 | |
| 98 | One of the main purposes of this macro is to allow variability in using enumerations. By relating them to their names through |
| 99 | an array of strings, we are no more dependant on their precise ordering. What is more, we can add or remove any without harming |
| 100 | any applications which are using this library. |
| 101 | |
| 102 | \todo Write a more detailed explanation including also examples |
| 103 | |
| 104 | \ref ui |
| 105 | */ |
| 106 | #define LOG_LEVEL(classname,...) public: enum log_level_enums { __VA_ARGS__ }; log_level_template<classname> log_level; private: friend class log_level_template<classname>; static const Array<string> &log_level_names() { static const Array<string> log_level_names = log_level_template<classname>::string2Array( #__VA_ARGS__ ); return log_level_names; } |