00001 /* 00002 * Filter.cpp 00003 * 00004 * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved. 00005 * Copyright 2001, Bastiaan Bakker. All rights reserved. 00006 * 00007 * See the COPYING file for the terms of usage and distribution. 00008 */ 00009 00010 #include "PortabilityImpl.hh" 00011 #include <log4cpp/Filter.hh> 00012 00013 namespace log4cpp { 00014 00015 Filter::Filter() : 00016 _chainedFilter(NULL) { 00017 } 00018 00019 Filter::~Filter() { 00020 if (_chainedFilter) 00021 delete _chainedFilter; 00022 } 00023 00024 void Filter::setChainedFilter(Filter* filter) { 00025 if (filter != _chainedFilter) { 00026 if (_chainedFilter) 00027 delete _chainedFilter; 00028 00029 _chainedFilter = filter; 00030 } 00031 } 00032 00033 Filter* Filter::getChainedFilter() { 00034 return _chainedFilter; 00035 } 00036 00037 Filter* Filter::getEndOfChain() { 00038 Filter* end = this; 00039 while(end->getChainedFilter()) { 00040 end = end->getChainedFilter(); 00041 } 00042 return end; 00043 } 00044 00045 void Filter::appendChainedFilter(Filter* filter) { 00046 Filter* end = getEndOfChain(); 00047 end->setChainedFilter(filter); 00048 } 00049 00050 Filter::Decision Filter::decide(const LoggingEvent& event) { 00051 Filter::Decision decision = _decide(event); 00052 00053 if ((Filter::NEUTRAL == decision) && getChainedFilter()) { 00054 decision = getChainedFilter()->decide(event); 00055 } 00056 00057 return decision; 00058 } 00059 00060 }