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