CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::ObjectMapping Class Reference

#include <RelationalMapping.h>

Inheritance diagram for ora::ObjectMapping:
ora::IRelationalMapping

List of all members.

Public Member Functions

 ObjectMapping (const Reflex::Type &attributeType, TableRegister &tableRegister)
void process (MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
 ~ObjectMapping ()

Private Attributes

TableRegisterm_tableRegister
Reflex::Type m_type

Detailed Description

Definition at line 157 of file RelationalMapping.h.


Constructor & Destructor Documentation

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

Definition at line 518 of file RelationalMapping.cc.

                                                                                              :
  m_type(attributeType), m_tableRegister( tableRegister ){
}
ora::ObjectMapping::~ObjectMapping ( )

Definition at line 522 of file RelationalMapping.cc.

                                {
}

Member Function Documentation

void ora::ObjectMapping::process ( MappingElement parentElement,
const std::string &  attributeName,
const std::string &  attributeNameForSchema,
const std::string &  scopeNameForSchema 
) [virtual]

Implements ora::IRelationalMapping.

Definition at line 568 of file RelationalMapping.cc.

References ora::MappingElement::appendSubElement(), className(), ora::MappingElement::columnNames(), i, ora::MappingRules::isMappedToBlob(), ora::MappingRules::mappingPropertyNameInDictionary(), ora::RelationalMappingFactory::newProcessor(), ora::MappingElement::objectMappingElementType(), ora::processBaseClasses(), ora::ClassUtils::resolvedType(), ora::MappingElement::setColumnNames(), ora::MappingElement::tableName(), and ora::throwException().

                                                                       {
  std::string className = m_type.Name(Reflex::SCOPED);
  std::string elementType = ora::MappingElement::objectMappingElementType();
  ora::MappingElement& me = parentElement.appendSubElement( elementType, attributeName, className, parentElement.tableName() );
  me.setColumnNames( parentElement.columnNames() );

  // resolve possible typedef chains
  Reflex::Type objectType = ClassUtils::resolvedType(m_type);
  // process base class data members
  processBaseClasses( me, m_type, scopeNameForSchema, m_tableRegister );
  RelationalMappingFactory mappingFactory( m_tableRegister );
  std::string scope = attributeName;
  std::string objectScopeNameForSchema = scopeNameForSchema;
  if( !objectScopeNameForSchema.empty() ) objectScopeNameForSchema +="_";
  objectScopeNameForSchema += attributeNameForSchema;

  // loop over the data members 
  for ( size_t i=0; i< objectType.DataMemberSize(); i++){

    Reflex::Member objectMember = m_type.DataMemberAt(i);
    // Skip the transient and the static ones
    if ( objectMember.IsTransient() || objectMember.IsStatic() ) continue;

    // Retrieve the field type
    Reflex::Type type = ClassUtils::resolvedType( objectMember.TypeOf() );
    // Check for the existence of the dictionary information
    if ( !type ){
      throwException( "Type for data member \""+objectMember.Name()+"\" of class \""+className+
                      "\" has not been found in the dictionary.",
                      "ObjectMapping::process");
    }
    
    // check if the member is from a class in the inheritance tree
    Reflex::Type declaringType = ClassUtils::resolvedType( objectMember.DeclaringType());
    if( declaringType != objectType ){
      continue;
    }
    // Retrieve the field name
    std::string objectMemberName = objectMember.Name();
    std::string objectNameForSchema = objectMember.Name();
    
    std::string mappingType("");
    Reflex::PropertyList memberProps = objectMember.Properties();
    if( memberProps.HasProperty(ora::MappingRules::mappingPropertyNameInDictionary())){
      mappingType = memberProps.PropertyAsString(ora::MappingRules::mappingPropertyNameInDictionary());
    }
    bool blobStreaming = ora::MappingRules::isMappedToBlob( mappingType );

    std::auto_ptr<IRelationalMapping> processor( mappingFactory.newProcessor( type, blobStreaming ) );
    processor->process( me, objectMemberName, objectNameForSchema, objectScopeNameForSchema  );
  }
  
}

Member Data Documentation

Definition at line 167 of file RelationalMapping.h.

Reflex::Type ora::ObjectMapping::m_type [private]

Definition at line 166 of file RelationalMapping.h.