[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators

Oliver Kellogg okellogg at users.sourceforge.net
Sun Oct 7 14:08:19 UTC 2007


SVN commit 722514 by okellogg:

merge r721197:722186 from trunk

 M  +26 -50    classifierinfo.cpp  
 M  +8 -14     classifierinfo.h  
 M  +0 -1      codegenfactory.cpp  
 M  +17 -15    cppheadercodedocument.cpp  
 M  +3 -4      cppheadercodedocument.h  
 M  +3 -3      cppwriter.cpp  
 M  +1 -3      javaclassifiercodedocument.h  
 M  +1 -1      pascalwriter.cpp  
 M  +1 -3      rubyclassifiercodedocument.h  
 M  +1 -1      rubywriter.cpp  
 M  +3 -3      tclwriter.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/classifierinfo.cpp #722513:722514
@@ -15,38 +15,20 @@
 #include "../classifier.h"
 #include "../operation.h"
 
-ClassifierInfo::ClassifierInfo( UMLClassifier *classifier , UMLDoc */*doc*/)
+ClassifierInfo::ClassifierInfo( UMLClassifier *classifier)
 {
+    classifier_ = classifier;
 
-    init(classifier);
-}
-
-ClassifierInfo::~ClassifierInfo() { }
-
-void ClassifierInfo::init(UMLClassifier *c) {
-
-    // make all QPtrLists autoDelete false
-    atpub.setAutoDelete(false);
-    atprot.setAutoDelete(false);
-    atpriv.setAutoDelete(false);
-
-    static_atpub.setAutoDelete(false);
-    static_atprot.setAutoDelete(false);
-    static_atpriv.setAutoDelete(false);
-
     // set default class, file names
-    className = c->getName();
-    fileName = c->getName().lower();
+    className = classifier->getName();
+    fileName = classifier->getName().lower();
 
     // determine up-front what we are dealing with
-    isInterface = c->isInterface();
+    isInterface = classifier->isInterface();
 
-    // set id
-    m_nID = c->getID();
-
     // sort attributes by Scope
     if(!isInterface) {
-        UMLAttributeList atl = c->getAttributeList();
+        UMLAttributeList atl = classifier->getAttributeList();
         for(UMLAttribute *at=atl.first(); at ; at=atl.next()) {
             switch(at->getVisibility())
             {
@@ -70,29 +52,22 @@
                     atpriv.append(at);
                 break;
             }
-            m_AttsList.append(at);
         }
     }
 
     // inheritance issues
-    superclasses = c->getSuperClasses(); // list of what we inherit from
-    superclasses.setAutoDelete(false);
+    superclasses = classifier->getSuperClasses(); // list of what we inherit from
 
-    subclasses = c->getSubClasses();     // list of what inherits from us
-    subclasses.setAutoDelete(false);
+    subclasses = classifier->getSubClasses();     // list of what inherits from us
 
     // another preparation, determine what we have
-    plainAssociations = c->getSpecificAssocs(Uml::at_Association); // BAD! only way to get "general" associations.
-    plainAssociations.setAutoDelete(false);
+    plainAssociations = classifier->getSpecificAssocs(Uml::at_Association); // BAD! only way to get "general" associations.
 
-    uniAssociations = c->getUniAssociationToBeImplemented();
-    uniAssociations.setAutoDelete(false);
+    uniAssociations = classifier->getUniAssociationToBeImplemented();
 
-    aggregations = c->getAggregations();
-    aggregations.setAutoDelete(false);
+    aggregations = classifier->getAggregations();
 
-    compositions = c->getCompositions();
-    compositions.setAutoDelete(false);
+    compositions = classifier->getCompositions();
 
     // set some summary information about the classifier now
     hasAssociations = plainAssociations.count() > 0 || aggregations.count() > 0 || compositions.count() > 0 || uniAssociations.count() > 0;
@@ -107,7 +82,7 @@
 
     hasAccessorMethods = hasAttributes || hasAssociations;
 
-    hasOperationMethods = c->getOpList().last() ? true : false;
+    hasOperationMethods = classifier->getOpList().last() ? true : false;
 
     hasMethods = hasOperationMethods || hasAccessorMethods;
 
@@ -115,28 +90,28 @@
     // SINGLE objects, and WONT be declared as Vectors, so this
     // is a bit overly inclusive (I guess that's better than the other way around)
     hasVectorFields = hasAssociations ? true : false;
-
-
 }
 
-UMLClassifierList ClassifierInfo::getPlainAssocChildClassifierList() {
+ClassifierInfo::~ClassifierInfo() { }
+
+UMLClassifierList ClassifierInfo::getPlainAssocChildClassifierList()
+{
     return findAssocClassifierObjsInRoles(&plainAssociations);
 }
 
-UMLClassifierList ClassifierInfo::getAggregateChildClassifierList() {
+UMLClassifierList ClassifierInfo::getAggregateChildClassifierList()
+{
     return findAssocClassifierObjsInRoles(&aggregations);
 }
 
-UMLClassifierList ClassifierInfo::getCompositionChildClassifierList() {
+UMLClassifierList ClassifierInfo::getCompositionChildClassifierList() 
+{
     return findAssocClassifierObjsInRoles(&compositions);
 }
 
 UMLClassifierList ClassifierInfo::findAssocClassifierObjsInRoles (UMLAssociationList * list)
 {
-
-
     UMLClassifierList classifiers;
-    classifiers.setAutoDelete(false);
 
     for (UMLAssociation *a = list->first(); a; a = list->next()) {
         // DONT accept a classifier IF the association role is empty, by
@@ -144,11 +119,11 @@
         // the association.
         // We also ignore classifiers which are the same as the current one
         // (e.g. id matches), we only want the "other" classifiers
-        if (a->getObjectId(Uml::A) == m_nID && !a->getRoleName(Uml::B).isEmpty()) {
+        if (a->getObjectId(Uml::A) == classifier_->getID() && !a->getRoleName(Uml::B).isEmpty()) {
             UMLClassifier *c = dynamic_cast<UMLClassifier*>(a->getObject(Uml::B));
             if(c)
                 classifiers.append(c);
-        } else if (a->getObjectId(Uml::B) == m_nID && !a->getRoleName(Uml::A).isEmpty()) {
+        } else if (a->getObjectId(Uml::B) == classifier_->getID() && !a->getRoleName(Uml::A).isEmpty()) {
             UMLClassifier *c = dynamic_cast<UMLClassifier*>(a->getObject(Uml::A));
             if(c)
                 classifiers.append(c);
@@ -158,7 +133,8 @@
     return classifiers;
 }
 
-UMLAttributeList* ClassifierInfo::getAttList() {
-    return &m_AttsList;
+UMLAttributeList ClassifierInfo::getAttList()
+{
+    return classifier_->getAttributeList();
 }
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/classifierinfo.h #722513:722514
@@ -13,7 +13,6 @@
 #ifndef CLASSIFIERINFO_H
 #define CLASSIFIERINFO_H
 
-#include "../classifier.h"
 #include "../umldoc.h"
 #include "../attribute.h"
 #include "../association.h"
@@ -23,6 +22,10 @@
 
 #include <qstring.h>
 
+
+class UMLClassifier;
+	
+
 /**
   * class ClassInfo is an object to hold summary information about a classifier
   * in a convenient form for easy access by a code generator.
@@ -33,7 +36,7 @@
     /**
      * Constructor, initialises a couple of variables
      */
-    ClassifierInfo (UMLClassifier * classifier, UMLDoc * doc);
+    ClassifierInfo (UMLClassifier * classifier);
 
     /**
      * Destructor, empty
@@ -103,16 +106,12 @@
      * Utility method to obtain list of attributes, if they exist, for
      * the current classfier.
      */
-    UMLAttributeList* getAttList();
+    UMLAttributeList getAttList();
 
-
-protected:
-    void init (UMLClassifier *c);
-
 private:
 
-    Uml::IDType m_nID; // id of the classifier
-
+    UMLClassifier* classifier_;
+    
     /**
      * Utility method called by "get*ChildClassfierList()" methods. It basically
      * finds all the classifiers named in each association in the given association list
@@ -121,11 +120,6 @@
      */
     UMLClassifierList findAssocClassifierObjsInRoles (UMLAssociationList * list);
 
-    /**
-     *      List of all the attributes in this class.
-     */
-    UMLAttributeList m_AttsList;
-
 };
 
 #endif // CLASSIFIERINFO_H
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/codegenfactory.cpp #722513:722514
@@ -19,7 +19,6 @@
 #include "codegenfactory.h"
 
 // qt/kde includes
-#include <qstringlist.h>
 #include <kdebug.h>
 
 // app includes
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppheadercodedocument.cpp #722513:722514
@@ -52,7 +52,8 @@
 //
 
 CPPHeaderCodeDocument::CPPHeaderCodeDocument ( UMLClassifier * concept )
-        : ClassifierCodeDocument (concept) {
+        : ClassifierCodeDocument (concept)
+{
     setFileExtension(".h");
 
     //initCodeClassFields(); // this is dubious because it calls down to
@@ -77,7 +78,9 @@
 
 }
 
-CPPHeaderCodeDocument::~CPPHeaderCodeDocument ( ) { }
+CPPHeaderCodeDocument::~CPPHeaderCodeDocument ( ) {
+    resetTextBlocks();
+}
 
 //
 // Methods
@@ -273,33 +276,33 @@
  */
 // in the vannilla version, we just tack all operations on the end
 // of the document
-bool CPPHeaderCodeDocument::addCodeOperation (CodeOperation * op ) {
-
+bool CPPHeaderCodeDocument::addCodeOperation (CodeOperation * op )
+{
     Uml::Visibility scope = op->getParentOperation()->getVisibility();
     if(!op->getParentOperation()->isLifeOperation())
     {
         switch (scope) {
         default:
-              case Uml::Visibility::Public:
+        case Uml::Visibility::Public:
             return pubOperationsBlock->addTextBlock(op);
             break;
-              case Uml::Visibility::Protected:
+        case Uml::Visibility::Protected:
             return protOperationsBlock->addTextBlock(op);
             break;
-              case Uml::Visibility::Private:
+        case Uml::Visibility::Private:
             return privOperationsBlock->addTextBlock(op);
             break;
         }
     } else {
         switch (scope) {
         default:
-              case Uml::Visibility::Public:
+        case Uml::Visibility::Public:
             return pubConstructorBlock->addTextBlock(op);
             break;
-              case Uml::Visibility::Protected:
+        case Uml::Visibility::Protected:
             return protConstructorBlock->addTextBlock(op);
             break;
-              case Uml::Visibility::Private:
+        case Uml::Visibility::Private:
             return privConstructorBlock->addTextBlock(op);
             break;
         }
@@ -312,7 +315,8 @@
  * @return      bool    status of save
  */
 /*
-void CPPHeaderCodeDocument::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
+void CPPHeaderCodeDocument::saveToXMI ( QDomDocument & doc, QDomElement & root )
+{
         QDomElement docElement = doc.createElement( "" );
 
         setAttributesOnNode(doc, docElement);
@@ -330,7 +334,6 @@
 // comments) to appear or not, as needed.
 void CPPHeaderCodeDocument::updateContent( )
 {
-
     // Gather info on the various fields and parent objects of this class...
     UMLClassifier * c = getParentClassifier();
     CodeGenPolicyExt *pe = UMLApp::app()->getPolicyExt();
@@ -473,7 +476,7 @@
         QString indent = UMLApp::app()->getCommonPolicy()->getIndentation();
         UMLEnum* e = dynamic_cast<UMLEnum*>(c);
         if (e) {
-            enumStatement.append(indent + "enum "+cppClassName+" {"+endLine);
+            enumStatement.append(indent + "enum " + cppClassName + " {" + endLine);
 
             // populate
             UMLClassifierListItemList ell = e->getFilteredList(Uml::ot_EnumLiteral);
@@ -656,8 +659,7 @@
     // meta-data to state what the scope of this method is, we will make it
     // "public" as a default. This might present problems if the user wants
     // to move the block into the "private" or "protected" blocks.
-    QString CPPClassName = CodeGenerator::cleanName(c->getName());
-    QString emptyConstStatement = CPPClassName+" ( ) { }";
+    QString emptyConstStatement = cppClassName + " ( ) { }";
 
     // search for this first in the entire document. IF not present, put
     // it in the public constructor method block
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppheadercodedocument.h #722513:722514
@@ -97,10 +97,9 @@
     HierarchicalCodeBlock * privOperationsBlock;
     HierarchicalCodeBlock * protOperationsBlock;
 
-    QString fileName; // Just for our convience in creating code
-    QString endLine; // characters for ending line. Just for our convience in creating code
-    QString CPPClassName;
-
+    /**
+     *
+     */
     CPPHeaderClassDeclarationBlock * getClassDecl();
 
 };
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/cppwriter.cpp #722513:722514
@@ -92,7 +92,7 @@
     }
 
     // preparations
-    m_classifierInfo = new ClassifierInfo(c, m_doc);
+    m_classifierInfo = new ClassifierInfo(c);
     m_classifierInfo->fileName = fileName;
     m_classifierInfo->className = cleanName(c->getName());
 
@@ -1021,8 +1021,8 @@
 
     m_indentLevel++;
     // first, initiation of fields derived from attributes
-    UMLAttributeList* atl = m_classifierInfo->getAttList();
-    for(UMLAttribute *at = atl->first(); at ; at = atl->next()) {
+    UMLAttributeList atl = m_classifierInfo->getAttList();
+    for(UMLAttribute *at = atl.first(); at ; at = atl.next()) {
         if(!at->getInitialValue().isEmpty()) {
             QString varName = getAttributeVariableName(at);
             stream << getIndent() << varName << " = " << at->getInitialValue() << ";" << m_endl;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/javaclassifiercodedocument.h #722513:722514
@@ -20,6 +20,7 @@
 #define JAVACLASSIFIERCODEDOCUMENT_H
 
 #include <qstring.h>
+
 #include "../codeclassfieldlist.h"
 #include "../classifiercodedocument.h"
 #include "../classifier.h"
@@ -99,9 +100,6 @@
     HierarchicalCodeBlock * operationsBlock;
 
     ClassifierInfo * info;
-    QString fileName; // Just for our convience in creating code
-    QString endLine; // characters for ending line. Just for our convience in creating code
-    QString JavaClassName;
 
     void init ( );
     JavaClassDeclarationBlock * getClassDecl();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/pascalwriter.cpp #722513:722514
@@ -249,7 +249,7 @@
     }
     pas << m_endl;
 
-    ClassifierInfo info(c, UMLApp::app()->getDocument());
+    ClassifierInfo info(c);
     UMLAttributeList atpub = info.atpub;
     if (isClass && (forceSections() || atpub.count())) {
         pas << getIndent() << "// Public attributes:" << m_endl;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/rubyclassifiercodedocument.h #722513:722514
@@ -22,6 +22,7 @@
 #define RUBYCLASSIFIERCODEDOCUMENT_H
 
 #include <qstring.h>
+
 #include "../codeclassfieldlist.h"
 #include "../classifiercodedocument.h"
 #include "../classifier.h"
@@ -115,9 +116,6 @@
     HierarchicalCodeBlock * protOperationsBlock;
 
     ClassifierInfo * info;
-    QString fileName; // Just for our convience in creating code
-    QString endLine; // characters for ending line. Just for our convience in creating code
-    QString RubyClassName;
 
     void init ( );
     RubyClassDeclarationBlock * getClassDecl();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/rubywriter.cpp #722513:722514
@@ -66,7 +66,7 @@
     QTextStream h(&fileh);
 
     // preparations
-    classifierInfo = new ClassifierInfo(c, m_doc);
+    classifierInfo = new ClassifierInfo(c);
     classifierInfo->fileName = fileName;
     classifierInfo->className = cleanName(c->getName());
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/tclwriter.cpp #722513:722514
@@ -113,7 +113,7 @@
         return;
     }
     // preparations
-    classifierInfo = new ClassifierInfo(c, m_doc);
+    classifierInfo = new ClassifierInfo(c);
     classifierInfo->fileName = fileName;
     classifierInfo->className = cleanName(c->getName());
     mClass = cleanName(c->getName());
@@ -649,8 +649,8 @@
         m_indentLevel++;
 
         // first, initiation of fields derived from attributes
-        UMLAttributeList *atl = classifierInfo->getAttList();
-        for (UMLAttribute * at = atl->first(); at; at = atl->next()) {
+        UMLAttributeList atl = classifierInfo->getAttList();
+        for (UMLAttribute * at = atl.first(); at; at = atl.next()) {
             if (!at->getInitialValue().isEmpty()) {
                 varName = cleanName(at->getName());
                 writeCode("set " + varName + ' ' + at->getInitialValue());




More information about the umbrello-devel mailing list