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::MappingGenerator Class Reference

#include <MappingGenerator.h>

Public Member Functions

void createNewDependentMapping (const Reflex::Type &dependentClassDictionary, const MappingTree &parentClassMapping, MappingTree &destination)
 
void createNewDependentMapping (const Reflex::Type &dependentClassDictionary, const MappingTree &parentClassMapping, const MappingTree &dependentClassBaseMapping, MappingTree &destination)
 
void createNewMapping (const std::string &containerName, const Reflex::Type &classDictionary, MappingTree &destination)
 
void createNewMapping (const std::string &containerName, const Reflex::Type &classDictionary, const MappingTree &baseMapping, MappingTree &destination)
 
 MappingGenerator (coral::ISchema &schema)
 Constructor. More...
 
 ~MappingGenerator ()
 Destructor. More...
 

Private Attributes

coral::ISchema & m_schema
 
TableRegister m_tableRegister
 

Detailed Description

Definition at line 23 of file MappingGenerator.h.

Constructor & Destructor Documentation

ora::MappingGenerator::MappingGenerator ( coral::ISchema &  schema)
explicit

Constructor.

Definition at line 9 of file MappingGenerator.cc.

9  :
10  m_schema( schema ),
12 }
coral::ISchema & m_schema
TableRegister m_tableRegister
ora::MappingGenerator::~MappingGenerator ( )

Destructor.

Definition at line 14 of file MappingGenerator.cc.

14 {}

Member Function Documentation

void ora::MappingGenerator::createNewDependentMapping ( const Reflex::Type &  dependentClassDictionary,
const MappingTree parentClassMapping,
MappingTree destination 
)

Definition at line 58 of file MappingGenerator.cc.

References className(), ora::MappingRules::ClassNameLengthForSchema, ora::MappingRules::columnNameForId(), ora::MappingRules::columnNameForRefColumn(), ora::MappingRules::formatName(), i, ora::MappingRules::MaxColumnsPerTable, ora::MappingRules::MaxTableNameLength, ora::MappingRules::newNameForDepSchemaObject(), ora::RelationalMappingFactory::newProcessor(), ora::MappingElement::setColumnNames(), ora::MappingTree::setDependency(), ora::MappingTree::setTopElement(), ora::RelationalMapping::sizeInColumns(), AlCaHLTBitMon_QueryRunRegistry::string, ora::MappingElement::tableName(), ora::throwException(), and ora::MappingTree::topElement().

60  {
61  std::string className = classDictionary.Name(Reflex::SCOPED);
62 
63  size_t sz = RelationalMapping::sizeInColumns( classDictionary );
65  std::stringstream messg;
66  messg << "Cannot process default mapping for class \"" << className+"\"";
67  messg << " : number of columns ("<<sz<<") required exceedes maximum="<< MappingRules::MaxColumnsPerTable;
68  throwException( messg.str(),"MappingGenerator::processClass");
69  }
70 
71  std::string mainTableName = parentClassMapping.topElement().tableName();
72  std::string initialTable = mainTableName;
74  unsigned int i=0;
75  while(m_tableRegister.checkTable(tableName)){
77  i++;
78  }
79  m_tableRegister.insertTable(tableName);
80 
81  destination.setDependency( parentClassMapping );
82  ora::MappingElement& classElement = destination.setTopElement( className, tableName, true );
83  // Set the id of the class
84  std::vector<std::string> columns;
85  columns.push_back( ora::MappingRules::columnNameForId() );
86  columns.push_back( ora::MappingRules::columnNameForRefColumn() );
87  classElement.setColumnNames( columns );
88  m_tableRegister.insertColumns(tableName, columns );
89  RelationalMappingFactory mappingFactory( m_tableRegister );
90  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( classDictionary ) );
92  std::string scope("");
93  processor->process( classElement, className, nameForSchema, scope );
94 }
int i
Definition: DBlmapReader.cc:9
bool insertColumns(const std::string &tableName, const std::vector< std::string > &columns)
static std::string newNameForDepSchemaObject(const std::string &initialName, unsigned int index, size_t maxLength)
static std::string columnNameForRefColumn()
void insertTable(const std::string &tableName)
static std::string columnNameForId()
size_t sizeInColumns(const Reflex::Type &topLevelClassType)
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
TableRegister m_tableRegister
static const size_t ClassNameLengthForSchema
size parameters for table creation
Definition: MappingRules.h:18
static const size_t MaxTableNameLength
Definition: MappingRules.h:19
bool checkTable(const std::string &tableName)
static std::string formatName(const std::string &variableName, size_t maxLength)
formatting for variable names to schema object names
std::string className(const T &t)
Definition: ClassName.h:30
void setColumnNames(const std::vector< std::string > &columns)
void ora::MappingGenerator::createNewDependentMapping ( const Reflex::Type &  dependentClassDictionary,
const MappingTree parentClassMapping,
const MappingTree dependentClassBaseMapping,
MappingTree destination 
)

Definition at line 96 of file MappingGenerator.cc.

References ora::MappingTree::className(), ora::MappingTree::override(), and ora::throwException().

99  {
100  createNewDependentMapping( classDictionary, parentClassMapping, destination );
101  if(dependentClassBaseMapping.className()!=destination.className()){
102  throwException( "Mapping specified as base does not map the target class \"" + destination.className()+"\"",
103  "MappingGenerator::createNewDependentMapping" );
104  }
105  destination.override( dependentClassBaseMapping );
106 }
void createNewDependentMapping(const Reflex::Type &dependentClassDictionary, const MappingTree &parentClassMapping, MappingTree &destination)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void ora::MappingGenerator::createNewMapping ( const std::string &  containerName,
const Reflex::Type &  classDictionary,
MappingTree destination 
)

Definition at line 16 of file MappingGenerator.cc.

References className(), ora::MappingRules::ClassNameLengthForSchema, ora::MappingRules::columnNameForId(), ora::MappingElement::columnNames(), ora::MappingRules::formatName(), ora::MappingRules::MaxColumnsPerTable, ora::RelationalMappingFactory::newProcessor(), ora::MappingElement::setColumnNames(), ora::MappingTree::setTopElement(), ora::RelationalMapping::sizeInColumns(), AlCaHLTBitMon_QueryRunRegistry::string, ora::MappingRules::tableNameForItem(), and ora::throwException().

Referenced by ora::ContainerSchema::create().

18  {
19  std::string className = classDictionary.Name(Reflex::SCOPED);
20 
21  size_t sz = RelationalMapping::sizeInColumns( classDictionary );
23  std::stringstream messg;
24  messg << "Cannot process default mapping for class \"" << className+"\"";
25  messg << " : number of columns ("<<sz<<") required exceedes maximum="<< MappingRules::MaxColumnsPerTable;
26  throwException( messg.str(),"MappingGenerator::processClass");
27  }
28 
29  std::string tableName = ora::MappingRules::tableNameForItem( containerName );
30  if(m_tableRegister.checkTable(tableName)){
31  throwException( "Table \"" +tableName+ "\" already assigned, cannot be allocated for the mapping of class \""+className+"\"",
32  "MappingGenerator::processClass");
33  }
34  m_tableRegister.insertTable(tableName);
35  // Define the top level element
36  MappingElement& topElement = destination.setTopElement( className, tableName );
37  topElement.setColumnNames( std::vector< std::string >( 1, ora::MappingRules::columnNameForId() ) );
38  m_tableRegister.insertColumns(tableName, topElement.columnNames() );
39  RelationalMappingFactory mappingFactory( m_tableRegister );
40  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( classDictionary ) );
42  std::string scope("");
43  processor->process( topElement, className, nameForSchema, scope );
44 }
bool insertColumns(const std::string &tableName, const std::vector< std::string > &columns)
void insertTable(const std::string &tableName)
static std::string columnNameForId()
size_t sizeInColumns(const Reflex::Type &topLevelClassType)
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
TableRegister m_tableRegister
static const size_t ClassNameLengthForSchema
size parameters for table creation
Definition: MappingRules.h:18
static std::string tableNameForItem(const std::string &itemName)
schema object naming
bool checkTable(const std::string &tableName)
static std::string formatName(const std::string &variableName, size_t maxLength)
formatting for variable names to schema object names
std::string className(const T &t)
Definition: ClassName.h:30
void ora::MappingGenerator::createNewMapping ( const std::string &  containerName,
const Reflex::Type &  classDictionary,
const MappingTree baseMapping,
MappingTree destination 
)

Definition at line 46 of file MappingGenerator.cc.

References ora::MappingTree::className(), ora::MappingTree::override(), and ora::throwException().

49  {
50  createNewMapping( containerName, classDictionary, destination );
51  if(baseMapping.className()!=destination.className()){
52  throwException( "Mapping specified as base does not map the target class \"" + destination.className()+"\"",
53  "MappingGenerator::createNewMapping" );
54  }
55  destination.override( baseMapping );
56 }
void createNewMapping(const std::string &containerName, const Reflex::Type &classDictionary, MappingTree &destination)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10

Member Data Documentation

coral::ISchema& ora::MappingGenerator::m_schema
private

Definition at line 44 of file MappingGenerator.h.

TableRegister ora::MappingGenerator::m_tableRegister
private

Definition at line 45 of file MappingGenerator.h.