CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::PluginDescription< T > Class Template Reference

#include <PluginDescription.h>

Inheritance diagram for edm::PluginDescription< T >:
edm::ParameterDescriptionNode

Public Member Functions

ParameterDescriptionNodeclone () const final
 
 PluginDescription (std::string typeLabel, bool typeLabelIsTracked)
 
 PluginDescription (std::string typeLabel, std::string defaultType, bool typeLabelIsTracked)
 
- Public Member Functions inherited from edm::ParameterDescriptionNode
void checkAndGetLabelsAndTypes (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
 
std::string const & comment () const
 
bool exists (ParameterSet const &pset) const
 
bool hasNestedContent () const
 
int howManyXORSubNodesExist (ParameterSet const &pset) const
 
virtual bool isWildcard () const
 
 ParameterDescriptionNode ()
 
 ParameterDescriptionNode (Comment const &iComment)
 
bool partiallyExists (ParameterSet const &pset) const
 
void print (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const
 
void printNestedContent (std::ostream &os, bool optional, DocFormatHelper &dfh) const
 
void setComment (std::string const &value)
 
void setComment (char const *value)
 
void validate (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
 
void writeCfi (std::ostream &os, bool optional, bool &startWithComma, int indentation, CfiOptions &options, bool &wroteSomething) const
 
virtual ~ParameterDescriptionNode ()
 

Protected Member Functions

void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const final
 
bool exists_ (ParameterSet const &pset) const final
 
bool hasNestedContent_ () const final
 
int howManyXORSubNodesExist_ (ParameterSet const &pset) const final
 
bool partiallyExists_ (ParameterSet const &pset) const final
 
void printNestedContent_ (std::ostream &os, bool, DocFormatHelper &dfh) const final
 
void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const final
 
void writeCfi_ (std::ostream &os, bool optional, bool &startWithComma, int indentation, CfiOptions &options, bool &wroteSomething) const final
 
- Protected Member Functions inherited from edm::ParameterDescriptionNode
virtual void print_ (std::ostream &, bool, bool, DocFormatHelper &) const
 

Private Member Functions

std::string findType (edm::ParameterSet const &iPSet) const
 
ParameterSetDescription loadDescription (std::string const &iName) const
 

Private Attributes

std::string defaultType_
 
std::string typeLabel_
 
bool typeLabelIsTracked_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::ParameterDescriptionNode
static void printSpaces (std::ostream &os, int n)
 
- Protected Attributes inherited from edm::ParameterDescriptionNode
std::string comment_
 

Detailed Description

template<typename T>
class edm::PluginDescription< T >

Definition at line 100 of file PluginDescription.h.

Constructor & Destructor Documentation

◆ PluginDescription() [1/2]

template<typename T>
edm::PluginDescription< T >::PluginDescription ( std::string  typeLabel,
bool  typeLabelIsTracked 
)
inline

Constructor without a default for typeLabel

Parameters
[in]typeLabelthe label for the std::string parameter which holds the plugin type to be loaded
[in]typeLabelIsTracked'true' if the parameter typeLabel is tracked, else should be false

Definition at line 106 of file PluginDescription.h.

References eostools::move().

107  : typeLabel_{std::move(typeLabel)}, typeLabelIsTracked_{typeLabelIsTracked} {}
def move(src, dest)
Definition: eostools.py:511

◆ PluginDescription() [2/2]

template<typename T>
edm::PluginDescription< T >::PluginDescription ( std::string  typeLabel,
std::string  defaultType,
bool  typeLabelIsTracked 
)
inline

Constructor with a default for typeLabel

Parameters
[in]typeLabelthe label for the std::string parameter which holds the plugin type to be loaded
[in]defaultTypethe default plugin type that should be loaded if no type is given
[in]typeLabelIsTracked'true' if the parameter typeLabel is tracked, else should be false

Definition at line 114 of file PluginDescription.h.

References eostools::move().

115  : typeLabel_{std::move(typeLabel)},
116  defaultType_{std::move(defaultType)},
117  typeLabelIsTracked_{typeLabelIsTracked} {}
def move(src, dest)
Definition: eostools.py:511

Member Function Documentation

◆ checkAndGetLabelsAndTypes_()

template<typename T>
void edm::PluginDescription< T >::checkAndGetLabelsAndTypes_ ( std::set< std::string > &  usedLabels,
std::set< ParameterTypes > &  parameterTypes,
std::set< ParameterTypes > &  wildcardTypes 
) const
inlinefinalprotectedvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 123 of file PluginDescription.h.

125  {}

◆ clone()

template<typename T>
ParameterDescriptionNode* edm::PluginDescription< T >::clone ( void  ) const
inlinefinalvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 120 of file PluginDescription.h.

120 { return new PluginDescription<T>(*this); }

◆ exists_()

template<typename T>
bool edm::PluginDescription< T >::exists_ ( ParameterSet const &  pset) const
inlinefinalprotectedvirtual

◆ findType()

template<typename T>
std::string edm::PluginDescription< T >::findType ( edm::ParameterSet const &  iPSet) const
inlineprivate

Definition at line 246 of file PluginDescription.h.

References CMS_SA_ALLOW, edm::PluginDescription< T >::defaultType_, edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), AlCaHLTBitMon_QueryRunRegistry::string, edm::PluginDescription< T >::typeLabel_, and edm::PluginDescription< T >::typeLabelIsTracked_.

Referenced by edm::PluginDescription< T >::validate_().

246  {
247  if (typeLabelIsTracked_) {
248  CMS_SA_ALLOW if (iPSet.existsAs<std::string>(typeLabel_) || defaultType_.empty()) {
249  return iPSet.getParameter<std::string>(typeLabel_);
250  }
251  else {
252  return defaultType_;
253  }
254  }
255  if (defaultType_.empty()) {
256  return iPSet.getUntrackedParameter<std::string>(typeLabel_);
257  }
258  return iPSet.getUntrackedParameter<std::string>(typeLabel_, defaultType_);
259  }
#define CMS_SA_ALLOW

◆ hasNestedContent_()

template<typename T>
bool edm::PluginDescription< T >::hasNestedContent_ ( ) const
inlinefinalprotectedvirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 156 of file PluginDescription.h.

156 { return true; }

◆ howManyXORSubNodesExist_()

template<typename T>
int edm::PluginDescription< T >::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
inlinefinalprotectedvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 243 of file PluginDescription.h.

References edm::ParameterDescriptionNode::exists(), and muonDTDigis_cfi::pset.

243 { return exists(pset) ? 1 : 0; }
bool exists(ParameterSet const &pset) const

◆ loadDescription()

template<typename T>
ParameterSetDescription edm::PluginDescription< T >::loadDescription ( std::string const &  iName) const
inlineprivate

Definition at line 261 of file PluginDescription.h.

References a, beamerCreator::create(), edm::PluginDescription< T >::defaultType_, submitPVResolutionJobs::desc, AlCaHLTBitMon_QueryRunRegistry::string, edm::PluginDescription< T >::typeLabel_, and edm::PluginDescription< T >::typeLabelIsTracked_.

Referenced by edm::PluginDescription< T >::printNestedContent_(), edm::PluginDescription< T >::validate_(), and edm::PluginDescription< T >::writeCfi_().

261  {
263  std::unique_ptr<CreatedType> a(edmplugin::PluginFactory<CreatedType*()>::get()->create(iName));
264 
265  ParameterSetDescription desc = a->description();
266 
267  //There is no way to check to see if a node already wants a label
268  if (typeLabelIsTracked_) {
269  if (defaultType_.empty()) {
271  } else {
273  }
274  } else {
275  if (defaultType_.empty()) {
276  desc.addUntracked<std::string>(typeLabel_);
277  } else {
278  desc.addUntracked<std::string>(typeLabel_, defaultType_);
279  }
280  }
281  return desc;
282  }
def create(alignables, pedeDump, additionalData, outputFile, config)
double a
Definition: hdecay.h:121

◆ partiallyExists_()

template<typename T>
bool edm::PluginDescription< T >::partiallyExists_ ( ParameterSet const &  pset) const
inlinefinalprotectedvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 241 of file PluginDescription.h.

References edm::PluginDescription< T >::exists_(), and muonDTDigis_cfi::pset.

241 { return exists_(pset); }
bool exists_(ParameterSet const &pset) const final

◆ printNestedContent_()

template<typename T>
void edm::PluginDescription< T >::printNestedContent_ ( std::ostream &  os,
bool  ,
DocFormatHelper dfh 
) const
inlinefinalprotectedvirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 158 of file PluginDescription.h.

References spr::find(), edm::Factory::get(), edmplugin::PluginManager::get(), printContent_cfi::indentation, info(), edm::DocFormatHelper::init(), edm::PluginDescription< T >::loadDescription(), edm::DocFormatHelper::offsetSectionContent(), l1tGTMenu_BTagSeeds_cff::os, cond::pluginCategory(), edm::ParameterSetDescription::print(), edm::ParameterDescriptionNode::printSpaces(), edm::second(), hgcalPlots::section, edm::DocFormatHelper::setSection(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and edm::PluginDescription< T >::typeLabel_.

158  {
159  int indentation = dfh.indentation();
160 
163 
164  std::string const& pluginCategory = Factory::get()->category();
165 
167  os << "There are multiple possible different descriptions for this ParameterSet\n";
169  os << "because it will be used by a helper plugin object contained inside the top level\n";
171  os << "module plugin object and the type of the helper plugin object is configurable.\n";
173  os << "Or if it is in a vector of ParameterSets it might be used by multiple\n";
175  os << "helper plugin objects and each could be configured with a different plugin type.\n";
177  os << "Each plugin type could allow a different set of configuration parameters.\n";
179  os << "Each subsection of this section has one of the possible descriptions.\n";
181  os << "All of these plugins are from the category \"" << pluginCategory << "\".\n";
183  os << "The plugin type is specified by the parameter named \"" << typeLabel_ << "\".\n";
184 
185  if (!dfh.brief()) {
186  os << "\n";
187  }
188  std::string section = dfh.sectionOfCategoryAlreadyPrinted(pluginCategory);
189  if (!section.empty()) {
191  os << "*** The descriptions for this plugin category already started printing above (see Section " << section
192  << ")! ***\n";
194  os << "*** We might still be in the middle of that printout at this point because it might be recursive. ***\n";
196  os << "*** We'll not duplicate that printout and skip it. ***\n";
198  os << "*** (N.B. If we tried to print it again, we might fall into an infinite recursion.) ***\n";
199 
200  if (!dfh.brief()) {
201  os << "\n";
202  }
203  return;
204  }
205  dfh.addCategory(pluginCategory, dfh.section());
206 
208 
209  //loop over all possible plugins
210  unsigned int pluginCount = 1;
211  std::string previousName;
212  for (auto const& info : edmplugin::PluginManager::get()->categoryToInfos().find(pluginCategory)->second) {
213  // We only want to print the first instance of each plugin name
214  if (previousName == info.name_) {
215  continue;
216  }
217 
218  std::stringstream ss;
219  ss << dfh.section() << "." << pluginCount;
220  ++pluginCount;
221  std::string newSection = ss.str();
223  os << "Section " << newSection << " ParameterSet description for plugin named \"" << info.name_ << "\"\n";
224  if (!dfh.brief())
225  os << "\n";
226 
227  DocFormatHelper new_dfh(dfh);
228  new_dfh.init();
229  new_dfh.setSection(newSection);
230 
231  loadDescription(info.name_).print(os, new_dfh);
232 
233  previousName = info.name_;
234  }
235  }
static const TGPicture * info(bool iBackgroundIsBlack)
void print(std::ostream &os, DocFormatHelper &dfh) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
U second(std::pair< T, U > const &p)
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
const char * pluginCategory()
ParameterSetDescription loadDescription(std::string const &iName) const
static Factory const * get()
Definition: Factory.cc:21
static PluginManager * get()

◆ validate_()

template<typename T>
void edm::PluginDescription< T >::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
inlinefinalprotectedvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 127 of file PluginDescription.h.

References edm::PluginDescription< T >::findType(), edm::PluginDescription< T >::loadDescription(), create_idmaps::n, muonDTDigis_cfi::pset, and edm::ParameterSetDescription::validate().

127  {
129  //all names are good
130  auto n = pset.getParameterNames();
131  validatedLabels.insert(n.begin(), n.end());
132  }
std::string findType(edm::ParameterSet const &iPSet) const
ParameterSetDescription loadDescription(std::string const &iName) const
void validate(ParameterSet &pset) const

◆ writeCfi_()

template<typename T>
void edm::PluginDescription< T >::writeCfi_ ( std::ostream &  os,
bool  optional,
bool &  startWithComma,
int  indentation,
CfiOptions options,
bool &  wroteSomething 
) const
inlinefinalprotectedvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 134 of file PluginDescription.h.

References edmplugin::standard::config(), edmplugin::PluginManager::configure(), edm::PluginDescription< T >::defaultType_, printContent_cfi::indentation, edmplugin::PluginManager::isAvailable(), edm::PluginDescription< T >::loadDescription(), AlcaSiPixelAliHarvester0T_cff::options, l1tGTMenu_BTagSeeds_cff::os, edm::cfi::parameterMustBeTyped(), and edm::ParameterSetDescription::writeCfi().

139  {
140  if (not defaultType_.empty()) {
142  auto conf = edmplugin::standard::config();
143  conf.allowNoCache();
145  }
146  //given each plugin can have very different parameters we should do a full dump
147  CfiOptions ops = cfi::Typed{};
148  loadDescription(defaultType_).writeCfi(os, startWithComma, indentation, ops);
149  wroteSomething = true;
150  }
151  if (std::holds_alternative<cfi::ClassFile>(options)) {
152  std::get<cfi::ClassFile>(options).parameterMustBeTyped();
153  }
154  }
static PluginManager & configure(const Config &)
void parameterMustBeTyped(CfiOptions &iOps) noexcept
PluginManager::Config config()
Definition: standard.cc:21
ParameterSetDescription loadDescription(std::string const &iName) const
void writeCfi(std::ostream &os, bool startWithComma, int indentation, CfiOptions &) const
cfi::CfiOptions CfiOptions

Member Data Documentation

◆ defaultType_

template<typename T>
std::string edm::PluginDescription< T >::defaultType_
private

◆ typeLabel_

template<typename T>
std::string edm::PluginDescription< T >::typeLabel_
private

◆ typeLabelIsTracked_

template<typename T>
bool edm::PluginDescription< T >::typeLabelIsTracked_
private