VirtualBox

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

Last change on this file since 69785 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1/* $Id: HGCMObjects.h 69500 2017-10-28 15:14:05Z vboxsync $ */
2/** @file
3 * HGCMObjects - Host-Guest Communication Manager objects header.
4 */
5
6/*
7 * Copyright (C) 2006-2017 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#include <iprt/assert.h>
22#include <iprt/avl.h>
23#include <iprt/critsect.h>
24#include <iprt/asm.h>
25
26class HGCMObject;
27
28typedef struct _ObjectAVLCore
29{
30 AVLULNODECORE AvlCore;
31 HGCMObject *pSelf;
32} ObjectAVLCore;
33
34typedef enum
35{
36 HGCMOBJ_CLIENT,
37 HGCMOBJ_THREAD,
38 HGCMOBJ_MSG,
39 HGCMOBJ_SizeHack = 0x7fffffff
40} HGCMOBJ_TYPE;
41
42class HGCMObject
43{
44 private:
45 friend uint32_t hgcmObjMake(HGCMObject *pObject, uint32_t u32HandleIn);
46
47 int32_t volatile m_cRefs;
48 HGCMOBJ_TYPE m_enmObjType;
49
50 ObjectAVLCore m_core;
51
52 protected:
53 virtual ~HGCMObject()
54 {};
55
56 public:
57 HGCMObject(HGCMOBJ_TYPE enmObjType)
58 : m_cRefs(0)
59 {
60 this->m_enmObjType = enmObjType;
61 };
62
63 void Reference()
64 {
65 int32_t refCnt = ASMAtomicIncS32(&m_cRefs);
66 NOREF(refCnt);
67 Log(("Reference: refCnt = %d\n", refCnt));
68 }
69
70 void Dereference()
71 {
72 int32_t refCnt = ASMAtomicDecS32(&m_cRefs);
73
74 Log(("Dereference: refCnt = %d\n", refCnt));
75
76 AssertRelease(refCnt >= 0);
77
78 if (refCnt)
79 {
80 return;
81 }
82
83 delete this;
84 }
85
86 uint32_t Handle()
87 {
88 return (uint32_t)m_core.AvlCore.Key;
89 };
90
91 HGCMOBJ_TYPE Type()
92 {
93 return m_enmObjType;
94 };
95};
96
97int hgcmObjInit();
98
99void hgcmObjUninit();
100
101uint32_t hgcmObjGenerateHandle(HGCMObject *pObject);
102uint32_t hgcmObjAssignHandle(HGCMObject *pObject, uint32_t u32Handle);
103
104void hgcmObjDeleteHandle(uint32_t handle);
105
106HGCMObject *hgcmObjReference(uint32_t handle, HGCMOBJ_TYPE enmObjType);
107
108void hgcmObjDereference(HGCMObject *pObject);
109
110uint32_t hgcmObjQueryHandleCount();
111void hgcmObjSetHandleCount(uint32_t u32HandleCount);
112
113#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