NERvDN Library
0.2.0.20160420-0019
NERvLibrary - Nerve Gear Developer Network
|
This tutorial will show you the classification of components and how to use them.
We can classify the components into internal and external implementations:
These component implementations are provided by the core of NERvGear, you can instance these component objects calling corresponding NERvGear::NERvCreateXXX()
functions or calling NERvGear::NERvCreateObject()
with specific component and interface IDs. It is possible to instance these components in the call of IPlugin::OnInitial()
or IPlugin::OnRelease()
because these components must be initialed and registered before any plug-ins is loaded.
These component implementations are provided by other plug-ins, you must instance these component objects by calling NERvGear::NERvCreateObject()
with specific component and interface IDs. Trying to access these components in the call of IPlugin::OnInitial()
or IPlugin::OnRelease()
may be failed because the plug-in initialization order is not determined.
Here's the codes that create the Window
component which expose NERvGear::UI::IWindow
interface implemented by NERvGear:
The
Window
and GUI relative components are not available currently.
The following codes show you the way to find and instance a default implementation of the Data Source
component:
Data Source
is the first defined, cooperative and public component. You can access varieties of data with its NERvGear::IDataSource
and NERvGear::IData
interfaces. NERvGear provide an internal implementation called 'NERvGear Data Collection' with some useful system and common data for this component.
The codes above show how we can instance the 'NERvGear Data Collection' Data Source
component, find the system name data and account name value, copy the value to our buffer and finally print to the std
output or a log file. Like all the COM interfaces, you should release the interface handle by calling its IUnknown::Release()
when you no longer need it.
See NERvGear Interfaces Reference for more details about
NERvGear::IDataSource
andNERvGear::IData
interfaces.
Basically we use the same way to use external components, however there're still some differences we should pay attention to:
Since a plug-in doesn't link against other plug-in DLLs directly, we can't use the symbols exported by the plug-ins, therefore we should initialize the ID symbols manually. Define NVG_FLAG_INIT_UID
flag in your source files before including any headers, then the IDs will be defined and initialized so that we will no longer get undefined reference
linking error for the external UID symbols.
Also note that the headers for external resources are located in the NERvHub/*
, please see API Reference for the header locations of all the external available resources.
Codes above instance the 'Demo Object' implementing Demo
component, then invoke the FooBar()
method of Demo::IDemo interface. See Demo Object Reference for the implementation details, usages or notes.
You can also pass NERvGear::ID_NULL
to the object ID parameter when you call NERvGear::NERvCreateObject()
, in this way, you don't care about whom implements this component and system will find an object providing specified interface.