24#ifndef _SB_DELEGATE_H_
25#define _SB_DELEGATE_H_
27#include <Inventor/SbDelegatePtrFunImpl.h>
28#include <Inventor/SbDelegateMemberFunImpl.h>
40template<
typename ReturnType,
typename ArgType>
51 SbDelegate(
const SbDelegate<ReturnType, ArgType>& other )
52 : m_delegateImpl ( other.m_delegateImpl->clone() )
62 SbDelegate(ReturnType (*f)(ArgType))
65 m_delegateImpl =
new inventor::impl::SbDelegatePtrFunImpl<ReturnType, ArgType>(f);
67 m_delegateImpl = NULL;
80 template<
typename ClassType>
81 SbDelegate(ClassType& a, ReturnType (ClassType::*f)(ArgType))
84 m_delegateImpl =
new inventor::impl::SbDelegateMemberFunImpl<ReturnType, ArgType, ClassType>(a, f);
86 m_delegateImpl = NULL;
93 ReturnType operator()(ArgType arg)
const
95 if ( m_delegateImpl.ptr() != NULL )
96 return m_delegateImpl->call(arg);
105 bool equal(ReturnType (*f)(ArgType))
const
107 if ( m_delegateImpl.ptr() == NULL )
110 inventor::impl::SbDelegatePtrFunImpl<ReturnType, ArgType>* delegatePtrFun =
dynamic_cast< inventor::impl::SbDelegatePtrFunImpl<ReturnType, ArgType>*
>(m_delegateImpl.ptr());
111 if ( delegatePtrFun != NULL )
112 return delegatePtrFun->equal(f);
121 template<
typename ClassType>
122 bool equal(ClassType& a, ReturnType (ClassType::*f)(ArgType)) const
124 if ( m_delegateImpl.ptr() == NULL )
127 inventor::impl::SbDelegateMemberFunImpl<ReturnType, ArgType, ClassType>* delegateMemberFun = NULL;
128 delegateMemberFun =
dynamic_cast< inventor::impl::SbDelegateMemberFunImpl<ReturnType, ArgType, ClassType>*
>(m_delegateImpl.ptr());
129 if ( delegateMemberFun != NULL )
130 return delegateMemberFun->equal(a, f);
Smart pointer for any class inheriting SoRefCounter.