CMS 3D CMS Logo

Public Member Functions | Private Attributes

ora::MappingTree Class Reference

#include <MappingTree.h>

List of all members.

Public Member Functions

const std::string & className () const
 MappingTree (const std::string &version)
 Constructor.
 MappingTree ()
 Constructor.
 MappingTree (const MappingTree &rhs)
MappingTreeoperator= (const MappingTree &rhs)
void override (const MappingTree &source)
 replace present data with the provided source
void printXML (std::ostream &outputStream) const
void setDependency (const MappingTree &parentTree)
MappingElementsetTopElement (const std::string &className, const std::string &tableName, bool isDependent=false)
void setVersion (const std::string &version)
std::vector< TableInfotables () const
const MappingElementtopElement () const
MappingElementtopElement ()
const std::string & version () const
 ~MappingTree ()
 Destructor.

Private Attributes

MappingElement m_element
std::auto_ptr< TableInfom_parentTable
std::string m_version

Detailed Description

The structure holding an object/relational mapping.

Definition at line 53 of file MappingTree.h.


Constructor & Destructor Documentation

ora::MappingTree::MappingTree ( )

Constructor.

Public methods:

Definition at line 7 of file MappingTree.cc.

                           :
  m_version( "" ),
  m_element(),
  m_parentTable(){
}
ora::MappingTree::MappingTree ( const std::string &  version) [explicit]

Constructor.

Definition at line 13 of file MappingTree.cc.

ora::MappingTree::MappingTree ( const MappingTree rhs)

Definition at line 19 of file MappingTree.cc.

References m_parentTable.

                                                   :
  m_version( rhs.m_version ),
  m_element( rhs.m_element ),
  m_parentTable(){
  if( rhs.m_parentTable.get()) m_parentTable.reset( new TableInfo( *rhs.m_parentTable ) );
}
ora::MappingTree::~MappingTree ( )

Destructor.

Definition at line 26 of file MappingTree.cc.

                            {
}

Member Function Documentation

const std::string & ora::MappingTree::className ( ) const [inline]
ora::MappingTree & ora::MappingTree::operator= ( const MappingTree rhs)

Definition at line 29 of file MappingTree.cc.

References m_element, m_parentTable, and m_version.

                                                                 {
  if( this != &rhs ){
    m_version = rhs.m_version;
    m_element = rhs.m_element;
    m_parentTable.reset();
    if( rhs.m_parentTable.get()) m_parentTable.reset( new TableInfo( *rhs.m_parentTable ) );
  }
  return *this;
}
void ora::MappingTree::override ( const MappingTree source)

replace present data with the provided source

Definition at line 58 of file MappingTree.cc.

References className(), className(), and m_element.

Referenced by ora::MappingGenerator::createNewDependentMapping(), and ora::MappingGenerator::createNewMapping().

{
  if( className() == source.className() ) m_element.override( source.m_element );
}
void ora::MappingTree::printXML ( std::ostream &  outputStream) const

Definition at line 142 of file MappingTree.cc.

Referenced by ora::DatabaseUtilitySession::dumpMapping().

                                                              {
  outputStream << "<?xml version=\'1.0\' encoding=\"UTF-8\"?>" << std::endl;
  outputStream << "<!DOCTYPE OraDatabase SYSTEM \"InMemory\">" << std::endl;
  outputStream << " <OraDatabase>" << std::endl;
  outputStream << "  <Mapping version=\""<<m_version<<"\" >"<< std::endl;
  m_element.printXML( outputStream, "   " );
  outputStream << "  </Mapping >"<< std::endl;
  outputStream << " </OraDatabase>" << std::endl;
}
void ora::MappingTree::setDependency ( const MappingTree parentTree)

Definition at line 52 of file MappingTree.cc.

References ora::MappingElement::columnNames(), m_element, and ora::MappingElement::tableName().

Referenced by ora::MappingGenerator::createNewDependentMapping().

                                                                 {
  m_parentTable.reset( new TableInfo() );
  m_parentTable->m_tableName = parentTree.m_element.tableName();
  m_parentTable->m_idColumns = parentTree.m_element.columnNames();
}
ora::MappingElement & ora::MappingTree::setTopElement ( const std::string &  className,
const std::string &  tableName,
bool  isDependent = false 
)

Appends the element to the structure

Parameters:
classNameThe class name of the new element
tableNameThe table name of the new element
elementTypeThe type code of the new element

Definition at line 40 of file MappingTree.cc.

References ora::MappingElement::classMappingElementType(), and ora::MappingElement::dependencyMappingElementType().

Referenced by ora::MappingGenerator::createNewDependentMapping(), ora::MappingGenerator::createNewMapping(), and ora::MappingDatabase::getMappingByVersion().

                                                     {
  std::string elementType = ora::MappingElement::classMappingElementType();
  if( isDependency ) elementType = ora::MappingElement::dependencyMappingElementType();
  m_element = ora::MappingElement( elementType,
                                   className,
                                   className,
                                   tableName );
  return m_element;
}
void ora::MappingTree::setVersion ( const std::string &  version) [inline]

Definition at line 133 of file MappingTree.h.

References BeamSplash_cfg::version.

Referenced by ora::MappingDatabase::getMappingByVersion().

std::vector< ora::TableInfo > ora::MappingTree::tables ( ) const

Definition at line 123 of file MappingTree.cc.

References runTheMatrix::ret, and ora::scanElement().

Referenced by ora::MappingToSchema::alter(), ora::MappingToSchema::check(), and ora::MappingToSchema::create().

                                                     {
  std::vector<std::string> tableHierarchy;
  std::map<std::string,TableInfo> tableMap;
  TableInfo mainTable;
  bool isDependency = false;
  if( m_parentTable.get() ){
    isDependency = true;
    mainTable = *m_parentTable;
  }
  scanElement( m_element, mainTable, isDependency, tableHierarchy, tableMap );
  std::vector<TableInfo> ret;
  for( std::vector<std::string>::const_iterator iT = tableHierarchy.begin();
       iT != tableHierarchy.end(); ++iT ){
    std::map<std::string,TableInfo>::const_iterator iM = tableMap.find( *iT );
    ret.push_back( iM->second );
  }
  return ret;
}
ora::MappingElement & ora::MappingTree::topElement ( ) [inline]

Returns the main mapping element

Definition at line 148 of file MappingTree.h.

                          {
  return m_element;
}
const ora::MappingElement & ora::MappingTree::topElement ( ) const [inline]
const std::string & ora::MappingTree::version ( ) const [inline]

Returns the version of the mapping

Definition at line 128 of file MappingTree.h.

References m_version.

Referenced by ora::DatabaseUtilitySession::importContainerSchema(), and ora::MappingDatabase::storeMapping().

                              {
  return m_version;
}

Member Data Documentation

The main tree

Definition at line 120 of file MappingTree.h.

Referenced by operator=(), override(), and setDependency().

std::auto_ptr<TableInfo> ora::MappingTree::m_parentTable [private]

Definition at line 122 of file MappingTree.h.

Referenced by MappingTree(), and operator=().

std::string ora::MappingTree::m_version [private]

The mapping version

Definition at line 115 of file MappingTree.h.

Referenced by operator=(), and version().