20 #ifndef __OpenKarto_MetaClassHelper_h__ 21 #define __OpenKarto_MetaClassHelper_h__ 41 MetaClassHelper(MetaClass& target)
42 : m_pMetaClass(&target)
43 , m_pAttributes(m_pMetaClass)
51 MetaClassHelper<T>& Base()
53 const MetaClass& baseClass = GetMetaClassByType<U>();
56 karto_forEach(List<const MetaClass*>, &m_pMetaClass->m_BaseClasses)
58 assert((*iter)->GetName() != baseName);
61 m_pMetaClass->m_BaseClasses.Add(&baseClass);
69 MetaClassHelper<T>& Attribute(
const karto::String& rAttributeName)
71 return Attribute(rAttributeName,
"");
78 MetaClassHelper<T>& Attribute(
const karto::String& rAttributeName,
const U& rValue)
80 assert(m_pAttributes && !m_pAttributes->HasAttribute(rAttributeName));
82 m_pAttributes->AddAttribute(rAttributeName, rValue);
90 template <
typename F1,
typename F2>
91 MetaClassHelper<T>& Parameter(
const karto::String& rParameterName, F1 accessor1, F2 accessor2)
99 MetaClassHelper<T>& Constructor0()
101 MetaConstructor* pConstructor =
new MetaConstructorImpl0<T>;
102 m_pMetaClass->m_Constructors.Add(pConstructor);
110 template <
typename A0>
111 MetaClassHelper<T>& Constructor1()
113 MetaConstructor* pConstructor =
new MetaConstructorImpl1<T, A0>;
114 m_pMetaClass->m_Constructors.Add(pConstructor);
122 template <
typename A0,
typename A1>
123 MetaClassHelper<T>& Constructor2()
125 MetaConstructor* pConstructor =
new MetaConstructorImpl2<T, A0, A1>;
126 m_pMetaClass->m_Constructors.Add(pConstructor);
132 MetaClass* m_pMetaClass;
133 MetaAttribute* m_pAttributes;
142 #endif // __OpenKarto_MetaClassHelper_h__
#define karto_forEach(listtype, list)