VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/xpcom/module.cpp@ 55747

Last change on this file since 55747 was 55401, checked in by vboxsync, 10 years ago

added a couple of missing Id headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/* $Id: module.cpp 55401 2015-04-23 10:03:17Z vboxsync $ */
2/** @file
3 *
4 * XPCOM module implementation functions
5 */
6
7/*
8 * Copyright (C) 2006-2014 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19/* Make sure all the stdint.h macros are included - must come first! */
20#ifndef __STDC_LIMIT_MACROS
21# define __STDC_LIMIT_MACROS
22#endif
23#ifndef __STDC_CONSTANT_MACROS
24# define __STDC_CONSTANT_MACROS
25#endif
26
27#include <nsIGenericFactory.h>
28
29// generated file
30#include "VirtualBox_XPCOM.h"
31
32#include "SessionImpl.h"
33#include "VirtualBoxClientImpl.h"
34#include "RemoteUSBDeviceImpl.h"
35#include "USBDeviceImpl.h"
36
37#include "Logging.h"
38
39// XPCOM glue code unfolding
40
41#ifndef VBOX_COM_INPROC_API_CLIENT
42NS_DECL_CLASSINFO(RemoteUSBDevice)
43NS_IMPL_THREADSAFE_ISUPPORTS2_CI(RemoteUSBDevice, IHostUSBDevice, IUSBDevice)
44#endif /* VBOX_COM_INPROC_API_CLIENT */
45
46/*
47 * Declare extern variables here to tell the compiler that
48 * NS_DECL_CLASSINFO(SessionWrap)
49 * already exists in the VBoxAPIWrap library.
50 */
51NS_DECL_CI_INTERFACE_GETTER(SessionWrap)
52extern nsIClassInfo *NS_CLASSINFO_NAME(SessionWrap);
53
54/*
55 * Declare extern variables here to tell the compiler that
56 * NS_DECL_CLASSINFO(VirtualBoxClientWrap)
57 * already exists in the VBoxAPIWrap library.
58 */
59NS_DECL_CI_INTERFACE_GETTER(VirtualBoxClientWrap)
60extern nsIClassInfo *NS_CLASSINFO_NAME(VirtualBoxClientWrap);
61
62/**
63 * Singleton class factory that holds a reference to the created instance
64 * (preventing it from being destroyed) until the module is explicitly
65 * unloaded by the XPCOM shutdown code.
66 *
67 * Suitable for IN-PROC components.
68 */
69class SessionClassFactory : public Session
70{
71public:
72 virtual ~SessionClassFactory() {
73 FinalRelease();
74 instance = 0;
75 }
76 static nsresult getInstance (Session **inst) {
77 int rv = NS_OK;
78 if (instance == 0) {
79 instance = new SessionClassFactory();
80 if (instance) {
81 instance->AddRef(); // protect FinalConstruct()
82 rv = instance->FinalConstruct();
83 if (NS_FAILED(rv))
84 instance->Release();
85 else
86 instance->AddRef(); // self-reference
87 } else {
88 rv = NS_ERROR_OUT_OF_MEMORY;
89 }
90 } else {
91 instance->AddRef();
92 }
93 *inst = instance;
94 return rv;
95 }
96 static nsresult releaseInstance () {
97 if (instance)
98 instance->Release();
99 return NS_OK;
100 }
101
102private:
103 static Session *instance;
104};
105
106/** @note this is for singleton; disabled for now */
107//
108//Session *SessionClassFactory::instance = 0;
109//
110//NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR_WITH_RC (
111// Session, SessionClassFactory::getInstance
112//)
113
114NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC(Session)
115
116NS_GENERIC_FACTORY_CONSTRUCTOR_WITH_RC(VirtualBoxClient)
117
118/**
119 * Component definition table.
120 * Lists all components defined in this module.
121 */
122static const nsModuleComponentInfo components[] =
123{
124 {
125 "Session component", // description
126 NS_SESSION_CID, NS_SESSION_CONTRACTID, // CID/ContractID
127 SessionConstructor, // constructor function
128 NULL, // registration function
129 NULL, // deregistration function
130/** @note this is for singleton; disabled for now */
131// SessionClassFactory::releaseInstance,
132 NULL, // destructor function
133 NS_CI_INTERFACE_GETTER_NAME(SessionWrap), // interfaces function
134 NULL, // language helper
135 &NS_CLASSINFO_NAME(SessionWrap) // global class info & flags
136 },
137 {
138 "VirtualBoxClient component", // description
139 NS_VIRTUALBOXCLIENT_CID, NS_VIRTUALBOXCLIENT_CONTRACTID, // CID/ContractID
140 VirtualBoxClientConstructor, // constructor function
141 NULL, // registration function
142 NULL, // deregistration function
143 NULL, // destructor function
144 NS_CI_INTERFACE_GETTER_NAME(VirtualBoxClientWrap), // interfaces function
145 NULL, // language helper
146 &NS_CLASSINFO_NAME(VirtualBoxClientWrap) // global class info & flags
147 },
148};
149
150NS_IMPL_NSGETMODULE (VirtualBox_Client_Module, components)
151/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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