VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBFE/HGCMObjects.h@ 35273

Last change on this file since 35273 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/** @file
2 *
3 * HGCMObjects - Host-Guest Communication Manager objects header.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Oracle Corporation
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef __HGCMOBJECTS__H
19#define __HGCMOBJECTS__H
20
21#define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_HGCM
22#include "Logging.h"
23
24#include <iprt/assert.h>
25#include <iprt/avl.h>
26#include <iprt/critsect.h>
27#include <iprt/asm.h>
28
29class HGCMObject;
30
31typedef struct _ObjectAVLCore
32{
33 AVLULNODECORE AvlCore;
34 HGCMObject *pSelf;
35} ObjectAVLCore;
36
37typedef enum
38{
39 HGCMOBJ_CLIENT,
40 HGCMOBJ_THREAD,
41 HGCMOBJ_MSG,
42 HGCMOBJ_SizeHack = 0x7fffffff
43} HGCMOBJ_TYPE;
44
45class HGCMObject
46{
47 private:
48 friend uint32_t hgcmObjMake (HGCMObject *pObject, uint32_t u32HandleIn);
49
50 int32_t volatile cRef;
51 HGCMOBJ_TYPE enmObjType;
52
53 ObjectAVLCore Core;
54
55 protected:
56 virtual ~HGCMObject (void) {};
57
58 public:
59 HGCMObject (HGCMOBJ_TYPE enmObjType) : cRef (0)
60 {
61 this->enmObjType = enmObjType;
62 };
63
64 void Reference (void)
65 {
66 int32_t refCnt = ASMAtomicIncS32 (&cRef);
67 NOREF(refCnt);
68 Log(("Reference: refCnt = %d\n", refCnt));
69 }
70
71 void Dereference (void)
72 {
73 int32_t refCnt = ASMAtomicDecS32 (&cRef);
74
75 Log(("Dereference: refCnt = %d\n", refCnt));
76
77 AssertRelease(refCnt >= 0);
78
79 if (refCnt)
80 {
81 return;
82 }
83
84 delete this;
85 }
86
87 uint32_t Handle (void)
88 {
89 return Core.AvlCore.Key;
90 };
91
92 HGCMOBJ_TYPE Type (void)
93 {
94 return enmObjType;
95 };
96};
97
98int hgcmObjInit (void);
99
100void hgcmObjUninit (void);
101
102uint32_t hgcmObjGenerateHandle (HGCMObject *pObject);
103uint32_t hgcmObjAssignHandle (HGCMObject *pObject, uint32_t u32Handle);
104
105void hgcmObjDeleteHandle (uint32_t handle);
106
107HGCMObject *hgcmObjReference (uint32_t handle, HGCMOBJ_TYPE enmObjType);
108
109void hgcmObjDereference (HGCMObject *pObject);
110
111uint32_t hgcmObjQueryHandleCount ();
112void hgcmObjSetHandleCount (uint32_t u32HandleCount);
113
114#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