umbrello API Documentation

cppheaderclassdeclarationblock.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2004-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 /*  This code generated by:
00013  *      Author : thomas
00014  *      Date   : Mon Sep 1 2003
00015  */
00016 
00017 #include "cppheaderclassdeclarationblock.h"
00018 #include "cppcodegenerator.h"
00019 #include "cppcodegenerationpolicy.h"
00020 #include "cppcodedocumentation.h"
00021 #include "../model_utils.h"
00022 #include "../uml.h"
00023 
00024 // Constructors/Destructors
00025 //
00026 
00027 CPPHeaderClassDeclarationBlock::CPPHeaderClassDeclarationBlock
00028   ( CPPHeaderCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
00029         : OwnedHierarchicalCodeBlock(parentDoc->getParentClassifier(), parentDoc, startText, endText, comment)
00030 {
00031     init(parentDoc, comment);
00032 }
00033 
00034 CPPHeaderClassDeclarationBlock::~CPPHeaderClassDeclarationBlock ( ) { }
00035 
00036 //
00037 // Methods
00038 //
00039 
00043 void CPPHeaderClassDeclarationBlock::loadFromXMI ( QDomElement & root )
00044 {
00045     setAttributesFromNode(root);
00046 }
00047 
00050 void CPPHeaderClassDeclarationBlock::setAttributesFromObject (TextBlock * obj)
00051 {
00052     HierarchicalCodeBlock::setAttributesFromObject(obj);
00053 }
00054 
00058 void CPPHeaderClassDeclarationBlock::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
00059     QDomElement blockElement = doc.createElement( "cppheaderclassdeclarationblock" );
00060 
00061     setAttributesOnNode(doc, blockElement);
00062 
00063     root.appendChild( blockElement );
00064 }
00065 
00066 // Accessor methods
00067 //
00068 
00069 // Other methods
00070 //
00071 
00075 void CPPHeaderClassDeclarationBlock::updateContent ( )
00076 {
00077 
00078     CPPHeaderCodeDocument *parentDoc = dynamic_cast<CPPHeaderCodeDocument*>(getParentDocument());
00079     UMLClassifier *c = parentDoc->getParentClassifier();
00080     QString endLine = UMLApp::app()->getCommonPolicy()->getNewLineEndingChars();
00081     bool isInterface = parentDoc->parentIsInterface(); // a little shortcut
00082     QString CPPHeaderClassName = CodeGenerator::cleanName(c->getName());
00083     bool forceDoc = UMLApp::app()->getCommonPolicy()->getCodeVerboseDocumentComments();
00084 
00085     // COMMENT
00086 
00087     //check if class is abstract.. it should have abstract methods
00088     if(!isInterface && c->getAbstract() && !c->hasAbstractOps())
00089     {
00090         getComment()->setText("******************************* Abstract Class ****************************"+endLine
00091                               +CPPHeaderClassName+" does not have any pure virtual methods, but its author"+endLine
00092                               +"  defined it as an abstract class, so you should not use it directly."+endLine
00093                               +"  Inherit from it instead and create only objects from the derived classes"+endLine
00094                               +"*****************************************************************************");
00095     } else {
00096         if(isInterface)
00097             getComment()->setText("Interface "+CPPHeaderClassName+endLine+c->getDoc());
00098         else
00099             getComment()->setText("Class "+CPPHeaderClassName+endLine+c->getDoc());
00100     }
00101 
00102     if(forceDoc || !c->getDoc().isEmpty())
00103         getComment()->setWriteOutText(true);
00104     else
00105         getComment()->setWriteOutText(false);
00106 
00107 
00108     // Now set START/ENDING Text
00109     QString startText = "";
00110 
00111     /*
00112     */
00113 
00114     /*
00115         if(parentDoc->parentIsInterface())
00116                 startText.append("interface ");
00117         else
00118     */
00119     startText.append("class ");
00120 
00121     startText.append(CPPHeaderClassName);
00122 
00123     // write inheritances out
00124     UMLClassifierList superclasses = c->findSuperClassConcepts();
00125     int nrof_superclasses = superclasses.count();
00126 
00127     // write out inheritance
00128     int i = 0;
00129     if(nrof_superclasses >0)
00130         startText.append(" : ");
00131     for (UMLClassifier * concept= superclasses.first(); concept; concept = superclasses.next())
00132     {
00133         startText.append(concept->getVisibility().toString() + ' ' +
00134                          CodeGenerator::cleanName(concept->getName()));
00135         if(i != (nrof_superclasses-1))
00136             startText.append(", ");
00137         i++;
00138     }
00139 
00140     // Set the header and end text for the hier.codeblock
00141     setStartText(startText+" {");
00142 
00143     // setEndText("}"); // not needed
00144 
00145 }
00146 
00147 void CPPHeaderClassDeclarationBlock::init (CPPHeaderCodeDocument *parentDoc, const QString &comment)
00148 {
00149 
00150     setComment(new CPPCodeDocumentation(parentDoc));
00151     getComment()->setText(comment);
00152 
00153     setEndText("};");
00154 
00155     updateContent();
00156 
00157 }
00158 
00159 
00160 #include "cppheaderclassdeclarationblock.moc"
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:55 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003