#ifndef __agh_class_func_ptr_H__
#define __agh_class_func_ptr_H__


template <typename _R,
	MSL_PP_COMMA_REPEART_INC(NUM,_CMyuClassFuncPtr_TMPL_ARGS_)>
class CMyuClassFuncPtr##NUM	
{
public:
	class _CDummyBase{}; /* ダミークラス（コンパイラを誤魔化すためだけに・・・ */
	typedef _R (_CDummyBase::*CLASS_FUNC_PTR)(
		MSL_PP_COMMA_REPEART_INC(NUM, _CMyuClassFuncPtr_FUNC_ARGS_));

protected:
	void* m_pInstance;
	CLASS_FUNC_PTR m_pFunc;

public:
	CMyuClassFuncPtr##NUM(){}
	virtual ~CMyuClassFuncPtr##NUM(){}

	void Set(void* pInstance, CLASS_FUNC_PTR pFunc){
		m_pInstance = pInstance;
		m_pFunc = pFunc;
	}

	_R Call(
		MSL_PP_COMMA_REPEART_INC(NUM,_CMyuClassFuncPtr_FUNC_ARGS_) )
	{
		return (((_CDummyBase*)m_pInstance)->*(m_pFunc))(
			MSL_PP_COMMA_REPEART_INC(NUM,_CMyuClassFuncPtr_CALL_ARGS_) ); }	\
};

#define _CMyuClassFuncPtr_0(NUM)	\
	template <typename _R \
		MSL_PP_COMMA_REPEART_INC(NUM,_CMyuClassFuncPtr_TMPL_ARGS_)>	\
	class CMyuClassFuncPtr##NUM		\
	{	\
	public:	\
		class _CDummyBase{}; /* ダミークラス（コンパイラを誤魔化すためだけに・・・ */	\
		typedef _R (_CDummyBase::*CLASS_FUNC_PTR)(	\
			MSL_PP_COMMA_REPEART_INC(NUM, _CMyuClassFuncPtr_FUNC_ARGS_));	\
		\
	protected:	\
		void* m_pInstance;	\
		CLASS_FUNC_PTR m_pFunc;	\
	\
	public:	\
		CMyuClassFuncPtr##NUM(){}	\
		virtual ~CMyuClassFuncPtr##NUM(){}	\
		\
		void Set(void* pInstance, CLASS_FUNC_PTR pFunc){	\
			m_pInstance = pInstance;	\
			m_pFunc = pFunc;	\
		}	\
		\
		_R Call(	\
			MSL_PP_COMMA_REPEART_INC(NUM,_CMyuClassFuncPtr_FUNC_ARGS_) )	\
		{	\
			return (((_CDummyBase*)m_pInstance)->*(m_pFunc))(	\
				MSL_PP_COMMA_REPEART_INC(NUM,_CMyuClassFuncPtr_CALL_ARGS_) ); }	\
	};
	

#endif//__agh_class_func_ptr_H__
