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__
16 #include "wx/fl/fldefs.h"
21 wxList mRefs
; // references to other nodes
24 inline void* gc_node_to_obj( wxObjectList::compatibility_iterator pGCNode
)
26 return ( (GCItem
*) (pGCNode
->GetData()) )->mpObj
;
30 This class implements an extremely slow but simple garbage collection algorithm.
33 class WXDLLIMPEXP_FL GarbageCollector
40 // Internal method for finding a node.
41 wxNode
* FindItemNode( void* pForObj
);
43 // Internal method for resolving references.
44 void ResolveReferences();
46 // Internal method for findind and freeing a node.
47 wxNode
* FindReferenceFreeItemNode();
49 // Remove references to this node.
50 void RemoveReferencesToNode( wxNode
* pItemNode
);
52 // Destroys a list of items.
53 void DestroyItemList( wxList
& lst
);
57 // Default constructor.
61 virtual ~GarbageCollector();
63 // Prepare data for garbage collection.
65 virtual void AddObject( void* pObj
, int refCnt
= 1 );
67 // Prepare data for garbage collection.
69 virtual void AddDependency( void* pObj
, void* pDependsOnObj
);
71 // Executes garbage collection algorithm.
73 virtual void ArrangeCollection();
75 // Accesses the results of the algorithm.
77 wxList
& GetRegularObjects();
79 // Get cycled objects.
81 wxList
& GetCycledObjects();
83 // Removes all data from the garbage collector.
88 #endif /* __GARBAGEC_G__ */