source: pacpusframework/trunk/3rd/apache-log4cxx/include/log4cxx/helpers/object.h@ 67

Last change on this file since 67 was 2, checked in by sgosseli, 12 years ago

Add 3rd party libraries (log4cxx).

File size: 5.1 KB
Line 
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_OBJECT_H
19#define _LOG4CXX_HELPERS_OBJECT_H
20
21#include <log4cxx/logstring.h>
22#include <log4cxx/helpers/class.h>
23#include <log4cxx/helpers/objectptr.h>
24#include <log4cxx/helpers/classregistration.h>
25
26
27#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)\
28public:\
29class Clazz##object : public helpers::Class\
30{\
31public:\
32 Clazz##object() : helpers::Class() {}\
33 virtual ~Clazz##object() {}\
34 virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
35};\
36virtual const helpers::Class& getClass() const;\
37static const helpers::Class& getStaticClass(); \
38static const log4cxx::helpers::ClassRegistration& registerClass();
39
40#define DECLARE_LOG4CXX_OBJECT(object)\
41public:\
42class Clazz##object : public helpers::Class\
43{\
44public:\
45 Clazz##object() : helpers::Class() {}\
46 virtual ~Clazz##object() {}\
47 virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
48 virtual helpers::ObjectPtr newInstance() const\
49 {\
50 return new object();\
51 }\
52};\
53virtual const helpers::Class& getClass() const;\
54static const helpers::Class& getStaticClass(); \
55static const log4cxx::helpers::ClassRegistration& registerClass();
56
57#define DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
58public:\
59virtual const helpers::Class& getClass() const;\
60static const helpers::Class& getStaticClass();\
61static const log4cxx::helpers::ClassRegistration& registerClass();
62
63#define IMPLEMENT_LOG4CXX_OBJECT(object)\
64const log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\
65const log4cxx::helpers::Class& object::getStaticClass() { \
66 static Clazz##object theClass; \
67 return theClass; \
68} \
69const log4cxx::helpers::ClassRegistration& object::registerClass() { \
70 static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \
71 return classReg; \
72}\
73namespace log4cxx { namespace classes { \
74const log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \
75} }
76
77
78#define IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
79const log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\
80const log4cxx::helpers::Class& object::getStaticClass() { \
81 static class theClass; \
82 return theClass; \
83} \
84const log4cxx::helpers::ClassRegistration& object::registerClass() { \
85 static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \
86 return classReg; \
87}\
88namespace log4cxx { namespace classes { \
89const log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \
90} }
91
92namespace log4cxx
93{
94 class AppenderSkeleton;
95 class Logger;
96
97 namespace helpers
98 {
99 class Pool;
100
101 /** base class for java-like objects.*/
102 class LOG4CXX_EXPORT Object
103 {
104 public:
105 DECLARE_ABSTRACT_LOG4CXX_OBJECT(Object)
106 virtual ~Object() {}
107 virtual void addRef() const = 0;
108 virtual void releaseRef() const = 0;
109 virtual bool instanceof(const Class& clazz) const = 0;
110 virtual const void * cast(const Class& clazz) const = 0;
111 };
112 LOG4CXX_PTR_DEF(Object);
113 }
114}
115
116#define BEGIN_LOG4CXX_CAST_MAP()\
117const void * cast(const helpers::Class& clazz) const\
118{\
119 const void * object = 0;\
120 if (&clazz == &helpers::Object::getStaticClass()) return (const helpers::Object *)this;
121
122#define END_LOG4CXX_CAST_MAP()\
123 return object;\
124}\
125bool instanceof(const helpers::Class& clazz) const\
126{ return cast(clazz) != 0; }
127
128#define LOG4CXX_CAST_ENTRY(Interface)\
129if (&clazz == &Interface::getStaticClass()) return (const Interface *)this;
130
131#define LOG4CXX_CAST_ENTRY2(Interface, interface2)\
132if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this;
133
134#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)\
135object = Interface::cast(clazz);\
136if (object != 0) return object;
137
138#endif //_LOG4CXX_HELPERS_OBJECT_H
Note: See TracBrowser for help on using the repository browser.