User`s guide
4 Defining Your Adaptor Class
4-12
Implementing Your Adaptor Class Constructor
Because you write the code that calls your adaptor class constructor, you can define
the arguments accepted by your adaptor class constructor. At a minimum, adaptor
constructors must accept a handle to an IEngine object that represents the connection
between the engine and your adaptor. This is defined by the IAdaptor superclass. Your
adaptor uses this handle to access engine functions for packaging image frames and
returning them to the engine.
In addition to this required argument, many adaptors also accept two other arguments
• Handle to an IDeviceInfo object that specifies the device to which you want to
connect
• Text string specifying the desired acquisition source format or the full path to a device
configuration file (also known as a camera file)
These are the same arguments passed to your adaptor's createInstance() function.
Suggested Algorithm
The requirements of your image acquisition device will determine what your class
constructor must do. Class constructors typically perform tasks that only need to be
performed once by the class, such as
• Setting up listeners for all device-specific properties. Listeners notify the class when
a user changes the value of a device-specific property. See “Implementing Get and Set
Support for Device-Specific Properties” on page 6-10.
• Creating a critical section object. Your adaptor will use the critical section to protect
data members that might be accessed from multiple threads. See “Using Critical
Sections” on page 5-30.
Note Your class constructor should not perform any device initialization, because a
user might want to create multiple video input objects. Device initialization occurs
when a user has requested frames — see “Opening and Closing Connection with a
Device” on page 5-10.
Example
The following example shows a createInstance() function that instantiates an object
of class MyDeviceAdaptor.