fastdelegate.h.svn-base
来自「ffshow源码」· SVN-BASE 代码 · 共 1,415 行 · 第 1/5 页
SVN-BASE
1,415 行
bool operator ==(const FastDelegate3 &x) const { return m_Closure.IsEqual(x.m_Closure); } bool operator !=(const FastDelegate3 &x) const { return !m_Closure.IsEqual(x.m_Closure); } bool operator <(const FastDelegate3 &x) const { return m_Closure.IsLess(x.m_Closure); } bool operator >(const FastDelegate3 &x) const { return x.m_Closure.IsLess(m_Closure); } // Binding to non-const member functions template < class X, class Y > FastDelegate3(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) { m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } template < class X, class Y > inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) { m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } // Binding to const member functions. template < class X, class Y > FastDelegate3(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) { m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); } template < class X, class Y > inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) { m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); } // Static functions. We convert them into a member function call. // This constructor also provides implicit conversion FastDelegate3(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) { bind(function_to_bind); } // for efficiency, prevent creation of a temporary void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) { bind(function_to_bind); } inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) { m_Closure.bindstaticfunc(this, &FastDelegate3::InvokeStaticFunction, function_to_bind); } // Invoke the delegate RetType operator() (Param1 p1, Param2 p2, Param3 p3) const { return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3); } // Implicit conversion to "bool" using the safe_bool idiomprivate: typedef struct SafeBoolStruct { int a_data_pointer_to_this_is_0_on_buggy_compilers; StaticFunctionPtr m_nonzero; } UselessTypedef; typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;public: operator unspecified_bool_type() const { return empty()? 0: &SafeBoolStruct::m_nonzero; } // necessary to allow ==0 to work despite the safe_bool idiom inline bool operator==(StaticFunctionPtr funcptr) { return m_Closure.IsEqualToStaticFuncPtr(funcptr); } inline bool operator!=(StaticFunctionPtr funcptr) { return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } inline bool operator ! () const { // Is it bound to anything? return !m_Closure; } inline bool empty() const { return !m_Closure; } void clear() { m_Closure.clear();} // Conversion to and from the DelegateMemento storage class const DelegateMemento & GetMemento() { return m_Closure; } void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }private: // Invoker for static functions RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3) const { return (*(m_Closure.GetStaticFunction()))(p1, p2, p3); }};//N=4template<class Param1, class Param2, class Param3, class Param4, class RetType=detail::DefaultVoid>class FastDelegate4 {private: typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType; typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4); typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4); typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4); typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType; ClosureType m_Closure;public: // Typedefs to aid generic programming typedef FastDelegate4 type; // Construction and comparison functions FastDelegate4() { clear(); } FastDelegate4(const FastDelegate4 &x) { m_Closure.CopyFrom(this, x.m_Closure); } void operator = (const FastDelegate4 &x) { m_Closure.CopyFrom(this, x.m_Closure); } bool operator ==(const FastDelegate4 &x) const { return m_Closure.IsEqual(x.m_Closure); } bool operator !=(const FastDelegate4 &x) const { return !m_Closure.IsEqual(x.m_Closure); } bool operator <(const FastDelegate4 &x) const { return m_Closure.IsLess(x.m_Closure); } bool operator >(const FastDelegate4 &x) const { return x.m_Closure.IsLess(m_Closure); } // Binding to non-const member functions template < class X, class Y > FastDelegate4(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) { m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } template < class X, class Y > inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) { m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } // Binding to const member functions. template < class X, class Y > FastDelegate4(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) { m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); } template < class X, class Y > inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) { m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); } // Static functions. We convert them into a member function call. // This constructor also provides implicit conversion FastDelegate4(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) { bind(function_to_bind); } // for efficiency, prevent creation of a temporary void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) { bind(function_to_bind); } inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) { m_Closure.bindstaticfunc(this, &FastDelegate4::InvokeStaticFunction, function_to_bind); } // Invoke the delegate RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const { return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4); } // Implicit conversion to "bool" using the safe_bool idiomprivate: typedef struct SafeBoolStruct { int a_data_pointer_to_this_is_0_on_buggy_compilers; StaticFunctionPtr m_nonzero; } UselessTypedef; typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;public: operator unspecified_bool_type() const { return empty()? 0: &SafeBoolStruct::m_nonzero; } // necessary to allow ==0 to work despite the safe_bool idiom inline bool operator==(StaticFunctionPtr funcptr) { return m_Closure.IsEqualToStaticFuncPtr(funcptr); } inline bool operator!=(StaticFunctionPtr funcptr) { return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } inline bool operator ! () const { // Is it bound to anything? return !m_Closure; } inline bool empty() const { return !m_Closure; } void clear() { m_Closure.clear();} // Conversion to and from the DelegateMemento storage class const DelegateMemento & GetMemento() { return m_Closure; } void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }private: // Invoker for static functions RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const { return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4); }};//N=5template<class Param1, class Param2, class Param3, class Param4, class Param5, class RetType=detail::DefaultVoid>class FastDelegate5 {private: typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType; typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5); typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5); typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5); typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType; ClosureType m_Closure;public: // Typedefs to aid generic programming typedef FastDelegate5 type; // Construction and comparison functions FastDelegate5() { clear(); } FastDelegate5(const FastDelegate5 &x) { m_Closure.CopyFrom(this, x.m_Closure); } void operator = (const FastDelegate5 &x) { m_Closure.CopyFrom(this, x.m_Closure); } bool operator ==(const FastDelegate5 &x) const { return m_Closure.IsEqual(x.m_Closure); } bool operator !=(const FastDelegate5 &x) const { return !m_Closure.IsEqual(x.m_Closure); } bool operator <(const FastDelegate5 &x) const { return m_Closure.IsLess(x.m_Closure); } bool operator >(const FastDelegate5 &x) const { return x.m_Closure.IsLess(m_Closure); } // Binding to non-const member functions template < class X, class Y > FastDelegate5(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) { m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } template < class X, class Y > inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) { m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } // Binding to const member functions. template < class X, class Y > FastDelegate5(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) { m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); } template < class X, class Y > inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) { m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); } // Static functions. We convert them into a member function call. // This constructor also provides implicit conversion FastDelegate5(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) { bind(function_to_bind); } // for efficiency, prevent creation of a temporary void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) { bind(function_to_bind); } inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) { m_Closure.bindstaticfunc(this, &FastDelegate5::InvokeStaticFunction, function_to_bind); } // Invoke the delegate RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const { return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5); } // Implicit conversion to "bool" using the safe_bool idiomprivate: typedef struct SafeBoolStruct { int a_data_pointer_to_this_is_0_on_buggy_compilers; StaticFunctionPtr m_nonzero; } UselessTypedef; typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;public: operator unspecified_bool_type() const { return empty()? 0: &SafeBoolStruct::m_nonzero; } // necessary to allow ==0 to work despite the safe_bool idiom inline bool operator==(StaticFunctionPtr funcptr) { return m_Closure.IsEqualToStaticFuncPtr(funcptr); } inline bool operator!=(StaticFunctionPtr funcptr) { return !m_Closure.IsEqualToStaticFuncPtr(funcptr); } inline bool operator ! () const { // Is it bound to anything? return !m_Closure; } inline bool empty() const { return !m_Closure; } void clear() { m_Closure.clear();} // Conversion to and from the DelegateMemento storage class const DelegateMemento & GetMemento() { return m_Closure; } void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }private: // Invoker for static functions RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const { return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5); }};//N=6template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType=detail::DefaultVoid>class FastDelegate6 {private: typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType; typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6); typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6); typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6); typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType; ClosureType m_Closure;public: // Typedefs to aid generic programming typedef FastDelegate6 type; // Construction and comparison functions FastDelegate6() { clear(); } FastDelegate6(const FastDelegate6 &x) { m_Closure.CopyFrom(this, x.m_Closure); } void operator = (const FastDelegate6 &x) { m_Closure.CopyFrom(this, x.m_Closure); } bool operator ==(const FastDelegate6 &x) const { return m_Closure.IsEqual(x.m_Closure); } bool operator !=(const FastDelegate6 &x) const { return !m_Closure.IsEqual(x.m_Closure); } bool operator <(const FastDelegate6 &x) const { return m_Closure.IsLess(x.m_Closure); } bool operator >(const FastDelegate6 &x) const { return x.m_Closure.IsLess(m_Closure); } // Binding to non-const member functions template < class X, class Y > FastDelegate6(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) { m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } template < class X, class Y > inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) { m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); } // Binding to const member functions. template < class X, class Y > FastDelegate6(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) { m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); } template < class X, class Y > inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) { m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); } // Static functions. We convert them into a member function call. // This constructor also provides implicit conversion FastDelegate6(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) { bind(function_to_bind); } // for efficiency, prevent creation of a temporary void operator =
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?