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
169
170
171
172
173
174
|
/***************************************************************************
tclwriter.h - description
-------------------
begin : Thu Jul 26 2005
copyright : (C) 2005 by Rene Meyer
email : rene.meyer@sturmit.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef TCLWRITER_H
#define TCLWRITER_H
#include <tqstringlist.h>
#include "simplecodegenerator.h"
#include "../umloperationlist.h"
#include "../umlattributelist.h"
#include "../umlassociationlist.h"
class TQFile;
class TQTextStream;
class ClassifierInfo;
/**
* class TclWriter is a code generator for UMLClassifier objects.
* Create an instance of this class, and feed it a UMLClassifier when
* calling writeClass and it will generate both a header (.h) and
* source (.tcl) file for that classifier.
*/
class TclWriter : public SimpleCodeGenerator
{
public:
/**
* Constructor, initialises a couple of variables
*/
TclWriter();
/**
* Destructor, empty
*/
virtual ~ TclWriter();
/**
* call this method to generate tcl code for a UMLClassifier
* @param c the class to generate code for
*/
virtual void writeClass(UMLClassifier * c);
/**
* returns "Tcl"
*/
virtual Uml::Programming_Language getLanguage();
/**
* get list of reserved keywords
*/
virtual const TQStringList reservedKeywords() const;
private:
/**
* Current output stream.
*/
TQTextStream * mStream;
/**
* write the header file for this classifier.
*/
void writeHeaderFile(UMLClassifier * c, TQFile & file);
/**
* write the source code body file for this classifier.
*/
void writeSourceFile(UMLClassifier * c, TQFile & file);
/**
* write the source codei text.
*/
void writeCode(const TQString &text);
/**
* write comment text.
*/
void writeComm(const TQString &text);
/**
* write documentation text.
*/
void writeDocu(const TQString &text);
void writeConstructorDecl();
void writeDestructorDecl();
/**
* Summary information about current classifier.
*/
ClassifierInfo *classifierInfo;
TQString mNamespace;
TQString mClass;
TQString mClassGlobal;
/**
* writes the Attribute declarations
* @param visibility the visibility of the attribs to print out
* @param writeStatic whether to write static or non-static attributes out
* @param stream text stream
*/
void writeAttributeDecl(Uml::Visibility visibility, bool writeStatic);
void writeAssociationIncl(UMLAssociationList list,
Uml::IDType myId, const TQString &type);
/**
* Searches a list of associations for appropriate ones to write out as attributes
*/
void writeAssociationDecl(UMLAssociationList associations,
Uml::Visibility permit, Uml::IDType id,
const TQString &type);
/**
* Writes out an association as an attribute using Vector
*/
void writeAssociationRoleDecl(const TQString &fieldClassName,
const TQString &roleName, const TQString &multi, const TQString &doc, const TQString &docname);
/**
* If needed, write out the declaration for the method to initialize attributes of our class.
*/
void writeInitAttributeHeader();
void writeInitAttributeSource();
void writeConstructorHeader();
void writeConstructorSource();
void writeDestructorHeader();
void writeDestructorSource();
void writeOperationHeader(UMLClassifier * c,
Uml::Visibility permitScope);
void writeOperationSource(UMLClassifier * c,
Uml::Visibility permitScope);
void writeAttributeSource();
void writeAssociationSource(UMLAssociationList associations,
Uml::IDType id);
void writeAssociationRoleSource(const TQString &fieldClassName,
const TQString &roleName,
const TQString &multi);
void writeUse(UMLClassifier * c);
/**
* Returns the name of the given object (if it exists)
*/
TQString getUMLObjectName(UMLObject * obj);
/**
* Replaces `string' with STRING_TYPENAME.
*/
TQString fixTypeName(const TQString &string);
TQStringList ObjectFieldVariables;
TQStringList VectorFieldVariables;
};
#endif // TCLWRITER_H
|