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

Last change on this file since 6502 was 5950, checked in by sandervl, 24 years ago

bugfixes

File size: 1.7 KB
Line 
1/* $Id: gen_object.h,v 1.7 2001-06-10 09:19:57 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#ifdef DEBUG
32 LONG addRef();
33#else
34 LONG addRef() { return InterlockedIncrement(&refCount); };
35#endif
36 LONG getRefCount() { return refCount; };
37 LONG release();
38
39 void markDeleted() { fDeletePending = TRUE; };
40
41static void lock(CRITICAL_SECTION *pLock) { EnterCriticalSection(pLock); };
42static void unlock(CRITICAL_SECTION *pLock) { LeaveCriticalSection(pLock); };
43
44static void DestroyAll(GenericObject *head);
45
46#ifdef __DEBUG_ALLOC__
47 void *operator new(size_t size, const char *filename, size_t lineno)
48 {
49 return _smalloc(size);
50 }
51 void operator delete(void *location, const char *filename, size_t lineno)
52 {
53 free(location);
54 }
55#else
56 void *operator new(size_t size)
57 {
58 return _smalloc(size);
59 }
60 void operator delete(void *location)
61 {
62 free(location);
63 }
64#endif
65
66private:
67
68protected:
69
70 CRITICAL_SECTION *pLock;
71 LONG refCount;
72 ULONG fLinked : 1,
73 fDeletePending : 1;
74
75 GenericObject **head;
76 GenericObject *next;
77};
78
79#endif
Note: See TracBrowser for help on using the repository browser.