This topic has not yet been rated - Rate this topic

Initializing and Binding a Pipeline Module

Pipeline modules must create and bind to a pipeline module connector when their IFsrmPipelineModuleImplementation::OnLoad implementation is called. This can be done as the last step of any module initialization that is performed in the function.

The following example shows how to create and bind to a pipeline module connector:


#include <windows.h>
#include <stdio.h>
#include <comutil.h>
#include <atlbase.h>
#include <atlcom.h>
#include <FsrmQuota.h>  // quota objects
#include <FsrmTlb.h>    // Contains CLSIDs.
// <...>
STDMETHODIMP CCustomModule::OnLoad(
    IFsrmPipelineModuleDefinition   *pDefinition,
    IFsrmPipelineModuleConnector    **ppModuleConnector
    )
{
    HRESULT hr = S_OK;

    //
    //  ...perform module initialization...
    //

    //  Create the connector
    CComPtr<IFsrmPipelineModuleConnector> spConnector;
    hr = CoCreateInstance(CLSID_FsrmPipelineModuleConnector,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          __uuidof(IFsrmPipelineModuleConnector),
                          (LPVOID *)&spConnector);
    if (FAILED(hr))
    {
        ATLTRACE(L"CoCreateInstance(FsrmPipelineModuleConnector) failed, 0x%x.\n", hr);
        goto cleanup;
    }

    CComQIPtr<IFsrmPipelineModuleImplementation> spModuleImpl = GetControllingUnknown();
    if (spModuleImpl == NULL)
    {
        ATLTRACE(L"GetControllingUnknown failed.\n");
        hr = E_OUTOFMEMORY;
        goto cleanup;
    }

    //  Bind the connector to the module
    hr = spConnector->Bind(pDefinition, spModuleImpl);
    if (FAILED(hr))
    {
        ATLTRACE(L"spConnector->Bind failed, 0x%x.\n", hr);
        goto cleanup;
    }

    //  Return the connector
    *ppModuleConnector = spConnector.Detach();

cleanup:

    return hr;
}


 

 

Send comments about this topic to Microsoft

Build date: 12/6/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.