⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boundclasstype_tmpl.hpp

📁 一个实现C++反射机制的类库
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************\*                                                                              **   BoundClassType_tmpl.h                                                                        **                                                                              **   <Purpose of this file>                                                     **                                                                              *\******************************************************************************/// $Id: BoundClassType_tmpl.hpp,v 1.1 2007/10/25 14:05:23 tdevadit Exp $#ifndef REFLCPP_BOUND_CLASS_TYPE_TMPL_HPP#define REFLCPP_BOUND_CLASS_TYPE_TMPL_HPP#include <assert.h>#include <reflcpp/BoundClassType.hpp>#include <reflcpp/macros.hpp>/*------------------------------------------------------------------------------    Forwards (global)                                                         */namespace reflcpp {/*------------------------------------------------------------------------------    Forwards (within namespace)                                               */class BoundDataMember_body;template <typename Obj_T> class ClassType_body_tmpl;template <typename Obj_T> class ClassType_tmpl;class DataMember_body;template <typename Obj_T> class DataMember_body_tmpl1;template <typename Obj_T, typename Val_T> class DataMember_body_tmpl2;template <typename Obj_T, typename Ret_T> class MemberFunction_body_tmpl2;class PtrHolder;template <typename T> class PtrHolder_tmpl;/*-----------------------------------------------------------------------------\|------------------------------------------------------------------------------||                                                                              ||   BoundDataMember_body_tmpl1                                                 ||                                                                              ||------------------------------------------------------------------------------|\------------------------------------------------------------------------------/    <Class comments>-                                                                             */template <typename Obj_T>class BoundDataMember_body_tmpl1 : public BoundDataMember_body {    /*--------------------------------------------------------------------------        Constructors, Initters, Assignments, and Destructors                  */    public:        BoundDataMember_body_tmpl1(Obj_T *o) : m_obj(o) {}	private:	    	    // Disallow these unless specifically allowed.	    BoundDataMember_body_tmpl1(const BoundDataMember_body_tmpl1 &);	    BoundDataMember_body_tmpl1 &operator=(const BoundDataMember_body_tmpl1 &);    /*--------------------------------------------------------------------------        Methods                                                               */    public:        virtual void getPtr(PtrHolder *vph) const = 0;    /*--------------------------------------------------------------------------        Data                                                                  */    protected:        Obj_T *const m_obj;};/*-----------------------------------------------------------------------------\|------------------------------------------------------------------------------||                                                                              ||   BoundDataMember_body_tmpl2                                                 ||                                                                              ||------------------------------------------------------------------------------|\------------------------------------------------------------------------------/    <Class comments>-                                                                             */template <typename Obj_T, typename Val_T>class BoundDataMember_body_tmpl2 : public BoundDataMember_body_tmpl1<Obj_T> {    /*--------------------------------------------------------------------------        Constructors, Initters, Assignments, and Destructors                  */    public:        BoundDataMember_body_tmpl2(Obj_T *o,            const DataMember_body_tmpl2<Obj_T, Val_T> *f)            : BoundDataMember_body_tmpl1<Obj_T>(o), m_field(f) {}	private:	    	    // Disallow these unless specifically allowed.	    BoundDataMember_body_tmpl2(const BoundDataMember_body_tmpl2 &);	    BoundDataMember_body_tmpl2 &operator=(const BoundDataMember_body_tmpl2 &);    /*--------------------------------------------------------------------------        Methods                                                               */        virtual void getPtr(PtrHolder *vph) const;    /*--------------------------------------------------------------------------        Data                                                                  */    private:        // DataMember bodies are static, so this should be okay.        const DataMember_body_tmpl2<Obj_T, Val_T> *const m_field;};template <typename Obj_T, typename Val_T>voidBoundDataMember_body_tmpl2<Obj_T, Val_T>::getPtr(PtrHolder *vph) const {        IXCR_DCDCL(PtrHolder_tmpl<typename Val_T::type> *, vph_t, vph);    assert(vph_t != NULL);    vph_t->ptr = m_field->ptr(this->m_obj);}/*-----------------------------------------------------------------------------\|------------------------------------------------------------------------------||                                                                              ||   BoundMemberFunction_body_tmpl1                                             ||                                                                              ||------------------------------------------------------------------------------|\------------------------------------------------------------------------------/    <Class comments>-                                                                             */template <typename Obj_T>class BoundMemberFunction_body_tmpl1 : public BoundMemberFunction_body {    /*--------------------------------------------------------------------------        Constructors, Initters, Assignments, and Destructors                  */    public:        BoundMemberFunction_body_tmpl1(Obj_T *o) : m_obj(o) {}	private:	    	    // Disallow these unless specifically allowed.	    BoundMemberFunction_body_tmpl1(const BoundMemberFunction_body_tmpl1 &);	    BoundMemberFunction_body_tmpl1 &operator=(const BoundMemberFunction_body_tmpl1 &);    /*--------------------------------------------------------------------------        Data                                                                  */    protected:        Obj_T *const m_obj;};/*-----------------------------------------------------------------------------\|------------------------------------------------------------------------------||                                                                              ||   BoundMemberFunction_body_tmpl2                                             ||                                                                              ||------------------------------------------------------------------------------|\------------------------------------------------------------------------------/    <Class comments>-                                                                             */template <typename Obj_T, typename Ret_T>class BoundMemberFunction_body_tmpl2 : public BoundMemberFunction_body_tmpl1<Obj_T> {    typedef std::vector<PtrHolder *> arg_vector_t;    /*--------------------------------------------------------------------------        Constructors, Initters, Assignments, and Destructors                  */    public:        BoundMemberFunction_body_tmpl2(Obj_T *o,            const MemberFunction_body_tmpl2<Obj_T, Ret_T> *f)            : BoundMemberFunction_body_tmpl1<Obj_T>(o), m_function(f) {}	private:	    	    // Disallow these unless specifically allowed.	    BoundMemberFunction_body_tmpl2(const BoundMemberFunction_body_tmpl2 &);	    BoundMemberFunction_body_tmpl2 &operator=(const BoundMemberFunction_body_tmpl2 &);    /*--------------------------------------------------------------------------        Methods                                                               */        virtual const std::vector<const Type *> &getArguments() const { return m_function->getArguments(); }        virtual void invoke1(RetValHolder &rvh, const int n, Arguments &args) const;    /*--------------------------------------------------------------------------        Data                                                                  */    private:        // MemberFunction bodies are static, so this should be okay.        const MemberFunction_body_tmpl2<Obj_T, Ret_T> *const m_function;};template <typename Obj_T, typename Ret_T>void BoundMemberFunction_body_tmpl2<Obj_T, Ret_T>::invoke1(RetValHolder &rvh, const int n, Arguments &args) const {    m_function->invoke2(this->m_obj, rvh, n, args);}/*-----------------------------------------------------------------------------\|------------------------------------------------------------------------------||                                                                              ||   BoundClassType_body                                                        ||                                                                              ||------------------------------------------------------------------------------|\------------------------------------------------------------------------------/    <Class comments>-                                                                             *//*------------------------------------------------------------------------------    Forwards (only needed by this class)                                      *//*------------------------------------------------------------------------------    Inline Helper Functions and Helper Classes                                */template <typename Obj_T>class BoundClassType_body_tmpl {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -