• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • kdesdk
  • Sitemap
  • Contact Us
 

umbrello/umbrello

codegenerator.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   This program is free software; you can redistribute it and/or modify  *
00003  *   it under the terms of the GNU General Public License as published by  *
00004  *   the Free Software Foundation; either version 2 of the License, or     *
00005  *   (at your option) any later version.                                   *
00006  *                                                                         *
00007  *   copyright (C) 2003      Brian Thomas <thomas@mail630.gsfc.nasa.gov>   *
00008  *   copyright (C) 2004-2008                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 #ifndef CODEGENERATOR_H
00013 #define CODEGENERATOR_H
00014 
00015 #include <QtCore/QHash>
00016 #include <QtCore/QList>
00017 #include <QtCore/QDir>
00018 
00019 #include "codegenerators/codegenpolicyext.h"
00020 #include "codegenerationpolicy.h"
00021 #include "umlpackagelist.h"
00022 #include "umlclassifierlist.h"
00023 #include "codedocumentlist.h"
00024 #include "codeviewerstate.h"
00025 #include "umlnamespace.h"
00026 
00027 class UMLDoc;
00028 class UMLObject;
00029 class ClassifierCodeDocument;
00030 class CodeBlock;
00031 class CodeDocument;
00032 class CodeViewerDialog;
00033 class QDomDocument;
00034 class QDomElement;
00035 
00068 class CodeGenerator : public QObject
00069 {
00070     Q_OBJECT
00071 
00072 public:
00073 
00074     CodeGenerator ();
00075     CodeGenerator (QDomElement & element );
00076 
00077     virtual ~CodeGenerator ( );
00078 
00079     bool addCodeDocument ( CodeDocument * add_object );
00080 
00081 //    /**
00082 //     * Replace (or possibly add a new) CodeDocument object to the m_codedocumentVector List.
00083 //     * As names must be unique and each code document must have a name.
00084 //     * @return  boolean value which will be true if the passed document was able to replace some
00085 //     *    other document OR was added(no prior document existed..only when addIfPriorDocumentNotPresent is true).
00086 //     *    The document which was replaced will be deleted IF deleteReplacedDocument is true.
00087 //     */
00088 //    bool replaceCodeDocument (  CodeDocument * replace_doc=0, bool addIfPriorDocumentNotPresent=true,
00089 //                                bool deleteReplacedDocument=true );
00090 
00091     bool removeCodeDocument ( CodeDocument * remove_object );
00092 
00093     CodeDocumentList * getCodeDocumentList ( );
00094 
00095     QString getUniqueID ( CodeDocument * codeDoc );
00096 
00097     virtual void saveToXMI ( QDomDocument & doc, QDomElement & root );
00098 
00099     CodeDocument * findCodeDocumentByID (const QString &id );
00100 
00101     virtual void writeCodeToFile ( );
00102     virtual void writeCodeToFile(UMLClassifierList &list);
00103 
00104     // these are utility methods for accessing the default
00105     // code gen policy object and *perhaps* should go away when we
00106     // finally implement the CodeGenDialog class -b.t.
00107 
00108     void setModifyNamePolicy(CodeGenerationPolicy::ModifyNamePolicy p);
00109     CodeGenerationPolicy::ModifyNamePolicy modifyNamePolicy()const;
00110 
00111     void setIncludeHeadings(bool i);
00112     bool includeHeadings() const;
00113 
00114     void setHeadingFileDir(const QString &);
00115     QString headingFileDir() const;
00116 
00117     void setForceDoc(bool f);
00118     bool forceDoc() const;
00119 
00120     void setForceSections(bool f);
00121     bool forceSections() const;
00122 
00123     virtual QString getHeadingFile (const QString &file );
00124 
00125     QString findFileName(CodeDocument * codeDocument);
00126 
00127     static QString cleanName ( const QString &name );
00128 
00129     static QString formatDoc (const QString& text, const QString& linePrefix = " *", int lineWidth = 80 );
00130 
00131     static QString formatSourceCode(const QString& code, const QString& indentation);
00132 
00133     static void findObjectsRelated(UMLClassifier *c, UMLPackageList &cList);
00134 
00139     virtual CodeDocument * newClassifierCodeDocument (UMLClassifier * classifier ) = 0;
00140 
00141     virtual void loadFromXMI (QDomElement & element );
00142 
00143     virtual CodeDocument * newCodeDocument ( );
00144 
00148     virtual Uml::Programming_Language getLanguage() = 0;
00149 
00155     //FIX
00156     // NOTE: this should be 'protected' or we could have problems with CPP code generator
00157     CodeDocument * findCodeDocumentByClassifier (UMLClassifier * classifier );
00158 
00159     virtual QStringList defaultDatatypes();
00160 
00161     virtual CodeViewerDialog * getCodeViewerDialog( QWidget* parent, CodeDocument * doc,
00162             Settings::CodeViewerState state);
00163 
00164     virtual bool isReservedKeyword(const QString & keyword);
00165 
00169     virtual const QStringList reservedKeywords() const;
00170 
00171     virtual void createDefaultStereotypes ();
00172 
00173     virtual void initFromParentDocument( );
00174 
00175     void connect_newcodegen_slots();
00176 
00177 protected:
00178 
00179 //    /**
00180 //     * Remove (and possibly delete) all AutoGenerated content type CodeDocuments but leave
00181 //     * the UserGenerated (and any other type) documents in this generator alone.
00182 //     */
00183 //    void removeAndDeleteAllAutoGeneratedCodeDocuments ( bool deleteRemovedDocs=true );
00184 
00185     QString overwritableName (const QString& name, const QString &extension );
00186 
00187     bool openFile (QFile& file, const QString &name);
00188 
00189     void writeListedCodeDocsToFile(CodeDocumentList * docs);
00190 
00191     static const char * hierarchicalCodeBlockNodeName;
00192 
00193     // map of what code documents we currently have in this generator.
00194     QHash<QString, CodeDocument*> m_codeDocumentDictionary;
00195 
00200     bool m_applyToAllRemaining;
00201 
00205     UMLDoc* m_document;
00206 
00207 private:
00208 
00209 //    /**
00210 //     * Maps CodeDocuments to filenames. Used for finding out which file
00211 //     * each class was written to.
00212 //     */
00213     // this seems silly and overkill now. -b.t.
00214     // QMap<CodeDocument*,QString> *m_fileMap;
00215 
00216     CodeDocumentList m_codedocumentVector;
00217     int lastIDIndex;
00218 
00219     void initFields() ;
00220 
00221     void loadCodeForOperation(const QString& id, const QDomElement& codeDocElement);
00222 
00223 public slots:
00224 
00225     virtual void checkAddUMLObject (UMLObject * obj);
00226     virtual void checkRemoveUMLObject (UMLObject * obj);
00227 
00228     virtual void syncCodeToDocument ( );
00229 
00230 signals:
00231 
00232     void codeGenerated(UMLClassifier* concept, bool generated);
00233 
00234 };
00235 
00236 #endif // CODEGENERATOR_H
00237 

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdesdk

Skip menu "kdesdk"
  • kapptemplate
  • kate
  •     kate
  • kbugbuster
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello
Generated for kdesdk by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal