CppDelegate::Internal Namespace Reference

Only for library's internal use. More...


Classes

union  horrible_union
struct  DefaultVoidToVoid
struct  DefaultVoidToVoid< DefaultVoid >
struct  VoidToDefaultVoid
struct  VoidToDefaultVoid< void >
struct  SimplifyMemFunc
struct  SimplifyMemFunc< SINGLE_MEMFUNCPTR_SIZE >
class  DelegateMemento
class  ClosurePtr

Typedefs

typedef void DefaultVoid

Functions

template<class OutputClass, class InputClass>
OutputClass implicit_cast (InputClass input)
template<class OutputClass, class InputClass>
OutputClass horrible_cast (const InputClass input)
template<class Delegate, class FastDelegate>
bool AddFastDelegate (Delegate &delegate, FastDelegate &addable)
template<class Delegate, typename Function>
bool AddFunction (Delegate &delegate, Function function)
template<class Delegate, class Object, typename MemberFunction>
bool AddMemberFunction (Delegate &delegate, Object *object, MemberFunction function)
template<class Delegate, class FastDelegate>
bool RemoveAll (Delegate &delegate, FastDelegate &removable)
template<class Delegate, class FastDelegate>
bool Remove (Delegate &delegate, FastDelegate &removable)
template<class Delegate>
void Clear (Delegate &delegate)

Variables

const int SINGLE_MEMFUNCPTR_SIZE = sizeof(void (GenericClass::*)())


Detailed Description

Only for library's internal use.

Typedef Documentation

typedef void CppDelegate::Internal::DefaultVoid

Definition at line 255 of file Delegate.h.


Function Documentation

template<class Delegate, class FastDelegate>
bool CppDelegate::Internal::AddFastDelegate ( Delegate &  delegate,
FastDelegate &  addable 
) [inline]

Definition at line 1555 of file Delegate.h.

01556                 {
01557                         
01558                         if (!delegate.me)
01559                         {
01560                                 delegate.me = addable;
01561                         }
01562                         else
01563                         {
01564                                 if (delegate.next == NULL)
01565                                 {
01566                                         delegate.next = new Delegate(addable);
01567                                         if (delegate.next == NULL) return false;
01568                                 }
01569                                 else
01570                                 {
01571                                         return delegate.next->Add(addable);
01572                                 }
01573                         }
01574                         
01575                         return true;
01576                         
01577                 } // AddFastDelegate

template<class Delegate, typename Function>
bool CppDelegate::Internal::AddFunction ( Delegate &  delegate,
Function  function 
) [inline]

Definition at line 1579 of file Delegate.h.

01580                 {
01581                         if (!delegate.me)
01582                         {
01583                                 delegate.me.Bind(function);
01584                         }
01585                         else
01586                         {
01587                                 if (delegate.next == NULL)
01588                                 {
01589                                         delegate.next = new Delegate(function);
01590                                         if (delegate.next == NULL) return false;
01591                                 }
01592                                 else
01593                                 {
01594                                         return delegate.next->Add(function);
01595                                 }
01596                         }
01597                         
01598                         return true;
01599                         
01600                 } // AddFunction

template<class Delegate, class Object, typename MemberFunction>
bool CppDelegate::Internal::AddMemberFunction ( Delegate &  delegate,
Object *  object,
MemberFunction  function 
) [inline]

Definition at line 1603 of file Delegate.h.

01604                 {
01605                         if (!delegate.me)
01606                         {
01607                                 delegate.me.Bind(object, function);
01608                         }
01609                         else
01610                         {
01611                                 if (delegate.next == NULL)
01612                                 {
01613                                         delegate.next = new Delegate(object, function);
01614                                         if (delegate.next == NULL) return false;
01615                                 }
01616                                 else
01617                                 {
01618                                         return delegate.next->Add(object, function);
01619                                 }
01620                         }
01621                         
01622                         return true;
01623                         
01624                 } // AddMemberFunction

template<class Delegate>
void CppDelegate::Internal::Clear ( Delegate &  delegate  )  [inline]

Definition at line 1705 of file Delegate.h.

01706                 {
01707                         if (delegate.next != NULL)
01708                         {
01709                                 delegate.next->Clear();
01710                                 delete delegate.next;
01711                                 delegate.next = NULL;
01712                         }
01713                         delegate.me.Clear();
01714                         
01715                 } // Clear

template<class OutputClass, class InputClass>
OutputClass CppDelegate::Internal::horrible_cast ( const InputClass  input  )  [inline]

Definition at line 208 of file Delegate.h.

00208                                                         {
00209         horrible_union<OutputClass, InputClass> u;
00210         // Cause a compile-time error if in, out and u are not the same size.
00211         // If the compile fails here, it means the compiler has peculiar
00212         // unions which would prevent the cast from working.
00213         typedef int ERROR_CantUseHorrible_cast[sizeof(InputClass)==sizeof(u) 
00214                 && sizeof(InputClass)==sizeof(OutputClass) ? 1 : -1];
00215         u.in = input;
00216         return u.out;
00217 }

template<class OutputClass, class InputClass>
OutputClass CppDelegate::Internal::implicit_cast ( InputClass  input  )  [inline]

Definition at line 187 of file Delegate.h.

00187                                                   {
00188         return input;
00189 }

template<class Delegate, class FastDelegate>
bool CppDelegate::Internal::Remove ( Delegate &  delegate,
FastDelegate &  removable 
) [inline]

Definition at line 1675 of file Delegate.h.

01676                 {
01677                         if (removable == delegate.me)
01678                         {
01679                                 if (delegate.next == NULL)
01680                                 {
01681                                         delegate.me.Clear();
01682                                 }
01683                                 else
01684                                 {
01685                                         Delegate *cutOut = delegate.next;
01686                                         
01687                                         delegate.me = cutOut->me;
01688                                         delegate.next = cutOut->next;
01689                                         
01690                                         delete cutOut;
01691                                 }
01692                         }
01693                         else
01694                         {
01695                                 if (delegate.next == NULL)
01696                                         return false;
01697                                 else
01698                                         return delegate.next->Remove(removable);
01699                         }
01700                         
01701                         return true;
01702                         
01703                 } // Remove

template<class Delegate, class FastDelegate>
bool CppDelegate::Internal::RemoveAll ( Delegate &  delegate,
FastDelegate &  removable 
) [inline]

Definition at line 1626 of file Delegate.h.

01627                 {
01628                         if (removable == delegate.me)
01629                         {
01630                                 if (delegate.next == NULL)
01631                                 {
01632                                         delegate.me.Clear();
01633                                 }
01634                                 else
01635                                 {
01636                                         Delegate *cutOut, *cutOutNext = delegate.next;
01637                                         
01638                                         while (cutOutNext->me == removable)
01639                                         {
01640                                                 cutOut = cutOutNext;
01641                                                 cutOutNext = cutOut->next;
01642                                                 
01643                                                 delete cutOut;
01644                                                 
01645                                                 if (cutOutNext == NULL)
01646                                                 {
01647                                                         delegate.next = NULL;
01648                                                         delegate.me.Clear();
01649                                                         return true;
01650                                                 }
01651                                         }
01652                                         
01653                                         delegate.me = cutOutNext->me;
01654                                         delegate.next = cutOutNext->next;
01655                                         
01656                                         delete cutOutNext;
01657                                         
01658                                         if (delegate.next != NULL)
01659                                                 delegate.next->RemoveAll(removable);
01660                                         
01661                                 }
01662                         }
01663                         else
01664                         {
01665                                 if (delegate.next == NULL)
01666                                         return false;
01667                                 else
01668                                         return delegate.next->RemoveAll(removable);
01669                         }
01670                         
01671                         return true;
01672                         
01673                 } // RemoveAll


Variable Documentation

const int CppDelegate::Internal::SINGLE_MEMFUNCPTR_SIZE = sizeof(void (GenericClass::*)())

Definition at line 309 of file Delegate.h.


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