umbrello API Documentation

codedocument.h

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   : Wed Jun 18 2003
00015  */
00016 
00017 #ifndef CODEDOCUMENT_H
00018 #define CODEDOCUMENT_H
00019 
00020 #include <qobject.h>
00021 #include <qmap.h>
00022 #include <qstring.h>
00023 
00024 #include "codegenerationpolicy.h"
00025 #include "codegenobjectwithtextblocks.h"
00026 #include "hierarchicalcodeblock.h"
00027 
00028 class QWidget;
00029 class CodeAccessorMethod;
00030 class CodeBlockWithComments;
00031 class CodeComment;
00032 class CodeOperation;
00033 class TextBlock;
00034 class UMLPackage;
00035 
00036 //#include "codedocumentdialog.h"
00037 
00043 // "friend" status is needed for HBlock so it may call addChildTagToMap which
00044 // is protected.
00045 class CodeDocument : public QObject, public CodeGenObjectWithTextBlocks
00046 {
00047     friend class HierarchicalCodeBlock;
00048     Q_OBJECT
00049 public:
00050 
00051     // Constructors/Destructors
00052     //
00053 
00054 
00061     CodeDocument ( );
00062 
00066     virtual ~CodeDocument ( );
00067 
00068     // Public attributes
00069     //
00070 
00071     // Public attribute accessor methods
00072     //
00073 
00078     void setFileExtension ( const QString &new_var );
00079 
00084     QString getFileExtension ( ) const;
00085 
00090     void setFileName ( const QString &new_var );
00091 
00097     QString getFileName ( ) const;
00098 
00103     void setPackage ( UMLPackage *new_var );
00104 
00109     QString getPackage ( ) const;
00110 
00115     virtual QString getPath ( );
00116 
00121     void setID ( const QString &new_id);
00122 
00127     QString getID ( ) const;
00128 
00135     void setWriteOutCode ( bool new_var );
00136 
00143     bool getWriteOutCode ( );
00144 
00148     void setHeader ( CodeComment * comment );
00149 
00153     CodeComment * getHeader ( );
00154 
00159     bool insertTextBlock (TextBlock * newBlock, TextBlock * existingBlock, bool after = true);
00160 
00166     TextBlock * findTextBlockByTag( const QString &tag , bool descendIntoChildren = false);
00167 
00172     virtual QString toString ( );
00173 
00177     virtual void saveToXMI ( QDomDocument & doc, QDomElement & root );
00178 
00182     virtual void loadFromXMI ( QDomElement & root );
00183 
00188     virtual CodeBlock * newCodeBlock ( );
00189 
00194     virtual HierarchicalCodeBlock * newHierarchicalCodeBlock ( );
00195 
00200     virtual CodeBlockWithComments * newCodeBlockWithComments ( );
00201 
00202     // return a unique, and currently unallocated, text block tag for this document
00203     virtual QString getUniqueTag( QString prefix = QString("") );
00204 
00207     QString cleanName ( const QString &name );
00208 
00209     // Cause this code document to synchronize to current generator policy
00210     virtual void synchronize();
00211 
00212 
00213 protected:
00214 
00218     virtual void setAttributesOnNode ( QDomDocument & doc, QDomElement & blockElement);
00219 
00223     virtual void setAttributesFromNode ( QDomElement & element);
00224 
00225     // these next 2 are needed by child hierarchical code blocks so
00226     // that when they call getUniqueTag, we really get a unique tag
00227     // Also, it allows 'findTextBlockByTag' To find any tagged text block
00228     // anywhere in the document, whether directly owned by the document OR
00229     // by some child hierarchical textblock
00230     void addChildTagToMap ( const QString &tag, TextBlock * tb);
00231     void removeChildTagFromMap ( const QString &tag );
00232 
00233     // update the header text of this codedocument
00234     void updateHeader ();
00235 
00236     // reset/clear our inventory of textblocks in this document
00237     void resetTextBlocks();
00238 
00239     // update the content of this code document
00240     // this is where you should lay out your code document structure of textblocks
00241     // in the inheriting class, should it have any text in it.
00242     virtual void updateContent();
00243 
00244     // have to implement this for CodeObjectWithTextBlocks
00245     // doenst actually do anythying fo ra vannilla code document
00246     virtual TextBlock * findCodeClassFieldTextBlockByTag( const QString &tag );
00247 
00248 private:
00249 
00250     int lastTagIndex;
00251     QString m_filename;
00252     QString m_fileExtension;
00253     QString m_ID;
00254     QString m_pathName;
00255     UMLPackage *m_package;
00256 
00257     bool m_writeOutCode; // Whether or not to write out this code document
00258     // and any codeblocks, etc that it owns.
00259 
00260     CodeComment * m_header;
00261 
00262 
00263     void initDoc ( ) ;
00264 
00265     // TextBlockList m_textblockVector;
00266     // QMap<QString, TextBlock *> m_textBlockTagMap;
00267 
00268     // for recording all of the textblocks held by child hierarchical codeblocks
00269     QMap<QString, TextBlock *> m_childTextBlockTagMap;
00270 
00271 };
00272 
00273 #endif // CODEDOCUMENT_H
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