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)
124 Ret* casted =
reinterpret_cast<Ret*
>(
const_cast<void*
>(incoming->cast(Ret::getStaticClass())));
128 return std::shared_ptr<Ret>( incoming, casted );
131 return std::shared_ptr<Ret>();
136 #define BEGIN_LOG4CXX_CAST_MAP()\ 137 const void * cast(const helpers::Class& clazz) const\ 139 const void * object = 0;\ 140 if (&clazz == &helpers::Object::getStaticClass()) return (const helpers::Object *)this; 142 #define END_LOG4CXX_CAST_MAP()\ 145 bool instanceof(const helpers::Class& clazz) const\ 146 { return cast(clazz) != 0; } 148 #define LOG4CXX_CAST_ENTRY(Interface)\ 149 if (&clazz == &Interface::getStaticClass()) return (const Interface *)this; 151 #define LOG4CXX_CAST_ENTRY2(Interface, interface2)\ 152 if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this; 154 #define LOG4CXX_CAST_ENTRY_CHAIN(Interface)\ 155 object = Interface::cast(clazz);\ 156 if (object != 0) return object; 158 #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