CMS 3D CMS Logo

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

#include <RelationalMapping.h>

Inheritance diagram for ora::CArrayMapping:
ora::IRelationalMapping

Public Member Functions

 CArrayMapping (const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
 
void process (MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
 
 ~CArrayMapping ()
 
- Public Member Functions inherited from ora::IRelationalMapping
virtual ~IRelationalMapping ()
 

Private Attributes

TableRegisterm_tableRegister
 
edm::TypeWithDict m_type
 

Detailed Description

Definition at line 143 of file RelationalMapping.h.

Constructor & Destructor Documentation

ora::CArrayMapping::CArrayMapping ( const edm::TypeWithDict attributeType,
TableRegister tableRegister 
)

Definition at line 449 of file RelationalMapping.cc.

449  :
450  m_type(attributeType), m_tableRegister( tableRegister ){
451 }
TableRegister & m_tableRegister
edm::TypeWithDict m_type
ora::CArrayMapping::~CArrayMapping ( )

Definition at line 453 of file RelationalMapping.cc.

453  {
454 }

Member Function Documentation

void ora::CArrayMapping::process ( MappingElement parentElement,
const std::string &  attributeName,
const std::string &  attributeNameForSchema,
const std::string &  scopeNameForSchema 
)
virtual

otherwise, process as standard CArrays in separate tables

Implements ora::IRelationalMapping.

Definition at line 456 of file RelationalMapping.cc.

References ora::MappingElement::appendSubElement(), ora::ClassUtils::arrayLength(), ora::MappingElement::CArrayMappingElementType(), className(), ora::MappingRules::columnNameForId(), ora::MappingRules::columnNameForPosition(), ora::MappingElement::columnNames(), mps_check::columns, i, ora::MappingElement::inlineCArrayMappingElementType(), ora::MappingRules::MaxColumnsForInlineCArray, ora::MappingRules::MaxColumnsPerTable, ora::MappingRules::MaxTableNameLength, edm::TypeWithDict::name(), ora::MappingRules::newNameForArraySchemaObject(), ora::RelationalMappingFactory::newProcessor(), ora::ClassUtils::resolvedType(), ora::MappingElement::setColumnNames(), ora::RelationalMapping::sizeInColumnsForCArray(), AlCaHLTBitMon_QueryRunRegistry::string, HLT_25ns10e33_v2_cff::tableName, ora::MappingElement::tableName(), ora::throwException(), edm::TypeWithDict::toType(), ora::MappingRules::variableNameForArrayColumn(), and ora::MappingRules::variableNameForArrayIndex().

Referenced by ConfigBuilder.ConfigBuilder::addExtraStream(), ConfigBuilder.ConfigBuilder::completeInputCommand(), ConfigBuilder.ConfigBuilder::doNotInlineEventContent(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::dumpPython(), ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::open(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::outputEventContent(), ConfigBuilder.ConfigBuilder::prepare_HLT(), ConfigBuilder.ConfigBuilder::prepare_LHE(), ConfigBuilder.ConfigBuilder::prepare_PATFILTER(), ConfigBuilder.ConfigBuilder::prepare_VALIDATION(), ConfigBuilder.ConfigBuilder::renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder::renameInputTagsInSequence(), ConfigBuilder.ConfigBuilder::scheduleSequence(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProcess(), and Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProperty().

459  {
460  edm::TypeWithDict arrayElementType = m_type.toType();
461  if( !arrayElementType || !ClassUtils::resolvedType( arrayElementType ) ){
462  throwException("Cannot resolve the type of the content of the array \""+m_type.cppName()+"\".",
463  "CArrayMapping::process");
464  }
465 
466  if(!m_tableRegister.checkTable(parentElement.tableName())){
467  throwException("Table \""+parentElement.tableName()+"\" has not been allocated.",
468  "CArrayMapping::process");
469  }
471  RelationalMappingFactory mappingFactory( m_tableRegister );
472 
473  std::string arrayScopeNameForSchema = scopeNameForSchema;
474  if( !arrayScopeNameForSchema.empty() ) arrayScopeNameForSchema +="_";
475  arrayScopeNameForSchema += attributeNameForSchema;
476 
477  std::pair<bool,size_t> arraySizeInColumns = RelationalMapping::sizeInColumnsForCArray( m_type );
478 
479  if( !arraySizeInColumns.first && arraySizeInColumns.second < MappingRules::MaxColumnsForInlineCArray ) {
480  size_t columnsInTable = m_tableRegister.numberOfColumns(parentElement.tableName()) + arraySizeInColumns.second;
481  if( columnsInTable < MappingRules::MaxColumnsPerTable ){
482  // Inline C-Array
484  ora::MappingElement& me = parentElement.appendSubElement( mappingElementType, attributeName, className, parentElement.tableName() );
485  me.setColumnNames( parentElement.columnNames() );
486  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( arrayElementType ) );
487  size_t arraySize = ClassUtils::arrayLength( m_type );
488  for(size_t i=0;i<arraySize;i++){
489  processor->process( me, MappingRules::variableNameForArrayIndex(attributeName,i),
490  MappingRules::variableNameForArrayColumn(i), arrayScopeNameForSchema );
491  }
492  return;
493  }
494  }
496  std::string tableName = parentElement.tableName();
497  std::string initialTable(tableName);
498 
499  std::string arrayTable(initialTable);
500  unsigned int i=0;
501  while(m_tableRegister.checkTable(arrayTable)){
503  i++;
504  }
505  m_tableRegister.insertTable(arrayTable);
507  attributeName, className, arrayTable );
508  const std::vector<std::string>& parentColumns = parentElement.columnNames();
509  if( parentColumns.empty()){
510  throwException( "No column name found in the parent mapping element.","CArrayMapping::process");
511  }
512  std::vector<std::string> columns;
513  // always comes the oid first
514  columns.push_back( ora::MappingRules::columnNameForId() );
515  std::vector<std::string>::const_iterator iColumn = parentColumns.begin();
516  // then copy the columns except the id...
517  iColumn++;
518  for ( ;iColumn != parentColumns.end(); ++iColumn ) {
519  columns.push_back( ora::MappingRules::columnNameForId() + "_" + *iColumn );
520  }
521  // and finally add the position!
522  columns.push_back( ora::MappingRules::columnNameForPosition() );
523  me.setColumnNames( columns );
524  m_tableRegister.insertColumns(arrayTable, columns );
525 
526  std::string contentTypeName = arrayElementType.name();
528  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( arrayElementType ) );
529  processor->process( me, contentTypeName, variableNameForSchema, arrayScopeNameForSchema );
530 }
int i
Definition: DBlmapReader.cc:9
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
static std::string variableNameForArrayIndex(const std::string &arrayVariable, unsigned int index)
static std::string variableNameForArrayColumn(unsigned int arrayIndex)
bool insertColumns(const std::string &tableName, const std::vector< std::string > &columns)
static const size_t MaxColumnsForInlineCArray
Definition: MappingRules.h:22
size_t numberOfColumns(const std::string &tableName)
MappingElement & appendSubElement(const std::string &elementType, const std::string &variableName, const std::string &variableType, const std::string &tableName)
TypeWithDict toType() const
static std::string columnNameForPosition()
std::string name() const
std::string cppName() const
void insertTable(const std::string &tableName)
static std::string newNameForArraySchemaObject(const std::string &initialName, unsigned int index, size_t maxLength)
static std::string columnNameForId()
const std::vector< std::string > & columnNames() const
TableRegister & m_tableRegister
static std::string inlineCArrayMappingElementType()
Returns the name of the inline array mapping element type.
size_t arrayLength(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:493
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
static const size_t MaxColumnsPerTable
Definition: MappingRules.h:21
edm::TypeWithDict m_type
tuple columns
Definition: mps_check.py:210
static const size_t MaxTableNameLength
Definition: MappingRules.h:19
bool checkTable(const std::string &tableName)
static std::string CArrayMappingElementType()
Returns the name of the array mapping element type.
std::pair< bool, size_t > sizeInColumnsForCArray(const edm::TypeWithDict &arrayType)
std::string className(const T &t)
Definition: ClassName.h:30
void setColumnNames(const std::vector< std::string > &columns)

Member Data Documentation

TableRegister& ora::CArrayMapping::m_tableRegister
private

Definition at line 153 of file RelationalMapping.h.

edm::TypeWithDict ora::CArrayMapping::m_type
private

Definition at line 152 of file RelationalMapping.h.