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();
67 std::vector<std::string>& tableHierarchy,
68 std::map<std::string,TableInfo>& tableMap ){
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) ) ));
90 iT->second.m_dataColumns.insert( std::make_pair( dataCols[1],
91 coral::AttributeSpecification::typeNameForId(
typeid(
std::string) ) ));
92 iT->second.m_nullableColumns.insert( dataCols[1] );
95 iT->second.m_dataColumns.insert( std::make_pair( dataCols[0],
96 coral::AttributeSpecification::typeNameForId(
typeid(
int) ) ));
97 iT->second.m_dataColumns.insert( std::make_pair( dataCols[1],
98 coral::AttributeSpecification::typeNameForId(
typeid(
int) ) ));
101 iT->second.m_dataColumns.insert( std::make_pair( dataCols[0],
102 coral::AttributeSpecification::typeNameForId(
typeid(
std::string) ) ));
105 iT->second.m_dataColumns.insert( std::make_pair( dataCols[0],
106 coral::AttributeSpecification::typeNameForId(
typeid(
std::string) ) ));
107 iT->second.m_dataColumns.insert( std::make_pair( dataCols[1],
108 coral::AttributeSpecification::typeNameForId(
typeid(
int) ) ));
116 iM != element.
end(); ++iM ){
117 scanElement( iM->second, currT, isDependency, tableHierarchy, tableMap );
124 std::vector<std::string> tableHierarchy;
125 std::map<std::string,TableInfo> tableMap;
127 bool isDependency =
false;
128 if( m_parentTable.get() ){
130 mainTable = *m_parentTable;
132 scanElement( m_element, mainTable, isDependency, tableHierarchy, tableMap );
133 std::vector<TableInfo>
ret;
134 for( std::vector<std::string>::const_iterator iT = tableHierarchy.begin();
135 iT != tableHierarchy.end(); ++iT ){
136 std::map<std::string,TableInfo>::const_iterator iM = tableMap.find( *iT );
137 ret.push_back( iM->second );
143 outputStream <<
"<?xml version=\'1.0\' encoding=\"UTF-8\"?>" << std::endl;
144 outputStream <<
"<!DOCTYPE OraDatabase SYSTEM \"InMemory\">" << std::endl;
145 outputStream <<
" <OraDatabase>" << std::endl;
146 outputStream <<
" <Mapping version=\""<<m_version<<
"\" >"<< std::endl;
147 m_element.printXML( outputStream,
" " );
148 outputStream <<
" </Mapping >"<< std::endl;
149 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.
static std::string const source
std::string className(const T &t)