The Example mBSA plugin provides public plugin interface (IExample) and an implementation to show how to get another mBSA plugin instance (ID_ICONFIGMANAGER) and use its public interface (IConfigManager).
Sources and Directory Structure
The sources of the Example mBSA Plugin are the following:
Public plugin interface (IExample), visible to other mBSA plugins from the shared directory of mbsa/demo/include/mbsaIExample.h. It provides a single public function:
virtual presult functionToBeImplemented() = 0;
Plugin library IPlugin implementation:
mbsa/demo/include/example/mbsaPExamplePlugin.h
mbsa/demo/example/mbsaPExamplePlugin.cpp
Private implementation for IExample interface:
mbsa/demo/include/example/mbsaPExample.h
mbsa/demo/example/mbsaPExample.cpp – the PExample::loadConfig() shows how to get another mBSA plugin instance (ID_ICONFIGMANAGER) and use it's public interface (IConfigManager).
To build from the sources:
For Linux:
$ make -C mbsa/demo/example clean install
For Win32:
Use MSVC project: mbsa/demo/example/msvc/PluginExample.sln
The most important headers in demo/include directory are:
mbsaTypes.h – contains all PortingLater classes.
mbsaPPtr.h – smart pointer class used for automatic memory cleanup in mBSA.
mbsaIPlugin.h – provides base class for all plugins : IPlugin. The mBSA plugins are shared libraries. They export the following function, which returns IPlugin implementation to the Core:
MBSA_PLUGIN_FUNC IPlugin* mbsaGetPlugin()
This method is called on each loading of plugin module from the Core. A plugin must provide implementation of IPlugin interface and must not execute any business logic in this method (business logic is allowed only into IPlugin::init() method).
Normally this method should be called only once, but in case the plugin was unloaded and later loaded back, the Core should call it more than once. This is the only method the plugin module exports.
mbsaIExample.h – public interface, defining IExample plugin class.
the rest of the headers mbsaI*.h are public plugin interfaces.
Enabling Auto-Starting
To enable the auto-start of the Example plugin in mBSA:
open mbsa/bin/configs/<platform>/mbsal.core.prs
append mbsap.example in core.autostart.list property
Enabling Example Config
To enable the Example config in ConfigManager:
Copy mbsa/demo/example/mbsap.example.prs in common configuration directory: mbsa/bin/configs/<platform>/
Open mbsa/bin/configs/<platform>/mbsap.configmanager.prs
Append the following lines at the end:
mbsap.example = mbsap.example.prs
mbsap.example:name = Example plugin
mbsap.example:description = Example plugin configuration
Example Plugin Log
The Example plugin logs in file:
mbsa/bin/logs/mbsap.Example-XXX.log and on stdout.