diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-10 01:27:27 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-10 01:27:27 +0000 |
commit | 76718abdb2138623102398a10f3228e576dd0ae8 (patch) | |
tree | ddb098baac9689b9e661a41c2a28a8a23ef246d4 /diff_ext_for_kdiff3/class_factory.cpp | |
download | kdiff3-76718abdb2138623102398a10f3228e576dd0ae8.tar.gz kdiff3-76718abdb2138623102398a10f3228e576dd0ae8.zip |
Added abandoned KDE3 version of kdiff3
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdiff3@1088041 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'diff_ext_for_kdiff3/class_factory.cpp')
-rw-r--r-- | diff_ext_for_kdiff3/class_factory.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/diff_ext_for_kdiff3/class_factory.cpp b/diff_ext_for_kdiff3/class_factory.cpp new file mode 100644 index 0000000..0618862 --- /dev/null +++ b/diff_ext_for_kdiff3/class_factory.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2003, Sergey Zorin. All rights reserved. + * + * This software is distributable under the BSD license. See the terms + * of the BSD license in the LICENSE file provided with this software. + * + */ + +#include "class_factory.h" +#include "diff_ext.h" +#include "server.h" + +CLASS_FACTORY::CLASS_FACTORY() { + _ref_count = 0L; + + SERVER::instance()->lock(); +} + +CLASS_FACTORY::~CLASS_FACTORY() { + SERVER::instance()->release(); +} + +STDMETHODIMP +CLASS_FACTORY::QueryInterface(REFIID riid, void** ppv) { + HRESULT ret = E_NOINTERFACE; + *ppv = 0; + + if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory)) { + *ppv = static_cast<CLASS_FACTORY*>(this); + + AddRef(); + + ret = NOERROR; + } + + return ret; +} + +STDMETHODIMP_(ULONG) +CLASS_FACTORY::AddRef() { + return InterlockedIncrement((LPLONG)&_ref_count); +} + +STDMETHODIMP_(ULONG) +CLASS_FACTORY::Release() { + ULONG ret = 0L; + + if(InterlockedDecrement((LPLONG)&_ref_count) != 0) + ret = _ref_count; + else + delete this; + + return ret; +} + +STDMETHODIMP +CLASS_FACTORY::CreateInstance(IUnknown* outer, REFIID refiid, void** obj) { + HRESULT ret = CLASS_E_NOAGGREGATION; + *obj = 0; + + // Shell extensions typically don't support aggregation (inheritance) + if(outer == 0) { + DIFF_EXT* ext = new DIFF_EXT(); + + if(ext == 0) + ret = E_OUTOFMEMORY; + else + ret = ext->QueryInterface(refiid, obj); + } + + return ret; +} + +STDMETHODIMP +CLASS_FACTORY::LockServer(BOOL) { + return NOERROR; +} |