aboutsummaryrefslogtreecommitdiff
path: root/src/api/burn/bextutil/inc/BextBaseBundleExtension.h
blob: 5bda04e19af962714ef6e4732b80a136a9aff075 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

#include <windows.h>

#include "bextutil.h"

class CBextBaseBundleExtension : public IBundleExtension
{
public: // IUnknown
    virtual STDMETHODIMP QueryInterface(
        __in REFIID riid,
        __out LPVOID *ppvObject
        )
    {
        if (!ppvObject)
        {
            return E_INVALIDARG;
        }

        *ppvObject = NULL;

        if (::IsEqualIID(__uuidof(IBundleExtension), riid))
        {
            *ppvObject = static_cast<IBundleExtension*>(this);
        }
        else if (::IsEqualIID(IID_IUnknown, riid))
        {
            *ppvObject = static_cast<IUnknown*>(this);
        }
        else // no interface for requested iid
        {
            return E_NOINTERFACE;
        }

        AddRef();
        return S_OK;
    }

    virtual STDMETHODIMP_(ULONG) AddRef()
    {
        return ::InterlockedIncrement(&this->m_cReferences);
    }

    virtual STDMETHODIMP_(ULONG) Release()
    {
        long l = ::InterlockedDecrement(&this->m_cReferences);
        if (0 < l)
        {
            return l;
        }

        delete this;
        return 0;
    }

public: // IBundleExtension
    virtual STDMETHODIMP Search(
        __in LPCWSTR /*wzId*/,
        __in LPCWSTR /*wzVariable*/
        )
    {
        return E_NOTIMPL;
    }

    virtual STDMETHODIMP BundleExtensionProc(
        __in BUNDLE_EXTENSION_MESSAGE /*message*/,
        __in const LPVOID /*pvArgs*/,
        __inout LPVOID /*pvResults*/,
        __in_opt LPVOID /*pvContext*/
        )
    {
        return E_NOTIMPL;
    }

public: //CBextBaseBundleExtension
    virtual STDMETHODIMP Initialize(
        __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs
        )
    {
        HRESULT hr = S_OK;

        hr = StrAllocString(&m_sczBundleExtensionDataPath, pCreateArgs->wzBundleExtensionDataPath, 0);
        ExitOnFailure(hr, "Failed to copy BundleExtensionDataPath.");

    LExit:
        return hr;
    }

protected:

    CBextBaseBundleExtension(
        __in IBundleExtensionEngine* pEngine
        )
    {
        m_cReferences = 1;

        pEngine->AddRef();
        m_pEngine = pEngine;

        m_sczBundleExtensionDataPath = NULL;
    }

    virtual ~CBextBaseBundleExtension()
    {
        ReleaseNullObject(m_pEngine);
        ReleaseStr(m_sczBundleExtensionDataPath);
    }

protected:
    IBundleExtensionEngine* m_pEngine;
    LPWSTR m_sczBundleExtensionDataPath;

private:
    long m_cReferences;
};