]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/fl/garbagec.h
Fixed a typemap.
[wxWidgets.git] / contrib / include / wx / fl / garbagec.h
CommitLineData
8e08b761
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas (@Lithuania)
5// Modified by:
6// Created: ??/10/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows license
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{
23 void* mpObj;
24 wxList mRefs; // references to other nodes
25};
26
27inline void* gc_node_to_obj( wxNode* pGCNode )
28{
29 return ( (GCItem*) (pGCNode->Data()) )->mpObj;
30}
31
32// class implements extremely slow, but probably one of the most simple GC algorithms
33
34class GarbageCollector
35{
36protected:
37 wxList mAllNodes;
38 wxList mRegularLst;
39 wxList mCycledLst;
40
41 wxNode* FindItemNode( void* pForObj );
42 void ResolveReferences();
43
44 wxNode* FindReferenceFreeItemNode();
45 void RemoveReferencesToNode( wxNode* pItemNode );
46 void DestroyItemList( wxList& lst );
47
48public:
49
50 GarbageCollector() {}
51
52 virtual ~GarbageCollector();
53
54 // prepare data for GC alg.
55
56 virtual void AddObject( void* pObj, int refCnt = 1 );
57 virtual void AddDependency( void* pObj, void* pDependsOnObj );
58
59 // executes GC alg.
60
61 virtual void ArrangeCollection();
62
63 // access results of the alg.
64
65 wxList& GetRegularObjects();
66 wxList& GetCycledObjects();
67
68 // removes all data from GC
69
70 void Reset();
71};
72
73#endif /* __GARBAGEC_G__ */
74