00001 /****************************************************************************** 00002 * 00003 * package: Log4Qt 00004 * file: filter.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_FILTER_H 00026 #define LOG4QT_FILTER_H 00027 00028 00029 /****************************************************************************** 00030 * Dependencies 00031 ******************************************************************************/ 00032 00033 #include "log4qt/helpers/logobject.h" 00034 00035 #include "log4qt/helpers/logobjectptr.h" 00036 #include "log4qt/log4qt.h" 00037 00038 00039 /****************************************************************************** 00040 * Declarations 00041 ******************************************************************************/ 00042 00043 namespace Log4Qt 00044 { 00045 00046 class LoggingEvent; 00047 00054 class Filter : public LogObject 00055 { 00056 Q_OBJECT 00057 00065 Q_PROPERTY(Filter* next READ next WRITE setNext) 00066 00067 public: 00068 enum Decision 00069 { 00070 ACCEPT, 00071 DENY, 00072 NEUTRAL 00073 }; 00074 Q_ENUMS(Decision); 00075 00076 public: 00077 Filter(QObject *pObject = 0); 00078 // Filter(const Filter &rOther); // Use compiler default 00079 virtual ~Filter(); 00080 // Filter &operator=(const Filter &rOther); // Use compiler default 00081 00082 Filter* next() const; 00083 void setNext(Filter *pFilter); 00084 00085 virtual void activateOptions(); 00086 virtual Decision decide(const LoggingEvent &rEvent) const = 0; 00087 00088 private: 00089 LogObjectPtr<Filter> mpNext; 00090 }; 00091 00092 00093 /************************************************************************** 00094 * Operators, Helper 00095 **************************************************************************/ 00096 00097 00098 /************************************************************************** 00099 * Inline 00100 **************************************************************************/ 00101 00102 inline Filter::Filter(QObject *pObject) : 00103 LogObject(pObject), 00104 mpNext(0) 00105 {} 00106 00107 inline Filter::~Filter() 00108 {} 00109 00110 inline Filter* Filter::next() const 00111 { return mpNext; } 00112 00113 inline void Filter::activateOptions() 00114 {} 00115 00116 00117 } // namespace Log4Qt 00118 00119 00120 // Q_DECLARE_TYPEINFO(Log4Qt::Filter, Q_COMPLEX_TYPE); // Use default 00121 Q_DECLARE_TYPEINFO(Log4Qt::LogObjectPtr<Log4Qt::Filter>, Q_MOVABLE_TYPE); 00122 00123 00124 #endif // LOG4QT_FILTER_H