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 Reflex::Type &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
 
Reflex::Type m_type
 

Detailed Description

Definition at line 143 of file RelationalMapping.h.

Constructor & Destructor Documentation

ora::CArrayMapping::CArrayMapping ( const Reflex::Type &  attributeType,
TableRegister tableRegister 
)

Definition at line 445 of file RelationalMapping.cc.

445  :
446  m_type(attributeType), m_tableRegister( tableRegister ){
447 }
TableRegister & m_tableRegister
ora::CArrayMapping::~CArrayMapping ( )

Definition at line 449 of file RelationalMapping.cc.

449  {
450 }

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 452 of file RelationalMapping.cc.

References ora::MappingElement::appendSubElement(), ora::MappingElement::CArrayMappingElementType(), className(), ora::MappingRules::columnNameForId(), ora::MappingRules::columnNameForPosition(), ora::MappingElement::columnNames(), i, ora::MappingElement::inlineCArrayMappingElementType(), ora::MappingRules::MaxColumnsForInlineCArray, ora::MappingRules::MaxColumnsPerTable, ora::MappingRules::MaxTableNameLength, ora::MappingRules::newNameForArraySchemaObject(), ora::RelationalMappingFactory::newProcessor(), ora::ClassUtils::resolvedType(), ora::MappingElement::setColumnNames(), ora::RelationalMapping::sizeInColumnsForCArray(), AlCaHLTBitMon_QueryRunRegistry::string, ora::MappingElement::tableName(), ora::throwException(), 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_FASTSIM(), ConfigBuilder.ConfigBuilder::prepare_HLT(), ConfigBuilder.ConfigBuilder::prepare_LHE(), 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().

455  {
456  Reflex::Type arrayElementType = m_type.ToType();
457  if( !arrayElementType || !ClassUtils::resolvedType( arrayElementType ) ){
458  throwException("Cannot resolve the type of the content of the array \""+m_type.Name(Reflex::SCOPED)+"\".",
459  "CArrayMapping::process");
460  }
461 
462  if(!m_tableRegister.checkTable(parentElement.tableName())){
463  throwException("Table \""+parentElement.tableName()+"\" has not been allocated.",
464  "CArrayMapping::process");
465  }
466  std::string className = m_type.Name(Reflex::SCOPED);
467  RelationalMappingFactory mappingFactory( m_tableRegister );
468 
469  std::string arrayScopeNameForSchema = scopeNameForSchema;
470  if( !arrayScopeNameForSchema.empty() ) arrayScopeNameForSchema +="_";
471  arrayScopeNameForSchema += attributeNameForSchema;
472 
473  std::pair<bool,size_t> arraySizeInColumns = RelationalMapping::sizeInColumnsForCArray( m_type );
474  if( !arraySizeInColumns.first && arraySizeInColumns.second < MappingRules::MaxColumnsForInlineCArray ) {
475  size_t columnsInTable = m_tableRegister.numberOfColumns(parentElement.tableName()) + arraySizeInColumns.second;
476  if( columnsInTable < MappingRules::MaxColumnsPerTable ){
477  // Inline C-Array
479  ora::MappingElement& me = parentElement.appendSubElement( mappingElementType, attributeName, className, parentElement.tableName() );
480  me.setColumnNames( parentElement.columnNames() );
481  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( arrayElementType ) );
482  for(size_t i=0;i<m_type.ArrayLength();i++){
483  processor->process( me, MappingRules::variableNameForArrayIndex(attributeName,i),
484  MappingRules::variableNameForArrayColumn(i), arrayScopeNameForSchema );
485  }
486  return;
487  }
488  }
490  std::string tableName = parentElement.tableName();
491  std::string initialTable(tableName);
492 
493  std::string arrayTable(initialTable);
494  unsigned int i=0;
495  while(m_tableRegister.checkTable(arrayTable)){
497  i++;
498  }
499  m_tableRegister.insertTable(arrayTable);
501  attributeName, className, arrayTable );
502  const std::vector<std::string>& parentColumns = parentElement.columnNames();
503  if( parentColumns.empty()){
504  throwException( "No column name found in the parent mapping element.","CArrayMapping::process");
505  }
506  std::vector<std::string> columns;
507  // always comes the oid first
508  columns.push_back( ora::MappingRules::columnNameForId() );
509  std::vector<std::string>::const_iterator iColumn = parentColumns.begin();
510  // then copy the columns except the id...
511  iColumn++;
512  for ( ;iColumn != parentColumns.end(); ++iColumn ) {
513  columns.push_back( ora::MappingRules::columnNameForId() + "_" + *iColumn );
514  }
515  // and finally add the position!
516  columns.push_back( ora::MappingRules::columnNameForPosition() );
517  me.setColumnNames( columns );
518  m_tableRegister.insertColumns(arrayTable, columns );
519 
520  std::string contentTypeName = arrayElementType.Name();
522  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( arrayElementType ) );
523  processor->process( me, contentTypeName, variableNameForSchema, arrayScopeNameForSchema );
524 }
int i
Definition: DBlmapReader.cc:9
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)
static std::string columnNameForPosition()
void insertTable(const std::string &tableName)
std::pair< bool, size_t > sizeInColumnsForCArray(const Reflex::Type &arrayType)
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
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
static std::string inlineCArrayMappingElementType()
Returns the name of the inline array mapping element type.
static const size_t MaxColumnsPerTable
Definition: MappingRules.h:21
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
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::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.

Reflex::Type ora::CArrayMapping::m_type
private

Definition at line 152 of file RelationalMapping.h.