Added Aleksandras' framelayout code, with more or less working Linux Makefiles
General makefiles to be added later. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1876 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
69
utils/framelayout/src/garbagec.h
Normal file
69
utils/framelayout/src/garbagec.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: No names yet.
|
||||
// Purpose: Contrib. demo
|
||||
// Author: Aleksandras Gluchovas (@Lithuania)
|
||||
// Modified by:
|
||||
// Created: ??/10/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Aleksandras Gluchovas
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __GARBAGEC_G__
|
||||
#define __GARBAGEC_G__
|
||||
|
||||
#include "wx/list.h"
|
||||
|
||||
struct GCItem
|
||||
{
|
||||
void* mpObj;
|
||||
wxList mRefs; // references to other nodes
|
||||
};
|
||||
|
||||
inline void* gc_node_to_obj( wxNode* pGCNode )
|
||||
{
|
||||
return ( (GCItem*) (pGCNode->Data()) )->mpObj;
|
||||
}
|
||||
|
||||
// class implements extreamly slow, but probably one of the most simple GC alogrithms
|
||||
|
||||
class GarbageCollector
|
||||
{
|
||||
protected:
|
||||
wxList mAllNodes;
|
||||
wxList mRegularLst;
|
||||
wxList mCycledLst;
|
||||
|
||||
wxNode* FindItemNode( void* pForObj );
|
||||
void ResolveReferences();
|
||||
|
||||
wxNode* FindRefernceFreeItemNode();
|
||||
void RemoveReferencesToNode( wxNode* pItemNode );
|
||||
void DestroyItemList( wxList& lst );
|
||||
|
||||
public:
|
||||
|
||||
GarbageCollector() {}
|
||||
|
||||
virtual ~GarbageCollector();
|
||||
|
||||
// prepare data for GC alg.
|
||||
|
||||
virtual void AddObject( void* pObj, int refCnt = 1 );
|
||||
virtual void AddDependency( void* pObj, void* pDepnedsOnObj );
|
||||
|
||||
// executes GC alg.
|
||||
|
||||
virtual void ArrangeCollection();
|
||||
|
||||
// acces results of the alg.
|
||||
|
||||
wxList& GetRegularObjects();
|
||||
wxList& GetCycledObjects();
|
||||
|
||||
// removes all date form GC
|
||||
|
||||
void Reset();
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user