source: trunk/src/user32/gen_object.h@ 5944

Last change on this file since 5944 was 5935, checked in by sandervl, 24 years ago

reference count (window + class objects) rewrite

File size: 1.7 KB
Line 
1/* $Id: gen_object.h,v 1.6 2001-06-09 14:50:17 sandervl Exp $ */
2/*
3 * Generic Object Class for OS/2
4 *
5 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
6 *
7 */
8#ifndef __GEN_OBJECT_H__
9#define __GEN_OBJECT_H__
10
11#include <heapshared.h>
12#ifdef OS2_INCLUDED
13#include <win32api.h>
14#endif
15
16class GenericObject
17{
18public:
19 GenericObject(GenericObject **head, CRITICAL_SECTION *pLock);
20virtual ~GenericObject();
21
22GenericObject *GetHead() { return *head; };
23GenericObject *GetNext() { return next; };
24
25 void lock() { EnterCriticalSection(pLock); };
26 void unlock() { LeaveCriticalSection(pLock); };
27
28 void link();
29 void unlink();
30
31 LONG addRef() { return InterlockedIncrement(&refCount); };
32 LONG getRefCount() { return refCount; };
33 LONG release();
34
35 void markDeleted() { fDeletePending = TRUE; };
36
37static void lock(CRITICAL_SECTION *pLock) { EnterCriticalSection(pLock); };
38static void unlock(CRITICAL_SECTION *pLock) { LeaveCriticalSection(pLock); };
39
40static void DestroyAll(GenericObject *head);
41
42#ifdef __DEBUG_ALLOC__
43 void *operator new(size_t size, const char *filename, size_t lineno)
44 {
45 return _smalloc(size);
46 }
47 void operator delete(void *location, const char *filename, size_t lineno)
48 {
49 free(location);
50 }
51#else
52 void *operator new(size_t size)
53 {
54 return _smalloc(size);
55 }
56 void operator delete(void *location)
57 {
58 free(location);
59 }
60#endif
61
62private:
63
64protected:
65
66 CRITICAL_SECTION *pLock;
67 LONG refCount;
68 ULONG fLinked : 1,
69 fDeletePending : 1;
70
71 GenericObject **head;
72 GenericObject *next;
73};
74
75#endif
Note: See TracBrowser for help on using the repository browser.