summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/codegenerators/cppcodegenerator.h
blob: a6687249e5319016a8431823afb0fa30d6309fd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   copyright (C) 2004-2006                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

/*  This code generated by:
 *      Author : thomas
 *      Date   : Thu Jun 19 2003
 */


#ifndef CPPCODEGENERATOR_H
#define CPPCODEGENERATOR_H

#include <tqstring.h>
#include "../codedocumentlist.h"
#include "../codeviewerstate.h"
#include "../codegenerator.h"
#include "../umldoc.h"
#include "cppmakecodedocument.h"

class CodeViewerDialog;
class CPPHeaderCodeDocument;
class CodeBlockWithComments;
class TDEConfig;

class CPPCodeGenerator : public CodeGenerator
{
    Q_OBJECT
  
public:

    static const bool DEFAULT_BUILD_MAKEFILE;

    // Constructors/Destructors
    //

    /**
     * Basic Constructor
     */
    CPPCodeGenerator ();

    /**
     * Empty Destructor
     */
    virtual ~CPPCodeGenerator ( );

    /**
     * Set the value of m_createMakefile
     * @param new_var the new value of m_createMakefile
     */
    void setCreateProjectMakefile ( bool new_var );

    /**
     * Get the value of m_createMakefile
     * @return the value of m_createMakefile
     */
    bool getCreateProjectMakefile ( );

    // Public attribute accessor methods
    //

    TQString fixTypeName(const TQString &string);

    /**
     * Add a header CodeDocument object from m_headercodedocumentVector List
     */
    bool addHeaderCodeDocument ( CPPHeaderCodeDocument * doc );

    /**
     * Remove a header CodeDocument object from m_headercodedocumentVector List
     */
    bool removeHeaderCodeDocument ( CPPHeaderCodeDocument * remove_object );

    /**
     * returns "Cpp"
     */
    Uml::Programming_Language getLanguage();

    // generate 2 different types of classifier code documents.
    CodeDocument * newClassifierCodeDocument (UMLClassifier * classifier);
    CPPHeaderCodeDocument * newHeaderClassifierCodeDocument (UMLClassifier * classifier);

    /** Get the editing dialog for this code document
     */
    virtual CodeViewerDialog * getCodeViewerDialog( TQWidget* parent, CodeDocument * doc,
            Settings::CodeViewerState state);

    /**
     * Write out all code documents to file as appropriate.
     */
    virtual void writeCodeToFile ( );

    // this method is here to provide class wizard the
    // ability to write out only those classes which
    // are selected by the user.
    virtual void writeCodeToFile(UMLClassifierList &list);

    /**
     * Add C++ primitives as datatypes
     */
    TQStringList defaultDatatypes();

    /**
     * Save the XMI representation of this object
     */
    virtual void saveToXMI ( TQDomDocument & doc, TQDomElement & root );

    /**
     * get list of reserved keywords
     */
    virtual const TQStringList reservedKeywords() const;

    /**
     * Add the default stereotypes for c++ (constructor, int etc)
     */
    virtual void createDefaultStereotypes ();

    void initFromParentDocument( );

protected:

    /**
     * @return  CPPMakeCodeDocument
     */
    CPPMakefileCodeDocument * newMakefileCodeDocument ( );

    /**
     * Find a cppheadercodedocument by the given classifier.
     * @return      CPPHeaderCodeDocument
     * @param       classifier
     */
    CPPHeaderCodeDocument * findHeaderCodeDocumentByClassifier (UMLClassifier * classifier );

private:

    bool m_createMakefile;

    // a separate list for recording the header documents
    CodeDocumentList m_headercodedocumentVector;

    void initAttributes ( ) ;

public slots:

    /** These 2 functions check for adding or removing objects to the UMLDocument
     * they are need to be overridden here because unlike in the Java (or most other lang)
     * we add 2 types of classifiercodedocument per classifier,
     * e.g. a "source" and a "header" document.
     */
    virtual void checkAddUMLObject (UMLObject * obj);
    virtual void checkRemoveUMLObject (UMLObject * obj);

    /**
     * Force a synchronize of this code generator, and its present contents, to that of the parent UMLDocument.
     * "UserGenerated" code will be preserved, but Autogenerated contents will be updated/replaced
     * or removed as is apppropriate.
     */
    virtual void syncCodeToDocument ( );
};

#endif // CPPCODEGENERATOR_H