NERvDN Library
0.2.0.20160420-0019
NERvLibrary - Nerve Gear Developer Network
|
This tutorial will show you how to use this SDK to implement components then register them to NERvGear.
The completed project is located in the
samples\Data Source Demo
folder.
A component object is generally a C++ class implementing a number of interfaces. You will find that writing a component object is just as simple as writing a common inherited class.
The codes above declare a class implementing the NERvGear::IDataSource
interface. Specially, you should use the NVG_DECLARE_OBJECT()
macro in the end of your class to accomplish the left essential codes for a component object.
Like implementation of a plug-in, we should specify the information for the component object.
Each component object implements at least one interface, no exception, even the plug-in object. We have to indicate the interfaces that our object supported, and specially the plug-in declaration macro help us filling the default interface information, but you are still able to override it.
Here's the codes how we can declare the interface information for the component object, you can copy and paste the codes following the object information block:
This macro block actually implements the IUnknown::QueryInterface()
method which is part of the COM standard. The IUnknown
interface is very important and necessary to all the component objects, you should never forget to declare this interface for your objects.
We're almost finished, except for the interface implementation. Just write the implementation codes for all the methods of each interface to accomplish this component object.
Notes that you can find the interface details and implementing instruction in each interface header, please read them carefully and follow the documents strictly.
Finally we have done our implementation of a Data Source
component, we should tell NERvGear that there's a new available object for this component.
Just as what the previous tutorial referred in the "Components Registration" section, we can declare the demo Data Source
component object in the component registration macro block.
After compiling your plug-in, you would better test it before launching to users. Copy your compiled DLL to the bin\win(32/64)\Plugins\YOUR PLUG-IN FOLDER
then run NERvGear.exe
.
When you click the Ready
button in the frame of NERvSDK Plug-in Manager, your plug-in DLL will be loaded into NERvGear and the objects will be registered automatically. Click the Show Data Picker...
button and find your Data Source
object to test all of its functions.