summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/codegenerators/csharpwriter.h
blob: 7e054d7f932b13cf0699f2144b0a0e31f7ca9e7e (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
/***************************************************************************
 *                                                                         *
 *   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) 2007                                                    *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

//
// C++ Interface: csharpwriter
//
// @author Ferenc Veres
//
#ifndef CSHARPWRITER_H
#define CSHARPWRITER_H

#include "simplecodegenerator.h"
#include "../umlattributelist.h"
#include "../umloperationlist.h"
#include "../classifierlistitem.h"
#include "../umlassociationlist.h"


/**
  * class CSharpWriter is a C# code generator for UMLClassifier objects
  * Just call writeClass and feed it a UMLClassifier;
  */
class CSharpWriter : public SimpleCodeGenerator
{
    TQ_OBJECT
  
public:
    CSharpWriter();

    virtual ~CSharpWriter();
    /**
      * call this method to generate Php code for a UMLClassifier
      * @param c the class you want to generate code for.
      */
    virtual void writeClass(UMLClassifier *c);

    /**
     * returns "C#"
     */
    virtual Uml::Programming_Language getLanguage();

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

    /**
     * get list of predefined data types
     */
    TQStringList defaultDatatypes();

private:

    /**
     * we do not want to write the comment "Private methods" twice
     */
    bool bPrivateSectionCommentIsWritten;

    /**
    * Adds extra indenting if the class is in a container (namespace)
    */
    TQString m_container_indent;

    /**
    * Collection of included namespaces, to skip them from variable types.
    */
    UMLPackageList m_seenIncludes;

    /**
    * Counts associations without a role name for giving a default name.
    */
    int m_unnamedRoles;

    /**
      * write realizations of a class and recurse to parent classes

      * @param currentClass class to start with
      * @param realizations realizations of this class
      * @param cs output stream
      */
    void writeRealizationsRecursive(UMLClassifier *currentClass,
                                    UMLAssociationList *realizations,
                                    TQTextStream &cs);

    /**
      * write all operations for a given class
      *
      * @param c the concept we are generating code for
      * @param cs output stream
      */
    void writeOperations(UMLClassifier *c, TQTextStream &cs);

    /**
      * write a list of class operations
      *
      * @param opList the list of operations
      * @param cs output stream
      * @param interface indicates if the operation is an interface member
      * @param isOverride implementation of an inherited abstract function
      */
    void writeOperations(UMLOperationList opList,
                         TQTextStream &cs,
                         bool interface = false,
                         bool isOverride = false,
                         bool generateErrorStub = false);

    /**
      * write superclasses' abstract methods
      *
      * @param superclasses List of superclasses to start recursing on
      * @param cs output stream
      */
    void writeOverridesRecursive(UMLClassifierList *superclasses, TQTextStream &cs);

    /** write all the attributes of a class
      * @param c the class we are generating code for
      * @param cs output stream
      */
    void writeAttributes(UMLClassifier *c, TQTextStream &cs);

    /** write a list of class attributes
      * @param atList the list of attributes
      * @param cs output stream
      */
    void writeAttributes(UMLAttributeList &atList, TQTextStream &cs);

    /**
      * write attributes from associated objects (compositions, aggregations)
      * @param associated list of associated objects
      * @param c currently written class, to see association direction
      * @param cs output stream
      */
    void writeAssociatedAttributes(UMLAssociationList &associated, UMLClassifier *c, TQTextStream &cs);

    /**
      * write a single attribute to the output stream
      * @param doc attribute documentation
      * @param visibility attribute visibility
      * @param isStatic static attribute
      * @param typeName class/type of the attribute
      * @param name name of the attribute
      * @param initialValue initial value given to the attribute at declaration
      * @param asProperty true writes as property (get/set), false writes single line variable
      * @param cs output stream
      */
    void writeAttribute(TQString doc, Uml::Visibility visibility, bool isStatic, TQString typeName, TQString name, TQString initialValue, bool asProperty, TQTextStream &cs);

    /** find the type in used namespaces, if namespace found return short name, complete otherwise.
      *
      * @param at Operation or Attribute to check type
      */
    TQString makeLocalTypeName(UMLClassifierListItem *cl);

};

#endif