00001 /****************************************************************************** 00002 * 00003 * package: Log4Qt 00004 * file: levelrangefilter.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_LEVELRANGEFILTER_H 00026 #define LOG4QT_LEVELRANGEFILTER_H 00027 00028 00029 /****************************************************************************** 00030 * Dependencies 00031 ******************************************************************************/ 00032 00033 #include "log4qt/spi/filter.h" 00034 00035 #include "log4qt/level.h" 00036 00037 00038 /****************************************************************************** 00039 * Declarations 00040 ******************************************************************************/ 00041 00042 namespace Log4Qt 00043 { 00044 00052 class LevelRangeFilter : public Filter 00053 { 00054 Q_OBJECT 00055 00063 Q_PROPERTY(bool acceptOnMatch READ acceptOnMatch WRITE setAcceptOnMatch) 00064 00065 00072 Q_PROPERTY(Level levelMax READ levelMax WRITE setLevelMax) 00073 00081 Q_PROPERTY(Level levelMin READ levelMin WRITE setLevelMin) 00082 00083 public: 00084 LevelRangeFilter(QObject *pParent = 0); 00085 // LevelRangeFilter(const LevelRangeFilter &rOther); // Use compiler default 00086 // virtual ~LevelRangeFilter(); // Use compiler default 00087 // LevelRangeFilter &operator=(const LevelRangeFilter &rOther); // Use compiler default 00088 00089 bool acceptOnMatch() const; 00090 Level levelMax() const; 00091 Level levelMin() const; 00092 void setAcceptOnMatch(bool accept); 00093 void setLevelMax(Level level); 00094 void setLevelMin(Level level); 00095 00096 virtual Decision decide(const LoggingEvent &rEvent) const; 00097 00098 protected: 00110 virtual QDebug debug(QDebug &rDebug) const; 00111 00112 private: 00113 bool mAcceptOnMatch; 00114 Level mLevelMin; 00115 Level mLevelMax; 00116 }; 00117 00118 00119 /************************************************************************** 00120 * Operators, Helper 00121 **************************************************************************/ 00122 00123 00124 /************************************************************************** 00125 * Inline 00126 **************************************************************************/ 00127 00128 inline bool LevelRangeFilter::acceptOnMatch() const 00129 { return mAcceptOnMatch; } 00130 00131 inline Level LevelRangeFilter::levelMax() const 00132 { return mLevelMax; } 00133 00134 inline Level LevelRangeFilter::levelMin() const 00135 { return mLevelMin; } 00136 00137 inline void LevelRangeFilter::setAcceptOnMatch(bool accept) 00138 { mAcceptOnMatch = accept; } 00139 00140 inline void LevelRangeFilter::setLevelMax(Level level) 00141 { mLevelMax = level; } 00142 00143 inline void LevelRangeFilter::setLevelMin(Level level) 00144 { mLevelMin = level; } 00145 00146 00147 } // namespace Log4Qt 00148 00149 00150 // Q_DECLARE_TYPEINFO(Log4Qt::LevelRangeFilter, Q_MOVABLE_TYPE); // Use default 00151 00152 00153 #endif // LOG4QT_LEVELRANGEFILTER_H