]> git.saurik.com Git - wxWidgets.git/blame_incremental - contrib/include/wx/fl/garbagec.h
Source cleaning: whitespaces, tabs, TRUE/true, FALSE/false, -1/wxID_ANY/wxDefaultCoor...
[wxWidgets.git] / contrib / include / wx / fl / garbagec.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: garbagec.h
3// Purpose: GarbageCollector class.
4// Author: Aleksandras Gluchovas (@Lithuania)
5// Modified by:
6// Created: ??/10/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __GARBAGEC_G__
13#define __GARBAGEC_G__
14
15#if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "garbagec.h"
17#endif
18
19#include "wx/list.h"
20#include "wx/fl/fldefs.h"
21
22struct GCItem
23{
24 void* mpObj;
25 wxList mRefs; // references to other nodes
26};
27
28inline void* gc_node_to_obj( wxObjectList::compatibility_iterator pGCNode )
29{
30 return ( (GCItem*) (pGCNode->GetData()) )->mpObj;
31}
32
33/*
34This class implements an extremely slow but simple garbage collection algorithm.
35*/
36
37class WXDLLIMPEXP_FL GarbageCollector
38{
39protected:
40 wxList mAllNodes;
41 wxList mRegularLst;
42 wxList mCycledLst;
43
44 // Internal method for finding a node.
45 wxNode* FindItemNode( void* pForObj );
46
47 // Internal method for resolving references.
48 void ResolveReferences();
49
50 // Internal method for findind and freeing a node.
51 wxNode* FindReferenceFreeItemNode();
52
53 // Remove references to this node.
54 void RemoveReferencesToNode( wxNode* pItemNode );
55
56 // Destroys a list of items.
57 void DestroyItemList( wxList& lst );
58
59public:
60
61 // Default constructor.
62 GarbageCollector() {}
63
64 // Destructor.
65 virtual ~GarbageCollector();
66
67 // Prepare data for garbage collection.
68
69 virtual void AddObject( void* pObj, int refCnt = 1 );
70
71 // Prepare data for garbage collection.
72
73 virtual void AddDependency( void* pObj, void* pDependsOnObj );
74
75 // Executes garbage collection algorithm.
76
77 virtual void ArrangeCollection();
78
79 // Accesses the results of the algorithm.
80
81 wxList& GetRegularObjects();
82
83 // Get cycled objects.
84
85 wxList& GetCycledObjects();
86
87 // Removes all data from the garbage collector.
88
89 void Reset();
90};
91
92#endif /* __GARBAGEC_G__ */
93