xref: /trunk/main/autodoc/inc/ary/cpp/c_class.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ARY_CPP_C_CLASS_HXX
29 #define ARY_CPP_C_CLASS_HXX
30 
31 
32 
33 // USED SERVICES
34     // BASE CLASSES
35 #include <ary/cpp/c_ce.hxx>
36 #include <ary/arygroup.hxx>
37     // OTHER
38 #include <ary/symtreenode.hxx>
39 #include <ary/cessentl.hxx>
40 #include <ary/sequentialids.hxx>
41 #include <ary/cpp/c_types4cpp.hxx>
42 #include <ary/cpp/c_slntry.hxx>
43 
44 namespace ary
45 {
46 namespace cpp
47 {
48     class Enum;
49     class Typedef;
50     class Function;
51     class Variable;
52 }
53 }
54 
55 
56 
57 namespace ary
58 {
59 namespace cpp
60 {
61 
62 
63 /** A C++ class.
64 */
65 class Class : public CodeEntity,
66               public AryGroup
67 {
68   public:
69     enum E_ClassId { class_id = 1001 };
70 
71     enum E_Slots
72     {
73         SLOT_Bases = 1,
74         SLOT_NestedClasses,
75         SLOT_Enums,
76         SLOT_Typedefs,
77         SLOT_Operations,
78         SLOT_StaticOperations,
79         SLOT_Data,
80         SLOT_StaticData,
81         SLOT_FriendClasses,
82         SLOT_FriendOperations
83     };
84 
85     typedef ::ary::symtree::Node<CeNode_Traits>    node_t;
86 
87 
88     // LIFECYCLE
89                         Class(
90                             const String  &     i_sLocalName,
91                             Ce_id               i_nOwner,
92                             E_Protection        i_eProtection,
93                             loc::Le_id          i_nFile,
94                             E_ClassKey          i_eClassKey );
95                         ~Class();
96 
97     // OPERATIONS
98     void                Add_BaseClass(
99                             const S_Classes_Base &
100                                                 i_rBaseClass );
101     void                Add_TemplateParameterType(
102                             const String  &     i_sLocalName,
103                             Type_id             i_nIdAsType );
104     void                Add_KnownDerivative(
105                             Ce_id               i_nId )
106                                                 { aKnownDerivatives.Add(i_nId); }
107 
108     void                Add_LocalClass(
109                             const String  &     i_sLocalName,
110                             Cid                 i_nId );
111     void                Add_LocalEnum(
112                             const String  &     i_sLocalName,
113                             Cid                 i_nId );
114     void                Add_LocalTypedef(
115                             const String  &     i_sLocalName,
116                             Cid                 i_nId );
117     void                Add_LocalOperation(
118                             const String  &     i_sLocalName,
119                             Cid                 i_nId );
120     void                Add_LocalStaticOperation(
121                             const String  &     i_sLocalName,
122                             Cid                 i_nId );
123     void                Add_LocalData(
124                             const String  &     i_sLocalName,
125                             Cid                 i_nId );
126     void                Add_LocalStaticData(
127                             const String  &     i_sLocalName,
128                             Cid                 i_nId );
129 
130     void                UpdateVirtuality(
131                             E_Virtuality        i_eVirtuality )
132                                                 { if ( int(i_eVirtuality) > int(eVirtuality) )
133                                                      eVirtuality = i_eVirtuality; }
134     const List_TplParam &
135                         TemplateParameters() const
136                                                 { return aTemplateParameterTypes; }
137     const List_Bases &  BaseClasses() const     { return aBaseClasses; }
138     const SequentialIds<Ce_id> &
139                         KnownDerivatives() const
140                                                 { return aKnownDerivatives; }
141 
142     // INQUIRY
143     E_ClassKey          ClassKey() const;
144     E_Protection        Protection() const;
145     E_Virtuality        Virtuality() const      { return eVirtuality; }
146 
147     Ce_id               Search_Child(
148                             const String &      i_key ) const;
149     Rid                 Search_LocalClass(
150                             const String  &     i_sName ) const;
151     const node_t &      AsNode() const;
152 
153     // ACCESS
154     node_t &            AsNode();
155 
156   private:
157     NON_COPYABLE(Class);
158 
159     // Interface csv::ConstProcessorClient
160     virtual void        do_Accept(
161                             csv::ProcessorIfc & io_processor ) const;
162 
163     // Interface ary::cpp::CodeEntity
164     virtual const String  &
165                         inq_LocalName() const;
166     virtual Cid         inq_Owner() const;
167     virtual loc::Le_id  inq_Location() const;
168 
169     // Interface ary::cpp::CppEntity
170     virtual ClassId     get_AryClass() const;
171 
172     // Interface ary::AryGroup
173     virtual Gid         inq_Id_Group() const;
174     virtual const cpp::CppEntity &
175                         inq_RE_Group() const;
176     virtual const group::SlotList &
177                         inq_Slots() const;
178     virtual DYN Slot *  inq_Create_Slot(
179                             SlotAccessId        i_nSlot ) const;
180     // Local
181     typedef List_LocalCe::const_iterator        CIterator_Locals;
182     typedef List_LocalCe::iterator              Iterator_Locals;
183     typedef SequentialIds<Ce_id>                IdSequence;
184 
185     CIterator_Locals    PosOfName(
186                             const List_LocalCe& i_rList,
187                             const String  &     i_sName ) const;
188     // DATA
189     CeEssentials        aEssentials;
190     node_t              aAssignedNode;
191 
192     List_Bases          aBaseClasses;
193     List_TplParam       aTemplateParameterTypes;
194 
195     List_LocalCe        aClasses;
196     List_LocalCe        aEnums;
197     List_LocalCe        aTypedefs;
198     List_LocalCe        aOperations;
199     List_LocalCe        aStaticOperations;
200     List_LocalCe        aData;
201     List_LocalCe        aStaticData;
202 
203     IdSequence          aFriendClasses;
204     IdSequence          aFriendOperations;
205     IdSequence          aKnownDerivatives;
206 
207     E_ClassKey          eClassKey;
208     E_Protection        eProtection;
209     E_Virtuality        eVirtuality;
210 };
211 
212 
213 
214 
215 // IMPLEMENTATION
216 inline E_ClassKey
217 Class::ClassKey() const
218 {
219     return eClassKey;
220 }
221 
222 inline E_Protection
223 Class::Protection() const
224 {
225     return eProtection;
226 }
227 
228 inline const Class::node_t &
229 Class::AsNode() const
230 {
231     return aAssignedNode;
232 }
233 
234 inline Class::node_t &
235 Class::AsNode()
236 {
237     return aAssignedNode;
238 }
239 
240 
241 
242 
243 }   //  namespace cpp
244 }   //  namespace ary
245 #endif
246