CMS 3D CMS Logo

PluginDescription Class Reference

#include "PluginDescription.h"

Detailed Description

Description: Use to describe how to validate a plugin that will be loaded

Usage: User defined plugins which are constructed by passing a edm::ParameterSet can have their parameters validated using the edm::PluginDescription. For this to work, one must

1) Plugin configuration All the parameters used by the Plugin must be contained within one PSet, this also includes an cms.string parameter containing the name of the actual plugin type to be loaded. E.g. if a module FooProd loaded a plugin of specific type BarHelper and BarHelper uses the parameter named value :

foo = cms.EDProducer("FooProd",
pluginDescription = cms.PSet(type = cms.string("BarHelper"),
value = cms.int32(5) ) )

2) Plugin fillPSetDescription Each user plugin must define a static member function:

The function fills the edm::ParameterSetDescription with the descriptions of the parameters necessary for that particular plugin. Note that the parameter used by the module to find the type of the plugin should NOT be declared in the edm::ParameterSetDescription since it will be added by the edm::PluginDescription itself. E.g.

3) Module's fillDescriptions The module which uses the plugins must use the edm::PluginDescription within its fillDescriptions static member function. The edm::PluginDescription object is attached to the edm::ParameterSetDescription object which is being used to represent the PSet for the plugin. In turn, that edm::ParamterSetDescription is attached to the module's top level ParameterSetDescription. This exactly mimics what would be done if the plugin's parameters were directly known to the module.

//specify how to get the plugin validation
//'type' is the label to the string containing which plugin to load
pluginDesc.addNode(edm::PluginDescription<HelperFactory>("type") );
desc.add<ParameterSetDescription>("pluginDescription", pluginDesc);
oDesc.addDefault(desc);
}

4) Factory registration Use EDM_REGISTER_VALIDATED_PLUGINFACTORY rather than EDM_REGISTER_PLUGINFACTORY. This new macro can be found in FWCore/ParameterSet/interface/ValidatedPluginFactoryMacros.h

5) Plugin registration Use DEFINE_EDM_VALIDATED_PLUGIN rather than DEFINE_EDM_PLUGIN. This new macro can be found in FWCore/Framework/interface/ValidatedPluginMacros.h