CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
RecordHelper< TOutput > Class Template Reference

#include <RecordHelper.h>

Public Types

typedef coral::AttributeList AttributeList
 
typedef std::vector< FieldHandlerBase< TOutput > * > FieldVector
 

Public Member Functions

template<typename TField >
void addField (const std::string &fieldName, void(TOutput::*setter)(const TField))
 
virtual void extractRecord (const AttributeList &source, TOutput &dest)
 
virtual std::vector< std::string > getColumnList ()
 
virtual ~RecordHelper ()
 

Protected Attributes

FieldVector fields_
 

Detailed Description

template<class TOutput>
class RecordHelper< TOutput >

Description: A microframework to deal with the need to fill rather boring getter/setter classes from Coral classes.

Definition at line 145 of file RecordHelper.h.

Member Typedef Documentation

◆ AttributeList

template<class TOutput>
typedef coral::AttributeList RecordHelper< TOutput >::AttributeList

Definition at line 147 of file RecordHelper.h.

◆ FieldVector

template<class TOutput>
typedef std::vector<FieldHandlerBase<TOutput>*> RecordHelper< TOutput >::FieldVector

A list of field handlers that determine how to handle a record.

Definition at line 149 of file RecordHelper.h.

Constructor & Destructor Documentation

◆ ~RecordHelper()

template<class TOutput>
virtual RecordHelper< TOutput >::~RecordHelper ( )
inlinevirtual

Destructor: Wipe out all the field handlers.

Definition at line 179 of file RecordHelper.h.

179  {
180  for (typename FieldVector::iterator it = fields_.begin(); it < fields_.end(); ++it) {
181  delete *it;
182  }
183  }

References RecordHelper< TOutput >::fields_.

Member Function Documentation

◆ addField()

template<class TOutput>
template<typename TField >
void RecordHelper< TOutput >::addField ( const std::string &  fieldName,
void(TOutput::*)(const TField)  setter 
)
inline

Definition at line 152 of file RecordHelper.h.

152  {
153 #ifdef RECORDHELPER_DEBUG
154  std::cout << "Adding field " << fieldName << ", type = " << typeid(TField).name() << std::endl;
155 #endif
156  this->fields_.push_back(
157  new typename GroupFieldHandler<TOutput, typename Group<TOutput>::Type, TField>::Type(fieldName, setter));
158  }

References gather_cfg::cout, RecordHelper< TOutput >::fields_, and Skims_PA_cff::name.

◆ extractRecord()

template<class TOutput>
virtual void RecordHelper< TOutput >::extractRecord ( const AttributeList source,
TOutput &  dest 
)
inlinevirtual

Iterates over all known fields and extracts the fields of the record in source to the object in dest.

Definition at line 162 of file RecordHelper.h.

162  {
163  for (typename FieldVector::const_iterator it = fields_.begin(); it != fields_.end(); ++it) {
164  (*it)->extractValue(source, dest);
165  }
166  }

References mps_fire::dest, RecordHelper< TOutput >::fields_, and source.

◆ getColumnList()

template<class TOutput>
virtual std::vector<std::string> RecordHelper< TOutput >::getColumnList ( )
inlinevirtual

Returns a list of database column names for the added fields.

Definition at line 169 of file RecordHelper.h.

169  {
170  std::vector<std::string> colList;
171  for (typename FieldVector::const_iterator it = fields_.begin(); it != fields_.end(); ++it) {
172  colList.push_back((*it)->getColumnName());
173  }
174 
175  return colList;
176  }

References RecordHelper< TOutput >::fields_.

Member Data Documentation

◆ fields_

template<class TOutput>
FieldVector RecordHelper< TOutput >::fields_
protected

List of known fields. TODO: Make private, add base type addField.

Definition at line 187 of file RecordHelper.h.

Referenced by RecordHelper< TOutput >::addField(), RecordHelper< TOutput >::extractRecord(), RecordHelper< TOutput >::getColumnList(), and RecordHelper< TOutput >::~RecordHelper().

GroupFieldHandler
Definition: RecordHelper.h:140
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RecordHelper::fields_
FieldVector fields_
Definition: RecordHelper.h:187
susybsm::HSCParticleType::Type
Type
Definition: HSCParticle.h:20
source
static const std::string source
Definition: EdmProvDump.cc:47
Group::Type
TStandardGroup Type
Definition: RecordHelper.h:120
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
mps_fire.dest
dest
Definition: mps_fire.py:179