18 #ifndef _LOG4CXX_HELPERS_OBJECT_H 19 #define _LOG4CXX_HELPERS_OBJECT_H 26 #define DECLARE_ABSTRACT_LOG4CXX_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 virtual const helpers::Class& getClass() const;\ 36 static const helpers::Class& getStaticClass(); \ 37 static const log4cxx::helpers::ClassRegistration& registerClass(); 39 #define DECLARE_LOG4CXX_OBJECT(object)\ 41 class Clazz##object : public helpers::Class\ 44 Clazz##object() : helpers::Class() {}\ 45 virtual ~Clazz##object() {}\ 46 virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \ 47 virtual object* newInstance() const\ 52 virtual const helpers::Class& getClass() const;\ 53 static const helpers::Class& getStaticClass(); \ 54 static const log4cxx::helpers::ClassRegistration& registerClass(); 56 #define DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\ 58 virtual const helpers::Class& getClass() const;\ 59 static const helpers::Class& getStaticClass();\ 60 static const log4cxx::helpers::ClassRegistration& registerClass(); 62 #define IMPLEMENT_LOG4CXX_OBJECT(object)\ 63 const ::log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\ 64 const ::log4cxx::helpers::Class& object::getStaticClass() { \ 65 static Clazz##object theClass; \ 68 const log4cxx::helpers::ClassRegistration& object::registerClass() { \ 69 static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \ 72 namespace log4cxx { namespace classes { \ 73 const ::log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \ 77 #define IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\ 78 const log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\ 79 const log4cxx::helpers::Class& object::getStaticClass() { \ 80 static class theClass; \ 83 const log4cxx::helpers::ClassRegistration& object::registerClass() { \ 84 static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \ 87 namespace log4cxx { namespace classes { \ 88 const log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \ 93 class AppenderSkeleton;
106 virtual bool instanceof(
const Class& clazz)
const = 0;
107 virtual const void*
cast(
const Class& clazz)
const = 0;
118 template<
typename Ret,
120 bool = std::is_base_of<Ret, helpers::Object>::value,
121 bool = std::is_base_of<Type, helpers::Object>::value>
122 std::shared_ptr<Ret>
cast(
const std::shared_ptr<Type>& incoming)
126 return std::shared_ptr<Ret>();
129 Ret* casted =
reinterpret_cast<Ret*
>(
const_cast<void*
>(incoming->cast(Ret::getStaticClass())));
133 return std::shared_ptr<Ret>( incoming, casted );
136 return std::shared_ptr<Ret>();
141 #define BEGIN_LOG4CXX_CAST_MAP()\ 142 const void * cast(const helpers::Class& clazz) const\ 144 const void * object = 0;\ 145 if (&clazz == &helpers::Object::getStaticClass()) return (const helpers::Object *)this; 147 #define END_LOG4CXX_CAST_MAP()\ 150 bool instanceof(const helpers::Class& clazz) const\ 151 { return cast(clazz) != 0; } 153 #define LOG4CXX_CAST_ENTRY(Interface)\ 154 if (&clazz == &Interface::getStaticClass()) return (const Interface *)this; 156 #define LOG4CXX_CAST_ENTRY2(Interface, interface2)\ 157 if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this; 159 #define LOG4CXX_CAST_ENTRY_CHAIN(Interface)\ 160 object = Interface::cast(clazz);\ 161 if (object != 0) return object; 163 #endif //_LOG4CXX_HELPERS_OBJECT_H #define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:26
LOG4CXX_PTR_DEF(AppenderAttachableImpl)
base class for java-like objects.
Definition: object.h:101
Definition: appender.h:32
std::shared_ptr< Ret > cast(const std::shared_ptr< Type > &incoming)
Attempt to cast one Object to another kind of Object.
Definition: object.h:122