00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef NOTIFYCATEGORYPROXY_H
00020 #define NOTIFYCATEGORYPROXY_H
00021
00022 #include <dtoolbase.h>
00023
00024 #include "notifyCategory.h"
00025 #include "notifySeverity.h"
00026 #include "notify.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 template<class GetCategory>
00065 class NotifyCategoryProxy {
00066 public:
00067
00068
00069 NotifyCategory *init();
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 INLINE NotifyCategory *get_unsafe_ptr();
00080 INLINE NotifyCategory *get_safe_ptr();
00081
00082
00083
00084
00085
00086 INLINE bool is_on(NotifySeverity severity);
00087
00088 INLINE bool is_spam();
00089 INLINE bool is_debug();
00090 INLINE bool is_info();
00091 INLINE bool is_warning();
00092 INLINE bool is_error();
00093 INLINE bool is_fatal();
00094
00095 INLINE ostream &out(NotifySeverity severity, bool prefix = true);
00096 INLINE ostream &spam(bool prefix = true);
00097 INLINE ostream &debug(bool prefix = true);
00098 INLINE ostream &info(bool prefix = true);
00099 INLINE ostream &warning(bool prefix = true);
00100 INLINE ostream &error(bool prefix = true);
00101 INLINE ostream &fatal(bool prefix = true);
00102
00103
00104
00105
00106 INLINE NotifyCategory *operator -> ();
00107 INLINE NotifyCategory &operator * ();
00108 INLINE operator NotifyCategory * ();
00109
00110 private:
00111 NotifyCategory *_ptr;
00112 };
00113
00114 template<class GetCategory>
00115 INLINE ostream &operator << (ostream &out, NotifyCategoryProxy<GetCategory> &proxy) {
00116 return out << proxy->get_fullname();
00117 }
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 #if defined(WIN32_VC) && !defined(CPPPARSER)
00128
00129 #define NotifyCategoryDecl(basename, expcl, exptp) \
00130 class expcl NotifyCategoryGetCategory_ ## basename { \
00131 public: \
00132 NotifyCategoryGetCategory_ ## basename(); \
00133 static NotifyCategory *get_category(); \
00134 }; \
00135 exptp template class expcl NotifyCategoryProxy<NotifyCategoryGetCategory_ ## basename>; \
00136 extern expcl NotifyCategoryProxy<NotifyCategoryGetCategory_ ## basename> basename ## _cat;
00137
00138 #else // WIN32_VC
00139
00140 #define NotifyCategoryDecl(basename, expcl, exptp) \
00141 class NotifyCategoryGetCategory_ ## basename { \
00142 public: \
00143 NotifyCategoryGetCategory_ ## basename(); \
00144 static NotifyCategory *get_category(); \
00145 }; \
00146 extern NotifyCategoryProxy<NotifyCategoryGetCategory_ ## basename> basename ## _cat;
00147
00148 #endif // WIN32_VC
00149
00150
00151
00152
00153 #define NotifyCategoryDeclNoExport(basename) \
00154 class NotifyCategoryGetCategory_ ## basename { \
00155 public: \
00156 NotifyCategoryGetCategory_ ## basename(); \
00157 static NotifyCategory *get_category(); \
00158 }; \
00159 extern NotifyCategoryProxy<NotifyCategoryGetCategory_ ## basename> basename ## _cat;
00160
00161
00162
00163
00164
00165
00166
00167 #ifdef CPPPARSER
00168 #define NotifyCategoryDefName(basename, actual_name, parent_category)
00169 #define NotifyCategoryDef(basename, parent_category)
00170
00171 #else
00172 #define NotifyCategoryDefName(basename, actual_name, parent_category) \
00173 NotifyCategoryProxy<NotifyCategoryGetCategory_ ## basename> basename ## _cat; \
00174 static NotifyCategoryGetCategory_ ## basename force_init_ ## basename ## _cat; \
00175 NotifyCategoryGetCategory_ ## basename:: \
00176 NotifyCategoryGetCategory_ ## basename() { \
00177 basename ## _cat.init(); \
00178 } \
00179 NotifyCategory *NotifyCategoryGetCategory_ ## basename:: \
00180 get_category() { \
00181 return Notify::ptr()->get_category(string(actual_name), parent_category); \
00182 }
00183 #define NotifyCategoryDef(basename, parent_category) \
00184 NotifyCategoryDefName(basename, #basename, parent_category);
00185
00186 #endif // CPPPARSER
00187
00188
00189 #include "notifyCategoryProxy.I"
00190
00191 #endif