PikeAero::CObjectList Class Reference

#include <cobjectlist.h>

Inheritance diagram for PikeAero::CObjectList:

Inheritance graph
[legend]
Collaboration diagram for PikeAero::CObjectList:

Collaboration graph
[legend]

Public Member Functions

virtual CObjectListappend (const CObject *object)
CObjectat (CMachine::bit32 n)
 CObjectList ()
CMachine::ubit32 count ()
CMachine::bit32 indexOf (const CObject *object)
virtual CObjectListinsert (const CObject *object, CMachine::bit32 pos)
CObjectListoperator+= (const CObject *object)
CObjectListoperator-= (const CObject *object)
CObjectoperator[] (int n)
virtual CObjectListremove (const CObject *object)
 ~CObjectList ()

Private Attributes

CMachine::bit32 mCount
CObject ** mObjectList

Detailed Description

Implements a list of object pointers.
Author:
Michael Sharkey <mike@pikeaero.com>

Definition at line 31 of file cobjectlist.h.


Constructor & Destructor Documentation

PikeAero::CObjectList::CObjectList (  ) 

TODO - make these list classes templace classes TODO - use const where applicable TODO - test insert at end of list

Definition at line 25 of file cobjectlist.cpp.

00026 : CObject()
00027 , mObjectList(NULL)
00028 , mCount(0)
00029 {
00030 }

PikeAero::CObjectList::~CObjectList (  ) 

Definition at line 33 of file cobjectlist.cpp.

00034 {
00035 }


Member Function Documentation

CObjectList & PikeAero::CObjectList::append ( const CObject object  )  [virtual]

Append an object to the list

Definition at line 54 of file cobjectlist.cpp.

References mCount, mObjectList, and PikeAero::CMemHeap::realloc().

Referenced by PikeAero::CTaskScheduler::append(), PikeAero::CEventQueue::enqueue(), insert(), PikeAero::CEventQueue::installListener(), PikeAero::CMachine::installVectorIRQ(), and operator+=().

00055 {
00056     mObjectList = (CObject**)CMemHeap::realloc( mObjectList, ( mCount + 1 ) * sizeof(CObject*) );
00057     if ( mObjectList != NULL )
00058     {
00059         mObjectList[mCount++] = (CObject*)object;
00060     }
00061     return *this;
00062 }

Here is the call graph for this function:

Here is the caller graph for this function:

CObject* PikeAero::CObjectList::at ( CMachine::bit32  n  )  [inline]

CMachine::ubit32 PikeAero::CObjectList::count (  )  [inline]

CMachine::bit32 PikeAero::CObjectList::indexOf ( const CObject object  ) 

find an object by pointer value and return it's index

Definition at line 38 of file cobjectlist.cpp.

References count(), and mObjectList.

Referenced by PikeAero::CTaskScheduler::append(), PikeAero::CMachine::installVectorIRQ(), and remove().

00039 {
00040     if ( object != NULL )
00041     {
00042         for( CMachine::ubit32 n=0; n < count(); n++ )
00043         {
00044             if ( mObjectList[n] == object )
00045             {
00046                 return n;
00047             }
00048         }
00049     }
00050     return -1;
00051 }

Here is the call graph for this function:

Here is the caller graph for this function:

CObjectList & PikeAero::CObjectList::insert ( const CObject object,
CMachine::bit32  pos 
) [virtual]

Insert an object into the list

Definition at line 77 of file cobjectlist.cpp.

References append(), mCount, memmove, mObjectList, and PikeAero::CMemHeap::realloc().

Referenced by PikeAero::CEventQueue::enqueue().

00078 {
00079     if ( pos < 0 || pos >= mCount )
00080     {
00081         mObjectList = (CObject**)CMemHeap::realloc( mObjectList, ( mCount + 1 ) * sizeof(CObject*) );
00082         memmove( &mObjectList[pos], &mObjectList[pos+1], ((mCount++) - pos) * sizeof(CObject*)  );
00083     }
00084     else
00085     {
00086         return append( object );
00087     }
00088     return *this;
00089 }

Here is the call graph for this function:

Here is the caller graph for this function:

CObjectList& PikeAero::CObjectList::operator+= ( const CObject object  )  [inline]

Definition at line 44 of file cobjectlist.h.

References append().

00044 {return append(object);}

Here is the call graph for this function:

CObjectList& PikeAero::CObjectList::operator-= ( const CObject object  )  [inline]

Definition at line 45 of file cobjectlist.h.

00045 {return remove(object);}

CObject* PikeAero::CObjectList::operator[] ( int  n  )  [inline]

Definition at line 46 of file cobjectlist.h.

References at().

00046 {return at(n);}

Here is the call graph for this function:

CObjectList & PikeAero::CObjectList::remove ( const CObject object  )  [virtual]

Remove an object from the list

Definition at line 65 of file cobjectlist.cpp.

References indexOf(), mCount, memmove, mObjectList, and PikeAero::CMemHeap::realloc().

Referenced by PikeAero::CEventQueue::removeListener(), and PikeAero::CMachine::removeVectorIRQ().

00066 {
00067     CMachine::bit32 i = indexOf( object );
00068     if ( i >= 0 )
00069     {
00070         memmove( &mObjectList[i], &mObjectList[i+1], ( mCount - i ) * sizeof(CObject*) );
00071         mObjectList = (CObject**)CMemHeap::realloc( mObjectList, (mCount--) * sizeof(CObject*) );
00072     }
00073     return *this;
00074 }

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

Definition at line 54 of file cobjectlist.h.

Referenced by append(), count(), insert(), and remove().

Definition at line 53 of file cobjectlist.h.

Referenced by append(), at(), indexOf(), insert(), and remove().


The documentation for this class was generated from the following files:

Generated on Sun Oct 25 14:00:13 2009 for stingray3 by  doxygen 1.5.8