Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

ogdf::UmlToGraphConverter Class Reference

This class performs all necessary steps to obtain a model graph and diagram graphs from the input file which contains an UML model in XML format. More...

#include <ogdf/fileformats/UmlToGraphConverter.h>

Public Member Functions

 UmlToGraphConverter (istream &is)
 Constructor. More...
 
 ~UmlToGraphConverter ()
 Destructor. More...
 
const SList< UmlDiagramGraph * > & getDiagramGraphs () const
 Access to diagram graphs. More...
 
const SList< UMLGraph * > & getDiagramGraphsInUMLGraphFormat () const
 Access to the diagrams graphs in UMLGraph format. More...
 
const UmlModelGraph & getModelGraph () const
 Access to model graph. More...
 
void printDiagramsInUMLGraphFormat (ofstream &os)
 Prints the content of each diagram to os. More...
 
void printIdToNodeMappingTable (ofstream &os)
 Print hash table which maps the ids to the nodes. More...
 

Private Types

enum  PredefinedInfoIndex {
  PredefinedInfoIndex::xmi = 0, PredefinedInfoIndex::xmiContent, PredefinedInfoIndex::xmiId, PredefinedInfoIndex::umlModel, PredefinedInfoIndex::umlNamespaceOwnedElement, PredefinedInfoIndex::umlClass, PredefinedInfoIndex::name, PredefinedInfoIndex::umlGeneralization, PredefinedInfoIndex::child, PredefinedInfoIndex::parent, PredefinedInfoIndex::umlAssociation, PredefinedInfoIndex::umlAssociationConnection, PredefinedInfoIndex::umlAssociationEnd, PredefinedInfoIndex::type,
  PredefinedInfoIndex::umlDiagram, PredefinedInfoIndex::rootUmlDiagramElement, PredefinedInfoIndex::umlDiagramElement, PredefinedInfoIndex::geometry, PredefinedInfoIndex::subject, PredefinedInfoIndex::umlPackage, PredefinedInfoIndex::umlInterface, PredefinedInfoIndex::umlDependency, PredefinedInfoIndex::client, PredefinedInfoIndex::supplier, PredefinedInfoIndex::diagramType, PredefinedInfoIndex::classDiagram, PredefinedInfoIndex::moduleDiagram, PredefinedInfoIndex::nextPredefinedInfoIndex
}
 Predefined info indices for known tag and attribute names. More...
 

Private Member Functions

bool createDiagramGraphs ()
 For each diagram converts the relevant information contained in the parse tree into the data structure of UmlDiagramGraph. More...
 
bool createDiagramGraphsInUMLGraphFormat (SList< UMLGraph *> &diagramGraphsInUMLGraphFormat)
 Transforms each diagram graph contained in m_diagramGraphs into an equivalent. More...
 
bool createModelGraph (UmlModelGraph &modelGraph)
 Converts the relevant information contained in the parse tree into the data structure of UmlModelGraph. More...
 
void initializePredefinedInfoIndices ()
 Inserts known strings for tags and attributes into the hashtable of the parser. More...
 
bool insertDependencyEdges (const XmlTagObject &currentRootTag, UmlModelGraph &modelGraph)
 Identifies dependency tags inside the parse tree and inserts a new edge between the corresponding nodes of the involved elements. More...
 
bool insertSpecificClassifierNodes (const XmlTagObject &currentRootTag, const string currentPackageName, int desiredClassifier, UmlModelGraph &modelGraph)
 Tries to find all classifiers of type desiredClassifier inside the parse tree (starting at currentRootTag). More...
 
bool traversePackagesAndInsertAssociationEdges (const XmlTagObject &currentRootTag, UmlModelGraph &modelGraph)
 Traverses the package structure and identifies associations inside the parse tree and inserts a new edge between the corresponding nodes of the involved classifiers. More...
 
bool traversePackagesAndInsertClassifierNodes (const XmlTagObject &currentRootTag, const string &currentPackageName, UmlModelGraph &modelGraph)
 Traverses the package structure and identifies classifiers inside the parse tree (starting at currentRootTag) and inserts a new node for each classifier. More...
 
bool traversePackagesAndInsertGeneralizationEdges (const XmlTagObject &currentRootTag, UmlModelGraph &modelGraph)
 Traverses the package structure and identifies generalization inside the parse tree and inserts a new edge between the corresponding nodes of the involved classifiers. More...
 

Private Attributes

SList< UmlDiagramGraph * > m_diagramGraphs
 The set of graphs which represent special diagrams contained in the model. More...
 
SList< UMLGraph * > m_diagramGraphsInUMLGraphFormat
 This list contains the set of graphs of the list m_diagramGraphs in UMLGraph format. More...
 
Hashing< int, edge > m_idToEdge
 Maps string info to edge. More...
 
Hashing< int, node > m_idToNode
 Maps string info to node. More...
 
UmlModelGraph * m_modelGraph
 The graph which represents the complete UML model. More...
 
XmlParser * m_xmlParser
 The parser used for parsing the input file. More...
 

Detailed Description

This class performs all necessary steps to obtain a model graph and diagram graphs from the input file which contains an UML model in XML format.

In particular the following is done:

  • Given the input file a class XmlParser is created which accomplishes the parsing of the XML file; as result of the parsing procedure a parse tree representing the xml document is accessible.
  • The parse tree is used to extract the model graph of the contained uml model as well as a set of diagram graphs which are part of the uml model.

The graphs can be accessed via the functions getModelGraph() and getDiagramGraphs().

In debug mode warnings and the content of the model graph and the diagram graphs are written into the log file named umlToGraphConversionLog.txt.

Definition at line 62 of file UmlToGraphConverter.h.

Member Enumeration Documentation

◆ PredefinedInfoIndex

Predefined info indices for known tag and attribute names.

Enumerator
xmi 
xmiContent 
xmiId 
umlModel 
umlNamespaceOwnedElement 
umlClass 
name 
umlGeneralization 
child 
parent 
umlAssociation 
umlAssociationConnection 
umlAssociationEnd 
type 
umlDiagram 
rootUmlDiagramElement 
umlDiagramElement 
geometry 
subject 
umlPackage 
umlInterface 
umlDependency 
client 
supplier 
diagramType 
classDiagram 
moduleDiagram 
nextPredefinedInfoIndex 

Definition at line 83 of file UmlToGraphConverter.h.

Constructor & Destructor Documentation

◆ UmlToGraphConverter()

ogdf::UmlToGraphConverter::UmlToGraphConverter ( istream &  is)
explicit

Constructor.

The constructor performs the following:

Parameters
isThe input stream of the xml file which contains the data of the uml model to be converted into the graph format.

◆ ~UmlToGraphConverter()

ogdf::UmlToGraphConverter::~UmlToGraphConverter ( )

Destructor.

The destructor destroys:

Member Function Documentation

◆ createDiagramGraphs()

bool ogdf::UmlToGraphConverter::createDiagramGraphs ( )
private

For each diagram converts the relevant information contained in the parse tree into the data structure of UmlDiagramGraph.

Returns
Returns true if conversion was succesful, false otherwise.

◆ createDiagramGraphsInUMLGraphFormat()

bool ogdf::UmlToGraphConverter::createDiagramGraphsInUMLGraphFormat ( SList< UMLGraph *> &  diagramGraphsInUMLGraphFormat)
private

Transforms each diagram graph contained in m_diagramGraphs into an equivalent.

Parameters
diagramGraphsInUMLGraphFormatThe list of diagram graphs in UMLGraph format which have been obtained from the diagram graphs.
Returns
Returns true if conversion was successful, false otherwise.

◆ createModelGraph()

bool ogdf::UmlToGraphConverter::createModelGraph ( UmlModelGraph &  modelGraph)
private

Converts the relevant information contained in the parse tree into the data structure of UmlModelGraph.

Parameters
modelGraphThe model graph into which the nodes and edges corresponding to UML elements and UML relations should be inserted.
Returns
Returns true if conversion was succesful, false otherwise.

◆ getDiagramGraphs()

const SList<UmlDiagramGraph*>& ogdf::UmlToGraphConverter::getDiagramGraphs ( ) const
inline

Access to diagram graphs.

Returns
A const reference to the list of diagram graphs.

Definition at line 166 of file UmlToGraphConverter.h.

◆ getDiagramGraphsInUMLGraphFormat()

const SList<UMLGraph*>& ogdf::UmlToGraphConverter::getDiagramGraphsInUMLGraphFormat ( ) const
inline

Access to the diagrams graphs in UMLGraph format.

Returns
A const reference to a list of diagram graphs in UMLGraph format.

Definition at line 173 of file UmlToGraphConverter.h.

◆ getModelGraph()

const UmlModelGraph& ogdf::UmlToGraphConverter::getModelGraph ( ) const
inline

Access to model graph.

Returns
A const reference to the model graph.

Definition at line 159 of file UmlToGraphConverter.h.

◆ initializePredefinedInfoIndices()

void ogdf::UmlToGraphConverter::initializePredefinedInfoIndices ( )
private

Inserts known strings for tags and attributes into the hashtable of the parser.

The info elements for the hashtable are taken from enum PredefinedInfoIndex.

◆ insertDependencyEdges()

bool ogdf::UmlToGraphConverter::insertDependencyEdges ( const XmlTagObject &  currentRootTag,
UmlModelGraph &  modelGraph 
)
private

Identifies dependency tags inside the parse tree and inserts a new edge between the corresponding nodes of the involved elements.

Parameters
currentRootTagThe tag where to start the search for dependencies.
modelGraphThe model graph into which edges are inserted.
Returns
False if something went wrong, true otherwise.

◆ insertSpecificClassifierNodes()

bool ogdf::UmlToGraphConverter::insertSpecificClassifierNodes ( const XmlTagObject &  currentRootTag,
const string  currentPackageName,
int  desiredClassifier,
UmlModelGraph &  modelGraph 
)
private

Tries to find all classifiers of type desiredClassifier inside the parse tree (starting at currentRootTag).

Inserts a new node into modelGraph for each classifier found.

Parameters
currentRootTagThe tag where to start the search for the desired classifier.
currentPackageNameThis string should contain the name of the package path corresponding to currentRootTag.
desiredClassifierThe info index of the desired class (see enum PredefinedInfoIndex).
modelGraphThe model graph into which nodes are inserted.
Returns
False if something went wrong, true otherwise.

◆ printDiagramsInUMLGraphFormat()

void ogdf::UmlToGraphConverter::printDiagramsInUMLGraphFormat ( ofstream &  os)

Prints the content of each diagram to os.

Parameters
osThe output stream where to direct the output to.

◆ printIdToNodeMappingTable()

void ogdf::UmlToGraphConverter::printIdToNodeMappingTable ( ofstream &  os)

Print hash table which maps the ids to the nodes.

Parameters
osThe output stream where to direct the output to.

◆ traversePackagesAndInsertAssociationEdges()

bool ogdf::UmlToGraphConverter::traversePackagesAndInsertAssociationEdges ( const XmlTagObject &  currentRootTag,
UmlModelGraph &  modelGraph 
)
private

Traverses the package structure and identifies associations inside the parse tree and inserts a new edge between the corresponding nodes of the involved classifiers.

Note that it is not possible to include this function into traversePackagesAndInsertClassifierNodes(). The reason is that it is possible that edges are specified prior to that one or both nodes have been created.

Parameters
currentRootTagThe tag where to start the search for associations.
modelGraphThe model graph into which edges are inserted.
Returns
False if something went wrong, true otherwise.

◆ traversePackagesAndInsertClassifierNodes()

bool ogdf::UmlToGraphConverter::traversePackagesAndInsertClassifierNodes ( const XmlTagObject &  currentRootTag,
const string &  currentPackageName,
UmlModelGraph &  modelGraph 
)
private

Traverses the package structure and identifies classifiers inside the parse tree (starting at currentRootTag) and inserts a new node for each classifier.

This function will call itself recursively while traversing nested packages.

Valid classifiers are currently: class and interface.

Parameters
currentRootTagThe tag where to start the search for classifiers.
currentPackageNameThis string should contain the name of the package path corresponding to currentRootTag.
modelGraphThe model graph into which nodes are inserted.
Returns
False if something went wrong, true otherwise.

◆ traversePackagesAndInsertGeneralizationEdges()

bool ogdf::UmlToGraphConverter::traversePackagesAndInsertGeneralizationEdges ( const XmlTagObject &  currentRootTag,
UmlModelGraph &  modelGraph 
)
private

Traverses the package structure and identifies generalization inside the parse tree and inserts a new edge between the corresponding nodes of the involved classifiers.

It does not make sense to put this function and traversePackagesAndInsertAssociationEdges() together since the generalization tags are inside the class tags, so first the classes have to be identified again in contrast to traversePackagesAndInsertAssociationEdges().

Parameters
currentRootTagThe tag where to start the search for generalizations.
modelGraphThe model graph into which edges are inserted.
Returns
False if something went wrong, true otherwise.

Member Data Documentation

◆ m_diagramGraphs

SList<UmlDiagramGraph*> ogdf::UmlToGraphConverter::m_diagramGraphs
private

The set of graphs which represent special diagrams contained in the model.

Definition at line 74 of file UmlToGraphConverter.h.

◆ m_diagramGraphsInUMLGraphFormat

SList<UMLGraph*> ogdf::UmlToGraphConverter::m_diagramGraphsInUMLGraphFormat
private

This list contains the set of graphs of the list m_diagramGraphs in UMLGraph format.

The transformation is performed in the constructor UmlToGraphConverter().

Definition at line 80 of file UmlToGraphConverter.h.

◆ m_idToEdge

Hashing<int,edge> ogdf::UmlToGraphConverter::m_idToEdge
private

Maps string info to edge.

The functionality is the same as for m_idToNode.

Definition at line 130 of file UmlToGraphConverter.h.

◆ m_idToNode

Hashing<int,node> ogdf::UmlToGraphConverter::m_idToNode
private

Maps string info to node.

We need this hash table for fast access to nodes corresponding to UML elements. For each UML Element in XMI format we have an unique identifier via the xmi.id attribute. The xmi.id attribute is saved as string in the hash table of the parser, hence we can use the info index of it. While scanning for relations between nodes we encounter the xmi.id attribute values of the involved elements referenced as type attribute in the relation. Now we can use the hash table to access the corresponding node.

Definition at line 125 of file UmlToGraphConverter.h.

◆ m_modelGraph

UmlModelGraph* ogdf::UmlToGraphConverter::m_modelGraph
private

The graph which represents the complete UML model.

Definition at line 69 of file UmlToGraphConverter.h.

◆ m_xmlParser

XmlParser* ogdf::UmlToGraphConverter::m_xmlParser
private

The parser used for parsing the input file.

Definition at line 66 of file UmlToGraphConverter.h.


The documentation for this class was generated from the following file: