1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_HELPERS_CLASS_H
19 #define _LOG4CXX_HELPERS_CLASS_H
20 
21 #if defined(_MSC_VER)
22 	#pragma warning (push)
23 	#pragma warning ( disable: 4231 4251 4275 4786 )
24 #endif
25 
26 
27 #include <log4cxx/logstring.h>
28 #include <log4cxx/helpers/objectptr.h>
29 #include <map>
30 
31 namespace log4cxx
32 {
33 namespace helpers
34 {
35 class Object;
36 typedef ObjectPtrT<Object> ObjectPtr;
37 
38 
39 class LOG4CXX_EXPORT Class
40 {
41 	public:
42 		virtual ~Class();
43 		virtual ObjectPtr newInstance() const;
44 		LogString toString() const;
45 		virtual LogString getName() const = 0;
46 		static const Class& forName(const LogString& className);
47 		static bool registerClass(const Class& newClass);
48 
49 	protected:
50 		Class();
51 
52 	private:
53 		Class(const Class&);
54 		Class& operator=(const Class&);
55 		typedef std::map<LogString, const Class*> ClassMap;
56 		static ClassMap& getRegistry();
57 		static void registerClasses();
58 };
59 }  // namespace log4cxx
60 } // namespace helper
61 
62 #if defined(_MSC_VER)
63 	#pragma warning (pop)
64 #endif
65 
66 
67 #endif //_LOG4CXX_HELPERS_CLASS_H
68