xref: /aoo41x/main/autodoc/inc/ary/cpp/c_class.hxx (revision 1c78a5d6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ARY_CPP_C_CLASS_HXX
25 #define ARY_CPP_C_CLASS_HXX
26 
27 
28 
29 // USED SERVICES
30 	// BASE CLASSES
31 #include <ary/cpp/c_ce.hxx>
32 #include <ary/arygroup.hxx>
33 	// OTHER
34 #include <ary/symtreenode.hxx>
35 #include <ary/cessentl.hxx>
36 #include <ary/sequentialids.hxx>
37 #include <ary/cpp/c_types4cpp.hxx>
38 #include <ary/cpp/c_slntry.hxx>
39 
40 namespace ary
41 {
42 namespace cpp
43 {
44     class Enum;
45     class Typedef;
46     class Function;
47     class Variable;
48 }
49 }
50 
51 
52 
53 namespace ary
54 {
55 namespace cpp
56 {
57 
58 
59 /** A C++ class.
60 */
61 class Class : public CodeEntity,
62               public AryGroup
63 {
64   public:
65     enum E_ClassId { class_id = 1001 };
66 
67     enum E_Slots
68     {
69         SLOT_Bases = 1,
70         SLOT_NestedClasses,
71         SLOT_Enums,
72         SLOT_Typedefs,
73         SLOT_Operations,
74         SLOT_StaticOperations,
75         SLOT_Data,
76         SLOT_StaticData,
77         SLOT_FriendClasses,
78         SLOT_FriendOperations
79     };
80 
81     typedef ::ary::symtree::Node<CeNode_Traits>    node_t;
82 
83 
84 	// LIFECYCLE
85 						Class(
86                             const String  &     i_sLocalName,
87                             Ce_id               i_nOwner,
88                             E_Protection        i_eProtection,
89                             loc::Le_id          i_nFile,
90                             E_ClassKey          i_eClassKey );
91 						~Class();
92 
93 	// OPERATIONS
94 	void				Add_BaseClass(
95 							const S_Classes_Base &
96                                                 i_rBaseClass );
97     void                Add_TemplateParameterType(
98                             const String  &     i_sLocalName,
99                             Type_id             i_nIdAsType );
Add_KnownDerivative(Ce_id i_nId)100 	void				Add_KnownDerivative(
101 							Ce_id               i_nId )
102                                                 { aKnownDerivatives.Add(i_nId); }
103 
104 	void                Add_LocalClass(
105                             const String  &     i_sLocalName,
106                             Cid                 i_nId );
107 	void                Add_LocalEnum(
108                             const String  &     i_sLocalName,
109                             Cid                 i_nId );
110 	void                Add_LocalTypedef(
111                             const String  &     i_sLocalName,
112                             Cid                 i_nId );
113 	void                Add_LocalOperation(
114                             const String  &     i_sLocalName,
115                             Cid                 i_nId );
116 	void                Add_LocalStaticOperation(
117                             const String  &     i_sLocalName,
118                             Cid                 i_nId );
119 	void                Add_LocalData(
120                             const String  &     i_sLocalName,
121                             Cid                 i_nId );
122 	void                Add_LocalStaticData(
123                             const String  &     i_sLocalName,
124                             Cid                 i_nId );
125 
UpdateVirtuality(E_Virtuality i_eVirtuality)126     void                UpdateVirtuality(
127                             E_Virtuality        i_eVirtuality )
128                                                 { if ( int(i_eVirtuality) > int(eVirtuality) )
129                                                      eVirtuality = i_eVirtuality; }
130     const List_TplParam &
TemplateParameters() const131                         TemplateParameters() const
132                                                 { return aTemplateParameterTypes; }
BaseClasses() const133     const List_Bases &  BaseClasses() const     { return aBaseClasses; }
134     const SequentialIds<Ce_id> &
KnownDerivatives() const135                         KnownDerivatives() const
136                                                 { return aKnownDerivatives; }
137 
138 	// INQUIRY
139     E_ClassKey			ClassKey() const;
140     E_Protection        Protection() const;
Virtuality() const141     E_Virtuality        Virtuality() const      { return eVirtuality; }
142 
143     Ce_id               Search_Child(
144                             const String &      i_key ) const;
145     Rid                 Search_LocalClass(
146                             const String  &     i_sName ) const;
147     const node_t &      AsNode() const;
148 
149     // ACCESS
150     node_t &            AsNode();
151 
152   private:
153     NON_COPYABLE(Class);
154 
155     // Interface csv::ConstProcessorClient
156     virtual void        do_Accept(
157                             csv::ProcessorIfc & io_processor ) const;
158 
159     // Interface ary::cpp::CodeEntity
160 	virtual const String  &
161                         inq_LocalName() const;
162 	virtual Cid         inq_Owner() const;
163 	virtual loc::Le_id  inq_Location() const;
164 
165     // Interface ary::cpp::CppEntity
166     virtual ClassId     get_AryClass() const;
167 
168     // Interface ary::AryGroup
169 	virtual Gid 		inq_Id_Group() const;
170     virtual const cpp::CppEntity &
171                         inq_RE_Group() const;
172 	virtual const group::SlotList &
173                         inq_Slots() const;
174     virtual DYN Slot *  inq_Create_Slot(
175                             SlotAccessId        i_nSlot ) const;
176     // Local
177  	typedef List_LocalCe::const_iterator        CIterator_Locals;
178  	typedef List_LocalCe::iterator              Iterator_Locals;
179     typedef SequentialIds<Ce_id>                IdSequence;
180 
181     CIterator_Locals    PosOfName(
182                             const List_LocalCe& i_rList,
183                             const String  &     i_sName ) const;
184 	// DATA
185 	CeEssentials		aEssentials;
186 	node_t              aAssignedNode;
187 
188 	List_Bases			aBaseClasses;
189     List_TplParam       aTemplateParameterTypes;
190 
191     List_LocalCe        aClasses;
192     List_LocalCe        aEnums;
193     List_LocalCe        aTypedefs;
194     List_LocalCe        aOperations;
195     List_LocalCe        aStaticOperations;
196     List_LocalCe        aData;
197     List_LocalCe        aStaticData;
198 
199     IdSequence          aFriendClasses;
200     IdSequence          aFriendOperations;
201     IdSequence          aKnownDerivatives;
202 
203 	E_ClassKey			eClassKey;
204 	E_Protection		eProtection;
205     E_Virtuality        eVirtuality;
206 };
207 
208 
209 
210 
211 // IMPLEMENTATION
212 inline E_ClassKey
ClassKey() const213 Class::ClassKey() const
214 {
215     return eClassKey;
216 }
217 
218 inline E_Protection
Protection() const219 Class::Protection() const
220 {
221     return eProtection;
222 }
223 
224 inline const Class::node_t &
AsNode() const225 Class::AsNode() const
226 {
227     return aAssignedNode;
228 }
229 
230 inline Class::node_t &
AsNode()231 Class::AsNode()
232 {
233     return aAssignedNode;
234 }
235 
236 
237 
238 
239 }   //  namespace cpp
240 }   //  namespace ary
241 #endif
242