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

« back to all changes in this revision

Viewing changes to Puma/src/infos/CClassInfo.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 __CClassInfo_h__
20
20
#define __CClassInfo_h__
21
21
 
22
 
// class/struct info 
23
 
// knows its base and derived classes
 
22
/** \file 
 
23
 *  Semantic information about a class. */
24
24
 
25
25
#include "Puma/CRecord.h"
26
26
#include "Puma/CTypeInfo.h"
30
30
 
31
31
namespace Puma {
32
32
 
33
 
/** \file 
34
 
 *  Representation of a C/C++ 'class' or 'struct'.
35
 
 *  \see Puma::CClassInfo */
36
 
 
37
 
/** \class CClassInfo CClassInfo.h Puma/infos/CClassInfo.h
38
 
 *  A CClassInfo object represents a C++ 'class' or 'struct'. Most of 
39
 
 *  the functionality of CClassInfo inherited by Puma::CRecord. It
40
 
 *  mainly manages the list of base classes and the list of derived
41
 
 *  classes. Note that a 'union', although syntactically very similar,
42
 
 *  is not represented by a CClassInfo object. */
 
33
/** \class CClassInfo CClassInfo.h Puma/CClassInfo.h
 
34
 *  Semantic information about a class. Note that 'struct's
 
35
 *  are ordinary classes where the member access type 
 
36
 *  defaults to \e public. Note also that a 'union', 
 
37
 *  although syntactically very similar, is not a class 
 
38
 *  and thus not represented by CClassInfo. */
43
39
class CClassInfo : public CRecord {
44
40
  Array<CBaseClassInfo*> _BaseClasses;
45
41
  Array<CClassInfo*> _Derived;
47
43
  bool _DepBaseClass;
48
44
 
49
45
protected:
50
 
  /** This constructor is to be used by classes inherited from
51
 
   *  CClassInfo. It makes it possible to set another object id
52
 
   *  than \c CLASS_INFO for abstractions not representing a 
53
 
   *  standard C++ class (e.g. CClassInstance).
54
 
   *  \param id The object id to be used instead of \c CLASS_INFO. */
 
46
  /** Constructor.
 
47
   *  \param id The object type. */
55
48
  CClassInfo (ObjectId id);
56
49
 
57
50
public: 
58
 
  /** Construct a new CClassInfo object. */
 
51
  /** Constructor. */
59
52
  CClassInfo ();
60
 
  /** Destroy the CClassInfo object. If the object id is 
61
 
   *  \c CLASS_INFO, Puma::CObjectInfo::CleanUp() is called. */
 
53
  /** Destructor. If the object type is CObjectInfo::CLASS_INFO, 
 
54
   *  then CObjectInfo::CleanUp() is called. */
62
55
  ~CClassInfo ();
63
56
 
64
 
  /** Get the base info object of the info object. <b>The 
65
 
   *  corresponding information is not yet set!</b>
66
 
   *  \return This method always returns \c NULL.
67
 
   *  \warning Do not use this method. */
68
 
  CClassInfo *BaseObject () const;
69
 
  /** Get the info object of the class definition. 
70
 
   *  \return The info or \e this if the class is not defined. */
 
57
  /** Get the semantic object of the class definition. 
 
58
   *  \see CObjectInfo::DefObject() */
71
59
  CClassInfo *DefObject () const;
72
 
  /** Get the type information object for the class. */
 
60
  /** Get the type information for the class. */
73
61
  CTypeClass *TypeInfo () const;
74
62
 
75
63
  /** Get the number of the base classes of the class. */
77
65
  /** Get the number of classes derived from the class. */
78
66
  unsigned DerivedClasses() const;
79
67
  /** Get the n-th base class. 
80
 
   *  \param n The number of the base class to return. 
81
 
   *  \return The base class info or \c NULL if \e n is not valid. */
 
68
   *  \param n The index of the base class. 
 
69
   *  \return The base class or if \e n is not valid. */
82
70
  CBaseClassInfo *BaseClass (unsigned n) const;
83
71
  /** Get the base class with the given name. 
84
 
   *  \param name The name of the base class to return.
85
 
   *  \return The base class info or \c NULL if there is no base 
 
72
   *  \param name The name of the base class.
 
73
   *  \return The base class or NULL if there is no base 
86
74
   *          class with the given name. */
87
75
  CBaseClassInfo *BaseClass (const char *name) const;
88
76
  /** Get the n-th derived class. 
89
 
   *  \param n The number of the derived class to return. 
90
 
   *  \return The class info of the derived class or \c NULL 
91
 
   *          if \e n is not valid. */
 
77
   *  \param n The index of the derived class. 
 
78
   *  \return The derived class or NULL if \e n is not valid. */
92
79
  CClassInfo *DerivedClass (unsigned n) const;
93
80
  /** Get the derived class with the given name. 
94
 
   *  \param name The name of the derived class to return.
95
 
   *  \return The class info of the derived class or \c NULL 
96
 
   *          if there is no derived class with the given name. */
 
81
   *  \param name The name of the derived class.
 
82
   *  \return The derived class or NULL if there is no derived
 
83
   *          class with the given name. */
97
84
  CClassInfo *DerivedClass (const char *name) const;
98
85
  
99
 
  /** Return \e true if the given class is a base class of the class.
100
 
   *  \param ci The class info of the possible base class.
101
 
   *  \param recursive If \e false it is only checked whether \e ci
102
 
   *         is a direct base class. */
103
 
  bool isBaseClass (const CClassInfo *ci, bool recursive = false) const;
104
 
  /** Return \e true if the given class is a derived class of the class.
105
 
   *  \param ci The class info of the possible base class.
106
 
   *  \param recursive If \e false it is only checked whether \e ci
107
 
   *         is directly derived from the class. */
108
 
  bool isDerivedClass (const CClassInfo *ci, bool recursive = false) const;
109
 
  /** Mark the class to have a base class that depends on template 
 
86
  /** Check if the given class is a base class of this class.
 
87
   *  \param base The base class.
 
88
   *  \param recursive If \e false then only the direct base classes
 
89
   *                   are considered. */
 
90
  bool isBaseClass (const CClassInfo *base, bool recursive = false) const;
 
91
  /** Check if the given class is derived from this class.
 
92
   *  \param dc The derived class.
 
93
   *  \param recursive If \e false then only the directly derived classes
 
94
   *                   are considered. */
 
95
  bool isDerivedClass (const CClassInfo *dc, bool recursive = false) const;
 
96
  /** Set that this class has a base class that depends on template 
110
97
   *  parameters. 
111
98
   *  \param depends \e true if there is a dependent base class. */
112
99
  void hasDepBaseClass (bool depends);
113
 
  /** Return \e true if the class has a base class that depends on 
 
100
  /** Check if this class has a base class that depends on 
114
101
   *  template parameters. */
115
102
  bool hasDepBaseClass () const;
116
103
 
117
 
  /** Add a base class to the class.
118
 
   *  \param bc The base class info object. */
 
104
  /** Add a base class to this class.
 
105
   *  \param bc The base class. */
119
106
  void addBaseClass (CBaseClassInfo *bc);
120
 
  /** Add a derived class to the class.
121
 
   *  \param dc The class info object of the derived class. */
 
107
  /** Add a derived class to this class.
 
108
   *  \param dc The derived class. */
122
109
  void addDerivedClass (CClassInfo *dc);
123
 
  /** Remove the given base class from the class.
124
 
   *  \param bc The base class info object to remove. */
 
110
  /** Remove the given base class from this class.
 
111
   *  \param bc The base class. */
125
112
  void removeBaseClass (const CBaseClassInfo *bc);
126
 
  /** Remove the given base class from the class.
127
 
   *  \param bc The class info object of the base class to remove. */
 
113
  /** Remove the given base class from this class.
 
114
   *  \param bc The base class. */
128
115
  void removeBaseClass (const CClassInfo *bc);
129
 
  /** Remove the given derived class from the class.
130
 
   *  \param dc The class info object of the derived class to remove. */
 
116
  /** Remove the given derived class from this class.
 
117
   *  \param dc The derived class. */
131
118
  void removeDerivedClass (const CClassInfo *dc);
132
119
 
133
 
  /** Create a new base class info object.
134
 
   *  \param bc The class info of the base class or \c NULL to create
135
 
   *         an empty base class info object. 
136
 
   *  \return The new base class info object. */
 
120
  /** Create a new base class semantic object.
 
121
   *  \param bc The semantic information about the of the base class
 
122
   *            or NULL to create an empty base class semantic object. */
137
123
  CBaseClassInfo *newBaseClass (CClassInfo *bc = 0);
138
124
 
139
 
  /** Return \e true if the class is declared using the keyword 'struct'. */
 
125
  /** Check if the class is declared using keyword 'struct'. */
140
126
  bool isStruct () const;
141
127
  
142
 
  /** Returns the accessibility of a particular member or base class member.
143
 
   *  For example, if the accessibility is "private", the object can be
144
 
   *  accessed by members of this class, but not by other classes.
145
 
   *  \param oi The object info of the checked function/attribute/...
146
 
   *  \return The accessibility, i.e. private, public, protected, or none */
 
128
  /** Get the accessibility of a particular member or base class member.
 
129
   *  \param oi The semantic object for the member. */
147
130
  CProtection::Type Accessibility (CObjectInfo *oi) const;
148
131
  
149
 
  /** Returns true if the argument function overrides any virtual function
 
132
  /** Check if the given function overrides any virtual function
150
133
   *  defined in this class or any of its base classes.
151
 
   *  \param fi function info object of the checked function. */
 
134
   *  \param fi The function. */
152
135
  bool overridesVirtual (const CFunctionInfo *fi) const;
153
136
   
154
 
  /** Returns true if this class is an aggregate according to 8.5.1-1. */
 
137
  /** Check if this class is an aggregate according to 
 
138
   *  paragraph 8.5.1-1 of the ISO C++ standard. */
155
139
  bool isAggregate () const;
156
140
};
157
141
 
164
148
  _DepBaseClass (false)
165
149
 {}
166
150
 
167
 
inline CClassInfo *CClassInfo::BaseObject () const
168
 
 { return (CClassInfo*)CObjectInfo::BaseObject (); }
169
151
inline CTypeClass *CClassInfo::TypeInfo () const
170
152
 { return (CTypeClass*)CObjectInfo::TypeInfo (); }
171
153