basictypes.h 9.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/***************************************************************************
 * Copyright (C) 2011 by Andi Fischer <andi.fischer@hispeed.ch>            *
 *                                                                         *
 * This 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, or (at your option)     *
 * any later version.                                                      *
 *                                                                         *
 * This software is distributed in the hope that it will be useful,        *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this package; see the file COPYING.  If not, write to        *
 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,   *
 * Boston, MA 02110-1301, USA.                                             *
 ***************************************************************************/

#ifndef BASICTYPES_H
#define BASICTYPES_H

23
24
// qt includes
#include <QFont>
25
#include <QString>
26

27
28
29
#include <string>

/**
Andi Fischer's avatar
Andi Fischer committed
30
 * This namespace contains all the enums used all over the code base.
31
 * The enums are embedded into namespaces and useful functionality is added.
32
33
34
35
 */
namespace Uml
{

Andi Fischer's avatar
Andi Fischer committed
36
37
38
39
    /**
     * The model type enum is used to identify the folder the diagrams belong to.
     */
    namespace ModelType
40
    {
Andi Fischer's avatar
Andi Fischer committed
41
        enum Enum {
42
43
44
45
46
47
48
            Logical,
            UseCase,
            Component,
            Deployment,
            EntityRelationship,
            N_MODELTYPES   // must remain last
        };
Andi Fischer's avatar
Andi Fischer committed
49
50
51
52
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
53
54

    /**
Andi Fischer's avatar
Andi Fischer committed
55
     * The visibility enum defines the visibility of attributes and operations.
56
     */
Andi Fischer's avatar
Andi Fischer committed
57
    namespace Visibility
58
    {
Andi Fischer's avatar
Andi Fischer committed
59
        enum Enum {
60
61
62
63
            Public,
            Private,
            Protected,
            Implementation, // objects marked with this are declared in the implementation file.
64
65
            FromParent = 3,  // alias for Implementation, used by CodeGenerationPolicy
            Unknown
66
        };
Andi Fischer's avatar
Andi Fischer committed
67
        QString toString(Enum item, bool mnemonic = false);
68
        Enum fromString(const QString& item, bool checkUnknown = false);
Andi Fischer's avatar
Andi Fischer committed
69
70
        Enum fromInt(int item);
    }
71
72
73
74

    /**
     * Supported diagram types.
     */
Andi Fischer's avatar
Andi Fischer committed
75
    namespace DiagramType
76
    {
Andi Fischer's avatar
Andi Fischer committed
77
        enum Enum {
78
79
80
81
82
83
84
85
86
87
88
89
            //the values in this enum are saved out to the file
            //for file compatibility, only add new values to the end
            Undefined = 0,
            Class,
            UseCase,
            Sequence,
            Collaboration,
            State,
            Activity,
            Component,
            Deployment,
            EntityRelationship,
90
            Object,
91
92
            N_DIAGRAMTYPES   // must remain last
        };
Andi Fischer's avatar
Andi Fischer committed
93
94
95
96
97
        QString toString(Enum item);
        QString toStringI18n(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
98
99
100
101

    /**
     * Association types.
     */
102
    namespace AssociationType
103
    {
104
105
        // only append entries to this type
        // it is used as xmi file attribute
106
        enum Enum {
107
108
109
110
111
            Generalization  =  500,
            Aggregation,
            Dependency,
            Association,
            Association_Self,
112
            Coll_Message_Asynchronous,
113
114
115
116
117
118
119
120
121
122
123
124
125
126
            Seq_Message,
            Coll_Message_Self,
            Seq_Message_Self,
            Containment,
            Composition,
            Realization,
            UniAssociation,
            Anchor,
            State,
            Activity,
            Exception,
            Category2Parent,
            Child2Category,
            Relationship,
127
            Coll_Message_Synchronous,
128
129
            // enter new entries before this line
            Reserved,
130
131
            Unknown  =  - 1
        };
132
133
134
135
136
137
        QString toString(Enum item);
        QString toStringI18n(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
        bool hasUMLRepresentation(Enum item);
    }
138
139
140
141

    /**
     * Signature types.
     */
142
    namespace SignatureType
143
    {
144
        enum Enum {
145
146
147
148
149
            NoSig  =  600,
            ShowSig,
            SigNoVis,
            NoSigNoVis
        };
150
151
152
153
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
154
155
156
157

    /**
     * TextRole types.
     */
158
    namespace TextRole
159
    {
160
        enum Enum {
161
162
163
164
165
166
167
168
169
170
171
172
            Floating  =  700,   //text widget on diagrams
            MultiA,             //Text for Multiple A
            MultiB,             //Text for Multiple B
            Name,               //middle text on most associations
            Seq_Message,        //message on seq diagram between two objects
            Seq_Message_Self,   //message to self on seq diagram - feature not implemented yet
            Coll_Message,       //message between two objects on a collab diagram
            Coll_Message_Self,  //message to object self on collab diagram
            State,
            RoleAName,          //RoleA text on associations
            RoleBName,          //RoleB text on associations
            ChangeA,            //Changeability A text on associations
173
174
            ChangeB,            //Changeability B text on associations
            Reserved            //Enter new entries before this line
175
        };
176
177
178
179
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
180
181
182
183

    /**
     * Changeability types.
     */
184
    namespace Changeability
185
    {
186
        enum Enum {
187
188
189
190
            Changeable = 900,
            Frozen,
            AddOnly
        };
191
192
193
194
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
195
196

    /**
197
     * SequenceMessage type
198
     */
199
    namespace SequenceMessage
200
    {
201
202
203
204
205
206
207
208
209
210
211
212
        enum Enum {
            //This is saved out to the file so only add new entries at the end
            Synchronous = 1000,
            Asynchronous,
            Creation,
            Lost,
            Found
        };
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
213
214
215
216

    /**
     * Constants used for indexing the roles of associations.
     */
217
218
219
220
221
222
223
224
225
226
    namespace RoleType
    {
        enum Enum {
            A,
            B
        };
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
227
228
229
230
231
232
233
234

    /**
     * Direction of operation parameters:
     *   in = operation uses the parameter as an input value
     *   out = operation fills the parameter as a return value
     *   inout = operation both reads and writes the parameter
     * The numeric values of this enum are not currently saved to file.
     */
235
236
237
238
239
240
241
242
243
244
245
    namespace ParameterDirection
    {
        enum Enum {
            In,
            InOut,
            Out
        };
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
246
247
248
249

    /**
     * Supported programming languages.
     */
Andi Fischer's avatar
Andi Fischer committed
250
    namespace ProgrammingLanguage
251
    {
Andi Fischer's avatar
Andi Fischer committed
252
        enum Enum {
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
            ActionScript,
            Ada,
            Cpp,
            CSharp,
            D,
            IDL,
            Java,
            JavaScript,
            MySQL,
            Pascal,
            Perl,
            PHP,
            PHP5,
            PostgreSQL,
            Python,
            Ruby,
            SQL,
            Tcl,
            Vala,
            XMLSchema,
            Reserved
        };
Andi Fischer's avatar
Andi Fischer committed
275
276
277
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
278
279
        QStringList toExtensions(Enum item);
        QString toExtensionsDescription(Enum item);
280
281
        bool isCaseSensitive(Enum item);
        QString scopeSeparator(Enum item);
Andi Fischer's avatar
Andi Fischer committed
282
    }
283
284
285
286

    /**
     * Enumeration used for stating where a line is on a widget.
     * @note Do not change this ordering, as we use these values in for loop.
287
     * @note See also associationwidget.h.
288
     */
289
290
291
292
293
294
295
296
297
298
299
    namespace Region
    {
        enum Enum {
            Error = 0,
            West,
            North,
            East,
            South,
            NorthWest,
            NorthEast,
            SouthEast,
300
301
            SouthWest,
            Center
302
303
304
305
306
        };
        QString toString(Enum item);
        Enum fromString(const QString& item);
        Enum fromInt(int item);
    }
307
308

    /**
309
     * Corner class with special operators.
310
     */
311
312
313
314
315
316
317
318
319
320
321
322
    class Corner
    {
    public:
        enum Enum {
            TopLeft     = 0x1,
            TopRight    = 0x2,
            BottomRight = 0x4,
            BottomLeft  = 0x8
        };
        static QString toString(Enum item);
        static Enum fromString(const QString& item);
        static Enum fromInt(int item);
323
    };
324
325
    Q_DECLARE_FLAGS(Corners, Corner::Enum)
    Q_DECLARE_OPERATORS_FOR_FLAGS(Corners)
326
327
328
329

    /**
     * The data type used for unique IDs.
     */
Andi Fischer's avatar
Andi Fischer committed
330
331
332
    namespace ID
    {
        typedef std::string Type;
333

Andi Fischer's avatar
Andi Fischer committed
334
335
        const Type None     = "-1";   ///< special value for uninitialized ID
        const Type Reserved = "0";    ///< special value for illegal ID
336

337
338
        QString toString(const ID::Type &id);
        ID::Type fromString(const QString &id);
Andi Fischer's avatar
Andi Fischer committed
339
340
        QDebug operator<<(QDebug out, ID::Type &type);
    }
341

342
343
QFont systemFont();

344
345
}  // end namespace Uml

346
347
348
349
350
351
352
353
354
355
static inline QString toString(Uml::ProgrammingLanguage::Enum lang)
{
    return Uml::ProgrammingLanguage::toString(lang);
}

static inline QString toString(Uml::Visibility::Enum visibility)
{
    return Uml::Visibility::toString(visibility);
}

356
357
qreal toDoubleFromAnyLocale(const QString &s);

358
#endif