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 (char const *value)
 
void setComment (std::string 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
 
std::shared_ptr< ParameterSetDescriptionloadDescription (std::string const &iName) const
 
void loadPlugin (std::string const &iName) const
 

Private Attributes

std::shared_ptr< ParameterSetDescriptioncache_
 
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 98 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 104 of file PluginDescription.h.

105  : typeLabel_{std::move(typeLabel)}, typeLabelIsTracked_{typeLabelIsTracked} {}

References eostools::move().

◆ 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 112 of file PluginDescription.h.

113  : typeLabel_{std::move(typeLabel)},
114  defaultType_{std::move(defaultType)},
115  typeLabelIsTracked_{typeLabelIsTracked} {}

References eostools::move().

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 121 of file PluginDescription.h.

123  {}

◆ clone()

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

Implements edm::ParameterDescriptionNode.

Definition at line 118 of file PluginDescription.h.

118 { 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 205 of file PluginDescription.h.

205  {
206  if (typeLabelIsTracked_) {
207  if (iPSet.existsAs<std::string>(typeLabel_) || defaultType_.empty()) {
208  return iPSet.getParameter<std::string>(typeLabel_);
209  } else {
210  return defaultType_;
211  }
212  }
213  if (defaultType_.empty()) {
214  return iPSet.getUntrackedParameter<std::string>(typeLabel_);
215  }
216  return iPSet.getUntrackedParameter<std::string>(typeLabel_, defaultType_);
217  }

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

◆ hasNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 149 of file PluginDescription.h.

149 { return true; }

◆ howManyXORSubNodesExist_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 202 of file PluginDescription.h.

202 { return exists(pset) ? 1 : 0; }

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

◆ loadDescription()

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

Definition at line 225 of file PluginDescription.h.

225  {
227  std::unique_ptr<CreatedType> a(edmplugin::PluginFactory<CreatedType*()>::get()->create(iName));
228 
229  std::shared_ptr<ParameterSetDescription> desc = std::make_shared<ParameterSetDescription>(a->description());
230 
231  //There is no way to check to see if a node already wants a label
232  if (typeLabelIsTracked_) {
233  if (defaultType_.empty()) {
234  desc->add<std::string>(typeLabel_);
235  } else {
237  }
238  } else {
239  if (defaultType_.empty()) {
240  desc->addUntracked<std::string>(typeLabel_);
241  } else {
242  desc->addUntracked<std::string>(typeLabel_, defaultType_);
243  }
244  }
245  return desc;
246  }

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

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

◆ loadPlugin()

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

◆ partiallyExists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 200 of file PluginDescription.h.

200 { return exists_(pset); }

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

◆ printNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 151 of file PluginDescription.h.

151  {
152  int indentation = dfh.indentation();
153 
155  using Factory = edmplugin::PluginFactory<CreatedType*()>;
156 
157  {
158  std::stringstream ss;
159  ss << dfh.section() << "." << dfh.counter();
160  std::string newSection = ss.str();
161 
163  os << "Section " << newSection << " " << Factory::get()->category() << " Plugins description:\n";
164  if (!dfh.brief())
165  os << "\n";
166  }
167 
168  //loop over all possible plugins
169  unsigned int pluginCount = 0;
170  std::string previousName;
171  for (auto const& info :
173  // We only want to print the first instance of each plugin name
174  if (previousName == info.name_) {
175  continue;
176  }
177 
178  std::stringstream ss;
179  ss << dfh.section() << "." << dfh.counter();
180  std::string newSection = ss.str();
182  os << "Section " << newSection << "." << ++pluginCount << " " << info.name_ << " Plugin description:\n";
183  if (!dfh.brief())
184  os << "\n";
185 
186  DocFormatHelper new_dfh(dfh);
187  new_dfh.init();
188  new_dfh.setSection(newSection);
189 
190  loadDescription(info.name_)->print(os, new_dfh);
191 
192  previousName = info.name_;
193  }
194  }

References taus_updatedMVAIds_cff::category, edmplugin::PluginManager::categoryToInfos(), edm::Factory::get(), edmplugin::PluginManager::get(), printContent_cfi::indentation, info(), edm::DocFormatHelper::init(), edm::PluginDescription< T >::loadDescription(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::setSection(), contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ 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 125 of file PluginDescription.h.

125  {
127  cache_->validate(pset);
128  //all names are good
129  auto n = pset.getParameterNames();
130  validatedLabels.insert(n.begin(), n.end());
131  }

References edm::PluginDescription< T >::cache_, edm::PluginDescription< T >::findType(), edm::PluginDescription< T >::loadPlugin(), dqmiodumpmetadata::n, and muonDTDigis_cfi::pset.

◆ 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 133 of file PluginDescription.h.

134  {
135  if (not defaultType_.empty()) {
137  auto conf = edmplugin::standard::config();
138  conf.allowNoCache();
140  }
141 
143 
144  cache_->writeCfi(os, startWithComma, indentation);
145  wroteSomething = true;
146  }
147  }

References edm::PluginDescription< T >::cache_, edmplugin::standard::config(), edmplugin::PluginManager::configure(), edm::PluginDescription< T >::defaultType_, printContent_cfi::indentation, edmplugin::PluginManager::isAvailable(), and edm::PluginDescription< T >::loadPlugin().

Member Data Documentation

◆ cache_

template<typename T >
std::shared_ptr<ParameterSetDescription> edm::PluginDescription< T >::cache_
mutableprivate

◆ 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
edm::PluginDescription::loadPlugin
void loadPlugin(std::string const &iName) const
Definition: PluginDescription.h:219
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
PluginDescription
edm::ParameterDescriptionNode::exists
bool exists(ParameterSet const &pset) const
Definition: ParameterDescriptionNode.h:134
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::PluginDescription::cache_
std::shared_ptr< ParameterSetDescription > cache_
Definition: PluginDescription.h:250
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
edmplugin::PluginManager::get
static PluginManager * get()
Definition: PluginManager.cc:306
edmplugin::PluginManager::categoryToInfos
const CategoryToInfos & categoryToInfos() const
Definition: PluginManager.h:82
edm::PluginDescription::defaultType_
std::string defaultType_
Definition: PluginDescription.h:252
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::PluginDescription::loadDescription
std::shared_ptr< ParameterSetDescription > loadDescription(std::string const &iName) const
Definition: PluginDescription.h:225
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::PluginDescription::exists_
bool exists_(ParameterSet const &pset) const final
Definition: PluginDescription.h:196
a
double a
Definition: hdecay.h:119
edm::PluginDescription::typeLabel_
std::string typeLabel_
Definition: PluginDescription.h:251
edmplugin::PluginManager::configure
static PluginManager & configure(const Config &)
Definition: PluginManager.cc:315
edmplugin::PluginFactory
Definition: PluginFactory.h:34
edm::PluginDescription::typeLabelIsTracked_
bool typeLabelIsTracked_
Definition: PluginDescription.h:253
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:675
edmplugin::standard::config
PluginManager::Config config()
Definition: standard.cc:21
edm::PluginDescription::findType
std::string findType(edm::ParameterSet const &iPSet) const
Definition: PluginDescription.h:205
edm::ParameterDescriptionNode::printSpaces
static void printSpaces(std::ostream &os, int n)
Definition: ParameterDescriptionNode.cc:124
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::Factory::get
static Factory const * get()
Definition: Factory.cc:23
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
PluginDescriptionAdaptorBase
edmplugin::PluginManager::isAvailable
static bool isAvailable()
Definition: PluginManager.cc:346
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27