FunctionBuilder.h

Go to the documentation of this file.
00001 // @(#)root/reflex:$Id: FunctionBuilder.h 29288 2009-07-01 13:03:35Z axel $
00002 // Author: Stefan Roiser 2004
00003 
00004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved.
00005 //
00006 // Permission to use, copy, modify, and distribute this software for any
00007 // purpose is hereby granted without fee, provided that this copyright and
00008 // permissions notice appear in all copies and derivatives.
00009 //
00010 // This software is provided "as is" without express or implied warranty.
00011 
00012 #ifndef Reflex_FunctionBuilder
00013 #define Reflex_FunctionBuilder
00014 
00015 // Include files
00016 #include "Reflex/Reflex.h"
00017 
00018 namespace Reflex {
00019 // forward declarations
00020 class FunctionMember;
00021 class Type;
00022 
00023 /**
00024  * @class FunctionBuilder FunctionBuilder.h Reflex/Builder/FunctionBuilder.h
00025  * @author Pere Mato
00026  * @date 1/8/2004
00027  * @ingroup RefBld
00028  */
00029 class RFLX_API FunctionBuilder {
00030 public:
00031    /** constructor */
00032    FunctionBuilder(const Type &typ,
00033                    const char* nam,
00034                    StubFunction stubFP,
00035                    void* stubCtx,
00036                    const char* params,
00037                    unsigned char modifiers);
00038 
00039 
00040    /** destructor */
00041    virtual ~FunctionBuilder();
00042 
00043 
00044    /** AddProperty will add a property
00045     * @param  key the property key
00046     * @param  value the value of the property
00047     * @return a reference to the building class
00048     */
00049    FunctionBuilder& AddProperty(const char* key,
00050                                 Any value);
00051    FunctionBuilder& AddProperty(const char* key,
00052                                 const char* value);
00053 
00054 
00055    /**
00056     * ToMember will return the member currently being built
00057     * @return member currently being built
00058     */
00059    Member ToMember();
00060 
00061 private:
00062    /** function member */
00063    Member fFunction;
00064 
00065 };    // class FunctionBuilder
00066 
00067 
00068 /**
00069  * @class FunctionBuilderImpl FunctionBuilder.h Reflex/Builder/FunctionBuilder.h
00070  * @author Pere Mato
00071  * @date 3/8/2004
00072  * @ingroup RefBld
00073  */
00074 class RFLX_API FunctionBuilderImpl {
00075 public:
00076    /** constructor */
00077    FunctionBuilderImpl(const char* nam,
00078                        const Type &typ,
00079                        StubFunction stubFP,
00080                        void* stubCtx,
00081                        const char* params,
00082                        unsigned char modifiers = 0);
00083 
00084 
00085    /** destructor */
00086    ~FunctionBuilderImpl();
00087 
00088 
00089    /** AddProperty will add a property
00090     * @param  key the property key
00091     * @param  value the value of the property
00092     * @return a reference to the building class
00093     */
00094    void AddProperty(const char* key,
00095                     Any value);
00096    void AddProperty(const char* key,
00097                     const char* value);
00098 
00099 
00100    /**
00101     * ToMember will return the member currently being built
00102     * @return member currently being built
00103     */
00104    Member ToMember();
00105 
00106 private:
00107    /** function member being built */
00108    Member fFunction;
00109 
00110 };    // class FunctionBuilderImpl
00111 
00112 
00113 /**
00114  * @class FunctionBuilderT FunctionBuilder.h Reflex/Builder/FunctionBuilder.h
00115  * @author Pere Mato
00116  * @date 1/8/2004
00117  * @ingroup RefBld
00118  */
00119 template <typename F> class FunctionBuilderT {
00120 public:
00121    /** constructor */
00122    FunctionBuilderT(const char* nam,
00123                     StubFunction stubFP,
00124                     void* stubCtx,
00125                     const char* params,
00126                     unsigned char modifiers);
00127 
00128    /** destructor */
00129    virtual ~FunctionBuilderT() {}
00130 
00131 
00132    /** AddProperty will add a property
00133     * @param  key the property key
00134     * @param  value the value of the property
00135     * @return a reference to the building class
00136     */
00137    template <typename P>
00138    FunctionBuilderT& AddProperty(const char* key,
00139                                  P value);
00140 
00141 
00142    /**
00143     * ToMember will return the member currently being built
00144     * @return member currently being built
00145     */
00146    Member ToMember();
00147 
00148 private:
00149    /** function builder implemenation */
00150    FunctionBuilderImpl fFunctionBuilderImpl;
00151 
00152 };    //class FunctionBuilderT
00153 
00154 } // namespace Reflex
00155 
00156 #include "Reflex/Builder/TypeBuilder.h"
00157 
00158 //-------------------------------------------------------------------------------
00159 template <typename  F>
00160 inline Reflex::FunctionBuilderT<F>::FunctionBuilderT(const char* nam,
00161                                                      StubFunction stubFP,
00162                                                      void* stubCtx,
00163                                                      const char* params,
00164                                                      unsigned char modifiers)
00165 //-------------------------------------------------------------------------------
00166    : fFunctionBuilderImpl(nam,
00167                           FunctionDistiller<F>::Get(),
00168                           stubFP,
00169                           stubCtx,
00170                           params,
00171                           modifiers) {
00172 }
00173 
00174 
00175 //-------------------------------------------------------------------------------
00176 template <typename F> template <typename P>
00177 inline Reflex::FunctionBuilderT<F>&
00178 Reflex::FunctionBuilderT<F
00179 >::AddProperty(const char* key,
00180                P value) {
00181 //-------------------------------------------------------------------------------
00182    fFunctionBuilderImpl.AddProperty(key, value);
00183    return *this;
00184 }
00185 
00186 
00187 //-------------------------------------------------------------------------------
00188 template <typename F> inline Reflex::Member
00189 Reflex::FunctionBuilderT<F
00190 >::ToMember() {
00191 //-------------------------------------------------------------------------------
00192    return fFunctionBuilderImpl.ToMember();
00193 }
00194 
00195 
00196 #endif // Reflex_FunctionBuilder

Generated on Tue Jul 5 14:25:48 2011 for ROOT_528-00b_version by  doxygen 1.5.1