source: trunk/src/user32/gen_object.h

Last change on this file was 10587, checked in by sandervl, 21 years ago

KSO: Update

File size: 1.7 KB
Line 
1/* $Id: gen_object.h,v 1.8 2004-04-20 10:11:42 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#include <VMutex.h>
16
17class GenericObject
18{
19public:
20 GenericObject(GenericObject **head, VMutex *pLock);
21virtual ~GenericObject();
22
23GenericObject *GetHead() { return *head; };
24GenericObject *GetNext() { return next; };
25
26 void lock() { pLock->enter(); };
27 void unlock() { pLock->leave(); };
28
29 void link();
30 void unlink();
31
32#ifdef DEBUG
33 LONG addRef();
34#else
35 LONG addRef() { return InterlockedIncrement(&refCount); };
36#endif
37 LONG getRefCount() { return refCount; };
38 LONG release();
39
40 void markDeleted() { fDeletePending = TRUE; };
41
42static void lock(VMutex *pLock) { pLock->enter(); };
43static void unlock(VMutex *pLock) { pLock->leave(); };
44
45static void DestroyAll(GenericObject *head);
46
47#ifdef __DEBUG_ALLOC__
48 void *operator new(size_t size, const char *filename, size_t lineno)
49 {
50 return _smalloc(size);
51 }
52 void operator delete(void *location, const char *filename, size_t lineno)
53 {
54 free(location);
55 }
56#else
57 void *operator new(size_t size)
58 {
59 return _smalloc(size);
60 }
61 void operator delete(void *location)
62 {
63 free(location);
64 }
65#endif
66
67private:
68
69protected:
70
71 VMutex *pLock;
72 LONG refCount;
73 ULONG fLinked : 1,
74 fDeletePending : 1;
75
76 GenericObject **head;
77 GenericObject *next;
78};
79
80#endif
Note: See TracBrowser for help on using the repository browser.