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