4. A B C D E F G H Normal objects in C and C++ are arranged as arrays or vectors in memory
5. CObjects lets you forget about how they are arranged in memory Even though they started out contiguous in memory A B C D E F G H
6.
7. A B C D E F G H Remove B from an Array Element *pElement = new Element;
8. B B->Remove(pList); OR pList->RemoveCObject(B); Remove CObject “B” from a CLinkList “pList” pList A C D E F G H
9. B Add or Append CObject “B” to CLinkList “pList” pList->AppendCObject(B); pList C D E F G H A pList->AddCObject(A);
10. pList C D Prev Next G H A pList->InsertCObject(Prev, A);
11.
12. Allocating a CObject from its CObjectFactory CObjectFactory *pFactory B Other lists A->OnAlloc(); is called Automatically! m_pFreeList m_pUsedList C D E F G H A pFactory->AllocObject()
13. Adding the CObject to a CLinkList CLinkList *pList = CLinkManager::GetSingleton()->CreateLinkList(); m_pUsedList A pList->AddCObject(A); OR pList->AppendCObject(A);
14. Remove a CObject from all lists: A DisplayList TransformList AnimationList m_pUsedList A->Remove(NULL); OR A->Remove(); WARNING: Removes A from its factory’s UsedList
15. CObjectFactory Release a CObject m_pUsedList DisplayList TransformList AnimationList m_pFreeList A A->Release(); A->OnRelease(); is called Automatically!
16.
17.
18.
Editor's Notes
First create a linked list. Then add your CObject to the linked list. Note that the CObject A is already attached to its factory’s used list.