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  me.setColumnNames( std::vector< std::string >( 1, columnName ) );
162  }
163 }
164 
166  m_type(attributeType),m_tableRegister( tableRegister ){
167 }
168 
170 }
171 
173  const std::string& attributeName,
174  const std::string& attributeNameForSchema,
175  const std::string& scopeNameForSchema ){
177  const std::type_info* attrType = &t.TypeInfo();
178  if(t.IsEnum()) attrType = &typeid(int);
179  //std::string tn = ClassUtils::demangledName(*attrType);
180  if(ClassUtils::isTypeString( t )) attrType = &typeid(std::string);
181  std::string typeName = coral::AttributeSpecification::typeNameForId(*attrType);
182 
183  processLeafElement(parentElement,
185  typeName,
186  attributeName,
187  attributeNameForSchema,
188  scopeNameForSchema,
189  m_tableRegister);
190 }
191 
192 ora::BlobMapping::BlobMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
193  m_type(attributeType),m_tableRegister( tableRegister ){
194 }
195 
197 }
199  const std::string& attributeName,
200  const std::string& attributeNameForSchema,
201  const std::string& scopeNameForSchema ){
202  std::string className = m_type.Name(Reflex::SCOPED);
203  processLeafElement(parentElement,
205  className,
206  attributeName,
207  attributeNameForSchema,
208  scopeNameForSchema,
209  m_tableRegister);
210 }
211 
213  m_type(attributeType),m_tableRegister( tableRegister ){
214 }
215 
217 }
218 
220  const std::string& attributeName,
221  const std::string& attributeNameForSchema,
222  const std::string& scopeNameForSchema ){
223  std::string className = m_type.Name(Reflex::SCOPED);
224  std::string elementType = ora::MappingElement::OraReferenceMappingElementType();
225  if(!m_tableRegister.checkTable( parentElement.tableName())){
226  throwException("Table \""+parentElement.tableName()+"\" has not been allocated.",
227  "OraReferenceMapping::process");
228  }
229  ora::MappingElement& me = parentElement.appendSubElement( elementType, attributeName, className, parentElement.tableName() );
230 
231  std::vector<std::string> cols;
232  for(unsigned int j=0;j<2;j++){
233  std::string inputCol = ora::MappingRules::columnNameForOID( attributeNameForSchema, scopeNameForSchema, j );
234  std::string columnName(inputCol);
235  unsigned int i=0;
236  while(m_tableRegister.checkColumn(parentElement.tableName(),columnName)){
238  i++;
239  }
240  m_tableRegister.insertColumn(parentElement.tableName(),columnName);
241  cols.push_back( columnName );
242  }
243  me.setColumnNames( cols );
244 }
245 
247  m_type(attributeType),m_tableRegister( tableRegister ){
248 }
249 
251 }
252 
254  const std::string& attributeName,
255  const std::string& attributeNameForSchema,
256  const std::string& scopeNameForSchema ){
257 
258  std::string typeName = m_type.Name(Reflex::SCOPED);
259  if(!m_tableRegister.checkTable( parentElement.tableName())){
260  throwException("Table \""+parentElement.tableName()+"\" has not been allocated.",
261  "UniqueReferenceMapping::process");
262  }
263  ora::MappingElement& me = parentElement.appendSubElement( ora::MappingElement::uniqueReferenceMappingElementType(), attributeName, typeName, parentElement.tableName() );
264 
265  std::vector< std::string > cols;
266  std::string inputCol = ora::MappingRules::columnNameForRefMetadata( attributeNameForSchema, scopeNameForSchema );
267  std::string columnName(inputCol);
268  unsigned int i=0;
269  while(m_tableRegister.checkColumn(parentElement.tableName(),columnName)){
271  i++;
272  }
273  m_tableRegister.insertColumn(parentElement.tableName(),columnName);
274  cols.push_back(columnName);
275 
276  std::string idCol = ora::MappingRules::columnNameForRefId( attributeNameForSchema, scopeNameForSchema);
277  columnName = idCol;
278  i=0;
279  while(m_tableRegister.checkColumn(parentElement.tableName(),columnName)){
281  i++;
282  }
283  m_tableRegister.insertColumn(parentElement.tableName(),columnName);
284  cols.push_back(columnName);
285 
286  me.setColumnNames( cols );
287 }
288 
289 ora::OraPtrMapping::OraPtrMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
290  m_type(attributeType), m_tableRegister( tableRegister ){
291 }
292 
294 }
295 
297  const std::string& attributeName,
298  const std::string& attributeNameForSchema,
299  const std::string& scopeNameForSchema ){
300 
301  std::string typeName = m_type.Name(Reflex::SCOPED);
302  ora::MappingElement& me = parentElement.appendSubElement( ora::MappingElement::OraPointerMappingElementType(), attributeName, typeName, parentElement.tableName() );
303  me.setColumnNames( parentElement.columnNames() );
304 
305  Reflex::Type ptrType = m_type.TemplateArgumentAt(0);
306  std::string ptrTypeName = ptrType.Name();
307 
308  RelationalMappingFactory factory( m_tableRegister );
309  std::auto_ptr<IRelationalMapping> processor( factory.newProcessor( ptrType ) );
310  processor->process( me, ptrTypeName, attributeNameForSchema, scopeNameForSchema );
311 }
312 
313 ora::NamedRefMapping::NamedRefMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
314  m_type( attributeType ),
315  m_tableRegister( tableRegister ){
316 }
317 
319 }
320 
322  const std::string& attributeName,
323  const std::string& attributeNameForSchema,
324  const std::string& scopeNameForSchema ){
325  std::string typeName = m_type.Name(Reflex::SCOPED);
326  ora::MappingElement& me = parentElement.appendSubElement( ora::MappingElement::namedReferenceMappingElementType(), attributeName, typeName, parentElement.tableName() );
327 
328  std::vector< std::string > cols;
329  std::string inputCol = ora::MappingRules::columnNameForNamedReference( attributeNameForSchema, scopeNameForSchema );
330  std::string columnName(inputCol);
331  unsigned int i=0;
332  while(m_tableRegister.checkColumn(parentElement.tableName(),columnName)){
334  i++;
335  }
336  m_tableRegister.insertColumn(parentElement.tableName(),columnName);
337  cols.push_back(columnName);
338 
339  me.setColumnNames( cols );
340 
341 }
342 
343 ora::ArrayMapping::ArrayMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
344  m_type(attributeType), m_tableRegister( tableRegister ){
345 }
346 
348 }
349 
351  const std::string& attributeName,
352  const std::string& attributeNameForSchema,
353  const std::string& scopeNameForSchema ){
354  std::string tableName = parentElement.tableName();
355  std::string initialTable(tableName);
356 
357  std::string arrayTable(initialTable);
358  unsigned int i=0;
359  while(m_tableRegister.checkTable(arrayTable)){
361  i++;
362  }
363  m_tableRegister.insertTable(arrayTable);
364 
365  std::string className = m_type.Name(Reflex::SCOPED);
366 
367  std::string elementType = ora::MappingElement::arrayMappingElementType();
370  }
371  ora::MappingElement& me = parentElement.appendSubElement( elementType,attributeName,className,arrayTable );
372  const std::vector<std::string>& parentColumns = parentElement.columnNames();
373  if( parentColumns.empty()){
374  throwException( "No column name found in the parent mapping element.","ArrayMapping::process");
375  }
376 
377  std::vector<std::string> columns;
378  // always comes the oid first
379  columns.push_back( ora::MappingRules::columnNameForId() );
380  std::vector<std::string>::const_iterator iColumn = parentColumns.begin();
381  // then copy the columns except the id...
382  iColumn++;
383  for ( ;iColumn != parentColumns.end(); iColumn++ ) {
384  columns.push_back( ora::MappingRules::columnNameForId() + "_" + *iColumn );
385  }
386  // and finally add the position!
387  columns.push_back( ora::MappingRules::columnNameForPosition() );
388 
389  me.setColumnNames( columns );
390  m_tableRegister.insertColumns(arrayTable, columns );
391 
392  std::string arrayScopeNameForSchema = scopeNameForSchema;
393  if( !arrayScopeNameForSchema.empty() ) arrayScopeNameForSchema +="_";
394  arrayScopeNameForSchema += attributeNameForSchema;
395 
396 
397  bool singleItemContainer = ora::ClassUtils::isTypeNonAssociativeContainer(m_type);
398  bool associativeContainer = ora::ClassUtils::isTypeAssociativeContainer(m_type);
399 
400  Reflex::Type contentType;
401  Reflex::Type keyType;
402 
403  if( singleItemContainer ){
404  contentType = ClassUtils::containerValueType(m_type);
405  }
406  else if ( associativeContainer ) { // This is an associative container type
407  contentType = ClassUtils::containerDataType( m_type );
408  keyType = ClassUtils::containerKeyType( m_type );
409  if( !keyType || !ClassUtils::resolvedType(keyType) ){
410  throwException( "Cannot not resolve the type of the key item of container \""+m_type.Name(Reflex::SCOPED)+"\".",
411  "ArrayMapping::process");
412  }
413  }
414  else {
415  // Not supported container
416  throwException( "Container type=\""+m_type.Name(Reflex::SCOPED)+"\".is not supported.",
417  "ArrayMapping::process");
418  }
419 
420  if( !contentType || !ClassUtils::resolvedType(contentType) ){
421  throwException( "Cannot not resolve the type of the content item of container \""+m_type.Name(Reflex::SCOPED)+"\".",
422  "ArrayMapping::process");
423  }
424  RelationalMappingFactory mappingFactory( m_tableRegister );
425  if ( keyType ) {
426  std::string keyTypeName = keyType.Name();
427  std::string keyTypeNameForSchema = MappingRules::variableNameForContainerKey();
428  std::auto_ptr<IRelationalMapping> keyProcessor( mappingFactory.newProcessor( keyType ) );
429  keyProcessor->process( me, keyTypeName, keyTypeNameForSchema, arrayScopeNameForSchema );
430  }
431  std::string contentTypeName = contentType.Name();
432  std::string contentTypeNameForSchema = MappingRules::variableNameForContainerValue();
433  std::auto_ptr<IRelationalMapping> contentProcessor( mappingFactory.newProcessor( contentType ) );
434  contentProcessor->process( me, contentTypeName, contentTypeNameForSchema, arrayScopeNameForSchema );
435 }
436 
437 ora::CArrayMapping::CArrayMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
438  m_type(attributeType), m_tableRegister( tableRegister ){
439 }
440 
442 }
443 
445  const std::string& attributeName,
446  const std::string& attributeNameForSchema,
447  const std::string& scopeNameForSchema ){
448  Reflex::Type arrayElementType = m_type.ToType();
449  if( !arrayElementType || !ClassUtils::resolvedType( arrayElementType ) ){
450  throwException("Cannot resolve the type of the content of the array \""+m_type.Name(Reflex::SCOPED)+"\".",
451  "CArrayMapping::process");
452  }
453 
454  if(!m_tableRegister.checkTable(parentElement.tableName())){
455  throwException("Table \""+parentElement.tableName()+"\" has not been allocated.",
456  "CArrayMapping::process");
457  }
458  std::string className = m_type.Name(Reflex::SCOPED);
459  RelationalMappingFactory mappingFactory( m_tableRegister );
460 
461  std::string arrayScopeNameForSchema = scopeNameForSchema;
462  if( !arrayScopeNameForSchema.empty() ) arrayScopeNameForSchema +="_";
463  arrayScopeNameForSchema += attributeNameForSchema;
464 
465  std::pair<bool,size_t> arraySizeInColumns = RelationalMapping::sizeInColumnsForCArray( m_type );
466  if( !arraySizeInColumns.first && arraySizeInColumns.second < MappingRules::MaxColumnsForInlineCArray ) {
467  size_t columnsInTable = m_tableRegister.numberOfColumns(parentElement.tableName()) + arraySizeInColumns.second;
468  if( columnsInTable < MappingRules::MaxColumnsPerTable ){
469  // Inline C-Array
470  std::string mappingElementType = ora::MappingElement::inlineCArrayMappingElementType();
471  ora::MappingElement& me = parentElement.appendSubElement( mappingElementType, attributeName, className, parentElement.tableName() );
472  me.setColumnNames( parentElement.columnNames() );
473  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( arrayElementType ) );
474  for(size_t i=0;i<m_type.ArrayLength();i++){
475  processor->process( me, MappingRules::variableNameForArrayIndex(attributeName,i),
476  MappingRules::variableNameForArrayColumn(i), arrayScopeNameForSchema );
477  }
478  return;
479  }
480  }
482  std::string tableName = parentElement.tableName();
483  std::string initialTable(tableName);
484 
485  std::string arrayTable(initialTable);
486  unsigned int i=0;
487  while(m_tableRegister.checkTable(arrayTable)){
489  i++;
490  }
491  m_tableRegister.insertTable(arrayTable);
493  attributeName, attributeName, arrayTable );
494  const std::vector<std::string>& parentColumns = parentElement.columnNames();
495  if( parentColumns.empty()){
496  throwException( "No column name found in the parent mapping element.","CArrayMapping::process");
497  }
498  std::vector<std::string> columns;
499  // always comes the oid first
500  columns.push_back( ora::MappingRules::columnNameForId() );
501  std::vector<std::string>::const_iterator iColumn = parentColumns.begin();
502  // then copy the columns except the id...
503  iColumn++;
504  for ( ;iColumn != parentColumns.end(); ++iColumn ) {
505  columns.push_back( ora::MappingRules::columnNameForId() + "_" + *iColumn );
506  }
507  // and finally add the position!
508  columns.push_back( ora::MappingRules::columnNameForPosition() );
509  me.setColumnNames( columns );
510  m_tableRegister.insertColumns(arrayTable, columns );
511 
512  std::string contentTypeName = arrayElementType.Name();
513  std::string variableNameForSchema = MappingRules::variableNameForArrayColumn( m_type );
514  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( arrayElementType ) );
515  processor->process( me, contentTypeName, variableNameForSchema, arrayScopeNameForSchema );
516 }
517 
518 ora::ObjectMapping::ObjectMapping( const Reflex::Type& attributeType, TableRegister& tableRegister ):
519  m_type(attributeType), m_tableRegister( tableRegister ){
520 }
521 
523 }
524 
525 namespace ora {
526 
527  void processBaseClasses( MappingElement& mappingElement,
528  const Reflex::Type& objType,
529  const std::string& scopeNameForSchema,
530  TableRegister& tableRegister ){
531  std::string className = objType.Name(Reflex::SCOPED);
532  for ( size_t i=0; i< objType.BaseSize(); i++){
533  Reflex::Base base = objType.BaseAt(i);
534  Reflex::Type baseType = ClassUtils::resolvedType( base.ToType() );
535  if(!baseType){
536  throwException( "Class for base \""+base.Name()+"\" is not in the dictionary.","ObjectMapping::process");
537  }
538 
539  // TO BE FIXED:: here there is still to fix the right scopeName to pass
540  processBaseClasses( mappingElement, baseType, scopeNameForSchema, tableRegister );
541  for ( size_t j=0; j< baseType.DataMemberSize(); j++){
542  Reflex::Member baseMember = baseType.DataMemberAt(j);
543  // Skip the transient and the static ones
544  if ( baseMember.IsTransient() || baseMember.IsStatic() ) continue;
545  // Retrieve the data member type
546  Reflex::Type type = ClassUtils::resolvedType( baseMember.TypeOf() );
547  Reflex::Type declaringType = ClassUtils::resolvedType( baseMember.DeclaringType());
548  std::string scope = declaringType.Name(Reflex::SCOPED);
549  // Retrieve the field name
550  std::string objectMemberName = ora::MappingRules::scopedVariableName( baseMember.Name(), scope );
551  std::string objectMemberNameForSchema = ora::MappingRules::scopedVariableForSchemaObjects( baseMember.Name(), scope );
552 
553  std::string mappingType("");
554  Reflex::PropertyList memberProps = baseMember.Properties();
555  if( memberProps.HasProperty(ora::MappingRules::mappingPropertyNameInDictionary())){
556  mappingType = memberProps.PropertyAsString(ora::MappingRules::mappingPropertyNameInDictionary());
557  }
558  bool blobStreaming = ora::MappingRules::isMappedToBlob( mappingType );
559 
560  RelationalMappingFactory mappingFactory( tableRegister );
561  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( type, blobStreaming ) );
562  processor->process( mappingElement, objectMemberName, objectMemberNameForSchema, scopeNameForSchema );
563  }
564  }
565  }
566 }
567 
569  const std::string& attributeName,
570  const std::string& attributeNameForSchema,
571  const std::string& scopeNameForSchema ){
572  std::string className = m_type.Name(Reflex::SCOPED);
573  std::string elementType = ora::MappingElement::objectMappingElementType();
574  ora::MappingElement& me = parentElement.appendSubElement( elementType, attributeName, className, parentElement.tableName() );
575  me.setColumnNames( parentElement.columnNames() );
576 
577  // resolve possible typedef chains
578  Reflex::Type objectType = ClassUtils::resolvedType(m_type);
579  // process base class data members
580  processBaseClasses( me, m_type, scopeNameForSchema, m_tableRegister );
581  RelationalMappingFactory mappingFactory( m_tableRegister );
582  std::string scope = attributeName;
583  std::string objectScopeNameForSchema = scopeNameForSchema;
584  if( !objectScopeNameForSchema.empty() ) objectScopeNameForSchema +="_";
585  objectScopeNameForSchema += attributeNameForSchema;
586 
587  // loop over the data members
588  for ( size_t i=0; i< objectType.DataMemberSize(); i++){
589 
590  Reflex::Member objectMember = m_type.DataMemberAt(i);
591  // Skip the transient and the static ones
592  if ( objectMember.IsTransient() || objectMember.IsStatic() ) continue;
593 
594  // Retrieve the field type
595  Reflex::Type type = ClassUtils::resolvedType( objectMember.TypeOf() );
596  // Check for the existence of the dictionary information
597  if ( !type ){
598  throwException( "Type for data member \""+objectMember.Name()+"\" of class \""+className+
599  "\" has not been found in the dictionary.",
600  "ObjectMapping::process");
601  }
602 
603  // check if the member is from a class in the inheritance tree
604  Reflex::Type declaringType = ClassUtils::resolvedType( objectMember.DeclaringType());
605  if( declaringType != objectType ){
606  continue;
607  }
608  // Retrieve the field name
609  std::string objectMemberName = objectMember.Name();
610  std::string objectNameForSchema = objectMember.Name();
611 
612  std::string mappingType("");
613  Reflex::PropertyList memberProps = objectMember.Properties();
614  if( memberProps.HasProperty(ora::MappingRules::mappingPropertyNameInDictionary())){
615  mappingType = memberProps.PropertyAsString(ora::MappingRules::mappingPropertyNameInDictionary());
616  }
617  bool blobStreaming = ora::MappingRules::isMappedToBlob( mappingType );
618 
619  std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( type, blobStreaming ) );
620  processor->process( me, objectMemberName, objectNameForSchema, objectScopeNameForSchema );
621  }
622 
623 }
624 
626 }
627 
629 }
630 
632  const std::string&,
633  const std::string&,
634  const std::string& ){
635 }
tuple base
Main Program
Definition: newFWLiteAna.py:92
type
Definition: HCALResponse.h:22
bool isTypeOraPointer(const Reflex::Type &typ)
Definition: ClassUtils.cc:241
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:202
bool isTypeString(const Reflex::Type &typ)
Definition: ClassUtils.cc:128
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 isTypePVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:275
static std::string variableNameForContainerValue()
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:262
static std::string mappingPropertyNameInDictionary()
class related parameters
Definition: MappingRules.cc:34
BlobMapping(const Reflex::Type &attributeType, TableRegister &tableRegister)
Reflex::Type containerDataType(const Reflex::Type &typ)
Definition: ClassUtils.cc:349
static std::string columnNameForPosition()
bool isTypeContainer(const Reflex::Type &typ)
Definition: ClassUtils.cc:138
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 newNameForArraySchemaObject(const std::string &initialName, unsigned int index, size_t maxLength)
static bool isMappedToBlob(const std::string &mappingProperty)
Definition: MappingRules.cc:41
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:333
Reflex::Type containerValueType(const Reflex::Type &typ)
Definition: ClassUtils.cc:317
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:380
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:134
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)
static const size_t MaxColumnsPerTable
Definition: MappingRules.h:21
bool isTypeNamedReference(const Reflex::Type &typ)
Definition: ClassUtils.cc:258
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
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
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:218
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:288