Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# hierarchy.h

Go to the documentation of this file.

    00001 // Module:  Log4CPLUS
    00002 // File:    hierarchy.h
    00003 // Created: 6/2001
    00004 // Author:  Tad E. Smith
    00005 //
    00006 //
    00007 // Copyright (C) Tad E. Smith  All rights reserved.
    00008 //
    00009 // This software is published under the terms of the Apache Software
    00010 // License version 1.1, a copy of which has been included with this
    00011 // distribution in the LICENSE.APL file.
    00012 //
    00013
    00016 #ifndef _LOG4CPLUS_HIERARCHY_HEADER_
    00017 #define _LOG4CPLUS_HIERARCHY_HEADER_
    00018
    00019 #include <log4cplus/config.h>
    00020 #include <log4cplus/logger.h>
    00021 #include <log4cplus/helpers/logloguser.h>
    00022 #include <log4cplus/helpers/pointer.h>
    00023 #include <log4cplus/helpers/threads.h>
    00024 #include <map>
    00025 #include <memory>
    00026 #include <vector>
    00027
    00028
    00029 namespace log4cplus {
    00030     // Forward Declarations
    00031     class HierarchyLocker;
    00032
    00052     class LOG4CPLUS_EXPORT Hierarchy : protected log4cplus::helpers::LogLogUser {
    00053     public:
    00054         // DISABLE_OFF should be set to a value lower than all possible
    00055         // priorities.
    00056         static const LogLevel DISABLE_OFF;
    00057         static const LogLevel DISABLE_OVERRIDE;
    00058
    00059       // Ctors
    00065         Hierarchy();
    00066
    00067       // Dtor
    00068         virtual ~Hierarchy();
    00069
    00070       // Methods
    00079         virtual void clear();
    00080
    00087         virtual bool exists(const log4cplus::tstring& name);
    00088
    00093         virtual void disable(const log4cplus::tstring& loglevelStr);
    00094
    00114         virtual void disable(LogLevel ll);
    00115
    00121         virtual void disableAll();
    00122
    00128         virtual void disableDebug();
    00129
    00135         virtual void disableInfo();
    00136
    00144         virtual void enableAll();
    00145
    00156         virtual Logger getInstance(const log4cplus::tstring& name);
    00157
    00170         virtual Logger getInstance(const log4cplus::tstring& name, spi::LoggerFactory& factory);
    00171
    00177         virtual LoggerList getCurrentLoggers();
    00178
    00182         virtual bool isDisabled(int level);
    00183
    00187         virtual Logger getRoot() const;
    00188
    00202         virtual void resetConfiguration();
    00203
    00207         virtual void setLoggerFactory(std::auto_ptr<spi::LoggerFactory> factory);
    00208
    00212         virtual spi::LoggerFactory* getLoggerFactory() { return defaultFactory.get(); }
    00213
    00227         virtual void shutdown();
    00228
    00229     private:
    00230       // Types
    00231         typedef std::vector<Logger> ProvisionNode;
    00232         typedef std::map<log4cplus::tstring, ProvisionNode> ProvisionNodeMap;
    00233         typedef std::map<log4cplus::tstring, Logger> LoggerMap;
    00234
    00235       // Methods
    00240         virtual Logger getInstanceImpl(const log4cplus::tstring& name,
    00241                                        spi::LoggerFactory& factory);
    00242
    00247         virtual void initializeLoggerList(LoggerList& list) const;
    00248
    00269         void updateParents(Logger logger);
    00270
    00285         void updateChildren(ProvisionNode& pn, Logger logger);
    00286
    00287     // Data
    00288        LOG4CPLUS_MUTEX_PTR_DECLARE hashtable_mutex;
    00289        std::auto_ptr<spi::LoggerFactory> defaultFactory;
    00290        ProvisionNodeMap provisionNodes;
    00291        LoggerMap loggerPtrs;
    00292        Logger root;
    00293
    00294        int disableValue;
    00295
    00296        bool emittedNoAppenderWarning;
    00297        bool emittedNoResourceBundleWarning;
    00298
    00299      // Disallow copying of instances of this class
    00300        Hierarchy(const Hierarchy&);
    00301        Hierarchy& operator=(const Hierarchy&);
    00302
    00303     // Friends
    00304        friend class log4cplus::spi::LoggerImpl;
    00305        friend class log4cplus::HierarchyLocker;
    00306     };
    00307
    00308 } // end namespace log4cplus
    00309
    00310 #endif // _LOG4CPLUS_HIERARCHY_HEADER_
    00311