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

Constructor & Destructor Documentation

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

References eostools::move(), and edm::PluginDescription< T >::typeLabelIsTracked_.

104  : typeLabel_{std::move(typeLabel)}, typeLabelIsTracked_{typeLabelIsTracked} {}
def move(src, dest)
Definition: eostools.py:511
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 111 of file PluginDescription.h.

References edm::PluginDescription< T >::defaultType_, eostools::move(), and edm::PluginDescription< T >::typeLabelIsTracked_.

112  : typeLabel_{std::move(typeLabel)},
113  defaultType_{std::move(defaultType)},
114  typeLabelIsTracked_{typeLabelIsTracked} {}
def move(src, dest)
Definition: eostools.py:511

Member Function Documentation

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

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

Implements edm::ParameterDescriptionNode.

Definition at line 117 of file PluginDescription.h.

117 { return new PluginDescription<T>(*this); }
template<typename T>
bool edm::PluginDescription< T >::exists_ ( ParameterSet const &  pset) const
inlinefinalprotectedvirtual
template<typename T>
std::string edm::PluginDescription< T >::findType ( edm::ParameterSet const &  iPSet) const
inlineprivate
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; }
template<typename T>
int edm::PluginDescription< T >::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
inlinefinalprotectedvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 202 of file PluginDescription.h.

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

202 { return exists(pset) ? 1 : 0; }
bool exists(ParameterSet const &pset) const
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.

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

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

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 {
236  desc->add<std::string>(typeLabel_, defaultType_);
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  }
def create(alignables, pedeDump, additionalData, outputFile, config)
double a
Definition: hdecay.h:121
template<typename T>
void edm::PluginDescription< T >::loadPlugin ( std::string const &  iName) const
inlineprivate

Definition at line 219 of file PluginDescription.h.

References edm::PluginDescription< T >::cache_, and edm::PluginDescription< T >::loadDescription().

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

219  {
220  if (not cache_) {
221  cache_ = loadDescription(iName);
222  }
223  }
std::shared_ptr< ParameterSetDescription > loadDescription(std::string const &iName) const
std::shared_ptr< ParameterSetDescription > cache_
template<typename T>
bool edm::PluginDescription< T >::partiallyExists_ ( ParameterSet const &  pset) const
inlinefinalprotectedvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 200 of file PluginDescription.h.

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

200 { return exists_(pset); }
bool exists_(ParameterSet const &pset) const final
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 taus_updatedMVAIds_cff::category, spr::find(), edm::Factory::get(), edmplugin::PluginManager::get(), info(), edm::DocFormatHelper::init(), edm::PluginDescription< T >::loadDescription(), edm::ParameterDescriptionNode::printSpaces(), edm::second(), edm::DocFormatHelper::setSection(), and AlCaHLTBitMon_QueryRunRegistry::string.

149  {
150  int indentation = dfh.indentation();
151 
154 
155  std::stringstream ss;
156  ss << dfh.section() << "." << dfh.counter();
157  std::string newSection = ss.str();
158 
159  printSpaces(os, indentation);
160  os << "Section " << newSection << " " << Factory::get()->category() << " Plugins description:\n";
161  if (!dfh.brief())
162  os << "\n";
163 
164  DocFormatHelper new_dfh(dfh);
165  new_dfh.init();
166  new_dfh.setSection(newSection);
167 
168  //loop over all possible plugins
169  unsigned int pluginCount = 0;
170  std::string previousName;
171  for (auto const& info :
172  edmplugin::PluginManager::get()->categoryToInfos().find(Factory::get()->category())->second) {
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();
181  printSpaces(os, indentation);
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  }
static const TGPicture * info(bool iBackgroundIsBlack)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
U second(std::pair< T, U > const &p)
std::shared_ptr< ParameterSetDescription > loadDescription(std::string const &iName) const
static Factory const * get()
Definition: Factory.cc:23
static void printSpaces(std::ostream &os, int n)
static PluginManager * get()
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 124 of file PluginDescription.h.

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

124  {
125  loadPlugin(findType(pset));
126  cache_->validate(pset);
127  //all names are good
128  auto n = pset.getParameterNames();
129  validatedLabels.insert(n.begin(), n.end());
130  }
std::string findType(edm::ParameterSet const &iPSet) const
void loadPlugin(std::string const &iName) const
std::shared_ptr< ParameterSetDescription > cache_
template<typename T>
void edm::PluginDescription< T >::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
inlinefinalprotectedvirtual

Implements edm::ParameterDescriptionNode.

Definition at line 132 of file PluginDescription.h.

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

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

Member Data Documentation

template<typename T>
std::shared_ptr<ParameterSetDescription> edm::PluginDescription< T >::cache_
mutableprivate
template<typename T>
std::string edm::PluginDescription< T >::defaultType_
private
template<typename T>
std::string edm::PluginDescription< T >::typeLabel_
private
template<typename T>
bool edm::PluginDescription< T >::typeLabelIsTracked_
private