📄 classbuilder.h
字号:
// @(#)root/reflex:$Name: $:$Id: ClassBuilder.h,v 1.11 2006/09/14 14:39:12 roiser Exp $// Author: Stefan Roiser 2004// Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved.//// Permission to use, copy, modify, and distribute this software for any// purpose is hereby granted without fee, provided that this copyright and// permissions notice appear in all copies and derivatives.//// This software is provided "as is" without express or implied warranty.#ifndef ROOT_Reflex_ClassBuilder#define ROOT_Reflex_ClassBuilder// Include files#include "Reflex/Kernel.h"#include "Reflex/Tools.h"#include "Reflex/Builder/TypeBuilder.h"#include "Reflex/Member.h"#include "Reflex/Callback.h"namespace ROOT { namespace Reflex { // forward declarations class Class; /** * @class ClassBuilderImpl ClassBuilder.h Reflex/Builder/ClassBuilder.h * @author Stefan Roiser * @date 30/3/2004 * @ingroup RefBld */ class RFLX_API ClassBuilderImpl { public: /** constructor */ ClassBuilderImpl( const char * nam, const std::type_info & ti, size_t size, unsigned int modifiers = 0, TYPE typ = CLASS ); /** destructor */ virtual ~ClassBuilderImpl(); /** * AddBase will add the information about one BaseAt class * @param Name of the BaseAt class * @param OffsetFP function pointer for Offset calculation * @param modifiers the modifiers of the class */ void AddBase( const Type & bas, OffsetFunction offsFP, unsigned int modifiers = 0 ); /** AddDataMember will add the information about one data * MemberAt of the class * * @param Name of the data MemberAt * @param At of the data MemberAt * @param Offset of the data MemberAt * @param modifiers the modifiers of the data MemberAt */ void AddDataMember( const char * nam, const Type & typ, size_t offs, unsigned int modifiers = 0 ); /** AddFunctionMember will add the information about one * function MemberAt of the class * * @param Name of the function MemberAt * @param At of the function MemberAt * @param stubFP Stub function pointer for the function * @param stubCxt Stub user context for the stub function * @param params pamater names and default values (semi-colon separated) * @param modifiers the modifiers of the data MemberAt */ 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 addUnion( const char * nam, // const char * values, // const std::type_info & ti, // unsigned int modifiers = 0 ); /** AddProperty will add a PropertyNth to the PropertyNth stack * which will be emtpied with the next call of a builder * class and attached to the item built with this call * * @param key the PropertyNth key * @param value the value of the PropertyNth */ void AddProperty( const char * key, Any value ); void AddProperty( const char * key, const char * value ); private: /** current class being built */ Class * fClass; /** last added MemberAt */ Member fLastMember; }; // class ClassBuilderImpl /** * @class ClassBuilder ClassBuilder.h Reflex/Builder/ClassBuilder.h * @author Stefan Roiser * @date 24/5/2004 * @ingroup RefBld */ class RFLX_API ClassBuilder { public: /** constructor */ ClassBuilder( const char * nam, const std::type_info & ti, size_t size, unsigned int modifiers = 0, TYPE typ = CLASS ); /** destructor */ virtual ~ClassBuilder() {} /** * AddBase will add the information about one BaseAt class * @param Name of the BaseAt class * @param OffsetFP function pointer for Offset calculation * @param modifiers the modifiers of the class */ template < class C, class B > ClassBuilder & AddBase( unsigned int modifiers = 0 ); ClassBuilder & AddBase( const Type & bas, OffsetFunction offsFP, unsigned int modifiers = 0 ); /** AddDataMember will add the information about one data * MemberAt of the class * * @param Name of the data MemberAt * @param Offset of data MemberAt * @param modifiers the modifiers of the data MemberAt * @return a reference to the ClassBuilder */ 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 ); /** AddFunctionMember will add the information about one * function MemberAt of the class * * @param Name of the function MemberAt * @param function templated function MemberAt to extract At information * @param stubFP Stub function pointer for the function * @param stubCxt Stub user context for the stub function * @param params pamater names and default values (semi-colon separated) * @param modifiers the modifiers of the data MemberAt * @return a reference to the ClassBuilder */ 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 ); //ClassBuilder & addUnion( const char * nam, // const char * values, // unsigned int modifiers ); /** AddProperty will add a PropertyNth to the last defined * data MemberAt, method or class. * @param key the PropertyNth key * @param value the value of the PropertyNth * @return a reference to the building class */ template < typename P > ClassBuilder & AddProperty( const char * key, P value ); private: ClassBuilderImpl fClassBuilderImpl; }; // class ClassBuilder /** * @class ClassBuilderT ClassBuilder.h Reflex/Builder/ClassBuilder.h * @author Stefan Roiser * @date 30/3/2004 * @ingroup RefBld */ template < class C > class ClassBuilderT { public: /** constructor */ ClassBuilderT( unsigned int modifiers = 0, TYPE typ = CLASS ); /** constructor */ ClassBuilderT( const char* nam, unsigned int modifiers = 0, TYPE typ = CLASS ); /** * AddBase will add the information about one BaseAt class * @param Name of the BaseAt class * @param OffsetFP function pointer for Offset calculation * @param modifiers the modifiers of the class */ template < class B > ClassBuilderT & AddBase( unsigned int modifiers = 0 ); ClassBuilderT & AddBase( const Type & bas, OffsetFunction offsFP, unsigned int modifiers = 0 ); /** AddDataMember will add the information about one data * MemberAt of the class * * @param Name of the data MemberAt * @param Offset of data MemberAt * @param modifiers the modifiers of the data MemberAt * @return a reference to the ClassBuilderT */ 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 ); /** AddFunctionMember will add the information about one * function MemberAt of the class * * @param Name of the function MemberAt * @param function templated function MemberAt to extract At information * @param stubFP Stub function pointer for the function * @param stubCxt Stub user context for the stub function * @param params pamater names and default values (semi-colon separated) * @param modifiers the modifiers of the data MemberAt * @return a reference to the ClassBuilder */ 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 );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -