18#ifndef _LOG4CXX_HELPERS_OBJECT_H
19#define _LOG4CXX_HELPERS_OBJECT_H
27#define DECLARE_LOG4CXX_CLAZZ_OBJECT(object)\
29 class Clazz##object : public helpers::Class\
32 Clazz##object() : helpers::Class() {}\
33 virtual ~Clazz##object() {}\
34 virtual LOG4CXX_NS::LogString getName() const { return LOG4CXX_STR(#object); } \
36 static const helpers::Class& getStaticClass(); \
37 static const LOG4CXX_NS::helpers::ClassRegistration& registerClass();
39#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)\
40 DECLARE_LOG4CXX_CLAZZ_OBJECT(object)\
41 const helpers::Class& getClass() const override;
43#define DECLARE_LOG4CXX_OBJECT(object)\
45 class Clazz##object : public helpers::Class\
48 Clazz##object() : helpers::Class() {}\
49 virtual ~Clazz##object() {}\
50 virtual LOG4CXX_NS::LogString getName() const { return LOG4CXX_STR(#object); } \
51 virtual object* newInstance() const\
56 const helpers::Class& getClass() const override;\
57 static const helpers::Class& getStaticClass(); \
58 static const LOG4CXX_NS::helpers::ClassRegistration& registerClass();
60#define DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
62 const helpers::Class& getClass() const override;\
63 static const helpers::Class& getStaticClass();\
64 static const LOG4CXX_NS::helpers::ClassRegistration& registerClass();
66#define IMPLEMENT_LOG4CXX_OBJECT(object)\
67 const ::LOG4CXX_NS::helpers::Class& object::getClass() const { return getStaticClass(); }\
68 const ::LOG4CXX_NS::helpers::Class& object::getStaticClass() { \
69 static ::LOG4CXX_NS::helpers::WideLife<Clazz##object> theClass; \
72 const LOG4CXX_NS::helpers::ClassRegistration& object::registerClass() { \
73 static ::LOG4CXX_NS::helpers::WideLife<::LOG4CXX_NS::helpers::ClassRegistration> classReg(object::getStaticClass); \
76 namespace LOG4CXX_NS { namespace classes { \
77 const ::LOG4CXX_NS::helpers::ClassRegistration& object##Registration = object::registerClass(); \
81#define IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
82 const LOG4CXX_NS::helpers::Class& object::getClass() const { return getStaticClass(); }\
83 const LOG4CXX_NS::helpers::Class& object::getStaticClass() { \
84 static LOG4CXX_NS::helpers::WideLife<class> theClass; \
87 const LOG4CXX_NS::helpers::ClassRegistration& object::registerClass() { \
88 static LOG4CXX_NS::helpers::WideLife<LOG4CXX_NS::helpers::ClassRegistration> classReg(object::getStaticClass); \
91 namespace LOG4CXX_NS { namespace classes { \
92 const LOG4CXX_NS::helpers::ClassRegistration& object##Registration = object::registerClass(); \
97class AppenderSkeleton;
123template<
typename Ret,
125 bool = std::is_base_of<Ret, helpers::Object>::value,
126 bool = std::is_base_of<Type, helpers::Object>::value>
127std::shared_ptr<Ret>
cast(
const std::shared_ptr<Type>& incoming)
131 return std::shared_ptr<Ret>();
134 Ret* casted =
reinterpret_cast<Ret*
>(
const_cast<void*
>(incoming->cast(Ret::getStaticClass())));
138 return std::shared_ptr<Ret>( incoming, casted );
141 return std::shared_ptr<Ret>();
146#define BEGIN_LOG4CXX_CAST_MAP()\
147 const void * cast(const helpers::Class& clazz) const override\
149 const void * object = 0;\
150 if (&clazz == &helpers::Object::getStaticClass()) return (const helpers::Object *)this;
152#define END_LOG4CXX_CAST_MAP()\
155 bool instanceof(const helpers::Class& clazz) const override\
156 { return cast(clazz) != 0; }
158#define LOG4CXX_CAST_ENTRY(Interface)\
159 if (&clazz == &Interface::getStaticClass()) return (const Interface *)this;
161#define LOG4CXX_CAST_ENTRY2(Interface, interface2)\
162 if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this;
164#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)\
165 object = Interface::cast(clazz);\
166 if (object != 0) return object;
base class for java-like objects.
Definition: object.h:106
virtual const helpers::Class & getClass() const =0
virtual ~Object()
Definition: object.h:108
virtual const void * cast(const Class &clazz) const =0
virtual bool instanceof(const Class &clazz) const =0
std::shared_ptr< Ret > cast(const std::shared_ptr< Type > &incoming)
Attempt to cast one Object to another kind of Object.
Definition: object.h:127
LOG4CXX_PTR_DEF(Appender)
#define DECLARE_LOG4CXX_CLAZZ_OBJECT(object)
Definition: object.h:27