00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025 #ifndef _LO4CPLUS_NDC_HEADER_
00026 #define _LO4CPLUS_NDC_HEADER_
00027
00028 #include "dcmtk/oflog/config.h"
00029 #include "dcmtk/oflog/tstring.h"
00030 #include "dcmtk/oflog/helpers/lloguser.h"
00031 #include "dcmtk/oflog/helpers/threads.h"
00032
00033
00034
00035 #include "dcmtk/ofstd/ofstack.h"
00036
00037 #if (defined(__MWERKS__) && defined(__MACOS__))
00038 using STD_NAMESPACE size_t;
00039 #endif
00040
00041
00042 namespace log4cplus {
00043
00044 class NDC;
00045 struct DiagnosticContext;
00046 typedef OFStack<DiagnosticContext> DiagnosticContextStack;
00047
00048 #if defined (_MSC_VER)
00049 LOG4CPLUS_EXPORT NDC& getNDC();
00050 #endif
00051
00052
00117 class LOG4CPLUS_EXPORT NDC : protected log4cplus::helpers::LogLogUser {
00118 public:
00127 void clear();
00128
00142 DiagnosticContextStack cloneStack();
00143
00158 void inherit(const DiagnosticContextStack& stack);
00159
00163 log4cplus::tstring get();
00164
00170 size_t getDepth();
00171
00183 log4cplus::tstring pop();
00184
00194 log4cplus::tstring peek();
00195
00206 void push(const log4cplus::tstring& message);
00207
00215 void remove();
00216
00247 void setMaxDepth(size_t maxDepth);
00248
00249
00250 ~NDC();
00251
00252 private:
00253
00254 DiagnosticContextStack* getPtr();
00255
00256
00257 LOG4CPLUS_THREAD_LOCAL_TYPE threadLocal;
00258
00259
00260 NDC();
00261 NDC(const NDC&);
00262 NDC& operator=(const NDC&);
00263
00264
00265 #if defined (_MSC_VER)
00266 friend LOG4CPLUS_EXPORT NDC& getNDC();
00267 #else
00268 friend NDC& getNDC();
00269 #endif
00270 };
00271
00272
00276 LOG4CPLUS_EXPORT NDC& getNDC();
00277
00278
00282 struct LOG4CPLUS_EXPORT DiagnosticContext {
00283
00284 DiagnosticContext(const log4cplus::tstring& message, DiagnosticContext *parent);
00285 DiagnosticContext(const log4cplus::tstring& message);
00286
00287
00288 log4cplus::tstring message;
00289 log4cplus::tstring fullMessage;
00290 };
00291
00292
00297 class LOG4CPLUS_EXPORT NDCContextCreator {
00298 public:
00300 NDCContextCreator(const log4cplus::tstring& msg);
00301
00303 ~NDCContextCreator();
00304 };
00305
00306 }
00307
00308
00309 #endif // _LO4CPLUS_NDC_HEADER_