VirtualBox

source: vbox/trunk/src/VBox/Main/include/hgcm/HGCMObjects.h@ 4041

Last change on this file since 4041 was 2981, checked in by vboxsync, 17 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/** @file
2 *
3 * HGCMObjects - Host-Guest Communication Manager objects header.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef __HGCMOBJECTS__H
23#define __HGCMOBJECTS__H
24
25#define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_HGCM
26#include "Logging.h"
27
28#include <iprt/assert.h>
29#include <iprt/avl.h>
30#include <iprt/critsect.h>
31#include <iprt/asm.h>
32
33class HGCMObject;
34
35typedef struct _ObjectAVLCore
36{
37 AVLULNODECORE AvlCore;
38 HGCMObject *pSelf;
39} ObjectAVLCore;
40
41typedef enum
42{
43 HGCMOBJ_CLIENT,
44 HGCMOBJ_THREAD,
45 HGCMOBJ_MSG,
46 HGCMOBJ_SizeHack = 0x7fffffff
47} HGCMOBJ_TYPE;
48
49class HGCMObject
50{
51 private:
52 friend uint32_t hgcmObjMake (HGCMObject *pObject, uint32_t u32HandleIn);
53
54 int32_t volatile cRef;
55 HGCMOBJ_TYPE enmObjType;
56
57 ObjectAVLCore Core;
58
59 protected:
60 virtual ~HGCMObject (void) {};
61
62 public:
63 HGCMObject (HGCMOBJ_TYPE enmObjType) : cRef (0)
64 {
65 this->enmObjType = enmObjType;
66 };
67
68 void Reference (void)
69 {
70 int32_t refCnt = ASMAtomicIncS32 (&cRef);
71 NOREF(refCnt);
72 Log(("Reference: refCnt = %d\n", refCnt));
73 }
74
75 void Dereference (void)
76 {
77 int32_t refCnt = ASMAtomicDecS32 (&cRef);
78
79 Log(("Dereference: refCnt = %d\n", refCnt));
80
81 AssertRelease(refCnt >= 0);
82
83 if (refCnt)
84 {
85 return;
86 }
87
88 delete this;
89 }
90
91 uint32_t Handle (void)
92 {
93 return Core.AvlCore.Key;
94 };
95
96 HGCMOBJ_TYPE Type (void)
97 {
98 return enmObjType;
99 };
100};
101
102int hgcmObjInit (void);
103
104void hgcmObjUninit (void);
105
106uint32_t hgcmObjGenerateHandle (HGCMObject *pObject);
107uint32_t hgcmObjAssignHandle (HGCMObject *pObject, uint32_t u32Handle);
108
109void hgcmObjDeleteHandle (uint32_t handle);
110
111HGCMObject *hgcmObjReference (uint32_t handle, HGCMOBJ_TYPE enmObjType);
112
113void hgcmObjDereference (HGCMObject *pObject);
114
115uint32_t hgcmObjQueryHandleCount ();
116void hgcmObjSetHandleCount (uint32_t u32HandleCount);
117
118#endif /* __HGCMOBJECTS__H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette