CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr > Class Template Reference

#include <Delegate.h>

Inherits CppDelegate::Internal::DelegateMemento.

List of all members.

Public Member Functions

template<class X, class XMemFunc>
void bindmemfunc (X *pthis, XMemFunc function_to_bind)
template<class X, class XMemFunc>
void bindconstmemfunc (const X *pthis, XMemFunc function_to_bind)
GenericClass * GetClosureThis () const
GenericMemFunc GetClosureMemPtr () const
template<class DerivedClass>
void CopyFrom (DerivedClass *pParent, const DelegateMemento &right)
template<class DerivedClass, class ParentInvokerSig>
void bindstaticfunc (DerivedClass *pParent, ParentInvokerSig static_function_invoker, StaticFuncPtr function_to_bind)
UnvoidStaticFuncPtr GetStaticFunction () const
bool IsEqualToStaticFuncPtr (StaticFuncPtr funcptr)
void Clear ()
bool IsEqual (const DelegateMemento &x) const
bool IsLess (const DelegateMemento &right) const
bool operator! () const
bool Empty () const
bool operator< (const DelegateMemento &right)
bool operator> (const DelegateMemento &right)

Protected Types

typedef void(Internal::GenericClass::*) GenericMemFuncType ()

Protected Member Functions

void SetMementoFrom (const DelegateMemento &right)

Protected Attributes

Internal::GenericClass * m_pthis
GenericMemFuncType m_pFunction


Detailed Description

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
class CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >

Definition at line 536 of file Delegate.h.


Member Typedef Documentation

typedef void(Internal::GenericClass::*) CppDelegate::Internal::DelegateMemento::GenericMemFuncType() [protected, inherited]

Definition at line 435 of file Delegate.h.


Member Function Documentation

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
template<class X, class XMemFunc>
void CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >::bindmemfunc ( X *  pthis,
XMemFunc  function_to_bind 
) [inline]

Definition at line 544 of file Delegate.h.

00544                                                                       {
00545                 m_pthis = SimplifyMemFunc< sizeof(function_to_bind) >
00546                         ::Convert(pthis, function_to_bind, m_pFunction);
00547 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00548                 m_pStaticFunction = 0;
00549 #endif
00550         }

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
template<class X, class XMemFunc>
void CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >::bindconstmemfunc ( const X *  pthis,
XMemFunc  function_to_bind 
) [inline]

Definition at line 556 of file Delegate.h.

00556                                                                                 {
00557                 m_pthis= SimplifyMemFunc< sizeof(function_to_bind) >
00558                         ::Convert(const_cast<X*>(pthis), function_to_bind, m_pFunction);
00559 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00560                 m_pStaticFunction = 0;
00561 #endif
00562         }

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
GenericClass* CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >::GetClosureThis (  )  const [inline]

Definition at line 573 of file Delegate.h.

00573 { return m_pthis; }

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
GenericMemFunc CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >::GetClosureMemPtr (  )  const [inline]

Definition at line 574 of file Delegate.h.

00574 { return reinterpret_cast<GenericMemFunc>(m_pFunction); }

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
template<class DerivedClass>
void CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >::CopyFrom ( DerivedClass *  pParent,
const DelegateMemento right 
) [inline]

Definition at line 631 of file Delegate.h.

00631                                                                                    {
00632                 SetMementoFrom(right);
00633         }

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
template<class DerivedClass, class ParentInvokerSig>
void CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >::bindstaticfunc ( DerivedClass *  pParent,
ParentInvokerSig  static_function_invoker,
StaticFuncPtr  function_to_bind 
) [inline]

Definition at line 639 of file Delegate.h.

00640                                                                 {
00641                 if (function_to_bind==0) { // cope with assignment to 0
00642                         m_pFunction=0;
00643                 } else { 
00644                    // We'll be ignoring the 'this' pointer, but we need to make sure we pass
00645                    // a valid value to bindmemfunc().
00646                         bindmemfunc(pParent, static_function_invoker);
00647         }
00648 
00649                 // WARNING! Evil hack. We store the function in the 'this' pointer!
00650                 // Ensure that there's a compilation failure if function pointers 
00651                 // and data pointers have different sizes.
00652                 // If you get this error, you need to #undef FASTDELEGATE_USESTATICFUNCTIONHACK.
00653                 typedef int ERROR_CantUseEvilMethod[sizeof(GenericClass *)==sizeof(function_to_bind) ? 1 : -1];
00654                 m_pthis = horrible_cast<GenericClass *>(function_to_bind);
00655                 // MSVC, SunC++ and DMC accept the following (non-standard) code:
00656                 // m_pthis = static_cast<GenericClass *>(static_cast<void *>(function_to_bind));
00657                 // BCC32, Comeau and DMC accept this method. MSVC7.1 needs __int64 instead of long
00658                 // m_pthis = reinterpret_cast<GenericClass *>(reinterpret_cast<long>(function_to_bind));
00659         }

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
UnvoidStaticFuncPtr CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >::GetStaticFunction (  )  const [inline]

Definition at line 664 of file Delegate.h.

00664                                                              {
00665                 // Ensure that there's a compilation failure if function pointers 
00666                 // and data pointers have different sizes.
00667                 // If you get this error, you need to #undef FASTDELEGATE_USESTATICFUNCTIONHACK.
00668                 typedef int ERROR_CantUseEvilMethod[sizeof(UnvoidStaticFuncPtr)==sizeof(this) ? 1 : -1];
00669                 return horrible_cast<UnvoidStaticFuncPtr>(this);
00670         }

template<class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
bool CppDelegate::Internal::ClosurePtr< GenericMemFunc, StaticFuncPtr, UnvoidStaticFuncPtr >::IsEqualToStaticFuncPtr ( StaticFuncPtr  funcptr  )  [inline]

Definition at line 674 of file Delegate.h.

00674                                                                  {
00675                 if (funcptr==0) return Empty(); 
00676         // For the Evil method, if it doesn't actually contain a static function, this will return an arbitrary
00677         // value that is not equal to any valid function pointer.
00678                 else return funcptr==reinterpret_cast<StaticFuncPtr>(GetStaticFunction());
00679         }

void CppDelegate::Internal::DelegateMemento::Clear (  )  [inline, inherited]

Definition at line 452 of file Delegate.h.

00452 {       m_pthis=0; m_pFunction=0;       }

bool CppDelegate::Internal::DelegateMemento::IsEqual ( const DelegateMemento x  )  const [inline, inherited]

Definition at line 465 of file Delegate.h.

00465                                                             {
00466                 return m_pthis==x.m_pthis && m_pFunction==x.m_pFunction;
00467         }

bool CppDelegate::Internal::DelegateMemento::IsLess ( const DelegateMemento right  )  const [inline, inherited]

Definition at line 470 of file Delegate.h.

00470                                                                {
00471                 // deal with static function pointers first
00472 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00473                 if (m_pStaticFunction !=0 || right.m_pStaticFunction!=0) 
00474                                 return m_pStaticFunction < right.m_pStaticFunction;
00475 #endif
00476                 if (m_pthis !=right.m_pthis) return m_pthis < right.m_pthis;
00477         // There are no ordering operators for member function pointers, 
00478         // but we can fake one by comparing each byte. The resulting ordering is
00479         // arbitrary (and compiler-dependent), but it permits storage in ordered STL containers.
00480                 return memcmp(&m_pFunction, &right.m_pFunction, sizeof(m_pFunction)) < 0;
00481 
00482         }

bool CppDelegate::Internal::DelegateMemento::operator! (  )  const [inline, inherited]

Definition at line 486 of file Delegate.h.

00487         { return m_pthis==0 && m_pFunction==0; }

bool CppDelegate::Internal::DelegateMemento::Empty (  )  const [inline, inherited]

Definition at line 488 of file Delegate.h.

00489         { return m_pthis==0 && m_pFunction==0; }

bool CppDelegate::Internal::DelegateMemento::operator< ( const DelegateMemento right  )  [inline, inherited]

Definition at line 495 of file Delegate.h.

00495                                                              {
00496                 return IsLess(right);
00497         }

bool CppDelegate::Internal::DelegateMemento::operator> ( const DelegateMemento right  )  [inline, inherited]

Definition at line 498 of file Delegate.h.

00498                                                              {
00499                 return right.IsLess(*this);
00500         }

void CppDelegate::Internal::DelegateMemento::SetMementoFrom ( const DelegateMemento right  )  [inline, protected, inherited]

Definition at line 508 of file Delegate.h.

00508                                                            {
00509                 m_pFunction = right.m_pFunction;
00510                 m_pthis = right.m_pthis;
00511 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00512                 m_pStaticFunction = right.m_pStaticFunction;
00513 #endif
00514         }


Member Data Documentation

Internal::GenericClass* CppDelegate::Internal::DelegateMemento::m_pthis [protected, inherited]

Definition at line 436 of file Delegate.h.

GenericMemFuncType CppDelegate::Internal::DelegateMemento::m_pFunction [protected, inherited]

Definition at line 437 of file Delegate.h.


The documentation for this class was generated from the following file:
Generated on Sat Sep 15 23:41:51 2007 for AVR C++ Lib (common) by  doxygen 1.5.2
SourceForge.net Logo MTÜ TTÜ Robotiklubi