#ifndef REFLEX_BUILD
#define REFLEX_BUILD
#endif
#include "Reflex/Builder/UnionBuilder.h"
#include "Reflex/Any.h"
#include "Reflex/Callback.h"
#include "Reflex/Member.h"
#include "DataMember.h"
#include "FunctionMemberTemplateInstance.h"
#include "Union.h"
Reflex::UnionBuilderImpl::UnionBuilderImpl(const char* nam, size_t size, const std::type_info& ti, unsigned int modifiers , TYPE typ )
: fUnion(0)
, fLastMember()
{
std::string nam2(nam);
const Type& c = Type::ByName(nam2);
if (c) {
if (c.IsTypedef()) {
nam2 += " @HIDDEN@";
}
else if (!c.IsClass()) {
throw RuntimeError("Attempt to replace a non-class type with a union");
}
}
fUnion = new Union(nam2.c_str(), size, ti, modifiers, typ);
}
Reflex::UnionBuilderImpl::~UnionBuilderImpl()
{
FireClassCallback(fUnion->ThisType());
}
void Reflex::UnionBuilderImpl::AddItem(const char* nam, const Type& typ)
{
fLastMember = Member(new DataMember(nam, typ, 0, 0));
fUnion->AddDataMember(fLastMember);
}
void Reflex::UnionBuilderImpl::AddDataMember(const char* nam, const Type& typ, size_t offs, unsigned int modifiers )
{
fLastMember = Member(new DataMember(nam, typ, offs, modifiers));
fUnion->AddDataMember(fLastMember);
}
void Reflex::UnionBuilderImpl::AddFunctionMember(const char* nam, const Type& typ, StubFunction stubFP, void* stubCtx , const char* params , unsigned int modifiers )
{
if (Tools::IsTemplated(nam)) {
fLastMember = Member(new FunctionMemberTemplateInstance(nam, typ, stubFP, stubCtx, params, modifiers, *(dynamic_cast<ScopeBase*>(fUnion))));
}
else {
fLastMember = Member(new FunctionMember(nam, typ, stubFP, stubCtx, params, modifiers));
}
fUnion->AddFunctionMember(fLastMember);
}
void Reflex::UnionBuilderImpl::AddProperty(const char* key, const char* value)
{
AddProperty(key, Any(value));
}
void Reflex::UnionBuilderImpl::AddProperty(const char* key, Any value)
{
if (fLastMember) {
fLastMember.Properties().AddProperty(key, value);
}
else {
fUnion->Properties().AddProperty(key, value);
}
}
void Reflex::UnionBuilderImpl::SetSizeOf(size_t size)
{
fUnion->SetSize(size);
}
Reflex::Type Reflex::UnionBuilderImpl::ToType()
{
return fUnion->ThisType();
}
Reflex::UnionBuilder::UnionBuilder(const char* nam, const std::type_info& ti, size_t size, unsigned int modifiers , TYPE typ )
: fUnionBuilderImpl(nam, size, ti, modifiers, typ)
{
}
Reflex::UnionBuilder::~UnionBuilder()
{
}
Reflex::UnionBuilder& Reflex::UnionBuilder::AddItem(const char* nam, const char* typ)
{
fUnionBuilderImpl.AddItem(nam, TypeBuilder(typ));
return *this;
}
Reflex::UnionBuilder& Reflex::UnionBuilder::AddDataMember(const Type& typ, const char* nam, size_t offs, unsigned int modifiers )
{
fUnionBuilderImpl.AddDataMember(nam, typ, offs, modifiers);
return *this;
}
Reflex::UnionBuilder& Reflex::UnionBuilder::AddFunctionMember(const Type& typ, const char* nam, StubFunction stubFP, void* stubCtx, const char* params, unsigned int modifiers)
{
fUnionBuilderImpl.AddFunctionMember(nam, typ, stubFP, stubCtx, params, modifiers);
return *this;
}
Reflex::UnionBuilder& Reflex::UnionBuilder::SetSizeOf(size_t size)
{
fUnionBuilderImpl.SetSizeOf(size);
return *this;
}
Reflex::Type Reflex::UnionBuilder::ToType()
{
return fUnionBuilderImpl.ToType();
}
Last change: Wed Jun 25 08:31:21 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.