log4cplus  2.0.0
appenderattachableimpl.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Module:  Log4CPLUS
00003 // File:    appenderattachableimpl.h
00004 // Created: 6/2001
00005 // Author:  Tad E. Smith
00006 //
00007 //
00008 // Copyright 2001-2015 Tad E. Smith
00009 //
00010 // Licensed under the Apache License, Version 2.0 (the "License");
00011 // you may not use this file except in compliance with the License.
00012 // You may obtain a copy of the License at
00013 //
00014 //     http://www.apache.org/licenses/LICENSE-2.0
00015 //
00016 // Unless required by applicable law or agreed to in writing, software
00017 // distributed under the License is distributed on an "AS IS" BASIS,
00018 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019 // See the License for the specific language governing permissions and
00020 // limitations under the License.
00021 
00024 #ifndef LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_
00025 #define LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_
00026 
00027 #include <log4cplus/config.hxx>
00028 
00029 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
00030 #pragma once
00031 #endif
00032 
00033 #include <log4cplus/tstring.h>
00034 #include <log4cplus/helpers/pointer.h>
00035 #include <log4cplus/spi/appenderattachable.h>
00036 #include <log4cplus/thread/syncprims.h>
00037 
00038 #include <memory>
00039 #include <vector>
00040 
00041 
00042 namespace log4cplus {
00043     namespace helpers {
00044  
00048         class LOG4CPLUS_EXPORT AppenderAttachableImpl 
00049             : public log4cplus::spi::AppenderAttachable
00050         {
00051         public:
00052           // Data
00053             thread::Mutex appender_list_mutex;
00054 
00055           // Ctors
00056             AppenderAttachableImpl();
00057 
00058           // Dtor
00059             virtual ~AppenderAttachableImpl();
00060 
00061           // Methods
00066             virtual void addAppender(SharedAppenderPtr newAppender);
00067 
00071             virtual SharedAppenderPtrList getAllAppenders();
00072 
00079             virtual SharedAppenderPtr getAppender(const log4cplus::tstring& name);
00080 
00084             virtual void removeAllAppenders();
00085 
00089             virtual void removeAppender(SharedAppenderPtr appender);
00090 
00095             virtual void removeAppender(const log4cplus::tstring& name);
00096 
00100             int appendLoopOnAppenders(const spi::InternalLoggingEvent& event) const;
00101 
00102         protected:
00103           // Types
00104             typedef std::vector<SharedAppenderPtr> ListType;
00105 
00106           // Data
00108             ListType appenderList;
00109 
00110         private:
00111             AppenderAttachableImpl(AppenderAttachableImpl const &);
00112             AppenderAttachableImpl & operator = (AppenderAttachableImpl const &);
00113         };  // end class AppenderAttachableImpl
00114 
00115     } // end namespace helpers
00116 } // end namespace log4cplus
00117 
00118 #endif // LOG4CPLUS_HELPERS_APPENDER_ATTACHABLE_IMPL_HEADER_
00119