10 sasanalyzer object events, 1 _isasanalyzerevents dispinterface, Isasanalyzerevents::ontracecreated – Teledyne LeCroy SAS_SATA Tracer_Trainer Automation API Manual User Manual

Page 89: Event

Advertising
background image

LeCroy Corporation

Automation API for SAS/SATATracer/Trainer

Manual Version 1.11

89

10 SASAnalyzer Object Events

10.1 _ISASAnalyzerEvents Dispinterface

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

_ISASAnalyzerEvents interface. Since this interface is the default source interface for the
SASAnalyzer 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 SASTracer 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<IDC_SRCOBJ, CAnalyzerSink>
{
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_SASAnalyzer, NULL,

CLSCTX_SERVER, IID_ISASAnalyzer, (LPVOID *)&m_poSASAnalyzer );

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_poSASAnalyzer, &poAnalyzerSink->m_libid,

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


if ( FAILED(hr) )

return 1;


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

if ( FAILED(hr) )

return 1;

Advertising