1 // Module:  Log4CPLUS
 2 // File:    hierarchylocker.h
 3 // Created: 8/2003
 4 // Author:  Tad E. Smith
 5 //
 6 //
 7 // Copyright (C) Tad E. Smith  All rights reserved.
 8 //
 9 // This software is published under the terms of the Apache Software
10 // License version 1.1, a copy of which has been included with this
11 // distribution in the LICENSE.APL file.
12 //
13 
14 /** @file */
15 
16 #ifndef _LOG4CPLUS_HIERARCHY_LOCKER_HEADER_
17 #define _LOG4CPLUS_HIERARCHY_LOCKER_HEADER_
18 
19 #include <log4cplus/hierarchy.h>
20 
21 
22 namespace log4cplus {
23 
24     /**
25      * This is used to lock a Hierarchy.  The dtor unlocks the Hierarchy.
26      */
27     class LOG4CPLUS_EXPORT HierarchyLocker {
28     public:
29       // ctor & dtor
30         HierarchyLocker(Hierarchy& h);
31         ~HierarchyLocker();
32         
33         /**
34          * Calls the <code>resetConfiguration()</code> method on the locked Hierarchy.
35          */
36         void resetConfiguration(); 
37         
38         /**
39          * Calls the <code>getInstance()</code> method on the locked Hierarchy.
40          */
41         Logger getInstance(const log4cplus::tstring& name);
42         
43         /**
44          * Calls the <code>getInstance()</code> method on the locked Hierarchy.
45          */
46         Logger getInstance(const log4cplus::tstring& name, spi::LoggerFactory& factory);
47         
48         void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender);
49         
50     private:
51       // Data
52         Hierarchy& h;
53         log4cplus::thread::Guard hierarchyLocker;
54         LoggerList loggerList;
55     };
56 
57 } // end namespace log4cplus
58 
59 #endif // _LOG4CPLUS_HIERARCHY_LOCKER_HEADER_


syntax highlighted by Code2HTML, v. 0.9.1