]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/fl/garbagec.h
remove odbc lib to prevent rpm errors about unpackaged files (patch 1151783)
[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
ab7ce33c 15#if defined(__GNUG__) && !defined(__APPLE__)
8e08b761
JS
16 #pragma interface "garbagec.h"
17#endif
18
19#include "wx/list.h"
2b5f62a0 20#include "wx/fl/fldefs.h"
8e08b761
JS
21
22struct GCItem
23{
4cbc57f0
JS
24 void* mpObj;
25 wxList mRefs; // references to other nodes
8e08b761
JS
26};
27
b02a6dc2 28inline void* gc_node_to_obj( wxObjectList::compatibility_iterator pGCNode )
8e08b761 29{
8495ba53 30 return ( (GCItem*) (pGCNode->GetData()) )->mpObj;
8e08b761
JS
31}
32
4cbc57f0
JS
33/*
34This class implements an extremely slow but simple garbage collection algorithm.
35*/
8e08b761 36
510b9edb 37class WXDLLIMPEXP_FL GarbageCollector
8e08b761
JS
38{
39protected:
4cbc57f0
JS
40 wxList mAllNodes;
41 wxList mRegularLst;
42 wxList mCycledLst;
8e08b761 43
4cbc57f0
JS
44 // Internal method for finding a node.
45 wxNode* FindItemNode( void* pForObj );
8e08b761 46
4cbc57f0
JS
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 );
8e08b761
JS
58
59public:
60
4cbc57f0
JS
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.
8e08b761 72
4cbc57f0 73 virtual void AddDependency( void* pObj, void* pDependsOnObj );
8e08b761 74
4cbc57f0 75 // Executes garbage collection algorithm.
8e08b761 76
4cbc57f0 77 virtual void ArrangeCollection();
8e08b761 78
4cbc57f0 79 // Accesses the results of the algorithm.
8e08b761 80
4cbc57f0 81 wxList& GetRegularObjects();
8e08b761 82
4cbc57f0 83 // Get cycled objects.
8e08b761 84
4cbc57f0 85 wxList& GetCycledObjects();
8e08b761 86
4cbc57f0 87 // Removes all data from the garbage collector.
8e08b761 88
4cbc57f0 89 void Reset();
8e08b761
JS
90};
91
92#endif /* __GARBAGEC_G__ */
93