summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/codeimport/import_utils.h
blob: 07794fafa88bf38eff7539e4929a7af227c9194e (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
169
170
171
172
173
174
175
/***************************************************************************
 *                                                                         *
 *   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) 2005-2006                                                *
 *  Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                   *
 ***************************************************************************/

#ifndef IMPORT_UTILS_H
#define IMPORT_UTILS_H

#include <tqstringlist.h>
#include "../umlnamespace.h"
#include "../umlattributelist.h"

class UMLObject;
class UMLClassifier;
class UMLPackage;
class UMLOperation;
class UMLEnum;

/**
 * Utilities for code import
 * @author Oliver Kellogg
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.trinitydesktop.org
 */

namespace Import_Utils {

    /**
     * Find or create a document object.
     */
    UMLObject* createUMLObject(Uml::Object_Type type,
                               const TQString& name,
                               UMLPackage *parentPkg = NULL,
                               const TQString& comment = TQString(),
                               const TQString& stereotype = TQString());
    /**
     * Control whether an object which is newly created by createUMLObject()
     * is put at the global scope.
     *
     * @param yesno  When set to false, the object is created at the scope
     *               given by the parentPkg argument of createUMLObject().
     */
    void putAtGlobalScope(bool yesno);

    /**
     * Set a related classifier for creation of dependencies on template
     * parameters in createUMLObject().
     */
    void setRelatedClassifier(UMLClassifier *c);

    /**
     * Control whether the creation methods solicit a new unique ID for the
     * created object.
     * By default, unique ID generation is turned on.
     *
     * @param yesno   False turns UID generation off, true turns it on.
     */
    void assignUniqueIdOnCreation(bool yesno);

    /**
     * Create a UMLAttribute and insert it into the document.
     */
    UMLObject* insertAttribute(UMLClassifier *klass, Uml::Visibility scope,
                               const TQString& name,
                               const TQString& type,
                               const TQString& comment = TQString(),
                               bool isStatic = false);
    /**
     * Create a UMLAttribute and insert it into the document.
     * Use the specified existing attrType.
     */
    UMLObject* insertAttribute(UMLClassifier *klass, Uml::Visibility scope,
                               const TQString& name,
                               UMLClassifier *attrType,
                               const TQString& comment /* ="" */,
                               bool isStatic /* =false */);
    /**
     * Create a UMLOperation.
     * The reason for this method is to not generate any TQt signals.
     * Instead, these are generated by insertMethod().
     * (If we generated a creation signal prematurely, i.e. without
     * the method parameters being known yet, then that would lead to
     * a conflict with a pre-existing parameterless method of the same
     * name.)
     */
    UMLOperation* makeOperation(UMLClassifier *parent, const TQString &name);

    /**
     * Insert the UMLOperation into the given classifier.
     *
     * @param klass  The classifier into which the operation shall be added.
     * @param op     Reference to pointer to the temporary UMLOperation
     *               for insertion.  The caller relinquishes ownership of the
     *               object pointed to.  If an UMLOperation of same signature
     *               already exists  at the classifier then the incoming
     *               UMLOperation is deleted and the pointer is set to the
     *               existing UMLOperation.
     * @param scope  The Uml::Visibility of the method
     * @param type   The return type
     * @param isStatic boolean switch to decide if method is static
     * @param isAbstract boolean switch to decide if method is abstract
     * @param isFriend true boolean switch to decide if methods is a friend function
     * @param isConstructor boolean switch to decide if methods is a constructor
     * @param comment The Documentation for this method
     */
    void insertMethod(UMLClassifier *klass, UMLOperation* &op,
                      Uml::Visibility scope, const TQString& type,
                      bool isStatic, bool isAbstract,
                      bool isFriend = false, bool isConstructor = false,
                      const TQString& comment = TQString());

    /**
     * Add an argument to a UMLOperation.
     * The parentPkg arg is only used for resolving possible scope
     * prefixes in the `type'.
     */
    UMLAttribute* addMethodParameter(UMLOperation *method,
                                     const TQString& type,
                                     const TQString& name);

    /**
     * Add an enum literal to an UMLEnum.
     */
    void addEnumLiteral(UMLEnum *enumType, const TQString &literal,
                        const TQString &comment = TQString());

    /**
     * Create a generalization from the given child classifier to the given
     * parent classifier.
     */
    void createGeneralization(UMLClassifier *child, UMLClassifier *parent);

    /**
     * Create a generalization from the existing child UMLObject to the given
     * parent class name.
     */
    void createGeneralization(UMLClassifier *child, const TQString &parentName);

    /**
     * Strip comment lines of leading whitespace and stars.
     */
    TQString formatComment(const TQString &comment);

    /**
     * Return the list of paths set by previous calls to addIncludePath()
     * and the environment variable UMBRELLO_INCPATH.
     * This list can be used for finding #included (or Ada with'ed or...)
     * files.
     */
    TQStringList includePathList();

    /**
     * Add a path to the include path list.
     */
    void addIncludePath(const TQString& path);

    /**
     * Returns whether the last createUMLObject() actually created
     * a new object or just returned an existing one.
     */
    bool newUMLObjectWasCreated();

    /**
     * Returns true if a type is an actual Datatype
     */
    bool isDatatype(const TQString& name, UMLPackage *parentPkg = NULL);

} // end namespace Import_Utils

#endif