Creating the library


aboucher - Posted on 10 April 2009

The last step is to add the GEOSTAT_PLUGIN macro at the end of the implementation file (.cpp). The macro takes as argument the name of the class that defines the new algorithm:


Named_interface* MovingAverage::create_new_interface( std::string& ) {
  return new MovingAverage;
}

GEOSTAT_PLUGIN(MovingAverage);



Compile the C++ files to obtain a .so (or .dll) library file and place it along with the .ui file into the plugins/Geostat directory.

Of course, it is possible to define several algorithms into a single plug-in. The plug-in will then be composed of a .so (or .dll) file and one .ui file for each algorithm. To define several algorithms into a single plug-in, define a function called plugin_init as extern "C" in one of your .cpp files (this file must include all the files defining the algorithms to be included into the plug-in). Then use macro BIND_GEOSTAT_ALGO to add each algorithm. The maccro is defined in <GsTLAppli/utils/gstl_plugins.h>. For example, if we have 2 algorithms implemented in classes MovingAverage and CubicSmoothing, add the following function to one of the cpp files:


extern "C" int plugin_init() {
  BIND_GEOSTAT_ALGO( MovingAverage );
  
BIND_GEOSTAT_ALGO( CubicSmoothing );
  return 0;
}