1*800f9471SAndrew Rist /**************************************************************
2*800f9471SAndrew Rist *
3*800f9471SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*800f9471SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*800f9471SAndrew Rist * distributed with this work for additional information
6*800f9471SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*800f9471SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*800f9471SAndrew Rist * "License"); you may not use this file except in compliance
9*800f9471SAndrew Rist * with the License. You may obtain a copy of the License at
10*800f9471SAndrew Rist *
11*800f9471SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*800f9471SAndrew Rist *
13*800f9471SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*800f9471SAndrew Rist * software distributed under the License is distributed on an
15*800f9471SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*800f9471SAndrew Rist * KIND, either express or implied. See the License for the
17*800f9471SAndrew Rist * specific language governing permissions and limitations
18*800f9471SAndrew Rist * under the License.
19*800f9471SAndrew Rist *
20*800f9471SAndrew Rist *************************************************************/
21*800f9471SAndrew Rist
22cdf0e10cSrcweir // XMergeFactory.cpp: implementation of the CXMergeFactory class.
23cdf0e10cSrcweir //
24cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
25cdf0e10cSrcweir
26cdf0e10cSrcweir #include "stdafx.h"
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "XMergeFilter.h"
29cdf0e10cSrcweir #include "XMergeFactory.h"
30cdf0e10cSrcweir
31cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
32cdf0e10cSrcweir // IUnknown implementation
33cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
QueryInterface(REFIID riid,void ** ppvObject)34cdf0e10cSrcweir STDMETHODIMP CXMergeFactory::QueryInterface(REFIID riid, void **ppvObject)
35cdf0e10cSrcweir {
36cdf0e10cSrcweir if(ppvObject == NULL)
37cdf0e10cSrcweir return E_INVALIDARG;
38cdf0e10cSrcweir
39cdf0e10cSrcweir if(::IsEqualIID(riid, IID_IUnknown) || ::IsEqualIID(riid, IID_IClassFactory))
40cdf0e10cSrcweir {
41cdf0e10cSrcweir *ppvObject = static_cast<IClassFactory*>(this);
42cdf0e10cSrcweir }
43cdf0e10cSrcweir else
44cdf0e10cSrcweir {
45cdf0e10cSrcweir *ppvObject = NULL;
46cdf0e10cSrcweir return E_NOINTERFACE;
47cdf0e10cSrcweir }
48cdf0e10cSrcweir
49cdf0e10cSrcweir reinterpret_cast<IUnknown*>(*ppvObject)->AddRef();
50cdf0e10cSrcweir return S_OK;
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir
STDMETHODIMP_(ULONG)54cdf0e10cSrcweir STDMETHODIMP_(ULONG) CXMergeFactory::AddRef()
55cdf0e10cSrcweir {
56cdf0e10cSrcweir return ::InterlockedIncrement(&m_cRef);
57cdf0e10cSrcweir }
58cdf0e10cSrcweir
59cdf0e10cSrcweir
STDMETHODIMP_(ULONG)60cdf0e10cSrcweir STDMETHODIMP_(ULONG) CXMergeFactory::Release()
61cdf0e10cSrcweir {
62cdf0e10cSrcweir if(::InterlockedDecrement(&m_cRef) == 0)
63cdf0e10cSrcweir {
64cdf0e10cSrcweir delete this;
65cdf0e10cSrcweir return 0;
66cdf0e10cSrcweir }
67cdf0e10cSrcweir
68cdf0e10cSrcweir return m_cRef;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
71cdf0e10cSrcweir
72cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
73cdf0e10cSrcweir // IUnknown implementation
74cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
CreateInstance(IUnknown * pUnkOuter,REFIID iid,void ** ppvObject)75cdf0e10cSrcweir STDMETHODIMP CXMergeFactory::CreateInstance(IUnknown *pUnkOuter, REFIID iid, void **ppvObject)
76cdf0e10cSrcweir {
77cdf0e10cSrcweir if (ppvObject == NULL)
78cdf0e10cSrcweir return E_INVALIDARG;
79cdf0e10cSrcweir
80cdf0e10cSrcweir if (pUnkOuter != NULL) // cannot aggregate
81cdf0e10cSrcweir {
82cdf0e10cSrcweir *ppvObject = NULL;
83cdf0e10cSrcweir return CLASS_E_NOAGGREGATION;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir if (iid == IID_ICeFileFilter)
87cdf0e10cSrcweir {
88cdf0e10cSrcweir CXMergeFilter *pFilter = new CXMergeFilter();
89cdf0e10cSrcweir if(pFilter == NULL)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir *ppvObject = NULL;
92cdf0e10cSrcweir return E_OUTOFMEMORY;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir HRESULT hr = pFilter->QueryInterface(iid, ppvObject);
96cdf0e10cSrcweir pFilter->Release();
97cdf0e10cSrcweir
98cdf0e10cSrcweir return hr;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir return E_INVALIDARG;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir
LockServer(BOOL fLock)105cdf0e10cSrcweir STDMETHODIMP CXMergeFactory::LockServer(BOOL fLock)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir _Module.LockServer(fLock);
108cdf0e10cSrcweir return S_OK;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir
112