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

ClassHierarchy Class Reference

Class that represents inheritance graph of application's classes. More...

#include <ClassHierarchy.h>

Inheritance diagram for ClassHierarchy:

Inheritance graph
[legend]
Collaboration diagram for ClassHierarchy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ClassHierarchy ()
virtual ~ClassHierarchy ()
int addClass (FullClassInfo &classInfo)
FullClassInfofindClass (const char *name)
CStdString getProjectName () const
void setProjectName (const char *newProjectName)
int createInheritanceHierarchy (CStdString &warningsForUser, CStdString &errorForUser)
int checkInheritanceHierarchy (CStdString &warningsForUser, CStdString &errorForUser)
int generateMissingValues (CStdString &warningsForUser, CStdString &errorForUser)
void topologicalSort (std::list< FullClassInfo * > &sortedClassList)
void printClasses ()

Protected Types

typedef std::map< CStdString,
FullClassInfo
ClassMap

Protected Member Functions

int checkChildren (FullClassInfo *classInfo, CStdString &warningsForUser, CStdString &errorForUser)
int generateMissingValuesHelper (FullClassInfo *classInfo, CStdString &warningsForUser, CStdString &errorForUser)
int generateTableNames (CStdString &warningsForUser, CStdString &errorForUser)
int generateColumnNames (CStdString &warningsForUser, CStdString &errorForUser)
int generateTableInfoMap (CStdString &warningsForUser, CStdString &errorForUser)
int getTableColumnsForClass (FullClassInfo *classInfo, TableInfoMap::iterator &where, CStdString &warningsForUser, CStdString &errorForUser)

Protected Attributes

ClassMap classMap
CStdString projectName
bool prepared
TableInfoMap classesColumns

Detailed Description

Class that represents inheritance graph of application's classes.

The class is actually a container for FullClassInfo-s, that are added to the class using addClass() method. Afterwards they are linked together to create the hierarchy by a call to createInheritanceHierarchy().


Member Typedef Documentation

typedef std::map<CStdString, FullClassInfo> ClassHierarchy::ClassMap [protected]
 

Map: key = class name, value = appropriate FullClassInfo.


Constructor & Destructor Documentation

ClassHierarchy::ClassHierarchy  )  [inline]
 

Simple constructor.

virtual ClassHierarchy::~ClassHierarchy  )  [inline, virtual]
 

Empty virtual destructor.


Member Function Documentation

int ClassHierarchy::addClass FullClassInfo classInfo  ) 
 

Adds given classInfo into classMap

Returns:
0 if OK, 1 if classMap already contains a class with the same name as classInfo.

FullClassInfo * ClassHierarchy::findClass const char *  name  ) 
 

Returns pointer to class of the given name.

Returns:
The pointer, NULL if the class is not present in classMap.

CStdString ClassHierarchy::getProjectName  )  const
 

Returns projectName.

void ClassHierarchy::setProjectName const char *  newProjectName  ) 
 

Sets projectName to newProjectName.

int ClassHierarchy::createInheritanceHierarchy CStdString &  warningsForUser,
CStdString &  errorForUser
 

Links FullClassInfo-s to create class inheritance hierarchy according to FullClassInfo::baseClassNames.

Fills in FullClassInfo::parents and FullClassInfo::children. Should be called after successfull filling of classMap.

Note:
FullClassInfo::parents and FullClassInfo::children should be empty when calling this function.
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.

int ClassHierarchy::checkInheritanceHierarchy CStdString &  warningsForUser,
CStdString &  errorForUser
 

Checks whether inheritance graph doesn't contain cycles

Note:
Uses FullClassInfo::flags.
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 if some cycle has been found.
See also:
checkChildren()

int ClassHierarchy::generateMissingValues CStdString &  warningsForUser,
CStdString &  errorForUser
 

Generates ClassHierarchy's missing values:

  • Generates globally unique column name for every database column, whose name has not been specified by user. (Doesn't check uniqueness of user specified ones - this is done when generating SQL in DBSchemaGenerator::generateCreationScript()).
  • Generates missing mapping types
  • Merges class attribute groups with groups from their class's parents (setting AttributeInfo::declaredIn, checking for errors in metadata).
  • Generates pointers FullClassInfo::addAttributesTo (for filtered mapping classes only).
  • Generates DB table names, if they are not specified. Checks whether specified ones are unique.

First action is implemented by a call to generateColumnNames() (must be called first - following call to generateMissingValuesHelper() propagates the information through the tree).

Second - fifth actions are implemented as a call to generateMissingValuesHelper() for every class. FullClassInfo::flags prevents class from beeing processed more then once.

Last action is implemented by a call to generateTableNames().

Note:
Uses FullClassInfo::flags.
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.
See also:
generateMissingValuesHelper()

void ClassHierarchy::topologicalSort std::list< FullClassInfo * > &  sortedClassList  ) 
 

Returns topologically sorted list of all classes in the hierarchy. Of course, createInheritanceHierarchy() must be called prior.

void ClassHierarchy::printClasses  ) 
 

For debug purposes only. Prints most of ClassHierarchy's information to stdout.

int ClassHierarchy::checkChildren FullClassInfo classInfo,
CStdString &  warningsForUser,
CStdString &  errorForUser
[protected]
 

Helper function used by checkInheritanceHierarchy().

Checks whether classInfo is not marked (FullClassInfo::flags) as FCI_VISITED_THIS_TURN. If it is, we have found a cycle. If it is marked as FCI_VISITED, children of classInfo have been already processed, so the function returns.

If FullClassInfo::flags is FCI_NORMAL, function sets it to FCI_VISITED_THIS_TURN, then calls itself on all children, and if no of the calls return any error, function sets the flags to FCI_VISITED and returns.

Note:
Uses FullClassInfo::flags.
Parameters:
classInfo Node (class) whose children should be checked.
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 if a cycle has been found.

int ClassHierarchy::generateMissingValuesHelper FullClassInfo classInfo,
CStdString &  warningsForUser,
CStdString &  errorForUser
[protected]
 

Helper function used by generateMissingValues().

Does the same thing as generateMissingValues() (except column names generation) but only for given class and its ancestors.

Note:
Uses FullClassInfo::flags.
Parameters:
classInfo Node (class) to be processed.
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 ClassHierarchy::generateTableNames CStdString &  warningsForUser,
CStdString &  errorForUser
[protected]
 

Generates missing table names and checks whether user supplied names are unique. Changes all table names to upper case. (Most DB systems treat table/column/... names as non case sensitive.)

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 in MWClassHierarchy.

int ClassHierarchy::generateColumnNames CStdString &  warningsForUser,
CStdString &  errorForUser
[protected]
 

Generates globally unique column name where the name has not been specified by user. (Doesn't check uniqueness of user specified ones - this is done when generating creation SQL in IOPC DBSC's DBSchemaGenerator::generateCreationScript()).

Changes all column names to upper case. (Most DB systems treat table/column/... names as non case sensitive.)

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.

int ClassHierarchy::generateTableInfoMap CStdString &  warningsForUser,
CStdString &  errorForUser
[protected]
 

Initializes classesColumns. Calls getTableColumnsForClass() for each class.

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.

int ClassHierarchy::getTableColumnsForClass FullClassInfo classInfo,
TableInfoMap::iterator &  where,
CStdString &  warningsForUser,
CStdString &  errorForUser
[protected]
 

Adds to classesColumns all columns from class classInfo, works recursively. If child uses IOPC_FILTERED mapping type, its attributes are added to appropriate parent.

Function also check uniqueness of column names inside one hierarchy (exactly - inside each table and inside each view).

Note:
If some attributes from a class are inherited through two ways (f.e. class A; class B : A, class C : A, class D : B, C) columns for these attributes are included only once. In C++ this is called virtual inheritance.
Inherited attributes are removed if mapping type is not equal to IOPC_HORIZONTAL. (It means they are not removed if they should be in appropriate table. If they shouldn't, they are temporary added to find out some collisions in column names.)

Note:
Skips class processing if it's already in classesColumns.
Parameters:
classInfo Class to be processed.
where Return value - iterator pointing to created classesColumns entry.
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.


Member Data Documentation

ClassMap ClassHierarchy::classMap [protected]
 

Container containing the hierarchy's classes.

CStdString ClassHierarchy::projectName [protected]
 

Name of the project whose class hierarchy is represented by this class.

bool ClassHierarchy::prepared [protected]
 

Flag set after successful finishing of generateMissingValues().

TableInfoMap ClassHierarchy::classesColumns [protected]
 

Map containing for each class information about appropriate DB table.

Note:
Initialized on demand by a call to generateTableInfoMap().


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