CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RelationalMapping.cc
Go to the documentation of this file.
4 #include "RelationalMapping.h"
5 #include "TableRegister.h"
6 #include "MappingElement.h"
7 #include "MappingRules.h"
8 #include "ClassUtils.h"
9 // externals
10 #include "Reflex/Reflex.h"
11 #include "CoralBase/AttributeSpecification.h"
12 
13 size_t
15  size_t sz=0;
16  bool hasDependencies = false;
17  _sizeInColumns(topLevelClassType, sz, hasDependencies );
18  return sz;
19 }
20 
21 std::pair<bool,size_t>
23  size_t sz=0;
24  bool hasDependencies = false;
25  _sizeInColumnsForCArray(topLevelClassType, sz, hasDependencies );
26  return std::make_pair(hasDependencies,sz);
27 }
28 
29 
30 void
32  size_t& sz,
33  bool& hasDependencies ){
34  // resolve possible typedef chains
35  Reflex::Type typ = ClassUtils::resolvedType( topLevelClassType );
36  bool isOraPolyPointer = ora::ClassUtils::isTypeUniqueReference(typ);
37  bool isPrimitive = ora::ClassUtils::isTypePrimitive( typ );
38 
39  // primitive and string
40  if( isPrimitive || isOraPolyPointer || ora::ClassUtils::isTypeNamedReference( typ)) {
41  ++sz;
42  } else if (typ.IsArray()){
43  size_t arraySize = 0;
44  _sizeInColumnsForCArray( typ,arraySize, hasDependencies );
45  if( arraySize < MappingRules::MaxColumnsForInlineCArray ) sz += arraySize;
46  else hasDependencies = true;
47  } else if (typ.TypeInfo() == typeid(ora::Reference) ||
48  typ.HasBase( Reflex::Type::ByTypeInfo( typeid(ora::Reference) ) )){
49  sz += 2;
50  } else {
51 
52  bool isContainer = ora::ClassUtils::isTypeNonAssociativeContainer(typ) ||
54  bool isOraPointer = ora::ClassUtils::isTypeOraPointer(typ);
55  if( !isContainer && !isOraPointer ){
56 
57  // loop over the data members
58  typ.UpdateMembers();
59  //std::vector<Reflex::Type> carrays;
60  for ( size_t i=0; i< typ.DataMemberSize(); i++){
61  Reflex::Member objMember = typ.DataMemberAt(i);
62 
63  // Skip the transient ones
64  if ( objMember.IsTransient() ) continue;
65 
66  // Retrieve the field type
67  Reflex::Type objMemberType = objMember.TypeOf();
68 
69  _sizeInColumns(objMemberType,sz, hasDependencies );
70  }
71  } else {
72  hasDependencies = true;
73  }
74  }
75 }
76 
77 void
79  size_t& sz,
80  bool& hasDependencies){
81  // resolve possible typedef chains
82  Reflex::Type typ = ClassUtils::resolvedType( topLevelClassType );
83  if( !typ.IsArray()){
84  return;
85  }
86 
87  size_t arraySize = typ.ArrayLength();
88  Reflex::Type arrayType = typ.ToType();
89  size_t arrayElementSize = 0;
90  _sizeInColumns(arrayType, arrayElementSize, hasDependencies);
91  size_t totSize = arraySize*arrayElementSize;
92  sz += totSize;
93 }
94 
95 
97  m_tableRegister( tableRegister ){
98 }
99 
101 }
102 
104  bool blobStreaming ){
105  if( blobStreaming ){
106  return new BlobMapping( attributeType, m_tableRegister );
107  }
108  Reflex::Type resType = ClassUtils::resolvedType( attributeType );
109  if ( ora::ClassUtils::isTypePrimitive(resType) ) {
110  return new PrimitiveMapping( attributeType, m_tableRegister );
111  }
112  else if ( resType.IsArray() ){
113  return new CArrayMapping( attributeType, m_tableRegister );
114  }
115  else if ( ora::ClassUtils::isTypeContainer( resType ) ) {
116  return new ArrayMapping( attributeType, m_tableRegister );
117  }
118  else if ( resType.IsPointer() || resType.IsReference() ){
119  return new EmptyMapping();
120  }
121  else if ( ora::ClassUtils::isTypeOraPointer( resType )){
122  return new OraPtrMapping( attributeType, m_tableRegister );
123  }
124  else if ( ora::ClassUtils::isTypeUniqueReference( resType )){
125  return new UniqueReferenceMapping( attributeType, m_tableRegister );
126  }
127  else if ( resType.TypeInfo() == typeid(ora::Reference) ||
128  resType.HasBase( Reflex::Type::ByTypeInfo( typeid(ora::Reference) ) ) ){
129  return new OraReferenceMapping( attributeType, m_tableRegister );
130  }
131  else if ( resType.TypeInfo() == typeid(ora::NamedReference) ||
132  resType.HasBase( Reflex::Type::ByTypeInfo( typeid(ora::NamedReference) ) ) ){
133  return new NamedRefMapping( attributeType, m_tableRegister );
134  }
135  else { // embeddedobject
136  return new ObjectMapping( attributeType, m_tableRegister );
137  }
138 }
139 
140 namespace ora {
141  void processLeafElement( MappingElement& parentElement,
142  const std::string& elementType,
143  const std::string& typeName,
144  const std::string& attributeName,
145  const std::string& attributeNameForSchema,
146  const std::string& scopeNameForSchema,
147  TableRegister& tableRegister){
148  if(!tableRegister.checkTable( parentElement.tableName())){
149  throwException("Table \""+parentElement.tableName()+"\" has not been allocated.",
150  "processLeafElement");
151  }
152  ora::MappingElement& me = parentElement.appendSubElement( elementType, attributeName, typeName, parentElement.tableName() );
153  std::string inputCol = ora::MappingRules::columnNameForVariable( attributeNameForSchema, scopeNameForSchema );
154  std::string columnName(inputCol);
155  unsigned int i=0;
156  while(tableRegister.checkColumn(parentElement.tableName(),columnName)){
158  i++;
159  }
160  tableRegister.insertColumn(parentElement.tableName(),columnName);
161  std::vector<std::string> cols;
162  cols.push_back( columnName );
163  // add metadata column for blobs
164  if( elementType == ora::MappingElement::blobMappingElementType() ){
165  std::string metaDataColumnName = ora::MappingRules::columnNameForBlobMetadata( columnName );
166  tableRegister.insertColumn(parentElement.tableName(),metaDataColumnName );
167  cols.push_back( metaDataColumnName );
168  }
169  me.setColumnNames( cols );
170  }
171 }
172 
174  m_type(attributeType),m_tableRegister( tableRegister ){
175 }
176 
178 }
179 
181  const std::string& attributeName,
182  const std::string& attributeNameForSchema,
183  const std::string& scopeNameForSchema ){
185  const std::type_info* attrType = &t.TypeInfo();
186  if(t.IsEnum()) attrType = &typeid(int);
187  //std::string tn = ClassUtils::demangledName(*attrType);
188  if(ClassUtils::isTypeString( t )) attrType = &typeid(std::string);
189  std::string typeName = coral::AttributeSpecification::typeNameForId(*attrType);
190 
191  processLeafElement(parentElement,
193  typeName,
194  attributeName,
195  attributeNameForSchema,
196  scopeNameForSchema,
197  m_tableRegister);
198 }
199 
200 ora::BlobMapping::BlobMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
201  m_type(attributeType),m_tableRegister( tableRegister ){
202 }
203 
205 }
207  const std::string& attributeName,
208  const std::string& attributeNameForSchema,
209  const std::string& scopeNameForSchema ){
210  std::string className = m_type.Name(Reflex::SCOPED);
211  processLeafElement(parentElement,
213  className,
214  attributeName,
215  attributeNameForSchema,
216  scopeNameForSchema,
217  m_tableRegister);
218 }
219 
221  m_type(attributeType),m_tableRegister( tableRegister ){
222 }
223 
225 }
226 
228  const std::string& attributeName,
229  const std::string& attributeNameForSchema,
230  const std::string& scopeNameForSchema ){
231  std::string className = m_type.Name(Reflex::SCOPED);
233  if(!m_tableRegister.checkTable( parentElement.tableName())){
234  throwException("Table \""+parentElement.tableName()+"\" has not been allocated.",
235  "OraReferenceMapping::process");
236  }
237  ora::MappingElement& me = parentElement.appendSubElement( elementType, attributeName, className, parentElement.tableName() );
238 
239  std::vector<std::string> cols;
240  for(unsigned int j=0;j<2;j++){
241  std::string inputCol = ora::MappingRules::columnNameForOID( attributeNameForSchema, scopeNameForSchema, j );
242  std::string columnName(inputCol);
243  unsigned int i=0;
244  while(m_tableRegister.checkColumn(parentElement.tableName(),columnName)){
246  i++;
247  }
248  m_tableRegister.insertColumn(parentElement.tableName(),columnName);
249  cols.push_back( columnName );
250  }
251  me.setColumnNames( cols );
252 }
253 
255  m_type(attributeType),m_tableRegister( tableRegister ){
256 }
257 
259 }
260 
262  const std::string& attributeName,
263  const std::string& attributeNameForSchema,
264  const std::string& scopeNameForSchema ){
265 
266  std::string typeName = m_type.Name(Reflex::SCOPED);
267  if(!m_tableRegister.checkTable( parentElement.tableName())){
268  throwException("Table \""+parentElement.tableName()+"\" has not been allocated.",
269  "UniqueReferenceMapping::process");
270  }
271  ora::MappingElement& me = parentElement.appendSubElement( ora::MappingElement::uniqueReferenceMappingElementType(), attributeName, typeName, parentElement.tableName() );
272 
273  std::vector< std::string > cols;
274  std::string inputCol = ora::MappingRules::columnNameForRefMetadata( attributeNameForSchema, scopeNameForSchema );
275  std::string columnName(inputCol);
276  unsigned int i=0;
277  while(m_tableRegister.checkColumn(parentElement.tableName(),columnName)){
279  i++;
280  }
281  m_tableRegister.insertColumn(parentElement.tableName(),columnName);
282  cols.push_back(columnName);
283 
284  std::string idCol = ora::MappingRules::columnNameForRefId( attributeNameForSchema, scopeNameForSchema);
285  columnName = idCol;
286  i=0;
287  while(m_tableRegister.checkColumn(parentElement.tableName(),columnName)){
289  i++;
290  }
291  m_tableRegister.insertColumn(parentElement.tableName(),columnName);
292  cols.push_back(columnName);
293 
294  me.setColumnNames( cols );
295 }
296 
297 ora::OraPtrMapping::OraPtrMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
298  m_type(attributeType), m_tableRegister( tableRegister ){
299 }
300 
302 }
303 
305  const std::string& attributeName,
306  const std::string& attributeNameForSchema,
307  const std::string& scopeNameForSchema ){
308 
309  std::string typeName = m_type.Name(Reflex::SCOPED);
310  ora::MappingElement& me = parentElement.appendSubElement( ora::MappingElement::OraPointerMappingElementType(), attributeName, typeName, parentElement.tableName() );
311  me.setColumnNames( parentElement.columnNames() );
312 
313  Reflex::Type ptrType = m_type.TemplateArgumentAt(0);
314  std::string ptrTypeName = ptrType.Name();
315 
316  RelationalMappingFactory factory( m_tableRegister );
317  std::auto_ptr<IRelationalMapping> processor( factory.newProcessor( ptrType ) );
318  processor->process( me, ptrTypeName, attributeNameForSchema, scopeNameForSchema );
319 }
320 
321 ora::NamedRefMapping::NamedRefMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
322  m_type( attributeType ),
323  m_tableRegister( tableRegister ){
324 }
325 
327 }
328 
330  const std::string& attributeName,
331  const std::string& attributeNameForSchema,
332  const std::string& scopeNameForSchema ){
333  std::string typeName = m_type.Name(Reflex::SCOPED);
334  ora::MappingElement& me = parentElement.appendSubElement( ora::MappingElement::namedReferenceMappingElementType(), attributeName, typeName, parentElement.tableName() );
335 
336  std::vector< std::string > cols;
337  std::string inputCol = ora::MappingRules::columnNameForNamedReference( attributeNameForSchema, scopeNameForSchema );
338  std::string columnName(inputCol);
339  unsigned int i=0;
340  while(m_tableRegister.checkColumn(parentElement.tableName(),columnName)){
342  i++;
343  }
344  m_tableRegister.insertColumn(parentElement.tableName(),columnName);
345  cols.push_back(columnName);
346 
347  me.setColumnNames( cols );
348 
349 }
350 
351 ora::ArrayMapping::ArrayMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
352  m_type(attributeType), m_tableRegister( tableRegister ){
353 }
354 
356 }
357 
359  const std::string& attributeName,
360  const std::string& attributeNameForSchema,
361  const std::string& scopeNameForSchema ){
362  std::string tableName = parentElement.tableName();
363  std::string initialTable(tableName);
364 
365  std::string arrayTable(initialTable);
366  unsigned int i=0;
367  while(m_tableRegister.checkTable(arrayTable)){
369  i++;
370  }
371  m_tableRegister.insertTable(arrayTable);
372 
373  std::string className = m_type.Name(Reflex::SCOPED);
374 
378  }
379  ora::MappingElement& me = parentElement.appendSubElement( elementType,attributeName,className,arrayTable );
380  const std::vector<std::string>& parentColumns = parentElement.columnNames();
381  if( parentColumns.empty()){
382  throwException( "No column name found in the parent mapping element.","ArrayMapping::process");
383  }
384 
385  std::vector<std::string> columns;
386  // always comes the oid first
387  columns.push_back( ora::MappingRules::columnNameForId() );
388  std::vector<std::string>::const_iterator iColumn = parentColumns.begin();
389  // then copy the columns except the id...
390  iColumn++;
391  for ( ;iColumn != parentColumns.end(); iColumn++ ) {
392  columns.push_back( ora::MappingRules::columnNameForId() + "_" + *iColumn );
393  }
394  // and finally add the position!
395  columns.push_back( ora::MappingRules::columnNameForPosition() );
396 
397  me.setColumnNames( columns );
398  m_tableRegister.insertColumns(arrayTable, columns );
399 
400  std::string arrayScopeNameForSchema = scopeNameForSchema;
401  if( !arrayScopeNameForSchema.empty() ) arrayScopeNameForSchema +="_";
402  arrayScopeNameForSchema += attributeNameForSchema;
403 
404 
405  bool singleItemContainer = ora::ClassUtils::isTypeNonAssociativeContainer(m_type);
406  bool associativeContainer = ora::ClassUtils::isTypeAssociativeContainer(m_type);
407 
408  Reflex::Type contentType;
409  Reflex::Type keyType;
410 
411  if( singleItemContainer ){
412  contentType = ClassUtils::containerValueType(m_type);
413  }
414  else if ( associativeContainer ) { // This is an associative container type
415  contentType = ClassUtils::containerDataType( m_type );
416  keyType = ClassUtils::containerKeyType( m_type );
417  if( !keyType || !ClassUtils::resolvedType(keyType) ){
418  throwException( "Cannot not resolve the type of the key item of container \""+m_type.Name(Reflex::SCOPED)+"\".",
419  "ArrayMapping::process");
420  }
421  }
422  else {
423  // Not supported container
424  throwException( "Container type=\""+m_type.Name(Reflex::SCOPED)+"\".is not supported.",
425  "ArrayMapping::process");
426  }
427 
428  if( !contentType || !ClassUtils::resolvedType(contentType) ){
429  throwException( "Cannot not resolve the type of the content item of container \""+m_type.Name(Reflex::SCOPED)+"\".",
430  "ArrayMapping::process");
431  }
432  RelationalMappingFactory mappingFactory( m_tableRegister );
433  if ( keyType ) {
434  std::string keyTypeName = keyType.Name();
436  std::auto_ptr<IRelationalMapping> keyProcessor( mappingFactory.newProcessor( keyType ) );
437  keyProcessor->process( me, keyTypeName, keyTypeNameForSchema, arrayScopeNameForSchema );
438  }
439  std::string contentTypeName = contentType.Name();
440  std::string contentTypeNameForSchema = MappingRules::variableNameForContainerValue();
441  std::auto_ptr<IRelationalMapping> contentProcessor( mappingFactory.newProcessor( contentType ) );
442  contentProcessor->process( me, contentTypeName, contentTypeNameForSchema, arrayScopeNameForSchema );
443 }
444 
445 ora::CArrayMapping::CArrayMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
446  m_type(attributeType), m_tableRegister( tableRegister ){
447 }
448 
450 }
451 
453  const std::string& attributeName,
454  const std::string& attributeNameForSchema,
455  const std::string& scopeNameForSchema ){
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();
521  std::string variableNameForSchema = MappingRules::variableNameForArrayColumn( m_type );
522  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( arrayElementType ) );
523  processor->process( me, contentTypeName, variableNameForSchema, arrayScopeNameForSchema );
524 }
525 
526 ora::ObjectMapping::ObjectMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
527  m_type(attributeType), m_tableRegister( tableRegister ){
528 }
529 
531 }
532 
533 namespace ora {
534 
535  bool isLoosePersistencyOnWriting( const Reflex::Member& dataMember ){
536  std::string persistencyType("");
537  Reflex::PropertyList memberProps = dataMember.Properties();
538  if( memberProps.HasProperty(ora::MappingRules::persistencyPropertyNameInDictionary())){
539  persistencyType = memberProps.PropertyAsString(ora::MappingRules::persistencyPropertyNameInDictionary());
540  }
541  return ora::MappingRules::isLooseOnWriting( persistencyType );
542  }
543 
544  void processBaseClasses( MappingElement& mappingElement,
545  const Reflex::Type& objType,
546  const std::string& scopeNameForSchema,
547  TableRegister& tableRegister ){
548  std::string className = objType.Name(Reflex::SCOPED);
549  for ( size_t i=0; i< objType.BaseSize(); i++){
550  Reflex::Base base = objType.BaseAt(i);
551  Reflex::Type baseType = ClassUtils::resolvedType( base.ToType() );
552  if(!baseType){
553  throwException( "Class for base \""+base.Name()+"\" is not in the dictionary.","ObjectMapping::process");
554  }
555 
556  // TO BE FIXED:: here there is still to fix the right scopeName to pass
557  processBaseClasses( mappingElement, baseType, scopeNameForSchema, tableRegister );
558  for ( size_t j=0; j< baseType.DataMemberSize(); j++){
559  Reflex::Member baseMember = baseType.DataMemberAt(j);
560  // Skip the transient and the static ones
561  if ( baseMember.IsTransient() || baseMember.IsStatic() || isLoosePersistencyOnWriting( baseMember ) ) continue;
562  // Retrieve the data member type
563  Reflex::Type type = ClassUtils::resolvedType( baseMember.TypeOf() );
564  Reflex::Type declaringType = ClassUtils::resolvedType( baseMember.DeclaringType());
565  std::string scope = declaringType.Name(Reflex::SCOPED);
566  // Retrieve the field name
567  std::string objectMemberName = ora::MappingRules::scopedVariableName( baseMember.Name(), scope );
568  std::string objectMemberNameForSchema = ora::MappingRules::scopedVariableForSchemaObjects( baseMember.Name(), scope );
569 
570  std::string mappingType("");
571  Reflex::PropertyList memberProps = baseMember.Properties();
572  if( memberProps.HasProperty(ora::MappingRules::mappingPropertyNameInDictionary())){
573  mappingType = memberProps.PropertyAsString(ora::MappingRules::mappingPropertyNameInDictionary());
574  }
575  bool blobStreaming = ora::MappingRules::isMappedToBlob( mappingType );
576 
577  RelationalMappingFactory mappingFactory( tableRegister );
578  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( type, blobStreaming ) );
579  processor->process( mappingElement, objectMemberName, objectMemberNameForSchema, scopeNameForSchema );
580  }
581  }
582  }
583 }
584 
586  const std::string& attributeName,
587  const std::string& attributeNameForSchema,
588  const std::string& scopeNameForSchema ){
589  std::string className = m_type.Name(Reflex::SCOPED);
591  ora::MappingElement& me = parentElement.appendSubElement( elementType, attributeName, className, parentElement.tableName() );
592  me.setColumnNames( parentElement.columnNames() );
593 
594  // resolve possible typedef chains
595  Reflex::Type objectType = ClassUtils::resolvedType(m_type);
596  // process base class data members
597  processBaseClasses( me, m_type, scopeNameForSchema, m_tableRegister );
598  RelationalMappingFactory mappingFactory( m_tableRegister );
599  std::string scope = attributeName;
600  std::string objectScopeNameForSchema = scopeNameForSchema;
601  if( !objectScopeNameForSchema.empty() ) objectScopeNameForSchema +="_";
602  objectScopeNameForSchema += attributeNameForSchema;
603 
604  // loop over the data members
605  for ( size_t i=0; i< objectType.DataMemberSize(); i++){
606 
607  Reflex::Member objectMember = m_type.DataMemberAt(i);
608  // Skip the transient and the static ones
609  if ( objectMember.IsTransient() || objectMember.IsStatic() || isLoosePersistencyOnWriting( objectMember )) continue;
610 
611  // Retrieve the field type
612  Reflex::Type type = ClassUtils::resolvedType( objectMember.TypeOf() );
613  // Check for the existence of the dictionary information
614  if ( !type ){
615  throwException( "Type for data member \""+objectMember.Name()+"\" of class \""+className+
616  "\" has not been found in the dictionary.",
617  "ObjectMapping::process");
618  }
619 
620  // check if the member is from a class in the inheritance tree
621  Reflex::Type declaringType = ClassUtils::resolvedType( objectMember.DeclaringType());
622  if( declaringType != objectType ){
623  continue;
624  }
625  // Retrieve the field name
626  std::string objectMemberName = objectMember.Name();
627  std::string objectNameForSchema = objectMember.Name();
628 
629  std::string mappingType("");
630  Reflex::PropertyList memberProps = objectMember.Properties();
631  if( memberProps.HasProperty(ora::MappingRules::mappingPropertyNameInDictionary())){
632  mappingType = memberProps.PropertyAsString(ora::MappingRules::mappingPropertyNameInDictionary());
633  }
634  bool blobStreaming = ora::MappingRules::isMappedToBlob( mappingType );
635 
636  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( type, blobStreaming ) );
637  processor->process( me, objectMemberName, objectNameForSchema, objectScopeNameForSchema );
638  }
639 
640 }
641 
643 }
644 
646 }
647 
649  const std::string&,
650  const std::string&,
651  const std::string& ){
652 }
tuple base
Main Program
Definition: newFWLiteAna.py:92
type
Definition: HCALResponse.h:21
bool isTypeOraPointer(const Reflex::Type &typ)
Definition: ClassUtils.cc:250
int i
Definition: DBlmapReader.cc:9
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.
static std::string arrayMappingElementType()
Returns the name of the array mapping element type.
NamedRefMapping(const Reflex::Type &attributeType, 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)
static std::string scopedVariableName(const std::string &variableName, const std::string &scope)
variable name manipulation
bool isTypeAssociativeContainer(const Reflex::Type &typ)
Definition: ClassUtils.cc:211
bool isTypeString(const Reflex::Type &typ)
Definition: ClassUtils.cc:137
static std::string variableNameForContainerKey()
static std::string primitiveMappingElementType()
Returns the name of the primitive mapping element type.
bool isLoosePersistencyOnWriting(const Reflex::Member &dataMember)
static std::string variableNameForArrayColumn(unsigned int arrayIndex)
bool isTypePVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:284
static std::string variableNameForContainerValue()
static std::string persistencyPropertyNameInDictionary()
Definition: MappingRules.cc:47
static const size_t MaxColumnsForInlineCArray
Definition: MappingRules.h:22
void _sizeInColumnsForCArray(const Reflex::Type &typ, size_t &sz, bool &hasDependencies)
PrimitiveMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
static std::string scopedVariableForSchemaObjects(const std::string &variableName, const std::string &scope)
bool insertColumn(const std::string &tableName, const std::string &columnName)
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)
static std::string columnNameForVariable(const std::string &variableName, const std::string &scope, bool forData=true)
UniqueReferenceMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
bool isTypeUniqueReference(const Reflex::Type &typ)
Definition: ClassUtils.cc:271
static std::string mappingPropertyNameInDictionary()
class related parameters
Definition: MappingRules.cc:35
BlobMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
Reflex::Type containerDataType(const Reflex::Type &typ)
Definition: ClassUtils.cc:373
static std::string columnNameForPosition()
bool isTypeContainer(const Reflex::Type &typ)
Definition: ClassUtils.cc:147
int j
Definition: DBlmapReader.cc:9
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
static std::string columnNameForOID(const std::string &variableName, const std::string &scope, unsigned int index)
std::pair< bool, size_t > sizeInColumnsForCArray(const Reflex::Type &arrayType)
static std::string objectMappingElementType()
Returns the name of the object mapping element type.
static std::string columnNameForBlobMetadata(const std::string &dataColumnName)
static std::string newNameForArraySchemaObject(const std::string &initialName, unsigned int index, size_t maxLength)
static bool isMappedToBlob(const std::string &mappingProperty)
Definition: MappingRules.cc:42
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
Reflex::Type containerKeyType(const Reflex::Type &typ)
Definition: ClassUtils.cc:357
Reflex::Type containerValueType(const Reflex::Type &typ)
Definition: ClassUtils.cc:341
CArrayMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
static bool isLooseOnWriting(const std::string &persistencyProperty)
Definition: MappingRules.cc:58
OraReferenceMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
static std::string inlineCArrayMappingElementType()
Returns the name of the inline array mapping element type.
ObjectMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
static std::string columnNameForRefMetadata(const std::string &variableName, const std::string &scope)
bool checkColumn(const std::string &tableName, const std::string &columnName)
size_t sizeInColumns(const Reflex::Type &topLevelClassType)
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)
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)
OraPtrMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
bool isTypePrimitive(const Reflex::Type &typ)
Definition: ClassUtils.cc:143
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
void processBaseClasses(MappingElement &mappingElement, const Reflex::Type &objType, const std::string &scopeNameForSchema, TableRegister &tableRegister)
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
bool isTypeNamedReference(const Reflex::Type &typ)
Definition: ClassUtils.cc:267
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.
static std::string OraArrayMappingElementType()
Returns the name of the ORA array mapping element type.
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
static const size_t MaxColumnNameLength
Definition: MappingRules.h:20
const std::string & tableName() const
ArrayMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
void _sizeInColumns(const Reflex::Type &typ, size_t &sz, bool &hasDependencies)
bool isTypeNonAssociativeContainer(const Reflex::Type &typ)
Definition: ClassUtils.cc:227
static const size_t MaxTableNameLength
Definition: MappingRules.h:19
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.
IRelationalMapping * newProcessor(const Reflex::Type &attributeType, bool blobStreaming=false)
std::string className(const T &t)
Definition: ClassName.h:30
void process(MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
void setColumnNames(const std::vector< std::string > &columns)
bool isTypeQueryableVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:297