Step 3 - Exporting plugins using calculator_plugins.cpp

In order to load the class of plugins dynamically, we have to export each class using a special macro called PLUGINLIB_EXPORT_CLASS. This macro has to put in any CPP file that consists of plugin classes. We have already defined the plugin class, and in this file we are going to define the macro statement only.

Locate the calculator_plugins.cpp file from the chapter_5_codes/pluginlib_calculator/src folder, and here is how we export each plugin:

#include <pluginlib/class_list_macros.h> 
#include <pluginlib_calculator/calculator_base.h> 
#include <pluginlib_calculator/calculator_plugins.h> 
 
PLUGINLIB_EXPORT_CLASS(calculator_plugins::Add, calculator_base::calc_functions); 

Inside PLUGINLIB_EXPORT_CLASS, we need to provide the class name of the plugin and the base class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.87.161