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
 
 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, 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, 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 237 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_().

237  {
238  if (typeLabelIsTracked_) {
239  CMS_SA_ALLOW if (iPSet.existsAs<std::string>(typeLabel_) || defaultType_.empty()) {
240  return iPSet.getParameter<std::string>(typeLabel_);
241  }
242  else {
243  return defaultType_;
244  }
245  }
246  if (defaultType_.empty()) {
247  return iPSet.getUntrackedParameter<std::string>(typeLabel_);
248  }
249  return iPSet.getUntrackedParameter<std::string>(typeLabel_, defaultType_);
250  }
#define CMS_SA_ALLOW

◆ hasNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 147 of file PluginDescription.h.

147 { return true; }

◆ howManyXORSubNodesExist_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 234 of file PluginDescription.h.

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

234 { 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 252 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_().

252  {
254  std::unique_ptr<CreatedType> a(edmplugin::PluginFactory<CreatedType*()>::get()->create(iName));
255 
256  ParameterSetDescription desc = a->description();
257 
258  //There is no way to check to see if a node already wants a label
259  if (typeLabelIsTracked_) {
260  if (defaultType_.empty()) {
262  } else {
264  }
265  } else {
266  if (defaultType_.empty()) {
267  desc.addUntracked<std::string>(typeLabel_);
268  } else {
269  desc.addUntracked<std::string>(typeLabel_, defaultType_);
270  }
271  }
272  return desc;
273  }
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 232 of file PluginDescription.h.

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

232 { 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 149 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(), 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_.

149  {
150  int indentation = dfh.indentation();
151 
154 
155  std::string const& pluginCategory = Factory::get()->category();
156 
158  os << "There are multiple possible different descriptions for this ParameterSet\n";
160  os << "because it will be used by a helper plugin object contained inside the top level\n";
162  os << "module plugin object and the type of the helper plugin object is configurable.\n";
164  os << "Or if it is in a vector of ParameterSets it might be used by multiple\n";
166  os << "helper plugin objects and each could be configured with a different plugin type.\n";
168  os << "Each plugin type could allow a different set of configuration parameters.\n";
170  os << "Each subsection of this section has one of the possible descriptions.\n";
172  os << "All of these plugins are from the category \"" << pluginCategory << "\".\n";
174  os << "The plugin type is specified by the parameter named \"" << typeLabel_ << "\".\n";
175 
176  if (!dfh.brief()) {
177  os << "\n";
178  }
179  std::string section = dfh.sectionOfCategoryAlreadyPrinted(pluginCategory);
180  if (!section.empty()) {
182  os << "*** The descriptions for this plugin category already started printing above (see Section " << section
183  << ")! ***\n";
185  os << "*** We might still be in the middle of that printout at this point because it might be recursive. ***\n";
187  os << "*** We'll not duplicate that printout and skip it. ***\n";
189  os << "*** (N.B. If we tried to print it again, we might fall into an infinite recursion.) ***\n";
190 
191  if (!dfh.brief()) {
192  os << "\n";
193  }
194  return;
195  }
196  dfh.addCategory(pluginCategory, dfh.section());
197 
199 
200  //loop over all possible plugins
201  unsigned int pluginCount = 1;
202  std::string previousName;
203  for (auto const& info : edmplugin::PluginManager::get()->categoryToInfos().find(pluginCategory)->second) {
204  // We only want to print the first instance of each plugin name
205  if (previousName == info.name_) {
206  continue;
207  }
208 
209  std::stringstream ss;
210  ss << dfh.section() << "." << pluginCount;
211  ++pluginCount;
212  std::string newSection = ss.str();
214  os << "Section " << newSection << " ParameterSet description for plugin named \"" << info.name_ << "\"\n";
215  if (!dfh.brief())
216  os << "\n";
217 
218  DocFormatHelper new_dfh(dfh);
219  new_dfh.init();
220  new_dfh.setSection(newSection);
221 
222  loadDescription(info.name_).print(os, new_dfh);
223 
224  previousName = info.name_;
225  }
226  }
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(), dqmiodumpmetadata::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,
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(), and edm::ParameterSetDescription::writeCfi().

135  {
136  if (not defaultType_.empty()) {
138  auto conf = edmplugin::standard::config();
139  conf.allowNoCache();
141  }
142  loadDescription(defaultType_).writeCfi(os, startWithComma, indentation);
143  wroteSomething = true;
144  }
145  }
static PluginManager & configure(const Config &)
void writeCfi(std::ostream &os, bool startWithComma, int indentation) const
PluginManager::Config config()
Definition: standard.cc:21
ParameterSetDescription loadDescription(std::string const &iName) const

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