]>
git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/fl/garbagec.h
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 #pragma interface "garbagec.h"
24 wxList mRefs
; // references to other nodes
27 inline void* gc_node_to_obj( wxNode
* pGCNode
)
29 return ( (GCItem
*) (pGCNode
->Data()) )->mpObj
;
33 This class implements an extremely slow but simple garbage collection algorithm.
36 class GarbageCollector
43 // Internal method for finding a node.
44 wxNode
* FindItemNode( void* pForObj
);
46 // Internal method for resolving references.
47 void ResolveReferences();
49 // Internal method for findind and freeing a node.
50 wxNode
* FindReferenceFreeItemNode();
52 // Remove references to this node.
53 void RemoveReferencesToNode( wxNode
* pItemNode
);
55 // Destroys a list of items.
56 void DestroyItemList( wxList
& lst
);
60 // Default constructor.
64 virtual ~GarbageCollector();
66 // Prepare data for garbage collection.
68 virtual void AddObject( void* pObj
, int refCnt
= 1 );
70 // Prepare data for garbage collection.
72 virtual void AddDependency( void* pObj
, void* pDependsOnObj
);
74 // Executes garbage collection algorithm.
76 virtual void ArrangeCollection();
78 // Accesses the results of the algorithm.
80 wxList
& GetRegularObjects();
82 // Get cycled objects.
84 wxList
& GetCycledObjects();
86 // Removes all data from the garbage collector.
91 #endif /* __GARBAGEC_G__ */