test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes | Private Attributes
ora::ObjectStreamerBase Class Referenceabstract

#include <ObjectStreamer.h>

Inheritance diagram for ora::ObjectStreamerBase:
ora::ObjectReader ora::ObjectUpdater ora::ObjectWriter

Public Member Functions

void buildBaseDataMembers (DataElement &dataElement, IRelationalData &relationalData, const edm::TypeWithDict &objType, RelationalBuffer *operationBuffer)
 
bool buildDataMembers (DataElement &dataElement, IRelationalData &relationalData, RelationalBuffer *operationBuffer)
 
 ObjectStreamerBase (const edm::TypeWithDict &objectType, MappingElement &mapping, ContainerSchema &contSchema)
 
virtual void processDataMember (DataElement &dataElement, IRelationalData &relationalData, edm::TypeWithDict &dataMemberType, MappingElement &dataMemberMapping, RelationalBuffer *operationBuffer)=0
 
virtual ~ObjectStreamerBase ()
 

Protected Attributes

RelationalStreamerFactory m_streamerFactory
 

Private Attributes

MappingElementm_mapping
 
edm::TypeWithDict m_objectType
 

Detailed Description

Definition at line 15 of file ObjectStreamer.h.

Constructor & Destructor Documentation

ora::ObjectStreamerBase::ObjectStreamerBase ( const edm::TypeWithDict objectType,
MappingElement mapping,
ContainerSchema contSchema 
)

Definition at line 20 of file ObjectStreamer.cc.

22  :
23  m_streamerFactory( contSchema ),
24  m_objectType( objectType ),
25  m_mapping( mapping ){
26 }
MappingElement & m_mapping
edm::TypeWithDict m_objectType
RelationalStreamerFactory m_streamerFactory
ora::ObjectStreamerBase::~ObjectStreamerBase ( )
virtual

Definition at line 28 of file ObjectStreamer.cc.

28  {
29 }

Member Function Documentation

void ora::ObjectStreamerBase::buildBaseDataMembers ( DataElement dataElement,
IRelationalData relationalData,
const edm::TypeWithDict objType,
RelationalBuffer operationBuffer 
)

Definition at line 32 of file ObjectStreamer.cc.

References ora::DataElement::addChild(), b, newFWLiteAna::base, ora::ClassUtils::checkMappedType(), edm::TypeWithDict::cppName(), edm::MemberWithDict::declaringType(), ora::isLoosePersistencyDataMember(), edm::MemberWithDict::isStatic(), edm::MemberWithDict::isTransient(), edm::MemberWithDict::name(), edm::TypeWithDict::name(), edm::BaseWithDict::offset(), edm::MemberWithDict::offset(), ora::ClassUtils::resolvedType(), ora::MappingRules::scopedVariableName(), AlCaHLTBitMon_QueryRunRegistry::string, ora::throwException(), edm::TypeWithDict::toType(), edm::BaseWithDict::typeOf(), edm::MemberWithDict::typeOf(), and ora::MappingElement::variableType().

35  {
36 
37  // Don't look for base classes of std:: stuff
38  if(objType.name().substr(0,5) == "std::") {
39  return;
40  }
41  edm::TypeBases bases(objType);
42  for (auto const & b : bases) {
44  edm::TypeWithDict baseType = ClassUtils::resolvedType( base.typeOf().toType() );
45  buildBaseDataMembers( dataElement, relationalData, baseType, operationBuffer );
46  edm::TypeDataMembers members(baseType);
47  for (auto const & member : members) {
48  edm::MemberWithDict dataMember(member);
49  DataElement& dataMemberElement = dataElement.addChild( dataMember.offset(), /*base.offsetFP()*/ base.offset() );
50  // Ignore the transients and the statics (how to deal with non-const statics?)
51  if ( dataMember.isTransient() || dataMember.isStatic() ) continue;
52  // Get the member type and resolve possible typedef chains
53  edm::TypeWithDict dataMemberType = ClassUtils::resolvedType( dataMember.typeOf() );
54  if ( ! dataMemberType ) {
55  throwException( "Missing dictionary information for data member \"" +
56  dataMember.name() + "\" of class \"" +
57  baseType.cppName() + "\"",
58  "ObjectStreamerBase::buildBaseDataMembers" );
59  }
60 
61  // check if the member is from a class in the inheritance tree
62  edm::TypeWithDict declaringType = ClassUtils::resolvedType( dataMember.declaringType());
63  std::string scope = declaringType.cppName();
64  // Get the data member name
65  std::string dataMemberName = MappingRules::scopedVariableName( dataMember.name(), scope );
66  // Retrieve the relevant mapping element
67  MappingElement::iterator iDataMemberMapping = m_mapping.find( dataMemberName );
68  if ( iDataMemberMapping != m_mapping.end() ) {
69  MappingElement& dataMemberMapping = iDataMemberMapping->second;
70  if( !ClassUtils::checkMappedType(dataMemberType,dataMemberMapping.variableType()) ){
71  throwException( "Data member \""+dataMemberName +"\" type \"" + dataMemberType.cppName() +
72  "\" does not match with the expected type in the mapping \""+dataMemberMapping.variableType()+"\".",
73  "ObjectStreamerBase::buildBaseDataMembers" );
74  }
75  processDataMember( dataMemberElement, relationalData, dataMemberType, dataMemberMapping, operationBuffer );
76  } else {
77  if( !isLoosePersistencyDataMember( dataMember ) ){
78  throwException( "Data member \"" + dataMemberName +
79  "\" not found in the mapping element of variable \""+m_mapping.variableName()+"\".",
80  "ObjectStreamerBase::buildBaseDataMembers" );
81  }
82  }
83  }
84  }
85 
86 }
tuple base
Main Program
Definition: newFWLiteAna.py:91
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
bool isLoosePersistencyDataMember(const edm::MemberWithDict &dataMember)
static std::string scopedVariableName(const std::string &variableName, const std::string &scope)
variable name manipulation
const std::string & variableName() const
MappingElement & m_mapping
virtual void processDataMember(DataElement &dataElement, IRelationalData &relationalData, edm::TypeWithDict &dataMemberType, MappingElement &dataMemberMapping, RelationalBuffer *operationBuffer)=0
std::string name() const
std::string cppName() const
bool checkMappedType(const edm::TypeWithDict &type, const std::string &mappedTypeName)
Definition: ClassUtils.cc:114
iterator find(const std::string &key)
Retrieves a sub-element.
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
void buildBaseDataMembers(DataElement &dataElement, IRelationalData &relationalData, const edm::TypeWithDict &objType, RelationalBuffer *operationBuffer)
double b
Definition: hdecay.h:120
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
iterator end()
Returns an iterator in the end of the sequence.
bool ora::ObjectStreamerBase::buildDataMembers ( DataElement dataElement,
IRelationalData relationalData,
RelationalBuffer operationBuffer 
)

Definition at line 88 of file ObjectStreamer.cc.

References ora::DataElement::addChild(), ora::ClassUtils::checkMappedType(), edm::TypeWithDict::cppName(), edm::MemberWithDict::declaringType(), ora::isLoosePersistencyDataMember(), edm::MemberWithDict::isStatic(), edm::MemberWithDict::isTransient(), edm::MemberWithDict::name(), edm::MemberWithDict::offset(), ora::ClassUtils::resolvedType(), ora::MappingRules::scopedVariableName(), AlCaHLTBitMon_QueryRunRegistry::string, ora::throwException(), edm::MemberWithDict::typeOf(), and ora::MappingElement::variableType().

90  {
91  buildBaseDataMembers( dataElement, relationalData, m_objectType, operationBuffer );
92  // Loop over the data members of the class.
94  for (auto const & member : members) {
95  edm::MemberWithDict dataMember(member);
96  DataElement& dataMemberElement = dataElement.addChild( dataMember.offset(), 0 );
97 
98  edm::TypeWithDict declaringType = ClassUtils::resolvedType( dataMember.declaringType());
99  if( declaringType != m_objectType ){
100  continue;
101  }
102 
103  // Ignore the transients and the statics (how to deal with non-const statics?)
104  if ( dataMember.isTransient() || dataMember.isStatic() ) continue;
105 
106  // Get the member type and resolve possible typedef chains
107  edm::TypeWithDict dataMemberType = ClassUtils::resolvedType( dataMember.typeOf() );
108  if ( ! dataMemberType ) {
109  throwException( "Missing dictionary information for data member \"" +
110  dataMember.name() + "\" of class \"" +
111  m_objectType.cppName() + "\"",
112  "ObjectStreamerBase::buildDataMembers" );
113  }
114 
115  // check if the member is from a class in the inheritance tree
116  std::string scope("");
117  // Get the data member name
118  std::string dataMemberName = MappingRules::scopedVariableName( dataMember.name(), scope );
119 
120  // Retrieve the relevant mapping element
121  MappingElement::iterator idataMemberMapping = m_mapping.find( dataMemberName );
122  if ( idataMemberMapping != m_mapping.end() ) {
123  MappingElement& dataMemberMapping = idataMemberMapping->second;
124  if( !ClassUtils::checkMappedType(dataMemberType,dataMemberMapping.variableType())){
125  throwException( "Data member \""+dataMemberName +"\" type \"" + dataMemberType.cppName() +
126  "\" does not match with the expected type in the mapping \""+dataMemberMapping.variableType()+"\".",
127  "ObjectStreamerBase::buildDataMembers" );
128  }
129  processDataMember( dataMemberElement, relationalData, dataMemberType, dataMemberMapping, operationBuffer );
130  } else {
131  if(!isLoosePersistencyDataMember( dataMember ) ){
132  throwException( "Data member \"" + dataMemberName +
133  "\" not found in the mapping element of variable \""+m_mapping.variableName()+"\".",
134  "ObjectStreamerBase::buildDataMembers" );
135  }
136  }
137  }
138  return true;
139 }
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
bool isLoosePersistencyDataMember(const edm::MemberWithDict &dataMember)
static std::string scopedVariableName(const std::string &variableName, const std::string &scope)
variable name manipulation
const std::string & variableName() const
MappingElement & m_mapping
virtual void processDataMember(DataElement &dataElement, IRelationalData &relationalData, edm::TypeWithDict &dataMemberType, MappingElement &dataMemberMapping, RelationalBuffer *operationBuffer)=0
std::string cppName() const
bool checkMappedType(const edm::TypeWithDict &type, const std::string &mappedTypeName)
Definition: ClassUtils.cc:114
iterator find(const std::string &key)
Retrieves a sub-element.
std::map< std::string, MappingElement >::iterator iterator
Iterator definition.
void buildBaseDataMembers(DataElement &dataElement, IRelationalData &relationalData, const edm::TypeWithDict &objType, RelationalBuffer *operationBuffer)
edm::TypeWithDict m_objectType
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
iterator end()
Returns an iterator in the end of the sequence.
virtual void ora::ObjectStreamerBase::processDataMember ( DataElement dataElement,
IRelationalData relationalData,
edm::TypeWithDict dataMemberType,
MappingElement dataMemberMapping,
RelationalBuffer operationBuffer 
)
pure virtual

Member Data Documentation

MappingElement& ora::ObjectStreamerBase::m_mapping
private

Definition at line 26 of file ObjectStreamer.h.

edm::TypeWithDict ora::ObjectStreamerBase::m_objectType
private

Definition at line 25 of file ObjectStreamer.h.

RelationalStreamerFactory ora::ObjectStreamerBase::m_streamerFactory
protected

Definition at line 23 of file ObjectStreamer.h.