~ubuntu-branches/ubuntu/jaunty/aspectc++/jaunty

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/inc/Puma/CClassDatabase.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-07-07 14:41:02 UTC
  • mfrom: (1.1.3 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080707144102-lzml7t07f3sl00r5
Tags: 1.0pre4~svn.20080711-1
* new upstream snapshot.
* include all upstream documentation. Clarifying emails regarding
  licensing has been included into debian/copyright.
* reformat description following recomendations of
  http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
  (Closes: #480316)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef __CClassDatabase_h__
20
20
#define __CClassDatabase_h__
21
21
 
22
 
#include "Puma/CScopeInfo.h"
23
 
#include "Puma/CProject.h"
24
 
#include <iostream>
25
 
#include <map>
26
 
using namespace std;
 
22
/** \file 
 
23
 *  Alias for CSemDatabase. */
 
24
 
 
25
#include "Puma/CSemDatabase.h"
27
26
 
28
27
namespace Puma {
29
28
 
30
29
 
31
 
class CObjectInfo;
32
 
class CClassInfo;
33
 
class CUnionInfo;
34
 
class CEnumInfo;
35
 
class CTypedefInfo;
36
 
class CTemplateParamInfo;
37
 
class CTypeInfo;
38
 
class CFileInfo;
39
 
class Token;
40
 
 
41
 
/** \file 
42
 
 *  Database of all semantic objects (infos) of a project. 
43
 
 *  \see Puma::CClassDatabase */
44
 
 
45
 
/** \class CClassDatabase CClassDatabase.h Puma/infos/CClassDatabase.h
46
 
 *  A CClassDatabase object is a database of all semantic objects
47
 
 *  (infos) of a project. */
48
 
class CClassDatabase {
49
 
  
50
 
  Array<CObjectInfo*> _Classes;    // index of classes
51
 
  Array<CObjectInfo*> _Unions;     // index of unions
52
 
  Array<CObjectInfo*> _Enums;      // index of enums
53
 
  Array<CObjectInfo*> _Typedefs;   // index of typedefs
54
 
  Array<CObjectInfo*> _Functions;  // index of functions
55
 
  Array<CObjectInfo*> _Files;      // index of files
56
 
 
57
 
  CProject *_Project; // associated project
58
 
  
59
 
  multimap<int,CFunctionInfo*> _builtin_ops; // map for built-in operator lookup
60
 
 
61
 
public:
62
 
  /** Construct a class database object.
63
 
   *  \param prj The corresponding project.
64
 
   *  \param size Not used. */
65
 
  CClassDatabase (CProject &prj, int size = 997);
66
 
  /** Destruct the class database. Also destroys all infos
67
 
   *  in the database. */
68
 
  virtual ~CClassDatabase ();
69
 
 
70
 
  // access to the database entries /////////////////////////////
71
 
  
72
 
  /** Get the number of semantic object infos. */
73
 
  unsigned ObjectInfos () const;
74
 
  /** Get the number of class infos. */
75
 
  unsigned ClassInfos () const;
76
 
  /** Get the number of union infos. */
77
 
  unsigned UnionInfos () const;
78
 
  /** Get the number of enumeration infos. */
79
 
  unsigned EnumInfos () const;
80
 
  /** Get the number of typedef infos. */
81
 
  unsigned TypedefInfos () const;
82
 
  /** Get the number of function infos. */
83
 
  unsigned FunctionInfos () const;
84
 
  /** Get the number of on-demand generated built-in operator functions. */
85
 
  unsigned FileInfos () const;
86
 
  /** Get the n-th semantic object info.
87
 
   *  \param n The number of the info.
88
 
   *  \return The info or \c NULL if \e n is invalid. */
89
 
  CObjectInfo *ObjectInfo (unsigned n) const;
90
 
  /** Get the n-th class info.
91
 
   *  \param n The number of the info.
92
 
   *  \return The info or \c NULL if \e n is invalid. */
93
 
  CClassInfo *ClassInfo (unsigned n) const;
94
 
  /** Get the n-th union info.
95
 
   *  \param n The number of the info.
96
 
   *  \return The info or \c NULL if \e n is invalid. */
97
 
  CUnionInfo *UnionInfo (unsigned n) const;
98
 
  /** Get the n-th enumeration info.
99
 
   *  \param n The number of the info.
100
 
   *  \return The info or \c NULL if \e n is invalid. */
101
 
  CEnumInfo *EnumInfo (unsigned n) const;
102
 
  /** Get the n-th typedef info.
103
 
   *  \param n The number of the info.
104
 
   *  \return The info or \c NULL if \e n is invalid. */
105
 
  CTypedefInfo *TypedefInfo (unsigned n) const;
106
 
  /** Get the n-th function info.
107
 
   *  \param n The number of the info.
108
 
   *  \return The info or \c NULL if \e n is invalid. */
109
 
  CFunctionInfo *FunctionInfo (unsigned n) const;
110
 
  /** Get the n-th on-demand generated built-in operator info.
111
 
   *  \param n The number of the info.
112
 
   *  \return The info or \c NULL if \e n is invalid. */
113
 
  CFileInfo *FileInfo (unsigned n) const;
114
 
 
115
 
  /** Get the semantic object info identified by the given
116
 
   *  source code position. 
117
 
   *  \param pos The position in the source code. 
118
 
   *  \return The info or \c NULL if the info could not be identified. */
119
 
  CObjectInfo *ObjectInfo (Token *pos) const; 
120
 
  /** Get the semantic object info identified by the given
121
 
   *  source code position.
122
 
   *  \param pos The position in the source code. 
123
 
   *  \return The info or \c NULL if the info could not be identified. */
124
 
  CObjectInfo *ObjectInfo (CT_Token *pos) const; 
125
 
 
126
 
public:
127
 
  // Administration /////////////////////////////////////////////
128
 
  
129
 
  /** Insert a new semantic object into the database.
130
 
   *  \param info The semantic object info to insert. */
131
 
  void Insert (CObjectInfo *info);
132
 
  /** Remove the given semantic object from the database.
133
 
   *  \param info The semantic object info to remove. */
134
 
  void Remove (CObjectInfo *info);
135
 
  /** Get a function info object for a built-in operator.
136
 
   *  \param name Operator name.
137
 
   *  \param tok Operator token type, used as a key for fast lookup.
138
 
   *  \param rtype result type of the operator. Not used for lookup,
139
 
   *         only for object creation.
140
 
   *  \param t0 first argument type.
141
 
   *  \param t1 second argument type or \c NULL.
142
 
   *  \return on-demand generated operator function object. */
143
 
  CFunctionInfo *BuiltinOperator (const char *name, int tok, CTypeInfo *rtype,
144
 
    CTypeInfo *t0, CTypeInfo *t1);
145
 
  /** Dump the contents of the database. The dump is indented as
146
 
   *  tree corresponding to the nesting of the semantic objects.
147
 
   *  \param out The output stream to dump to.
148
 
   *  \param depth The max. depth in the tree to be dumped. */
149
 
  void Dump (ostream &out, int depth = 0) const;
150
 
 
151
 
  /** Get the project info delivered to the constructor of the database. */
152
 
  CProject *Project () const;
153
 
 
154
 
private:
155
 
  void CreateParameter (CFunctionInfo *fi, CTypeInfo *type) const;
156
 
 
157
 
  void Dump (ostream &, CStructure *, int, int) const;
158
 
  void DumpType (ostream &, CObjectInfo *, int) const;
159
 
  void DumpUsing (ostream &, CUsingInfo *, int) const;
160
 
  void DumpFunction (ostream &, CFunctionInfo *, int, int) const;
161
 
  void DumpAttribute (ostream &, CAttributeInfo *, int) const;
162
 
  void DumpNamespace (ostream &, CNamespaceInfo *, int) const;
163
 
  void DumpQualities (ostream &, CObjectInfo *) const;
164
 
  void DumpScopeName (ostream &, CStructure *) const;
165
 
  void DumpLocalScope (ostream &, CObjectInfo *, int) const;
166
 
  void DumpTemplateParam (ostream &, CTemplateParamInfo *, int) const;
167
 
  void indent (ostream &, int) const;
168
 
 
169
 
//  unsigned Infos (const char *, unsigned) const;
170
 
//  CObjectInfo *Info (const char *, unsigned, unsigned) const;
171
 
};
172
 
 
173
 
inline CClassDatabase::CClassDatabase (CProject &p, int size) :
174
 
  _Project (&p)
175
 
 {}
176
 
 
177
 
inline unsigned CClassDatabase::ObjectInfos () const
178
 
 { return ClassInfos () + UnionInfos () + EnumInfos () + 
179
 
          TypedefInfos () + FunctionInfos () + FileInfos (); }
180
 
inline unsigned CClassDatabase::ClassInfos () const
181
 
 { return _Classes.length (); }
182
 
inline unsigned CClassDatabase::UnionInfos () const
183
 
 { return _Unions.length (); }
184
 
inline unsigned CClassDatabase::EnumInfos () const
185
 
 { return _Enums.length (); }
186
 
inline unsigned CClassDatabase::TypedefInfos () const
187
 
 { return _Typedefs.length (); }
188
 
inline unsigned CClassDatabase::FunctionInfos () const
189
 
 { return _Functions.length (); }
190
 
inline unsigned CClassDatabase::FileInfos () const
191
 
 { return _Files.length (); }
192
 
 
193
 
inline CClassInfo *CClassDatabase::ClassInfo (unsigned i) const
194
 
 { return (CClassInfo*)_Classes.lookup (i); }
195
 
inline CUnionInfo *CClassDatabase::UnionInfo (unsigned i) const
196
 
 { return (CUnionInfo*)_Unions.lookup (i); }
197
 
inline CEnumInfo *CClassDatabase::EnumInfo (unsigned i) const
198
 
 { return (CEnumInfo*)_Enums.lookup (i); }
199
 
inline CTypedefInfo *CClassDatabase::TypedefInfo (unsigned i) const
200
 
 { return (CTypedefInfo*)_Typedefs.lookup (i); }
201
 
inline CFunctionInfo *CClassDatabase::FunctionInfo (unsigned i) const
202
 
 { return (CFunctionInfo*)_Functions.lookup (i); }
203
 
inline CFileInfo *CClassDatabase::FileInfo (unsigned i) const
204
 
 { return (CFileInfo*)_Files.lookup (i); }
205
 
 
206
 
inline CProject *CClassDatabase::Project () const
207
 
 { return _Project; }
 
30
/** Backward compatibility alias for CSemDatabase. */
 
31
typedef CSemDatabase CClassDatabase;
208
32
 
209
33
 
210
34
} // namespace Puma