beautypg.com

8 fcanalyzer object events, 1 _ifcanalyzerevents dispinterface, Ifcanalyzerevents::ontracecreated – Teledyne LeCroy SierraFC Automation API User Manual

Page 66

background image

LeCroy Corporation

SierraFC M8-4 API Reference Manual

Manual Version 1.00

66

8 FCAnalyzer Object Events

8.1 _IFCAnalyzerEvents Dispinterface

In order to retrieve the events from a FCAnalyzer object, you must implement the

_IFCAnalyzerEvents interface. Since this interface is the default source interface for the
FCAnalyzer object, there is a very simple implementation from languages, such as Visual
Basic, VBA, VBScript, and WSH.


Some script engines impose restrictions on handling events from ―indirect‖ automation

objects in typeless script languages (when the automation interface to the object is obtained
from a call of some method, rather than from a creation function, such as CreateObject() in
VBScript). The SierraFC Protocol Analyzer application provides a special COM class,
allowing receiving and handling notifications from the VSE object even in script languages
not supporting event handling from "indirect" objects.


C++ implementation used in the examples below utilizes a sink object by deriving it

from IdispEventImpl, but not specifying the type library as a template argument. Instead, the
type library and default source interface for the object are determined using
AtlGetObjectSourceInterface()
.


A SINK_ENTRY() macro is used for each event from each source interface that is to

be handled:

class CAnalyzerSink : public IDispEventImpl
{
BEGIN_SINK_MAP(CAnalyzerSink)

// Make sure the Event Handlers have __stdcall calling convention.
SINK_ENTRY(IDC_SRCOBJ, 1, OnTraceCreated)
SINK_ENTRY(IDC_SRCOBJ, 2, OnStatusReport)

END_SINK_MAP()

. . .

}

Then, after you establish a connection with the server, you need to advise as to your
implementation of the event interface:

hr = CoCreateInstance( CLSID_FCAnalyzer, NULL,

CLSCTX_SERVER, IID_IFCAnalyzer, (LPVOID *)&m_poFCAnalyzer );

poAnalyzerSink = new CAnalyzerSink();

// Make sure the COM object corresponding to pUnk implements IProvideClassInfo2 or
// IPersist*. Call this method to extract info about source type library, if you
// specified only two parameters to IDispEventImpl.
hr = AtlGetObjectSourceInterface(m_poFCAnalyzer, &poAnalyzerSink->m_libid,

&poAnalyzerSink->m_iid, &poAnalyzerSink->m_wMajorVerNum,
&poAnalyzerSink->m_wMinorVerNum);


if ( FAILED(hr) )

return 1;


// Connect the sink and source. m_poFCAnalyzer is the source COM object.
hr = poAnalyzerSink->DispEventAdvise(m_poFCAnalyzer, &poAnalyzerSink->m_iid);

if ( FAILED(hr) )

return 1;