]>
git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/ExplorerPlugin/ClassFactory.cpp
1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2003-2004 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 #include "DebugServices.h"
22 #include "ExplorerBar.h"
23 #include "ExplorerPlugin.h"
25 #include "ClassFactory.h"
32 static char THIS_FILE
[] = __FILE__
;
35 //===========================================================================================================================
37 //===========================================================================================================================
39 ClassFactory::ClassFactory( CLSID inCLSID
)
41 mCLSIDObject
= inCLSID
;
46 //===========================================================================================================================
48 //===========================================================================================================================
50 ClassFactory::~ClassFactory( void )
52 check( gDLLRefCount
> 0 );
59 #pragma mark == IUnknown methods ==
62 //===========================================================================================================================
64 //===========================================================================================================================
66 STDMETHODIMP
ClassFactory::QueryInterface( REFIID inID
, LPVOID
*outResult
)
72 if( IsEqualIID( inID
, IID_IUnknown
) )
76 else if( IsEqualIID( inID
, IID_IClassFactory
) )
78 *outResult
= (IClassFactory
*) this;
87 ( *( (LPUNKNOWN
*) outResult
) )->AddRef();
94 //===========================================================================================================================
96 //===========================================================================================================================
98 STDMETHODIMP_( DWORD
) ClassFactory::AddRef( void )
100 return( ++mRefCount
);
103 //===========================================================================================================================
105 //===========================================================================================================================
107 STDMETHODIMP_( DWORD
) ClassFactory::Release( void )
121 #pragma mark == IClassFactory methods ==
124 //===========================================================================================================================
126 //===========================================================================================================================
128 STDMETHODIMP
ClassFactory::CreateInstance( LPUNKNOWN inUnknown
, REFIID inID
, LPVOID
*outObject
)
137 require_action( !inUnknown
, exit
, err
= CLASS_E_NOAGGREGATION
);
139 // Create the object based on the CLSID.
141 if( IsEqualCLSID( mCLSIDObject
, CLSID_ExplorerBar
) )
145 obj
= new ExplorerBar();
149 // Don't let exception escape.
151 require_action( obj
, exit
, err
= E_OUTOFMEMORY
);
159 // Query for the specified interface. Release the factory since QueryInterface retains it.
161 err
= ( (LPUNKNOWN
) obj
)->QueryInterface( inID
, outObject
);
162 ( (LPUNKNOWN
) obj
)->Release();
168 //===========================================================================================================================
170 //===========================================================================================================================
172 STDMETHODIMP
ClassFactory::LockServer( BOOL inLock
)
174 DEBUG_UNUSED( inLock
);