summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/codegenerators/rubywriter.h
blob: 37e657a49a2c5aad9fcb67935da8175c548854c5 (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
/***************************************************************************
                          rubywriter.h  -  description
                             -------------------
    begin                : Mon Jul 18 2005
    author               : Richard Dale
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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) 2006-2007                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

#ifndef RUBYWRITER_H
#define RUBYWRITER_H

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

#include <tqstringlist.h>

class ClassifierInfo;

/**
  * class RubyWriter is a ruby code generator for UMLClassifier objects
  * Just call writeClass and feed it a UMLClassifier;
  */
class RubyWriter : public SimpleCodeGenerator {
    Q_OBJECT
  
public:

    RubyWriter();
    virtual ~RubyWriter();

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

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

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

private:
    /**
     * Convert a C++ type such as 'int' or 'TQWidget' to
     * ruby types Integer and TQt::Widget
     *
     * @param cppType the C++ type to be converted
     */
    TQString cppToRubyType(const TQString &cppType);

    /**
     * Convert C++ names such as 'm_foobar' or pFoobar to
     * just 'foobar' for ruby
     *
     * @param cppName the C++ name to be converted
     */
    TQString cppToRubyName(const TQString &cppName);

    /**
     * calls @ref writeSingleAttributeAccessorMethods() on each of the attributes in attribs list.
     */
    void writeAttributeMethods(UMLAttributeList *attribs,
                               Uml::Visibility visibility, TQTextStream &stream);


    /**
     * write all method declarations, for attributes and associations
     * for the given permitted scope.
     */
    void writeSingleAttributeAccessorMethods(const TQString &fieldName,
                                             const TQString &description,
                                             TQTextStream &h);

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

    /**
      * write a list of class operations
      *
      * @param classname the name of the class
      * @param opList the list of operations
      * @param h output stream for the header file
      */
    void writeOperations(const TQString &classname, UMLOperationList &opList,
                         Uml::Visibility permitScope, TQTextStream &h);

    /**
     * Summary information about current classifier.
     */
    ClassifierInfo * classifierInfo;
};

#endif //RUBYWRITER