~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to lib/interfaces/codemodel.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of KDevelop
 
2
   Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
 
3
   Copyright (C) 2004 Matt Rogers <mattr@kde.org> 
 
4
   Copyright (C) 2004 Alexander Dymo <adymo@kdevelop.org>
 
5
 
 
6
   This library is free software; you can redistribute it and/or
 
7
   modify it under the terms of the GNU Library General Public
 
8
   License as published by the Free Software Foundation; either
 
9
   version 2 of the License, or (at your option) any later version.
 
10
 
 
11
   This library is distributed in the hope that it will be useful,
 
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
   Library General Public License for more details.
 
15
 
 
16
   You should have received a copy of the GNU Library General Public License
 
17
   along with this library; see the file COPYING.LIB.  If not, write to
 
18
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
   Boston, MA 02111-1307, USA.
 
20
*/
 
21
#ifndef CODEMODEL_H
 
22
#define CODEMODEL_H
 
23
 
 
24
/**
 
25
@file codemodel.h
 
26
Code Model - a memory symbol store.
 
27
*/
 
28
 
 
29
#include <qmap.h>
 
30
#include <qstringlist.h>
 
31
#include <ksharedptr.h>
 
32
 
 
33
class CodeModel;
 
34
class CodeModelItem;
 
35
class FileModel;
 
36
class NamespaceModel;
 
37
class ClassModel;
 
38
class FunctionModel;
 
39
class FunctionDefinitionModel;
 
40
class VariableModel;
 
41
class ArgumentModel;
 
42
class EnumModel;
 
43
class EnumeratorModel;
 
44
class TypeAliasModel;
 
45
 
 
46
/**@class ItemDom
 
47
Safe pointer to the @ref CodeModelItem.
 
48
This is a type definition: @code typedef KSharedPtr<CodeModelItem> ItemDom; @endcode
 
49
@sa KSharedPtr*/
 
50
typedef KSharedPtr<CodeModelItem> ItemDom;
 
51
/**@class FileDom
 
52
Safe pointer to the @ref FileModel.
 
53
This is a type definition: @code typedef KSharedPtr<FileModel> FileDom; @endcode
 
54
@sa KSharedPtr*/
 
55
typedef KSharedPtr<FileModel> FileDom;
 
56
/**@class NamespaceDom
 
57
Safe pointer to the @ref NamespaceModel.
 
58
This is a type definition: @code typedef KSharedPtr<NamespaceModel> NamespaceDom; @endcode
 
59
@sa KSharedPtr*/
 
60
typedef KSharedPtr<NamespaceModel> NamespaceDom;
 
61
/**@class ClassDom
 
62
Safe pointer to the @ref ClassModel.
 
63
This is a type definition: @code typedef KSharedPtr<ClassModel> ClassDom; @endcode
 
64
@sa KSharedPtr*/
 
65
typedef KSharedPtr<ClassModel> ClassDom;
 
66
/**@class FunctionDom
 
67
Safe pointer to the @ref FunctionModel.
 
68
This is a type definition: @code typedef KSharedPtr<FunctionModel> FunctionDom; @endcode
 
69
@sa KSharedPtr*/
 
70
typedef KSharedPtr<FunctionModel> FunctionDom;
 
71
/**@class FunctionDefinitionDom
 
72
Safe pointer to the @ref FunctionDefinitionModel.
 
73
This is a type definition: @code typedef KSharedPtr<FunctionDefinitionModel> FunctionDefinitionDom; @endcode
 
74
@sa KSharedPtr*/
 
75
typedef KSharedPtr<FunctionDefinitionModel> FunctionDefinitionDom;
 
76
/**@class VariableDom
 
77
Safe pointer to the @ref VariableModel.
 
78
This is a type definition: @code typedef KSharedPtr<VariableModel> VariableDom; @endcode
 
79
@sa KSharedPtr*/
 
80
typedef KSharedPtr<VariableModel> VariableDom;
 
81
/**@class ArgumentDom
 
82
Safe pointer to the @ref ArgumentModel.
 
83
This is a type definition: @code typedef KSharedPtr<ArgumentModel> ArgumentDom; @endcode
 
84
@sa KSharedPtr*/
 
85
typedef KSharedPtr<ArgumentModel> ArgumentDom;
 
86
/**@class EnumDom
 
87
Safe pointer to the @ref EnumModel.
 
88
This is a type definition: @code typedef KSharedPtr<EnumModel> EnumDom; @endcode
 
89
@sa KSharedPtr*/
 
90
typedef KSharedPtr<EnumModel> EnumDom;
 
91
/**@class TypeAliasDom
 
92
Safe pointer to the @ref TypeAliasModel.
 
93
This is a type definition: @code typedef KSharedPtr<TypeAliasModel> TypeAliasDom; @endcode
 
94
@sa KSharedPtr*/
 
95
typedef KSharedPtr<TypeAliasModel> TypeAliasDom;
 
96
/**@class EnumeratorDom
 
97
Safe pointer to the @ref EnumeratorModel.
 
98
This is a type definition: @code typedef KSharedPtr<EnumeratorModel> EnumeratorDom; @endcode
 
99
@sa KSharedPtr*/
 
100
typedef KSharedPtr<EnumeratorModel> EnumeratorDom;
 
101
 
 
102
/**@class ItemList
 
103
The list of code model items.
 
104
This is a type definition: @code typedef QValueList<ItemDom> ItemList; @endcode
 
105
@sa QValueList*/
 
106
typedef QValueList<ItemDom> ItemList;
 
107
/**@class FileList
 
108
The list of code model files.
 
109
This is a type definition: @code typedef QValueList<FileDom> FileList; @endcode
 
110
@sa QValueList*/
 
111
typedef QValueList<FileDom> FileList;
 
112
/**@class NamespaceList
 
113
The list of code model namespaces.
 
114
This is a type definition: @code typedef QValueList<NamespaceDom> NamespaceList; @endcode
 
115
@sa QValueList*/
 
116
typedef QValueList<NamespaceDom> NamespaceList;
 
117
/**@class ClassList
 
118
The list of code model classes.
 
119
This is a type definition: @code typedef QValueList<ClassDom> ClassList; @endcode
 
120
@sa QValueList*/
 
121
typedef QValueList<ClassDom> ClassList;
 
122
/**@class FunctionList
 
123
The list of code model functions.
 
124
This is a type definition: @code typedef QValueList<FunctionDom> FunctionList; @endcode
 
125
@sa QValueList*/
 
126
typedef QValueList<FunctionDom> FunctionList;
 
127
/**@class FunctionDefinitionList
 
128
The list of code model function definitions.
 
129
This is a type definition: @code typedef QValueList<FunctionDefinitionDom> FunctionDefinitionList; @endcode
 
130
@sa QValueList*/
 
131
typedef QValueList<FunctionDefinitionDom> FunctionDefinitionList;
 
132
/**@class VariableList
 
133
The list of code model variables.
 
134
This is a type definition: @code typedef QValueList<VariableDom> VariableList; @endcode
 
135
@sa QValueList*/
 
136
typedef QValueList<VariableDom> VariableList;
 
137
/**@class ArgumentList
 
138
The list of code model arguments.
 
139
This is a type definition: @code typedef QValueList<ArgumentDom> ArgumentList; @endcode
 
140
@sa QValueList*/
 
141
typedef QValueList<ArgumentDom> ArgumentList;
 
142
/**@class EnumList
 
143
The list of code model enums.
 
144
This is a type definition: @code typedef QValueList<EnumDom> EnumList; @endcode
 
145
@sa QValueList*/
 
146
typedef QValueList<EnumDom> EnumList;
 
147
/**@class TypeAliasList
 
148
The list of code model type aliases.
 
149
This is a type definition: @code typedef QValueList<TypeAliasDom> TypeAliasList; @endcode
 
150
@sa QValueList*/
 
151
typedef QValueList<TypeAliasDom> TypeAliasList;
 
152
/**@class EnumeratorList
 
153
The list of code model enumerators.
 
154
This is a type definition: @code typedef QValueList<EnumeratorDom> EnumeratorList; @endcode
 
155
@sa QValueList*/
 
156
typedef QValueList<EnumeratorDom> EnumeratorList;
 
157
 
 
158
/**Iterates through @p lst and creates sorted list of code model item names.
 
159
Can be used, for example, to get the list of classes in the store:
 
160
@code
 
161
QStringList classList = sortedNameList(codeModel()->globalNamespace()->classList());
 
162
@endcode
 
163
@param lst The list to iterate.
 
164
@return Sorted list of code model item names.*/
 
165
template <class ItemList>
 
166
QStringList sortedNameList( const ItemList& lst )
 
167
{
 
168
    QStringList nameList;
 
169
 
 
170
    typename ItemList::ConstIterator it = lst.begin();
 
171
    while( it != lst.end() ){
 
172
        if( !(*it)->name().isEmpty() )
 
173
            nameList << (*it)->name();
 
174
        ++it;
 
175
    }
 
176
 
 
177
    nameList.sort();
 
178
    return nameList;
 
179
}
 
180
 
 
181
/**Casts safe code model pointers (@p KSharedPtr<T> objects like
 
182
FileDom, NamespaceDom, etc.) to the @p Result type.
 
183
 
 
184
Example:
 
185
@code
 
186
//ns is of type NamespaceDom
 
187
ClassDom cl = model_cast<ClassDom>(ns);
 
188
@endcode
 
189
@param x Object to cast.*/
 
190
template <class Result, class T>
 
191
Result model_cast( KSharedPtr<T> x )
 
192
{
 
193
    Result r( static_cast<T*>(x) );
 
194
    return r;
 
195
}
 
196
 
 
197
/**Casts code model pointers (objects like
 
198
FileModel, NamespaceModel, etc.) to the @p Result type.
 
199
 
 
200
Example:
 
201
@code
 
202
//ns is of type NamespaceModel*
 
203
ClassDom cl = model_cast<ClassDom>(ns);
 
204
@endcode
 
205
@param x Object to cast.*/
 
206
template <class Result, class T>
 
207
Result model_cast( T* x )
 
208
{
 
209
    Result r( static_cast<T*>(x) );
 
210
    return r;
 
211
}
 
212
 
 
213
 
 
214
/**
 
215
Code Model - a memory symbol store.
 
216
Symbol store (aka class store) is a database of symbols
 
217
found in code with the important information about those symbols.
 
218
 
 
219
For example, programming language support plugins use symbol store
 
220
to remember information about classes, functions, etc. For each type
 
221
of symbol a certain information can be stored - symbol name, the
 
222
location in source file, etc.
 
223
 
 
224
@sa codemodel.h documentation for a list of typedefs and other convenience functions.
 
225
 
 
226
@sa codemodel_utils.h documentation for an additional code model utility functions and classes reference.
 
227
*/
 
228
class CodeModel
 
229
{
 
230
public:
 
231
    /**Constructor.*/
 
232
    CodeModel();
 
233
    /**Destructor.*/
 
234
    virtual ~CodeModel();
 
235
 
 
236
    /**Creates a code model item. This should be used to create
 
237
    code model items.
 
238
    
 
239
    For example, to create a class model somewhere in your plugin, use:
 
240
    @code
 
241
    klass = codeModel()->create<ClassModel>();
 
242
    klass->setName("ClassName");
 
243
    klass->setFileName("FileName");
 
244
    klass->setStartPosition(line, column);
 
245
    @endcode
 
246
    @return Created code model item.*/
 
247
    template <class T> typename T::Ptr create()
 
248
    {
 
249
        typename T::Ptr ptr( new T(this) );
 
250
        return ptr;
 
251
    }
 
252
 
 
253
    /**Resets the CodeModel.*/
 
254
    void wipeout();
 
255
 
 
256
    /**Gets the list of files in the store.
 
257
    @return The FileList object that contains the list of files.*/
 
258
    FileList fileList();
 
259
 
 
260
    /**Gets the list of files in the store.
 
261
    This is a const version for convenience.
 
262
    @return The FileList object that contains the list of files.*/
 
263
    const FileList fileList() const;
 
264
 
 
265
    /**Checks to see if a file is in the store.
 
266
    @return true if @p name is in the file list.*/
 
267
    bool hasFile( const QString& name ) const;
 
268
 
 
269
    /**Gets the FileDom object for a file.
 
270
    @param name The name of the file to get the FileDom object for.*/
 
271
    FileDom fileByName( const QString& name );
 
272
 
 
273
    /**Gets the FileDom object for a file.
 
274
    This is a const version provided for convenience.
 
275
    @param name the name of the file to get the FileDom object for.*/
 
276
    const FileDom fileByName( const QString& name ) const;
 
277
 
 
278
    /**Adds a file to the store.
 
279
    @param file The FileDom object to add to the store.
 
280
    @return true if the file was added successfully.*/
 
281
    bool addFile( FileDom file );
 
282
 
 
283
    /**Removes a file from the store.
 
284
    @param file the FileDom object to remove from the store.*/
 
285
    void removeFile( FileDom file  );
 
286
 
 
287
    /**Gets the global namespace
 
288
    @return The NamespaceDom object that represents the global namespace.*/
 
289
    const NamespaceDom globalNamespace() const;
 
290
 
 
291
    /**Reads the model from a stream.
 
292
    Use this to save the memory symbol store to a file.
 
293
    
 
294
    Language support plugins usually save symbols from projects before the project is 
 
295
    closed to avoid reparsing when the project is opened next time.
 
296
    @param stream Stream to read from.*/
 
297
    virtual void read( QDataStream& stream );
 
298
    /**Writes the model to a stream.
 
299
    Use this to restore the memory symbol store to a file.
 
300
    
 
301
    Language support plugins usually save symbols from projects before the project is 
 
302
    closed to avoid reparsing when the project is opened next time.
 
303
    @param stream Stream to write to.*/
 
304
    virtual void write( QDataStream& stream ) const;
 
305
    
 
306
private:
 
307
    /**Adds a namespace to the store.
 
308
    @param target The NamespaceDom object that the namespace will be added to.
 
309
    @param source The NamespaceDom object that contains the namespace to remove.*/
 
310
    void addNamespace( NamespaceDom target, NamespaceDom source );
 
311
 
 
312
    /**Removes a namespace from the store.
 
313
    @param target The NamespaceDom object that the namespace will be removed from.
 
314
    @param source The NamespaceDom object that contains the namespace to remove.*/
 
315
    void removeNamespace( NamespaceDom target, NamespaceDom source );
 
316
 
 
317
private:
 
318
    QMap<QString, FileDom> m_files;
 
319
    NamespaceDom m_globalNamespace;
 
320
 
 
321
private:
 
322
    CodeModel( const CodeModel& source );
 
323
    void operator = ( const CodeModel& source );
 
324
    friend class CodeModelItem;
 
325
};
 
326
 
 
327
 
 
328
/**
 
329
Item in code model (symbol store).
 
330
Item is a symbol in a store. Code model provides several predefined classes
 
331
for predefined item types (files, namespaces, classes, functions and function definitions,
 
332
variables, arguments, enums and enumerators, type aliases.
 
333
 
 
334
Instanses of this class should be created using @ref CodeModel::create method but usually
 
335
it is better to create instances of derived classes like ClassModel, NamespaceModel, FileModel, etc.
 
336
*/
 
337
class CodeModelItem: public KShared
 
338
{
 
339
public:
 
340
    /**A definition of safe pointer to the code model item.*/
 
341
    typedef ItemDom Ptr;
 
342
 
 
343
    /**A type of a code model item.*/
 
344
    enum Kind
 
345
    {
 
346
        File,                /**<File.*/
 
347
        Namespace,           /**<Namespace.*/
 
348
        Class,               /**<Class.*/
 
349
        Function,            /**<Function or class method.*/
 
350
        Variable,            /**<Variable.*/
 
351
        Argument,            /**<Function or method parameter.*/
 
352
        FunctionDefinition,  /**<Function definition.*/
 
353
        Enum,                /**<Enum.*/
 
354
        Enumerator,          /**<Enumerator - a member of an Enum (example: @code enum Type { A, B, C} @endcode 
 
355
                                Type will be an Enum; A, B and C - Enumerators.*/
 
356
        TypeAlias,           /**<Type alias (aka typedef in c++).*/
 
357
    
 
358
        Custom = 1000        /**<Custom model items should have type greater than 1000*/
 
359
    };
 
360
 
 
361
    /**An access to the code model item.*/
 
362
    enum Access
 
363
    {
 
364
        Public,        /**<Public.*/
 
365
        Protected,     /**<Protected.*/
 
366
        Private        /**<Private.*/
 
367
    };
 
368
 
 
369
protected:
 
370
    /**Constructor.
 
371
    @param kind The type, see also @ref CodeModelItem::Kind.
 
372
    @param model Code model which stores this item.*/
 
373
    CodeModelItem( int kind, CodeModel* model );
 
374
 
 
375
public:
 
376
    /**Destructor.*/
 
377
    virtual ~CodeModelItem();
 
378
 
 
379
    /**@return The type (kind) of item.*/
 
380
    int kind() const { return m_kind; }
 
381
 
 
382
    /**Sets the type (kind) of item.
 
383
    @param kind The type, see also @ref CodeModelItem::Kind.*/
 
384
    void setKind( int kind ) { m_kind = kind; }
 
385
 
 
386
    /**@return The name of the item.*/
 
387
    QString name() const;
 
388
 
 
389
    /**Sets the name of the item.
 
390
    @param name The name.*/
 
391
    void setName( const QString& name );
 
392
 
 
393
    /**Gets the file of the item.
 
394
    @return The FileDom object for the item.*/
 
395
    FileDom file();
 
396
 
 
397
    /**Gets the file of the item
 
398
    This is a const version provided for convenience.
 
399
    @return The FileDom object for the item.*/
 
400
    const FileDom file() const;
 
401
 
 
402
    /**@return The filename of the item.*/
 
403
    QString fileName() const;
 
404
 
 
405
    /**Sets the filename of the item.
 
406
    @param fileName The file name.*/
 
407
    void setFileName( const QString& fileName );
 
408
 
 
409
    /**Gets the start position of the item.
 
410
    @param line Will be set to the line number of the items start position. Pass 0 if line number is not necessary.
 
411
    @param col Will be set to the column number of the items start position. Pass 0 if column number is not necessary.*/
 
412
    void getStartPosition( int* line, int* col ) const;
 
413
 
 
414
    /**Sets the start position of the item.
 
415
    @param line Line number.
 
416
    @param col Column number.*/
 
417
    void setStartPosition( int line, int col );
 
418
 
 
419
    /**Get the end position of the item.
 
420
    @param line Will be set to the line number of the items end position. Pass 0 if line number is not necessary.
 
421
    @param col Will be set to the column number of the items end position. Pass 0 if column number is not necessary.*/
 
422
    void getEndPosition( int* line, int* col ) const;
 
423
 
 
424
    /**Set the end position of the item.
 
425
    @param line Line number.
 
426
    @param col Column number.*/
 
427
    void setEndPosition( int line, int col );
 
428
 
 
429
    /**@return true if an item is a FileModel.*/
 
430
    virtual bool isFile() const { return false; }
 
431
    /**@return true if an item is a NamespaceModel.*/
 
432
    virtual bool isNamespace() const { return false; }
 
433
    /**@return true if an item is a ClassModel.*/
 
434
    virtual bool isClass() const { return false; }
 
435
    /**@return true if an item is a FunctionModel.*/
 
436
    virtual bool isFunction() const { return false; }
 
437
    /**@return true if an item is a FileDefinitionModel.*/
 
438
    virtual bool isFunctionDefinition() const { return false; }
 
439
    /**@return true if an item is a VariableModel.*/
 
440
    virtual bool isVariable() const { return false; }
 
441
    /**@return true if an item is an ArgumentModel.*/
 
442
    virtual bool isArgument() const { return false; }
 
443
    /**@return true if an item is a EnumModel.*/
 
444
    virtual bool isEnum() const { return false; }
 
445
    /**@return true if an item is a EnumeratorModel.*/
 
446
    virtual bool isEnumerator() const { return false; }
 
447
    /**@return true if an item is a TypeAliasModel.*/
 
448
    virtual bool isTypeAlias() const { return false; }
 
449
    /**@return true if an item is a custom item.*/
 
450
    virtual bool isCustom() const { return false; }
 
451
 
 
452
    /**Reads an item from the stream.
 
453
    @param stream The stream to read from.*/
 
454
    virtual void read( QDataStream& stream );
 
455
    /**Writes an item to the stream.
 
456
    @param stream The stream to write to.*/
 
457
    virtual void write( QDataStream& stream ) const;
 
458
 
 
459
protected:
 
460
 
 
461
    /**@return The code model for this item.*/
 
462
    CodeModel* codeModel() { return m_model; }
 
463
 
 
464
    /**@note This is a const version provided for convenience.
 
465
    @return The code model for this item*/ 
 
466
    const CodeModel* codeModel() const { return m_model; }
 
467
 
 
468
private:
 
469
    int m_kind;
 
470
    CodeModel* m_model;
 
471
    QString m_name;
 
472
    QString m_fileName;
 
473
    int m_startLine, m_startColumn;
 
474
    int m_endLine, m_endColumn;
 
475
 
 
476
private:
 
477
    CodeModelItem( const CodeModelItem& source );
 
478
    void operator = ( const CodeModelItem& source );
 
479
};
 
480
 
 
481
 
 
482
/**
 
483
Class model.
 
484
Represents a class in the code model.
 
485
 
 
486
Instanses of this class should be created using @ref CodeModel::create method.
 
487
*/
 
488
class ClassModel: public CodeModelItem
 
489
{
 
490
protected:
 
491
    /**Constructor.
 
492
    @param model Code model which stores this item.*/
 
493
    ClassModel( CodeModel* model );
 
494
 
 
495
public:
 
496
    /**A definition of safe pointer to the class model.*/
 
497
    typedef ClassDom Ptr;
 
498
 
 
499
    virtual bool isClass() const { return true; }
 
500
 
 
501
    /**@return The scope of the class. Scope is a string list composed from names of parent classes and namespaces.*/
 
502
    QStringList scope() const { return m_scope; }
 
503
    /**Sets the scope of this class.
 
504
    @param scope The scope - a list of parent classes and namespaces.*/
 
505
    void setScope( const QStringList& scope ) { m_scope = scope; }
 
506
 
 
507
    /**@return The list of base class names.*/
 
508
    QStringList baseClassList() const;
 
509
 
 
510
    /**Adds a base class to the list of base classes.
 
511
    @param baseClass The base class name.*/
 
512
    bool addBaseClass( const QString& baseClass );
 
513
 
 
514
    /**Removes a base class from the list of base classes.
 
515
    @param baseClass The base class name.*/
 
516
    void removeBaseClass( const QString& baseClass );
 
517
 
 
518
    /**@return The list of (sub)classes in this model.*/
 
519
    ClassList classList();
 
520
 
 
521
    /**@note This is a const version provided for convenience.
 
522
    @return The list of (sub)classes in this model.*/
 
523
    const ClassList classList() const;
 
524
 
 
525
    /**Checks if the class specified by @p name is in this model.
 
526
    @param name The name of a class to look for.
 
527
    @return true if the model has a class.*/
 
528
    bool hasClass( const QString& name ) const;
 
529
 
 
530
    /**@param name The name of a class.
 
531
    @return A list of classes that match the name given by @p name.*/
 
532
    ClassList classByName( const QString& name );
 
533
 
 
534
    /**@param name The name of a class.
 
535
    @return A list of classes that match the name given by @p name.
 
536
    @note This is a const version provided for convenience.*/
 
537
    const ClassList classByName( const QString& name ) const;
 
538
 
 
539
    /**Adds a class to the model.
 
540
    @param klass The class model to add.
 
541
    @return true if addition was successful.*/
 
542
    bool addClass( ClassDom klass );
 
543
 
 
544
    /**Removes a class from the model.
 
545
    @param klass The class model to remove.*/    
 
546
    void removeClass( ClassDom klass );
 
547
 
 
548
    /**@return A list of functions in the model.*/
 
549
    FunctionList functionList();
 
550
 
 
551
    /**@return A list of functions in the model.
 
552
    @note This is a const version provided for convenience.*/
 
553
    const FunctionList functionList() const;
 
554
 
 
555
    /**Check if the function specified by @p name is in the model.
 
556
    @param name The name of a function to look for.
 
557
    @return true if the model has a class.*/
 
558
    bool hasFunction( const QString& name ) const;
 
559
 
 
560
    /**@param name The name of a function to look for.
 
561
    @return A list of functions that match the name given by @p name.*/
 
562
    FunctionList functionByName( const QString& name );
 
563
 
 
564
    /**@param name The name of a function to look for.
 
565
    @return A list of functions that match the name given by @p name.
 
566
    @note This is a const version provided for convenience.*/
 
567
    const FunctionList functionByName( const QString& name ) const;
 
568
 
 
569
    /**Adds a function to the class model.
 
570
    @param fun The function model to add.
 
571
    @return true if addition was successful.*/
 
572
    bool addFunction( FunctionDom fun );
 
573
 
 
574
    /**Removes a function from the class model.
 
575
    @param fun The FunctionDom object to remove from the model.*/
 
576
    void removeFunction( FunctionDom fun );
 
577
 
 
578
    /**@return The list of function definitions in the model.*/
 
579
    FunctionDefinitionList functionDefinitionList();
 
580
 
 
581
    /**@return The list of function definitions
 
582
    @note This is a const version provided for convenience.*/
 
583
    const FunctionDefinitionList functionDefinitionList() const;
 
584
 
 
585
    /**Checks if the function definition specified by \p name is in the model.
 
586
    @param name The name of a function definition to look for.
 
587
    @return true if the function definition was found.*/
 
588
    bool hasFunctionDefinition( const QString& name ) const;
 
589
 
 
590
    /**Gets the list of functions that match the name given by \p name.
 
591
    If there are no matches, then the list returned is empty.
 
592
    @param name The name of a function definition to look for.
 
593
    @return The FunctionDefinitionList object containing the definitions that match.*/
 
594
    FunctionDefinitionList functionDefinitionByName( const QString& name );
 
595
 
 
596
    /**Gets the list of functions that match the name given by \p name.
 
597
    If there are no matches, then the list returned is empty.
 
598
    @param name The name of a function definition to look for.
 
599
    @return The FunctionDefinitionList object containing the definitions that match.
 
600
    @note This is a const version provided for convenience.*/
 
601
    const FunctionDefinitionList functionDefinitionByName( const QString& name ) const;
 
602
 
 
603
    /**Adds a function definition to the model.
 
604
    @param fun The function fefinition model to add to the model.
 
605
    @return true if the addition was successful.*/
 
606
    bool addFunctionDefinition( FunctionDefinitionDom fun );
 
607
 
 
608
    /**Removes a function definition from the model.
 
609
    @param fun The function fefinition model to remove from the model.*/
 
610
    void removeFunctionDefinition( FunctionDefinitionDom fun );
 
611
 
 
612
    /**@return The list of variables in the model.*/
 
613
    VariableList variableList();
 
614
 
 
615
    /**@return The list of variables in the model.
 
616
    @note This is a const version provided for convenience.*/
 
617
    const VariableList variableList() const;
 
618
 
 
619
    /**Checks if the variable specified by @p name is in the model.
 
620
    @param name The name of a variable.
 
621
    @return true if the variable was found.*/
 
622
    bool hasVariable( const QString& name ) const;
 
623
 
 
624
    /**Gets the variable specified by @p name.
 
625
    If there are no matches, then the VariableDom object returned is empty.
 
626
    @param name The name of a variable.
 
627
    @return A VariableDom object that matches the name specified.*/
 
628
    VariableDom variableByName( const QString& name );
 
629
 
 
630
    /**Gets the variable specified by @p name.
 
631
    If there are no matches, then the VariableDom object returned is empty.
 
632
    @param name The name of a variable.
 
633
    @return A VariableDom object that matches the name specified.
 
634
    @note This is a const version provided for convenience.*/
 
635
    const VariableDom variableByName( const QString& name ) const;
 
636
 
 
637
    /**Adds a variable to the model.
 
638
    @param var The variable model to add to the model.
 
639
    @return true if the addition was successful.*/
 
640
    bool addVariable( VariableDom var );
 
641
 
 
642
    /**Removes a variable from the model.
 
643
    @param var The variable model to remove from the model.*/
 
644
    void removeVariable( VariableDom var );
 
645
 
 
646
    /**@return The type alias list for this model.*/
 
647
    TypeAliasList typeAliasList();
 
648
 
 
649
    /**@return The type alias list for this model.
 
650
    @note This is a const version provided for convenience.*/
 
651
    const TypeAliasList typeAliasList() const;
 
652
 
 
653
    /**Checks if the type alias specified by @p name is in the model.
 
654
    @param name The name of a type alias.
 
655
    @return true if the type alias was found.*/
 
656
    bool hasTypeAlias( const QString& name ) const;
 
657
 
 
658
    /**Gets the list of type aliases that match @p name.
 
659
    If there are no matches, the TypeAliasList object is empty.
 
660
    @param name The name of a type alias.
 
661
    @return A TypeAliasList object that contains the matches.*/
 
662
    TypeAliasList typeAliasByName( const QString& name );
 
663
 
 
664
    /**Gets the list of type aliases that match @p name.
 
665
    If there are no matches, the TypeAliasList object is empty.
 
666
    @param name The name of a type alias.
 
667
    @return A TypeAliasList object that contains the matches.
 
668
    @note This is a const version provided for convenience.*/
 
669
    const TypeAliasList typeAliasByName( const QString& name ) const;
 
670
 
 
671
    /**Adds a type alias to the model.
 
672
    @param typeAlias The type alias model to add to the model.
 
673
    @return true if the addition was successful.*/
 
674
    bool addTypeAlias( TypeAliasDom typeAlias );
 
675
 
 
676
    /**Removes a type alias from the model.
 
677
    @param typeAlias The TypeAliasDom object to remove from the model.*/
 
678
    void removeTypeAlias( TypeAliasDom typeAlias );
 
679
 
 
680
    /**@return The list of enums in the model.*/
 
681
    EnumList enumList();
 
682
 
 
683
    /**@return The list of enums in the model.
 
684
    @note This is a const version provided for convenience.*/
 
685
    const EnumList enumList() const;
 
686
 
 
687
    /**Checks if the enum specified by @p name is in the model.
 
688
    @param name The name of an enum.
 
689
    @return true if the enum was found.*/
 
690
    bool hasEnum( const QString& name ) const;
 
691
 
 
692
    /**Gets the enum specified by @p name.
 
693
    The EnumDom object returned will be empty if no match is found.
 
694
    @param name The name of an enum.
 
695
    @return The EnumDom object that contains the match.*/
 
696
    EnumDom enumByName( const QString& name );
 
697
 
 
698
    /**Gets the enum specified by @p name.
 
699
    The EnumDom object returned will be empty if no match is found.
 
700
    @param name The name of an enum.
 
701
    @return The EnumDom object that contains the match.*/
 
702
    const EnumDom enumByName( const QString& name ) const;
 
703
 
 
704
    /**Adds an enum to the model.
 
705
    @param e The enum model to add to the model.
 
706
    @return true if the addition was successful.*/
 
707
    bool addEnum( EnumDom e );
 
708
 
 
709
    /**Removes an enum from the model.
 
710
    @param e The enum model to remove from the model.*/
 
711
    void removeEnum( EnumDom e );
 
712
 
 
713
    virtual void read( QDataStream& stream );
 
714
    virtual void write( QDataStream& stream ) const;
 
715
 
 
716
private:
 
717
    QStringList m_scope;
 
718
    QStringList m_baseClassList;
 
719
    QMap<QString, ClassList> m_classes;
 
720
    QMap<QString, FunctionList> m_functions;
 
721
    QMap<QString, FunctionDefinitionList> m_functionDefinitions;
 
722
    QMap<QString, VariableDom> m_variables;
 
723
    QMap<QString, TypeAliasList> m_typeAliases;
 
724
    QMap<QString, EnumDom> m_enumerators;
 
725
 
 
726
private:
 
727
    ClassModel( const ClassModel& source );
 
728
    void operator = ( const ClassModel& source );
 
729
    friend class CodeModel;
 
730
};
 
731
 
 
732
 
 
733
/**
 
734
Namespace model.
 
735
Represents a namespace in the code model.
 
736
Namespace model can represent either usual c++ namespaces
 
737
and packages or modules from other languages.
 
738
 
 
739
Instanses of this class should be created using @ref CodeModel::create method.
 
740
*/
 
741
class NamespaceModel: public ClassModel
 
742
{
 
743
protected:
 
744
    /**Constructor.
 
745
    @param model Code model which stores this item.*/
 
746
    NamespaceModel( CodeModel* model );
 
747
 
 
748
public:
 
749
    /**A definition of safe pointer to the namespace model.*/
 
750
    typedef NamespaceDom Ptr;
 
751
 
 
752
    virtual bool isClass() const { return false; }
 
753
    virtual bool isNamespace() const { return true; }
 
754
 
 
755
    /**@return The list of namespaces in this model.*/
 
756
    NamespaceList namespaceList();
 
757
 
 
758
    /**@return The list of namespaces in this model.
 
759
    @note This is a const version provided for convenience.*/
 
760
    const NamespaceList namespaceList() const;
 
761
 
 
762
    /**Checks if the namespace referenced by @p name is in the model.
 
763
    @param name The name of a namespace.
 
764
    @return true if the namespace was found.*/
 
765
    bool hasNamespace( const QString& name ) const;
 
766
 
 
767
    /**Gets the namespace specified by @p name.
 
768
    If there are no matches, then the NamespaceDom object returned is empty.
 
769
    @param name The name of a namespace.
 
770
    @return The NamespaceDom object that contains the match.*/
 
771
    NamespaceDom namespaceByName( const QString& name );
 
772
 
 
773
    /**Gets the namespace specified by @p name.
 
774
    If there are no matches, then the NamespaceDom object returned is empty.
 
775
    @param name The name of a namespace.
 
776
    @return The NamespaceDom object that contains the match.
 
777
    @note This is a const version provided for convenience.*/
 
778
    const NamespaceDom namespaceByName( const QString& name ) const;
 
779
 
 
780
    /**Adds a namespace to the model.
 
781
    @param ns The namespace model to add to the model.
 
782
    @return true if addition was successful.*/
 
783
    bool addNamespace( NamespaceDom ns );
 
784
 
 
785
    /**Removes the namespace from the model.
 
786
    @param ns The namespace model to remove from the model.*/
 
787
    void removeNamespace( NamespaceDom ns );
 
788
 
 
789
    virtual void read( QDataStream& stream );
 
790
    virtual void write( QDataStream& stream ) const;
 
791
 
 
792
private:
 
793
    QMap<QString, NamespaceDom> m_namespaces;
 
794
 
 
795
private:
 
796
    NamespaceModel( const NamespaceModel& source );
 
797
    void operator = ( const NamespaceModel& source );
 
798
    friend class CodeModel;
 
799
};
 
800
 
 
801
 
 
802
 
 
803
/**
 
804
File model.
 
805
Represents a file in the code model.
 
806
Files in general contain classes, namespaces, functions,
 
807
types, etc. Therefore FileModel is derived from NamespaceModel.
 
808
 
 
809
Instanses of this class should be created using @ref CodeModel::create method.
 
810
*/
 
811
class FileModel: public NamespaceModel
 
812
{
 
813
protected:
 
814
    /**Constructor.
 
815
    @param model Code model which stores this item.*/
 
816
    FileModel( CodeModel* model );
 
817
 
 
818
public:
 
819
    /**A definition of safe pointer to the file model.*/
 
820
    typedef FileDom Ptr;
 
821
 
 
822
    virtual bool isFile() const { return true; }
 
823
 
 
824
    virtual void read( QDataStream& stream );
 
825
    virtual void write( QDataStream& stream ) const;
 
826
 
 
827
private:
 
828
    FileModel( const FileModel& );
 
829
    void operator = ( const FileModel& );
 
830
    friend class CodeModel;
 
831
};
 
832
 
 
833
 
 
834
/**
 
835
Function (procedure) argument model.
 
836
Represents an argument in the function.
 
837
 
 
838
Instanses of this class should be created using @ref CodeModel::create method.
 
839
*/
 
840
class ArgumentModel: public CodeModelItem
 
841
{
 
842
protected:
 
843
    ArgumentModel( CodeModel* model );
 
844
 
 
845
public:
 
846
    /**A definition of safe pointer to the argument model.*/
 
847
    typedef ArgumentDom Ptr;
 
848
 
 
849
    virtual bool isArgument() const { return true; }
 
850
 
 
851
    /**@return The type of this argument.*/
 
852
    QString type() const;
 
853
 
 
854
    /**Sets the type of this argument.
 
855
    @param type The type to set.*/
 
856
    void setType( const QString& type );
 
857
 
 
858
    /**@return The default value of this argument.*/
 
859
    QString defaultValue() const;
 
860
 
 
861
    /**Sets the default value of this argument.
 
862
    @param defaultValue The default value to set.*/
 
863
    void setDefaultValue( const QString& defaultValue );
 
864
 
 
865
    virtual void read( QDataStream& stream );
 
866
    virtual void write( QDataStream& stream ) const;
 
867
 
 
868
private:
 
869
    QString m_type;
 
870
    QString m_defaultValue;
 
871
 
 
872
private:
 
873
    ArgumentModel( const ArgumentModel& source );
 
874
    void operator = ( const ArgumentModel& source );
 
875
    friend class CodeModel;
 
876
};
 
877
 
 
878
 
 
879
/**
 
880
Function model.
 
881
Represents:
 
882
- functions;
 
883
- procedures;
 
884
- class methods;
 
885
.
 
886
In languages that have separate function declarations and definitions (c++)
 
887
this represents only function declarations. @see FunctionDefinitionModel 
 
888
for a model of function definitions.
 
889
 
 
890
Instanses of this class should be created using @ref CodeModel::create method.
 
891
*/
 
892
class FunctionModel: public CodeModelItem
 
893
{
 
894
protected:
 
895
    /**Constructor.
 
896
    @param model Code model which stores this item.*/
 
897
    FunctionModel( CodeModel* model );
 
898
 
 
899
public:
 
900
    /**A definition of safe pointer to the function model.*/
 
901
    typedef FunctionDom Ptr;
 
902
 
 
903
    virtual bool isFunction() const { return true; }
 
904
 
 
905
    /**@return The scope of the function. Scope is a string list composed 
 
906
    from names of parent functions, classes and namespaces.*/
 
907
    QStringList scope() const { return m_scope; }
 
908
 
 
909
    /**Sets the scope of the function.
 
910
    @param scope The scope to set.*/
 
911
    void setScope( const QStringList& scope ) { m_scope = scope; }
 
912
 
 
913
    /**@return The access level of the function. Can return either values of type @ref CodeModelItem::Access or 
 
914
    other integers if the function has other access level (for example pascal methods can have "published"
 
915
    access level).*/
 
916
    int access() const;
 
917
 
 
918
    /**Sets the access level of the function.
 
919
    @param access The access level.*/
 
920
    void setAccess( int access );
 
921
 
 
922
    /**@return true if the function is a signal.*/
 
923
    bool isSignal() const;
 
924
    /**Sets the function to be a signal.
 
925
    @param isSignal The signal flag.*/
 
926
    void setSignal( bool isSignal );
 
927
 
 
928
    /**@return true if the function is a slot.*/
 
929
    bool isSlot() const;
 
930
    /**Sets the function to be a slot.
 
931
    @param isSlot The slot flag.*/
 
932
    void setSlot( bool isSlot );
 
933
 
 
934
    /**@return true if the function is a virtual function.*/
 
935
    bool isVirtual() const;
 
936
    /**Sets the function to be a virtual function.
 
937
    @param isVirtual The virtual flag.*/
 
938
    void setVirtual( bool isVirtual );
 
939
 
 
940
    /**@return true if the function is a static function.*/
 
941
    bool isStatic() const;
 
942
    /**Sets the function to be a static function.
 
943
    @param isStatic The static flag.*/
 
944
    void setStatic( bool isStatic );
 
945
 
 
946
    /**@return true if the function is an inline function.*/
 
947
    bool isInline() const;
 
948
    /**Sets the function to be an inline function.
 
949
    @param isInline The inline flag.*/
 
950
    void setInline( bool isInline );
 
951
 
 
952
    /**@return true if the function is a constant function.*/
 
953
    bool isConstant() const;
 
954
    /**Sets the function to be a constant function.
 
955
    @param isConstant The constant flag.*/
 
956
    void setConstant( bool isConstant );
 
957
 
 
958
    /**@return true if the function is an abstract function.*/
 
959
    bool isAbstract() const;
 
960
    /**Sets the function to be an inline function.
 
961
    @param isAbstract The abstract flag.*/
 
962
    void setAbstract( bool isAbstract );
 
963
 
 
964
    /**@return The result type of a function.*/
 
965
    QString resultType() const;
 
966
    /**Sets the result type of a function.
 
967
    @param type The type of a function result.*/
 
968
    void setResultType( const QString& type );
 
969
 
 
970
    /**Gets the list of arguments being passed to the function.
 
971
    If there are no arguments, then the list is empty.
 
972
    @return The ArgumentList object that contains the arguments for this function.*/
 
973
    ArgumentList argumentList();
 
974
 
 
975
    /**Gets the list of arguments being passed to the function.
 
976
    If there are no arguments, then the list is empty.
 
977
    @return The ArgumentList object that contains the arguments for this function.
 
978
    @note This is a const version provided for convenience.*/
 
979
    const ArgumentList argumentList() const;
 
980
 
 
981
    /**Adds an argument to the function.
 
982
    @param arg The argument model to add as an argument to the function.
 
983
    @return true if the addition was successful.*/
 
984
    bool addArgument( ArgumentDom arg );
 
985
 
 
986
    /**Removes an argument from the function.
 
987
    @param arg The argument model to remove from the function.*/
 
988
    void removeArgument( ArgumentDom arg );
 
989
 
 
990
    virtual void read( QDataStream& stream );
 
991
    virtual void write( QDataStream& stream ) const;
 
992
 
 
993
private:
 
994
    QStringList m_scope;
 
995
    int m_access;
 
996
 
 
997
    union {
 
998
        struct {
 
999
            int m_signal : 1;
 
1000
            int m_slot : 1;
 
1001
            int m_virtual : 1;
 
1002
            int m_static : 1;
 
1003
            int m_inline : 1;
 
1004
            int m_constant : 1;
 
1005
            int m_abstract : 1;
 
1006
        } v;
 
1007
        int flags;
 
1008
    } d;
 
1009
 
 
1010
    QString m_resultType;
 
1011
    ArgumentList m_arguments;
 
1012
 
 
1013
private:
 
1014
    FunctionModel( const FunctionModel& source );
 
1015
    void operator = ( const FunctionModel& source );
 
1016
    friend class CodeModel;
 
1017
};
 
1018
 
 
1019
/**
 
1020
Function model.
 
1021
Represents function definition for languages that have such.
 
1022
 
 
1023
Instanses of this class should be created using @ref CodeModel::create method.
 
1024
*/
 
1025
class FunctionDefinitionModel: public FunctionModel
 
1026
{
 
1027
protected:
 
1028
    /**Constructor.
 
1029
    @param model Code model which stores this item.*/
 
1030
    FunctionDefinitionModel( CodeModel* model );
 
1031
 
 
1032
public:
 
1033
    /**A definition of safe pointer to the function definition model.*/
 
1034
    typedef FunctionDefinitionDom Ptr;
 
1035
 
 
1036
    virtual bool isFunctionDefinition() const { return true; }
 
1037
 
 
1038
private:
 
1039
    FunctionDefinitionModel( const FunctionDefinitionModel& source );
 
1040
    void operator = ( const FunctionDefinitionModel& source );
 
1041
    friend class CodeModel;
 
1042
};
 
1043
 
 
1044
 
 
1045
/**
 
1046
Variable model.
 
1047
Represents variables and class attributes.
 
1048
 
 
1049
Instanses of this class should be created using @ref CodeModel::create method.
 
1050
*/
 
1051
class VariableModel: public CodeModelItem
 
1052
{
 
1053
protected:
 
1054
    /**Constructor.
 
1055
    @param model Code model which stores this item.*/
 
1056
    VariableModel( CodeModel* model );
 
1057
 
 
1058
public:
 
1059
    /**A definition of safe pointer to the variable model.*/
 
1060
    typedef VariableDom Ptr;
 
1061
 
 
1062
    virtual bool isVariable() const { return true; }
 
1063
 
 
1064
    /**@return The access level of the variable. Can return either values of type @ref CodeModelItem::Access or 
 
1065
    other integers if the variable has other access level (for example pascal attributes can have "published"
 
1066
    access level).*/
 
1067
    int access() const;
 
1068
    /**Sets the access level of the variable.
 
1069
    @param access The access level.*/
 
1070
    void setAccess( int access );
 
1071
 
 
1072
    /**@return true if the variable is a static variable.*/
 
1073
    bool isStatic() const;
 
1074
    /**Sets the variable to be a static variable.
 
1075
    @param isStatic The static flag.*/
 
1076
    void setStatic( bool isStatic );
 
1077
 
 
1078
    /**@return A type of the variable.*/
 
1079
    QString type() const;
 
1080
    /**Sets the type of the variable.
 
1081
    @param type The type name.*/
 
1082
    void setType( const QString& type );
 
1083
 
 
1084
    virtual void read( QDataStream& stream );
 
1085
    virtual void write( QDataStream& stream ) const;
 
1086
 
 
1087
private:
 
1088
    int m_access;
 
1089
    int m_static;
 
1090
    QString m_type;
 
1091
 
 
1092
private:
 
1093
    VariableModel( const VariableModel& source );
 
1094
    void operator = ( const VariableModel& source );
 
1095
    friend class CodeModel;
 
1096
};
 
1097
 
 
1098
 
 
1099
/**
 
1100
Enum model.
 
1101
Represents enums.
 
1102
 
 
1103
Instanses of this class should be created using @ref CodeModel::create method.
 
1104
*/
 
1105
class EnumModel: public CodeModelItem
 
1106
{
 
1107
protected:
 
1108
    /**Constructor.
 
1109
    @param model Code model which stores this item.*/
 
1110
    EnumModel( CodeModel* model );
 
1111
 
 
1112
public:
 
1113
    /**A definition of safe pointer to the enum model.*/
 
1114
    typedef EnumDom Ptr;
 
1115
 
 
1116
    virtual bool isEnum() const { return true; }
 
1117
 
 
1118
    /**@return The access level of the enum. Can return either values 
 
1119
    of type @ref CodeModelItem::Access or other integers if the enum has other access level.*/
 
1120
    int access() const;
 
1121
    /**Sets the access level of the enum.
 
1122
    @param access The access level.*/
 
1123
    void setAccess( int access );
 
1124
    
 
1125
    /**@return The list of enumerators in this enum.*/
 
1126
    EnumeratorList enumeratorList();
 
1127
    /**@return The list of enumerators in this enum.
 
1128
    @note This is a const version provided for convenience.*/
 
1129
    const EnumeratorList enumeratorList() const;
 
1130
    /**Adds an enumerator to the model.
 
1131
    @param e The enumerator model to add.*/
 
1132
    void addEnumerator( EnumeratorDom e );
 
1133
    /**Removes an enumerator from the model.
 
1134
    @param e The enumerator model to remove.*/
 
1135
    void removeEnumerator( EnumeratorDom e );
 
1136
 
 
1137
    virtual void read( QDataStream& stream );
 
1138
    virtual void write( QDataStream& stream ) const;
 
1139
 
 
1140
private:
 
1141
    int m_access;
 
1142
    QMap<QString, EnumeratorDom> m_enumerators;
 
1143
 
 
1144
private:
 
1145
    EnumModel( const EnumModel& source );
 
1146
    void operator = ( const EnumModel& source );
 
1147
    friend class CodeModel;
 
1148
};
 
1149
 
 
1150
 
 
1151
/**
 
1152
Enumerator model.
 
1153
Represents enumerators. Enums consist of enumerators, for example in code:
 
1154
@code
 
1155
enum Type { A, B, C};
 
1156
@endcode
 
1157
Type is represented as EnumModel;\n
 
1158
A, B, C are represented with EnumeratorModel.
 
1159
 
 
1160
Instanses of this class should be created using @ref CodeModel::create method.
 
1161
*/
 
1162
class EnumeratorModel: public CodeModelItem
 
1163
{
 
1164
protected:
 
1165
    /**Constructor.
 
1166
    @param model Code model which stores this item.*/
 
1167
    EnumeratorModel( CodeModel* model );
 
1168
 
 
1169
public:
 
1170
    /**A definition of safe pointer to the enumerator model.*/
 
1171
    typedef EnumeratorDom Ptr;
 
1172
 
 
1173
    virtual bool isEnumerator() const { return true; }
 
1174
    
 
1175
    /**@return The value of an enumerator.*/
 
1176
    QString value() const;
 
1177
    /**Sets the value of an enumerator.
 
1178
    @param value The value.*/
 
1179
    void setValue( const QString& value );
 
1180
 
 
1181
    virtual void read( QDataStream& stream );
 
1182
    virtual void write( QDataStream& stream ) const;
 
1183
 
 
1184
private:
 
1185
    QString m_value;
 
1186
    
 
1187
private:
 
1188
    EnumeratorModel( const EnumeratorModel& source );
 
1189
    void operator = ( const EnumeratorModel& source );
 
1190
    friend class CodeModel;
 
1191
};
 
1192
 
 
1193
 
 
1194
/**
 
1195
Type alias model.
 
1196
Represents type aliases (like aliases in Ada and typedefs in c++).
 
1197
*/
 
1198
class TypeAliasModel: public CodeModelItem
 
1199
{
 
1200
protected:
 
1201
    /**Constructor.
 
1202
    @param model Code model which stores this item.*/
 
1203
    TypeAliasModel( CodeModel* model );
 
1204
 
 
1205
public:
 
1206
    /**A definition of safe pointer to the type alias model.*/
 
1207
    typedef TypeAliasDom Ptr;
 
1208
 
 
1209
    virtual bool isTypeAlias() const { return true; }
 
1210
    
 
1211
    /**@return The actual type of an alias.*/
 
1212
    QString type() const;
 
1213
    /**Sets the type of an alias.
 
1214
    @param type The type name.*/
 
1215
    void setType( const QString& type );
 
1216
    
 
1217
    virtual void read( QDataStream& stream );
 
1218
    virtual void write( QDataStream& stream ) const;
 
1219
 
 
1220
private:
 
1221
    QString m_type;
 
1222
    
 
1223
private:
 
1224
    TypeAliasModel( const TypeAliasModel& source );
 
1225
    void operator = ( const TypeAliasModel& source );
 
1226
    friend class CodeModel;
 
1227
};
 
1228
 
 
1229
#endif