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
00210 void push(const log4cplus::tstring& message);
00211
00221 void remove();
00222
00253 void setMaxDepth(size_t maxDepth);
00254
00255
00256 ~NDC();
00257
00258 private:
00259
00260 DiagnosticContextStack* getPtr();
00261
00262
00263 LOG4CPLUS_THREAD_LOCAL_TYPE threadLocal;
00264
00265
00266 NDC();
00267 NDC(const NDC&);
00268 NDC& operator=(const NDC&);
00269
00270
00271 #if defined (_MSC_VER)
00272 friend LOG4CPLUS_EXPORT NDC& getNDC();
00273 #else
00274 friend NDC& getNDC();
00275 #endif
00276 };
00277
00278
00282 LOG4CPLUS_EXPORT NDC& getNDC();
00283
00284
00288 struct LOG4CPLUS_EXPORT DiagnosticContext {
00289
00290 DiagnosticContext(const log4cplus::tstring& message, DiagnosticContext *parent);
00291 DiagnosticContext(const log4cplus::tstring& message);
00292
00293
00294 log4cplus::tstring message;
00295 log4cplus::tstring fullMessage;
00296 };
00297
00298
00303 class LOG4CPLUS_EXPORT NDCContextCreator {
00304 public:
00306 NDCContextCreator(const log4cplus::tstring& msg);
00307
00309 ~NDCContextCreator();
00310 };
00311
00312 }
00313
00314
00315 #endif // _LO4CPLUS_NDC_HEADER_