StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarOptionFilter.h
1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _LOG4CXX_VARIA_STAR_OPTION_FILTER_H
18 #define _LOG4CXX_VARIA_STAR_OPTION_FILTER_H
19 
20 #include "StLoggerConfig.h"
21 #include <log4cxx/spi/filter.h>
22 
23 namespace log4cxx
24 {
25  namespace varia
26  {
60  class StarOptionFilter;
61  typedef helpers::ObjectPtrT<StarOptionFilter> StarOptionFilterPtr;
62 
63  class LOG4CXX_EXPORT StarOptionFilter : public spi::Filter
64  {
65  private:
66  static String ACCEPT_REPEAT_COUNTER;
67  static String STRING_TO_COUNT_OPTION;
68  static String TOTAL_MESSAGE_LIMIT;
69 
70  int acceptRepeatCounter;
71  int acceptTotalCounter;
72  mutable int currentRepeatCounter;
73  mutable int currentTotalCounter;
74  mutable String lastLoggerMessageToCompare;
75  bool matchPredefinedStringOnly;
76 
77  public:
78  typedef spi::Filter BASE_CLASS;
79  DECLARE_LOG4CXX_OBJECT(StarOptionFilter)
80  BEGIN_LOG4CXX_CAST_MAP()
81  LOG4CXX_CAST_ENTRY(StarOptionFilter)
82  LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
83  END_LOG4CXX_CAST_MAP()
84 
86 
90  virtual void setOption(const String& option,
91  const String& value);
92 
93  void setRepeatCounterOption(int value);
94  void setTotalCounterOption(int value);
95 
96  inline void setAcceptRepeatCounter(int repeat)
97  { this->acceptRepeatCounter = repeat; }
98 
99  inline int RepeatCounter() const
100  { return acceptRepeatCounter; }
101 
102  inline int TotalCounter() const
103  { return acceptTotalCounter; }
104 
105  inline const String& lastLoggerMessage() const
106  { return lastLoggerMessageToCompare; }
107 
112  FilterDecision decide(const spi::LoggingEventPtr& event) const;
113 }; // class StarOptionFilter
114  } // namespace varia
115 }; // namespace log4cxx
116 
117 #endif // _LOG4CXX_VARIA_STAR_OPTION_FILTER_H