#ifndef Reflex_ClassBuilder
#define Reflex_ClassBuilder
#include "Reflex/Kernel.h"
#include "Reflex/Tools.h"
#include "Reflex/Builder/TypeBuilder.h"
#include "Reflex/Member.h"
#include "Reflex/Callback.h"
namespace Reflex {
class Class;
class RFLX_API ClassBuilderImpl {
public:
ClassBuilderImpl(const char* nam, const std::type_info& ti, size_t size, unsigned int modifiers = 0, TYPE typ = CLASS);
virtual ~ClassBuilderImpl();
void AddBase(const Type& bas, OffsetFunction offsFP, unsigned int modifiers = 0);
void AddDataMember(const char* nam, const Type& typ, size_t offs, unsigned int modifiers = 0);
void AddFunctionMember(const char* nam, const Type& typ, StubFunction stubFP, void* stubCtx = 0, const char* params = 0, unsigned int modifiers = 0);
void AddTypedef(const Type& typ, const char* def);
void AddEnum(const char* nam, const char* values, const std::type_info* ti, unsigned int modifiers = 0);
void AddProperty(const char* key, Any value);
void AddProperty(const char* key, const char* value);
void SetSizeOf(size_t size);
Type ToType();
private:
Class * fClass;
Member fLastMember;
};
class RFLX_API ClassBuilder {
public:
ClassBuilder(const char* nam, const std::type_info& ti, size_t size, unsigned int modifiers = 0, TYPE typ = CLASS);
virtual ~ClassBuilder();
template <class C, class B> ClassBuilder& AddBase(unsigned int modifiers = 0);
ClassBuilder& AddBase(const Type& bas, OffsetFunction offsFP, unsigned int modifiers = 0);
template <class T> ClassBuilder& AddDataMember(const char* nam, size_t offs, unsigned int modifiers = 0);
ClassBuilder& AddDataMember(const Type& typ, const char* nam, size_t offs, unsigned int modifiers = 0);
template <class F> ClassBuilder& AddFunctionMember(const char* nam, StubFunction stubFP, void* stubCtx = 0, const char* params = 0, unsigned int modifiers = 0);
ClassBuilder& AddFunctionMember(const Type& typ, const char* nam, StubFunction stubFP, void* stubCtx = 0, const char* params = 0, unsigned int modifiers = 0);
template <typename TD> ClassBuilder& AddTypedef(const char* def);
ClassBuilder& AddTypedef( const Type& typ, const char* def);
ClassBuilder& AddTypedef(const char* typ, const char* def);
template <typename E> ClassBuilder& AddEnum(const char* values, unsigned int modifiers = 0);
ClassBuilder& AddEnum(const char* nam, const char* values, const std::type_info* ti = 0, unsigned int modifiers = 0);
template <typename P> ClassBuilder& AddProperty(const char* key, P value);
ClassBuilder & SetSizeOf(size_t size);
Type ToType();
private:
ClassBuilderImpl fClassBuilderImpl;
};
template < class C >
class ClassBuilderT {
public:
ClassBuilderT( unsigned int modifiers = 0,
TYPE typ = CLASS );
ClassBuilderT( const char* nam,
unsigned int modifiers = 0,
TYPE typ = CLASS );
template < class B >
ClassBuilderT & AddBase( unsigned int modifiers = 0 );
ClassBuilderT & AddBase( const Type & bas,
OffsetFunction offsFP,
unsigned int modifiers = 0 );
template < class T >
ClassBuilderT & AddDataMember( const char * nam,
size_t offs,
unsigned int modifiers = 0 );
ClassBuilderT & AddDataMember( const Type & typ,
const char * nam,
size_t offs,
unsigned int modifiers = 0 );
template < class F >
ClassBuilderT & AddFunctionMember( const char * nam,
StubFunction stubFP,
void * stubCtx = 0,
const char * params = 0,
unsigned int modifiers = 0 );
ClassBuilderT & AddFunctionMember( const Type & typ,
const char * nam,
StubFunction stubFP,
void * stubCtx = 0,
const char * params = 0,
unsigned int modifiers = 0 );
template < typename TD >
ClassBuilderT & AddTypedef( const char * def );
ClassBuilderT & AddTypedef( const Type & typ,
const char * def );
ClassBuilderT & AddTypedef( const char * typ,
const char * def );
template < typename E >
ClassBuilderT & AddEnum( const char * values,
unsigned int modifiers = 0 );
ClassBuilderT & AddEnum( const char * nam,
const char * values,
const std::type_info * ti = 0,
unsigned int modifiers = 0 );
template < typename P >
ClassBuilderT & AddProperty( const char * key,
P value );
ClassBuilderT & SetSizeOf(size_t size);
Type ToType();
private:
ClassBuilderImpl fClassBuilderImpl;
};
}
template<typename C, typename B> inline Reflex::ClassBuilder& Reflex::ClassBuilder::AddBase(unsigned int modifiers)
{
fClassBuilderImpl.AddBase(GetType<B>(), BaseOffset<C,B>::Get(), modifiers);
return *this;
}
template<typename T> inline Reflex::ClassBuilder& Reflex::ClassBuilder::AddDataMember(const char* nam, size_t offs, unsigned int modifiers)
{
fClassBuilderImpl.AddDataMember(nam, TypeDistiller<T>::Get(), offs, modifiers);
return *this;
}
template <typename F> inline Reflex::ClassBuilder& Reflex::ClassBuilder::AddFunctionMember(const char* nam, StubFunction stubFP, void* stubCtx, const char* params, unsigned int modifiers)
{
fClassBuilderImpl.AddFunctionMember(nam, FunctionDistiller<F>::Get(), stubFP, stubCtx, params, modifiers);
return *this;
}
template <typename TD> inline Reflex::ClassBuilder& Reflex::ClassBuilder::AddTypedef(const char* def)
{
fClassBuilderImpl.AddTypedef(TypeDistiller<TD>::Get(), def);
return *this;
}
template <typename E> inline Reflex::ClassBuilder& Reflex::ClassBuilder::AddEnum(const char* values, unsigned int modifiers)
{
fClassBuilderImpl.AddEnum(Tools::Demangle(typeid(E)).c_str(), values, & typeid(E), modifiers);
return *this;
}
template <typename P> inline Reflex::ClassBuilder& Reflex::ClassBuilder::AddProperty(const char* key, P value)
{
fClassBuilderImpl.AddProperty(key , value);
return *this;
}
template <typename C> inline Reflex::ClassBuilderT<C>::ClassBuilderT(unsigned int modifiers, TYPE typ)
: fClassBuilderImpl(Tools::Demangle(typeid(C)).c_str(), typeid(C), sizeof(C), modifiers, typ)
{
}
template <class C> inline Reflex::ClassBuilderT<C>::ClassBuilderT(const char* nam, unsigned int modifiers, TYPE typ)
: fClassBuilderImpl(nam, typeid(C), sizeof(C), modifiers, typ)
{
}
template <typename C> template<typename B> inline Reflex::ClassBuilderT<C>& Reflex::ClassBuilderT<C>::AddBase(unsigned int modifiers)
{
fClassBuilderImpl.AddBase(GetType<B>(), BaseOffset<C,B>::Get(), modifiers);
return *this;
}
template <class C> inline Reflex::ClassBuilderT<C>& Reflex::ClassBuilderT<C>::AddBase(const Type& bas, OffsetFunction offsFP, unsigned int modifiers)
{
fClassBuilderImpl.AddBase(bas, offsFP, modifiers);
return *this;
}
template <class C> template<class T> inline Reflex::ClassBuilderT<C>& Reflex::ClassBuilderT<C>::AddDataMember(const char* nam, size_t offs, unsigned int modifiers)
{
fClassBuilderImpl.AddDataMember(nam, TypeDistiller<T>::Get(), offs, modifiers);
return *this;
}
template <class C> inline Reflex::ClassBuilderT<C>& Reflex::ClassBuilderT<C>::AddDataMember(const Type& typ, const char* nam, size_t offs, unsigned int modifiers)
{
fClassBuilderImpl.AddDataMember(nam, typ, offs, modifiers);
return *this;
}
template <typename C> template <typename F> inline Reflex::ClassBuilderT<C>& Reflex::ClassBuilderT<C>::AddFunctionMember(const char* nam, StubFunction stubFP, void* stubCtx, const char* params, unsigned int modifiers)
{
fClassBuilderImpl.AddFunctionMember(nam, FunctionDistiller<F>::Get(), stubFP, stubCtx, params, modifiers);
return *this;
}
template < class C >
inline Reflex::ClassBuilderT<C> &
Reflex::ClassBuilderT<C>::AddFunctionMember( const Type & typ,
const char * nam,
StubFunction stubFP,
void * stubCtx,
const char * params,
unsigned int modifiers )
{
fClassBuilderImpl.AddFunctionMember( nam,
typ,
stubFP,
stubCtx,
params,
modifiers );
return * this;
}
template < class C > template < typename TD >
inline Reflex::ClassBuilderT<C> &
Reflex::ClassBuilderT<C>::AddTypedef( const char * def ) {
fClassBuilderImpl.AddTypedef( TypeDistiller<TD>::Get(),
def );
return * this;
}
template < class C >
inline Reflex::ClassBuilderT<C> &
Reflex::ClassBuilderT<C>::AddTypedef( const char * typ,
const char * def ) {
fClassBuilderImpl.AddTypedef( TypeBuilder( typ ),
def );
return * this;
}
template < class C >
inline Reflex::ClassBuilderT<C> &
Reflex::ClassBuilderT<C>::AddTypedef( const Type & typ,
const char * def ) {
fClassBuilderImpl.AddTypedef( typ,
def );
return * this;
}
template < class C > template < typename E >
inline Reflex::ClassBuilderT<C> &
Reflex::ClassBuilderT<C>::AddEnum( const char * values,
unsigned int modifiers ) {
fClassBuilderImpl.AddEnum( Tools::Demangle(typeid(E)).c_str(),
values,
& typeid(E),
modifiers );
return * this;
}
template < class C >
inline Reflex::ClassBuilderT<C> &
Reflex::ClassBuilderT<C>::AddEnum( const char * nam,
const char * values,
const std::type_info * ti,
unsigned int modifiers ) {
fClassBuilderImpl.AddEnum( nam,
values,
ti,
modifiers );
return * this;
}
template < class C > template < class P >
inline Reflex::ClassBuilderT<C> &
Reflex::ClassBuilderT<C>::AddProperty( const char * key,
P value )
{
fClassBuilderImpl.AddProperty(key , value);
return * this;
}
template < class C >
inline Reflex::ClassBuilderT<C> &
Reflex::ClassBuilderT<C>::SetSizeOf(size_t size) {
fClassBuilderImpl.SetSizeOf(size);
return *this;
}
template < class C > inline Reflex::Type
Reflex::ClassBuilderT<C>::ToType() {
return fClassBuilderImpl.ToType();
}
#endif // Reflex_ClassBuilder
Last change: Wed Jun 25 08:31:12 2008
Last generated: 2008-06-25 08:31
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.