Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

MWClassHierarchy Class Reference

ClassHierarchy extended to support some features needed when writing metadata. More...

#include <MWClassHierarchy.h>

Inheritance diagram for MWClassHierarchy:

Inheritance graph
[legend]
Collaboration diagram for MWClassHierarchy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ~MWClassHierarchy ()
int setMappingType (IopcMappingType defaultMappingType, CStdString &warningsForUser, CStdString &errorForUser)
int generateTableNames (CStdString &warningsForUser, CStdString &errorForUser)
int generateColumnTypesAndNames (DatabaseSqlStatements *sqlStatements, CStdString &warningsForUser, CStdString &errorForUser)
int generateAttributeGroups (CStdString &warningsForUser, CStdString &errorForUser)

Protected Types

typedef std::list< FullClassInfo * > GraphComponent

Protected Member Functions

void getGraphComponentsList (std::list< GraphComponent > &componentsList)
void getGraphComponentsListHelper (FullClassInfo *classInfo, GraphComponent &component)

Protected Attributes

CStdString firstProcessedFile

Detailed Description

ClassHierarchy extended to support some features needed when writing metadata.

If the metadata come from C++ sources parsing, they doesn't contain all the data that it should - for example table names, column names, attribute groups etc. This missing information can be generated by methods of this class.


Member Typedef Documentation

typedef std::list<FullClassInfo *> MWClassHierarchy::GraphComponent [protected]
 

Type of one component of application classes inheritance graph.


Constructor & Destructor Documentation

MWClassHierarchy::~MWClassHierarchy  ) 
 

Destructor - deletes FullClassInfo::otherInfo if non-NULL. (XMLMetadataWriter::saveMetadata() uses it).


Member Function Documentation

int MWClassHierarchy::setMappingType IopcMappingType  defaultMappingType,
CStdString &  warningsForUser,
CStdString &  errorForUser
 

Sets mapping type of all classes without any persistent parent to defaultMappingType.

User could change the mapping types later in XML.

Parameters:
defaultMappingType The mapping type.
warningsForUser String used to send warning message(s) to user if needed.
errorForUser String used to send an error message to user if needed.
Returns:
0 if OK, non-zero in case of error.

int MWClassHierarchy::generateTableNames CStdString &  warningsForUser,
CStdString &  errorForUser
 

Generates table names for all classes that should have its own table.

No table names are given by user in this moment. Default table name is class name in upper case, if this will not be unique, _<number> is appended. User could change the names later in XML.

Parameters:
warningsForUser String used to send warning message(s) to user if needed.
errorForUser String used to send an error message to user if needed.
Returns:
0 if OK, non-zero in case of error.

Reimplemented from ClassHierarchy.

int MWClassHierarchy::generateColumnTypesAndNames DatabaseSqlStatements sqlStatements,
CStdString &  warningsForUser,
CStdString &  errorForUser
 

Generates DB column type and name for each persistent attribute.

Gets classes inhitance graph components using getGraphComponentsList(), sets column names to be unique inside appropriate component. Default column name is attribute name in upper case, if this will not be unique _<number> is appended. User could change this later in XML.

Generation of column types is trivial, DatabaseSqlStatements::getRecommendedColumnType() is used. If this function doesn't return any type, attribute is assumed to be of some complex data type, so we don't know which type should be used for it - therefore we set its persistent flag to false.

Note:
If using filtered mapping only, column names have to be unique inside their component of inheritance graph. If using other mapping types weaker criteria on column names could be used.
Parameters:
sqlStatements Object that is able to generate SQL statements for appropriate DB.
warningsForUser String used to send warning message(s) to user if needed.
errorForUser String used to send an error message to user if needed.
Returns:
0 if OK, non-zero in case of error.

int MWClassHierarchy::generateAttributeGroups CStdString &  warningsForUser,
CStdString &  errorForUser
 

Initially splits the attributes into groups.

All persistent capable attributes of a "number" type are references are put into DEFAULT_FETCH_GROUP, all other persistent capable attributes into FIRST_PERSISTENT_GROUP, all non-persistent capable ones into FIRST_TRANSIENT_GROUP. User could change this later in XML.

Parameters:
warningsForUser String used to send warning message(s) to user if needed.
errorForUser String used to send an error message to user if needed.
Returns:
0 if OK, non-zero in case of error.

void MWClassHierarchy::getGraphComponentsList std::list< GraphComponent > &  componentsList  )  [protected]
 

Returns list of inheritance graph components. Uses FullClassInfo::flags and functions topologicalSort() and getGraphComponentsListHelper().

Parameters:
componentsList Result of the function - the list of the components.

void MWClassHierarchy::getGraphComponentsListHelper FullClassInfo classInfo,
GraphComponent component
[protected]
 

Helper function used by getGraphComponentsList().

Adds all parents and children of classInfo whose flags is not FCI_VISITED to component, sets their flags to FCI_VISITED and calls this function on them.

Parameters:
classInfo Class to be processed.
component List of classes that belongs to current graph component.


Member Data Documentation

CStdString MWClassHierarchy::firstProcessedFile [protected]
 

Name of first temporary (*.iopc) file from which metadata have been loaded. Used in XMLMetadataWriter::loadTmpFile() to catch error when two files coming from different projects are said to be merged into one XML file.


The documentation for this class was generated from the following files:
Generated on Wed Aug 11 22:35:53 2004 for IOPC by Doxygen 1.3.6