48
Argus Encoder Family Version 2.6 API Developer’s Guide
FMTestApp
1. Derive a class from the IDispEventImpl template.
For example, in our
sample application, we derive CFilterManagerEvents from IDispEventImpl:
class CFilterManagerEvents:
public IDispEventImpl<1, CFilterManagerEvents>
The first argument to IDispEventImpl is a unique identifier for the event source.
Since Filter Manager is the only source from which our sample application
receives events, its ID of 1 is, indeed, unique.
The second argument is a reference back to the deriving class.
2. In the class definition, insert a SINK_MAP that includes each of the events
from Filter Manager that you’d like to receive.
For example, in our sample
application, we register to receive the error, log, finished, and pause events.
BEGIN_SINK_MAP(CFilterManagerEvents)
SINK_ENTRY(1, 1, OnError)
SINK_ENTRY(1, 2, OnLog)
SINK_ENTRY(1, 3, OnFinished)
SINK_ENTRY(1, 4, OnPause)
END_SINK_MAP()
The arguments for the SINK_ENTRY line are (SOURCE, DISPID, FUNC), where:
• SOURCE identifies the event source. Since Filter Manager was identified by
a value of ‘1’ in step 1, above, we use the value ‘1’ here to indicate that
we’re receiving events from Filter Manager.
• DISPID identifies the dispatch ID within the event source of the event that
we’re receiving. In Filter Manager, the Error Event has a dispatch ID of 1,
the Log Event has a dispatch ID of 2, the Finished Event has a dispid of 3,
and the Pause Event has a dispid of 4.
• FUNC identifies the function or method that will handle the received event.
This method will be defined within the class that we’re currently deriving
from IDispEventImpl.
3. Define and implement a method that calls AtlGetObjectSourceInterface()
and DispEventAdvise().
First call
AtlGetObjectSourceInterface()
to retrieve
pUnk
, a pointer to the interface ID of the default source interface. Then call
Disp-EventAdvise()
to establish a connection with the event source represented by
pUnk
. This connection allows events fired from
pUnk
(or, in our case, from Filter
Manager) to be routed to the handler functions specified in our event sink map.
In our C++ sample application, the EasyAdvise method is included in the CFilter-
ManagerEvents class to perform the connections described in the paragraph above: