4 #include "CoralBase/AttributeSpecification.h"
5 #include "CoralBase/Blob.h"
20 m_version( rhs.m_version ),
21 m_element( rhs.m_element ),
33 m_parentTable.reset();
41 const std::string& tableName,
67 std::vector<std::string>& tableHierarchy,
68 std::map<std::string,TableInfo>& tableMap ){
69 const std::string& tName = element.
tableName();
70 std::map<std::string,TableInfo>::iterator iT = tableMap.find( tName );
71 if( iT == tableMap.end() ){
72 tableHierarchy.push_back( tName );
73 iT = tableMap.insert( std::make_pair( tName,
TableInfo() ) ).first;
74 iT->second.m_dependency = isDependency;
75 iT->second.m_tableName = tName;
77 iT->second.m_parentTableName = currentTable.
m_tableName;
80 const std::vector<std::string>& dataCols = element.
columnNames();
82 switch ( elementType ) {
84 iT->second.m_dataColumns.insert( std::make_pair( dataCols[0],
88 iT->second.m_dataColumns.insert( std::make_pair( dataCols[0],
89 coral::AttributeSpecification::typeNameForId(
typeid(coral::Blob) ) ));
92 iT->second.m_dataColumns.insert( std::make_pair( dataCols[0],
93 coral::AttributeSpecification::typeNameForId(
typeid(
int) ) ));
94 iT->second.m_dataColumns.insert( std::make_pair( dataCols[1],
95 coral::AttributeSpecification::typeNameForId(
typeid(
int) ) ));
98 iT->second.m_dataColumns.insert( std::make_pair( dataCols[0],
99 coral::AttributeSpecification::typeNameForId(
typeid(std::string) ) ));
102 iT->second.m_dataColumns.insert( std::make_pair( dataCols[0],
103 coral::AttributeSpecification::typeNameForId(
typeid(std::string) ) ));
104 iT->second.m_dataColumns.insert( std::make_pair( dataCols[1],
105 coral::AttributeSpecification::typeNameForId(
typeid(
int) ) ));
113 iM != element.
end(); ++iM ){
114 scanElement( iM->second, currT, isDependency, tableHierarchy, tableMap );
121 std::vector<std::string> tableHierarchy;
122 std::map<std::string,TableInfo> tableMap;
124 bool isDependency =
false;
125 if( m_parentTable.get() ){
127 mainTable = *m_parentTable;
129 scanElement( m_element, mainTable, isDependency, tableHierarchy, tableMap );
130 std::vector<TableInfo>
ret;
131 for( std::vector<std::string>::const_iterator iT = tableHierarchy.begin();
132 iT != tableHierarchy.end(); ++iT ){
133 std::map<std::string,TableInfo>::const_iterator iM = tableMap.find( *iT );
134 ret.push_back( iM->second );
140 outputStream <<
"<?xml version=\'1.0\' encoding=\"UTF-8\"?>" << std::endl;
141 outputStream <<
"<!DOCTYPE OraDatabase SYSTEM \"InMemory\">" << std::endl;
142 outputStream <<
" <OraDatabase>" << std::endl;
143 outputStream <<
" <Mapping version=\""<<m_version<<
"\" >"<< std::endl;
144 m_element.printXML( outputStream,
" " );
145 outputStream <<
" </Mapping >"<< std::endl;
146 outputStream <<
" </OraDatabase>" << std::endl;
void override(const MappingTree &source)
replace present data with the provided source
std::auto_ptr< TableInfo > m_parentTable
const std::string & className() const
static std::string dependencyMappingElementType()
Returns the name of the dependent class mapping element type.
ElementType elementType() const
MappingElement & setTopElement(const std::string &className, const std::string &tableName, bool isDependent=false)
MappingTree & operator=(const MappingTree &rhs)
iterator begin()
Returns an iterator in the beginning of the sequence.
MappingTree()
Constructor.
~MappingTree()
Destructor.
void scanElement(const MappingElement &element, const TableInfo ¤tTable, bool isDependency, std::vector< std::string > &tableHierarchy, std::map< std::string, TableInfo > &tableMap)
std::vector< TableInfo > tables() const
const std::vector< std::string > & columnNames() const
void printXML(std::ostream &outputStream) const
const std::string & variableType() const
std::map< std::string, MappingElement >::const_iterator const_iterator
std::vector< std::string > m_idColumns
iterator end()
Returns an iterator in the end of the sequence.
const std::string & tableName() const
void setDependency(const MappingTree &parentTree)
static std::string classMappingElementType()
Returns the name of the class mapping element type.
std::string className(const T &t)