]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/fl/garbagec.h
build fix for latest C++ standard
[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
8e08b761 15#include "wx/list.h"
2b5f62a0 16#include "wx/fl/fldefs.h"
8e08b761
JS
17
18struct GCItem
19{
4cbc57f0
JS
20 void* mpObj;
21 wxList mRefs; // references to other nodes
8e08b761
JS
22};
23
b02a6dc2 24inline void* gc_node_to_obj( wxObjectList::compatibility_iterator pGCNode )
8e08b761 25{
8495ba53 26 return ( (GCItem*) (pGCNode->GetData()) )->mpObj;
8e08b761
JS
27}
28
4cbc57f0
JS
29/*
30This class implements an extremely slow but simple garbage collection algorithm.
31*/
8e08b761 32
510b9edb 33class WXDLLIMPEXP_FL GarbageCollector
8e08b761
JS
34{
35protected:
4cbc57f0
JS
36 wxList mAllNodes;
37 wxList mRegularLst;
38 wxList mCycledLst;
8e08b761 39
4cbc57f0
JS
40 // Internal method for finding a node.
41 wxNode* FindItemNode( void* pForObj );
8e08b761 42
4cbc57f0
JS
43 // Internal method for resolving references.
44 void ResolveReferences();
45
46 // Internal method for findind and freeing a node.
47 wxNode* FindReferenceFreeItemNode();
48
49 // Remove references to this node.
50 void RemoveReferencesToNode( wxNode* pItemNode );
51
52 // Destroys a list of items.
53 void DestroyItemList( wxList& lst );
8e08b761
JS
54
55public:
56
4cbc57f0
JS
57 // Default constructor.
58 GarbageCollector() {}
59
60 // Destructor.
61 virtual ~GarbageCollector();
62
63 // Prepare data for garbage collection.
64
65 virtual void AddObject( void* pObj, int refCnt = 1 );
66
67 // Prepare data for garbage collection.
8e08b761 68
4cbc57f0 69 virtual void AddDependency( void* pObj, void* pDependsOnObj );
8e08b761 70
4cbc57f0 71 // Executes garbage collection algorithm.
8e08b761 72
4cbc57f0 73 virtual void ArrangeCollection();
8e08b761 74
4cbc57f0 75 // Accesses the results of the algorithm.
8e08b761 76
4cbc57f0 77 wxList& GetRegularObjects();
8e08b761 78
4cbc57f0 79 // Get cycled objects.
8e08b761 80
4cbc57f0 81 wxList& GetCycledObjects();
8e08b761 82
4cbc57f0 83 // Removes all data from the garbage collector.
8e08b761 84
4cbc57f0 85 void Reset();
8e08b761
JS
86};
87
88#endif /* __GARBAGEC_G__ */
89