12 #include "CoralBase/AttributeSpecification.h"
17 bool hasDependencies =
false;
22 std::pair<bool,size_t>
25 bool hasDependencies =
false;
27 return std::make_pair(hasDependencies,sz);
34 bool& hasDependencies ){
46 if( arraySize < MappingRules::MaxColumnsForInlineCArray ) sz += arraySize;
47 else hasDependencies =
true;
56 if( !isContainer && !isOraPointer ){
62 for (
auto const & member : members) {
74 hasDependencies =
true;
82 bool& hasDependencies){
91 size_t arrayElementSize = 0;
93 size_t totSize = arraySize*arrayElementSize;
99 m_tableRegister( tableRegister ){
106 bool blobStreaming ){
108 return new BlobMapping( attributeType, m_tableRegister );
118 return new ArrayMapping( attributeType, m_tableRegister );
153 "processLeafElement");
164 std::vector<std::string> cols;
165 cols.push_back( columnName );
170 cols.push_back( metaDataColumnName );
177 m_type(attributeType),m_tableRegister( tableRegister ){
188 const std::type_info* attrType = t.
isEnum() ? &
typeid(int) : &t.
typeInfo();
191 std::string typeName = coral::AttributeSpecification::typeNameForId(*attrType);
197 attributeNameForSchema,
203 m_type(attributeType),m_tableRegister( tableRegister ){
217 attributeNameForSchema,
223 m_type(attributeType),m_tableRegister( tableRegister ){
235 if(!m_tableRegister.checkTable( parentElement.
tableName())){
237 "OraReferenceMapping::process");
241 std::vector<std::string> cols;
242 for(
unsigned int j=0;
j<2;
j++){
246 while(m_tableRegister.checkColumn(parentElement.
tableName(),columnName)){
250 m_tableRegister.insertColumn(parentElement.
tableName(),columnName);
251 cols.push_back( columnName );
257 m_type(attributeType),m_tableRegister( tableRegister ){
269 if(!m_tableRegister.checkTable( parentElement.
tableName())){
271 "UniqueReferenceMapping::process");
275 std::vector< std::string > cols;
279 while(m_tableRegister.checkColumn(parentElement.
tableName(),columnName)){
283 m_tableRegister.insertColumn(parentElement.
tableName(),columnName);
284 cols.push_back(columnName);
289 while(m_tableRegister.checkColumn(parentElement.
tableName(),columnName)){
293 m_tableRegister.insertColumn(parentElement.
tableName(),columnName);
294 cols.push_back(columnName);
300 m_type(attributeType), m_tableRegister( tableRegister ){
319 std::auto_ptr<IRelationalMapping> processor( factory.
newProcessor( ptrType ) );
320 processor->process( me, ptrTypeName, attributeNameForSchema, scopeNameForSchema );
324 m_type( attributeType ),
325 m_tableRegister( tableRegister ){
338 std::vector< std::string > cols;
342 while(m_tableRegister.checkColumn(parentElement.
tableName(),columnName)){
346 m_tableRegister.insertColumn(parentElement.
tableName(),columnName);
347 cols.push_back(columnName);
354 m_type(attributeType), m_tableRegister( tableRegister ){
369 while(m_tableRegister.checkTable(arrayTable)){
373 m_tableRegister.insertTable(arrayTable);
382 const std::vector<std::string>& parentColumns = parentElement.
columnNames();
383 if( parentColumns.empty()){
384 throwException(
"No column name found in the parent mapping element.",
"ArrayMapping::process");
387 std::vector<std::string>
columns;
390 std::vector<std::string>::const_iterator iColumn = parentColumns.begin();
393 for ( ;iColumn != parentColumns.end(); iColumn++ ) {
400 m_tableRegister.insertColumns(arrayTable, columns );
402 std::string arrayScopeNameForSchema = scopeNameForSchema;
403 if( !arrayScopeNameForSchema.empty() ) arrayScopeNameForSchema +=
"_";
404 arrayScopeNameForSchema += attributeNameForSchema;
414 if( singleItemContainer ){
416 contentTypeName =
"value_type";
418 else if ( associativeContainer ) {
420 contentTypeName =
"mapped_type";
423 throwException(
"Cannot not resolve the type of the key item of container \""+m_type.cppName()+
"\".",
424 "ArrayMapping::process");
429 throwException(
"Container type=\""+m_type.cppName()+
"\".is not supported.",
430 "ArrayMapping::process");
434 throwException(
"Cannot not resolve the type of the content item of container \""+m_type.cppName()+
"\".",
435 "ArrayMapping::process");
441 std::auto_ptr<IRelationalMapping> keyProcessor( mappingFactory.
newProcessor( keyType ) );
442 keyProcessor->process( me, keyTypeName, keyTypeNameForSchema, arrayScopeNameForSchema );
445 std::auto_ptr<IRelationalMapping> contentProcessor( mappingFactory.
newProcessor( contentType ) );
446 contentProcessor->process( me, contentTypeName, contentTypeNameForSchema, arrayScopeNameForSchema );
450 m_type(attributeType), m_tableRegister( tableRegister ){
462 throwException(
"Cannot resolve the type of the content of the array \""+m_type.cppName()+
"\".",
463 "CArrayMapping::process");
466 if(!m_tableRegister.checkTable(parentElement.
tableName())){
468 "CArrayMapping::process");
473 std::string arrayScopeNameForSchema = scopeNameForSchema;
474 if( !arrayScopeNameForSchema.empty() ) arrayScopeNameForSchema +=
"_";
475 arrayScopeNameForSchema += attributeNameForSchema;
480 size_t columnsInTable = m_tableRegister.numberOfColumns(parentElement.
tableName()) + arraySizeInColumns.second;
486 std::auto_ptr<IRelationalMapping> processor( mappingFactory.
newProcessor( arrayElementType ) );
488 for(
size_t i=0;
i<arraySize;
i++){
501 while(m_tableRegister.checkTable(arrayTable)){
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");
512 std::vector<std::string>
columns;
515 std::vector<std::string>::const_iterator iColumn = parentColumns.begin();
518 for ( ;iColumn != parentColumns.end(); ++iColumn ) {
524 m_tableRegister.insertColumns(arrayTable, columns );
528 std::auto_ptr<IRelationalMapping> processor( mappingFactory.
newProcessor( arrayElementType ) );
529 processor->process( me, contentTypeName, variableNameForSchema, arrayScopeNameForSchema );
533 m_type(attributeType), m_tableRegister( tableRegister ){
555 for (
auto const &
b : bases) {
559 throwException(
"Class for base \""+base.
name()+
"\" is not in the dictionary.",
"ObjectMapping::process");
565 for (
auto const & member : members) {
580 std::auto_ptr<IRelationalMapping> processor( mappingFactory.
newProcessor( type, blobStreaming ) );
581 processor->process( mappingElement, objectMemberName, objectMemberNameForSchema, scopeNameForSchema );
602 std::string objectScopeNameForSchema = scopeNameForSchema;
603 if( !objectScopeNameForSchema.empty() ) objectScopeNameForSchema +=
"_";
604 objectScopeNameForSchema += attributeNameForSchema;
608 for (
auto const & member : members) {
617 throwException(
"Type for data member \""+objectMember.
name()+
"\" of class \""+className+
618 "\" has not been found in the dictionary.",
619 "ObjectMapping::process");
624 if( declaringType != objectType ){
633 std::auto_ptr<IRelationalMapping> processor( mappingFactory.
newProcessor( type, blobStreaming ) );
634 processor->process( me, objectMemberName, objectNameForSchema, objectScopeNameForSchema );
static std::string namedReferenceMappingElementType()
Returns the name of the named reference element type.
static std::string blobMappingElementType()
Returns the name of the blob mapping element type.
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
static std::string arrayMappingElementType()
Returns the name of the array mapping element type.
void processBaseClasses(MappingElement &mappingElement, const edm::TypeWithDict &objType, const std::string &scopeNameForSchema, TableRegister &tableRegister)
static std::string columnNameForRefId(const std::string &variableName, const std::string &scope)
static std::string variableNameForArrayIndex(const std::string &arrayVariable, unsigned int index)
void _sizeInColumns(const edm::TypeWithDict &typ, size_t &sz, bool &hasDependencies)
static std::string scopedVariableName(const std::string &variableName, const std::string &scope)
variable name manipulation
static std::string variableNameForContainerKey()
static std::string primitiveMappingElementType()
Returns the name of the primitive mapping element type.
static std::string variableNameForArrayColumn(unsigned int arrayIndex)
bool isTypeNamedReference(const edm::TypeWithDict &typ)
static std::string variableNameForContainerValue()
static std::string persistencyPropertyNameInDictionary()
static const size_t MaxColumnsForInlineCArray
bool isTypeString(const edm::TypeWithDict &typ)
static std::string scopedVariableForSchemaObjects(const std::string &variableName, const std::string &scope)
bool insertColumn(const std::string &tableName, const std::string &columnName)
UniqueReferenceMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
RelationalMappingFactory(TableRegister &tableRegister)
static std::string OraReferenceMappingElementType()
Returns the name of the ORA reference mapping element type.
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
MappingElement & appendSubElement(const std::string &elementType, const std::string &variableName, const std::string &variableType, const std::string &tableName)
bool hasBase(std::string const &) const
bool isTypePrimitive(const edm::TypeWithDict &typ)
TypeWithDict toType() const
static std::string columnNameForVariable(const std::string &variableName, const std::string &scope, bool forData=true)
bool isTypeOraPointer(const edm::TypeWithDict &typ)
TypeWithDict templateArgumentAt(size_t index) const
TypeWithDict declaringType() const
bool isTypeNonAssociativeContainer(const edm::TypeWithDict &typ)
static std::string mappingPropertyNameInDictionary()
class related parameters
static std::string columnNameForPosition()
std::string cppName() const
bool isTypePVector(const edm::TypeWithDict &typ)
IRelationalMapping * newProcessor(const edm::TypeWithDict &attributeType, bool blobStreaming=false)
bool isTypeUniqueReference(const edm::TypeWithDict &typ)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
CArrayMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
static std::string columnNameForOID(const std::string &variableName, const std::string &scope, unsigned int index)
PrimitiveMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
TypeWithDict typeOf() const
static std::string objectMappingElementType()
Returns the name of the object mapping element type.
std::type_info const & typeInfo() const
TypeWithDict typeOf() const
static std::string columnNameForBlobMetadata(const std::string &dataColumnName)
void _sizeInColumnsForCArray(const edm::TypeWithDict &typ, size_t &sz, bool &hasDependencies)
static std::string newNameForArraySchemaObject(const std::string &initialName, unsigned int index, size_t maxLength)
static bool isMappedToBlob(const std::string &mappingProperty)
static std::string columnNameForId()
static std::string uniqueReferenceMappingElementType()
Returns the name of the ORA polymorphic pointer mapping element type.
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
const std::vector< std::string > & columnNames() const
OraReferenceMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
bool isMappedToBlob(const edm::MemberWithDict &dataMember)
static bool isLooseOnWriting(const std::string &persistencyProperty)
OraPtrMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
BlobMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
virtual ~RelationalMappingFactory()
static std::string inlineCArrayMappingElementType()
Returns the name of the inline array mapping element type.
static std::string columnNameForRefMetadata(const std::string &variableName, const std::string &scope)
bool checkColumn(const std::string &tableName, const std::string &columnName)
void processLeafElement(MappingElement &parentElement, const std::string &elementType, const std::string &typeName, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema, TableRegister &tableRegister)
bool isTypeAssociativeContainer(const edm::TypeWithDict &typ)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
size_t arrayLength(const edm::TypeWithDict &typ)
bool isTypeQueryableVector(const edm::TypeWithDict &typ)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
edm::TypeWithDict containerKeyType(const edm::TypeWithDict &typ)
edm::TypeWithDict containerDataType(const edm::TypeWithDict &typ)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
static const size_t MaxColumnsPerTable
static std::string columnNameForNamedReference(const std::string &variableName, const std::string &scope)
static std::string OraPointerMappingElementType()
Returns the name of the ORA pointer mapping element type.
size_t sizeInColumns(const edm::TypeWithDict &topLevelClassType)
static std::string OraArrayMappingElementType()
Returns the name of the ORA array mapping element type.
ArrayMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
ObjectMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
edm::TypeWithDict containerValueType(const edm::TypeWithDict &typ)
static const size_t MaxColumnNameLength
NamedRefMapping(const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
~UniqueReferenceMapping()
const std::string & tableName() const
bool isLoosePersistencyOnWriting(const edm::MemberWithDict &dataMember)
std::string getDataMemberProperty(const std::string &propertyName, const edm::MemberWithDict &dataMember)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
bool isTypeContainer(const edm::TypeWithDict &typ)
static const size_t MaxTableNameLength
bool checkTable(const std::string &tableName)
static std::string newNameForSchemaObject(const std::string &initialName, unsigned int index, size_t maxLength, char indexTrailer=0)
functions for new schema object name generation
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)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
void setColumnNames(const std::vector< std::string > &columns)