00001 /****************************************************************************** 00002 * 00003 * package: Log4Qt 00004 * file: ndc.h 00005 * created: September 2007 00006 * author: Martin Heinrich 00007 * 00008 * 00009 * Copyright 2007 Martin Heinrich 00010 * 00011 * Licensed under the Apache License, Version 2.0 (the "License"); 00012 * you may not use this file except in compliance with the License. 00013 * You may obtain a copy of the License at 00014 * 00015 * http://www.apache.org/licenses/LICENSE-2.0 00016 * 00017 * Unless required by applicable law or agreed to in writing, software 00018 * distributed under the License is distributed on an "AS IS" BASIS, 00019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 * See the License for the specific language governing permissions and 00021 * limitations under the License. 00022 * 00023 ******************************************************************************/ 00024 00025 #ifndef LOG4QT_NDC_H 00026 #define LOG4QT_NDC_H 00027 00028 00029 /****************************************************************************** 00030 * Dependencies 00031 ******************************************************************************/ 00032 00033 #include <QtCore/QString> 00034 #include <QtCore/QStack> 00035 #include <QtCore/QThreadStorage> 00036 #include "log4qt/log4qt.h" 00037 00038 00039 /****************************************************************************** 00040 * Declarations 00041 ******************************************************************************/ 00042 00043 namespace Log4Qt 00044 { 00045 00054 class NDC 00055 { 00056 private: 00057 NDC(); 00058 NDC(const NDC &rOther); // Not implemented 00059 // virtual ~NDC(); // Use compiler default 00060 NDC &operator=(const NDC &rOther); // Not implemented 00061 00062 public: 00063 static void clear(); 00064 // JAVA: static QStack<QString> cloneStack(); 00065 // JAVA: static QString get(); 00066 static int depth(); 00067 // JAVA: inherit(Stack stack) 00068 00072 static NDC *instance(); 00073 00074 static QString pop(); 00075 static void push(const QString &rMessage); 00076 // JAVA: static void remove(); // Not required 00077 static void setMaxDepth(int maxDepth); 00078 static QString peek(); 00079 00080 private: 00081 QThreadStorage< QStack<QString> * > mStack; 00082 }; 00083 00084 00085 /****************************************************************************** 00086 * Operators, Helper 00087 ******************************************************************************/ 00088 00089 #ifndef QT_NO_DEBUG_STREAM 00090 00101 QDebug operator<<(QDebug debug, 00102 const NDC &rNDC); 00103 #endif // QT_NO_DEBUG_STREAM 00104 00105 00106 /****************************************************************************** 00107 * Inline 00108 ******************************************************************************/ 00109 00110 inline NDC::NDC() : 00111 mStack() 00112 {} 00113 00114 00115 } // namespace Log4Qt 00116 00117 00118 // Q_DECLARE_TYPEINFO(Log4Qt::NDC, Q_COMPLEX_TYPE); // Use default 00119 00120 00121 #endif // LOG4QT_NDC_H