1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: GarbageCollector class.
4 // Author: Aleksandras Gluchovas (@Lithuania)
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __GARBAGEC_G__
13 #define __GARBAGEC_G__
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "garbagec.h"
20 #include "wx/fl/fldefs.h"
25 wxList mRefs
; // references to other nodes
28 inline void* gc_node_to_obj( wxObjectList::compatibility_iterator pGCNode
)
30 return ( (GCItem
*) (pGCNode
->GetData()) )->mpObj
;
34 This class implements an extremely slow but simple garbage collection algorithm.
37 class WXDLLIMPEXP_FL GarbageCollector
44 // Internal method for finding a node.
45 wxNode
* FindItemNode( void* pForObj
);
47 // Internal method for resolving references.
48 void ResolveReferences();
50 // Internal method for findind and freeing a node.
51 wxNode
* FindReferenceFreeItemNode();
53 // Remove references to this node.
54 void RemoveReferencesToNode( wxNode
* pItemNode
);
56 // Destroys a list of items.
57 void DestroyItemList( wxList
& lst
);
61 // Default constructor.
65 virtual ~GarbageCollector();
67 // Prepare data for garbage collection.
69 virtual void AddObject( void* pObj
, int refCnt
= 1 );
71 // Prepare data for garbage collection.
73 virtual void AddDependency( void* pObj
, void* pDependsOnObj
);
75 // Executes garbage collection algorithm.
77 virtual void ArrangeCollection();
79 // Accesses the results of the algorithm.
81 wxList
& GetRegularObjects();
83 // Get cycled objects.
85 wxList
& GetCycledObjects();
87 // Removes all data from the garbage collector.
92 #endif /* __GARBAGEC_G__ */