VirtualBox

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

Last change on this file since 28398 was 24989, checked in by vboxsync, 15 years ago

Main: enable -Wshadow gcc option to warn about shadowed variables and fix all resulting warnings; in particular, rename some stack and member variables and rename getter methods like id() to getId()

  • 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 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
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 m_cRefs;
55 HGCMOBJ_TYPE m_enmObjType;
56
57 ObjectAVLCore m_core;
58
59 protected:
60 virtual ~HGCMObject()
61 {};
62
63 public:
64 HGCMObject(HGCMOBJ_TYPE enmObjType)
65 : m_cRefs(0)
66 {
67 this->m_enmObjType = enmObjType;
68 };
69
70 void Reference()
71 {
72 int32_t refCnt = ASMAtomicIncS32(&m_cRefs);
73 NOREF(refCnt);
74 Log(("Reference: refCnt = %d\n", refCnt));
75 }
76
77 void Dereference()
78 {
79 int32_t refCnt = ASMAtomicDecS32(&m_cRefs);
80
81 Log(("Dereference: refCnt = %d\n", refCnt));
82
83 AssertRelease(refCnt >= 0);
84
85 if (refCnt)
86 {
87 return;
88 }
89
90 delete this;
91 }
92
93 uint32_t Handle()
94 {
95 return m_core.AvlCore.Key;
96 };
97
98 HGCMOBJ_TYPE Type()
99 {
100 return m_enmObjType;
101 };
102};
103
104int hgcmObjInit();
105
106void hgcmObjUninit();
107
108uint32_t hgcmObjGenerateHandle(HGCMObject *pObject);
109uint32_t hgcmObjAssignHandle(HGCMObject *pObject, uint32_t u32Handle);
110
111void hgcmObjDeleteHandle(uint32_t handle);
112
113HGCMObject *hgcmObjReference(uint32_t handle, HGCMOBJ_TYPE enmObjType);
114
115void hgcmObjDereference(HGCMObject *pObject);
116
117uint32_t hgcmObjQueryHandleCount();
118void hgcmObjSetHandleCount(uint32_t u32HandleCount);
119
120#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