]> git.saurik.com Git - wxWidgets.git/blame - utils/framelayout/src/garbagec.h
fixed the bug with the order of 2 size events when the scrollbar[s] (dis)appear in...
[wxWidgets.git] / utils / framelayout / src / garbagec.h
CommitLineData
bd9396d5
HH
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#include "wx/list.h"
16
17struct GCItem
18{
19 void* mpObj;
20 wxList mRefs; // references to other nodes
21};
22
23inline void* gc_node_to_obj( wxNode* pGCNode )
24{
25 return ( (GCItem*) (pGCNode->Data()) )->mpObj;
26}
27
28// class implements extreamly slow, but probably one of the most simple GC alogrithms
29
30class GarbageCollector
31{
32protected:
33 wxList mAllNodes;
34 wxList mRegularLst;
35 wxList mCycledLst;
36
37 wxNode* FindItemNode( void* pForObj );
38 void ResolveReferences();
39
40 wxNode* FindRefernceFreeItemNode();
41 void RemoveReferencesToNode( wxNode* pItemNode );
42 void DestroyItemList( wxList& lst );
43
44public:
45
46 GarbageCollector() {}
47
48 virtual ~GarbageCollector();
49
50 // prepare data for GC alg.
51
52 virtual void AddObject( void* pObj, int refCnt = 1 );
53 virtual void AddDependency( void* pObj, void* pDepnedsOnObj );
54
55 // executes GC alg.
56
57 virtual void ArrangeCollection();
58
59 // acces results of the alg.
60
61 wxList& GetRegularObjects();
62 wxList& GetCycledObjects();
63
64 // removes all date form GC
65
66 void Reset();
67};
68
69#endif