18#ifndef _LOG4CXX_HELPERS_OBJECT_H
19#define _LOG4CXX_HELPERS_OBJECT_H
26#define DECLARE_LOG4CXX_CLAZZ_OBJECT(object)\
28 class Clazz##object : public helpers::Class\
31 Clazz##object() : helpers::Class() {}\
32 virtual ~Clazz##object() {}\
33 virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
35 static const helpers::Class& getStaticClass(); \
36 static const log4cxx::helpers::ClassRegistration& registerClass();
38#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)\
39 DECLARE_LOG4CXX_CLAZZ_OBJECT(object)\
40 const helpers::Class& getClass() const override;
42#define DECLARE_LOG4CXX_OBJECT(object)\
44 class Clazz##object : public helpers::Class\
47 Clazz##object() : helpers::Class() {}\
48 virtual ~Clazz##object() {}\
49 virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
50 virtual object* newInstance() const\
55 const helpers::Class& getClass() const override;\
56 static const helpers::Class& getStaticClass(); \
57 static const log4cxx::helpers::ClassRegistration& registerClass();
59#define DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
61 const helpers::Class& getClass() const override;\
62 static const helpers::Class& getStaticClass();\
63 static const log4cxx::helpers::ClassRegistration& registerClass();
65#define IMPLEMENT_LOG4CXX_OBJECT(object)\
66 const ::log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\
67 const ::log4cxx::helpers::Class& object::getStaticClass() { \
68 static Clazz##object theClass; \
71 const log4cxx::helpers::ClassRegistration& object::registerClass() { \
72 static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \
75 namespace log4cxx { namespace classes { \
76 const ::log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \
80#define IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
81 const log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\
82 const log4cxx::helpers::Class& object::getStaticClass() { \
83 static class theClass; \
86 const log4cxx::helpers::ClassRegistration& object::registerClass() { \
87 static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \
90 namespace log4cxx { namespace classes { \
91 const log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \
96class AppenderSkeleton;
122template<
typename Ret,
124 bool = std::is_base_of<Ret, helpers::Object>::value,
125 bool = std::is_base_of<Type, helpers::Object>::value>
126std::shared_ptr<Ret>
cast(
const std::shared_ptr<Type>& incoming)
130 return std::shared_ptr<Ret>();
133 Ret* casted =
reinterpret_cast<Ret*
>(
const_cast<void*
>(incoming->cast(Ret::getStaticClass())));
137 return std::shared_ptr<Ret>( incoming, casted );
140 return std::shared_ptr<Ret>();
145#define BEGIN_LOG4CXX_CAST_MAP()\
146 const void * cast(const helpers::Class& clazz) const override\
148 const void * object = 0;\
149 if (&clazz == &helpers::Object::getStaticClass()) return (const helpers::Object *)this;
151#define END_LOG4CXX_CAST_MAP()\
154 bool instanceof(const helpers::Class& clazz) const override\
155 { return cast(clazz) != 0; }
157#define LOG4CXX_CAST_ENTRY(Interface)\
158 if (&clazz == &Interface::getStaticClass()) return (const Interface *)this;
160#define LOG4CXX_CAST_ENTRY2(Interface, interface2)\
161 if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this;
163#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)\
164 object = Interface::cast(clazz);\
165 if (object != 0) return object;
base class for java-like objects.
Definition: object.h:105
virtual const helpers::Class & getClass() const =0
virtual ~Object()
Definition: object.h:107
virtual const void * cast(const Class &clazz) const =0
virtual bool instanceof(const Class &clazz) const =0
Definition: configuration.h:25
std::shared_ptr< Ret > cast(const std::shared_ptr< Type > &incoming)
Attempt to cast one Object to another kind of Object.
Definition: object.h:126
#define DECLARE_LOG4CXX_CLAZZ_OBJECT(object)
Definition: object.h:26