xref: /AOO41X/main/autodoc/source/ary/cpp/c_class.cxx (revision d291ea287686f95dc2fff9ad28612d818a1c6b1e)
1*d291ea28SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d291ea28SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d291ea28SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d291ea28SAndrew Rist  * distributed with this work for additional information
6*d291ea28SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d291ea28SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d291ea28SAndrew Rist  * "License"); you may not use this file except in compliance
9*d291ea28SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*d291ea28SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*d291ea28SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d291ea28SAndrew Rist  * software distributed under the License is distributed on an
15*d291ea28SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d291ea28SAndrew Rist  * KIND, either express or implied.  See the License for the
17*d291ea28SAndrew Rist  * specific language governing permissions and limitations
18*d291ea28SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*d291ea28SAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <ary/cpp/c_class.hxx>
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
27cdf0e10cSrcweir #include <slots.hxx>
28cdf0e10cSrcweir #include "c_slots.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace ary
33cdf0e10cSrcweir {
34cdf0e10cSrcweir namespace cpp
35cdf0e10cSrcweir {
36cdf0e10cSrcweir 
Class(const String & i_sLocalName,Ce_id i_nOwner,E_Protection i_eProtection,loc::Le_id i_nFile,E_ClassKey i_eClassKey)37cdf0e10cSrcweir Class::Class( const String  &     i_sLocalName,
38cdf0e10cSrcweir               Ce_id               i_nOwner,
39cdf0e10cSrcweir               E_Protection        i_eProtection,
40cdf0e10cSrcweir               loc::Le_id          i_nFile,
41cdf0e10cSrcweir               E_ClassKey          i_eClassKey )
42cdf0e10cSrcweir     :   aEssentials( i_sLocalName,
43cdf0e10cSrcweir                      i_nOwner,
44cdf0e10cSrcweir                      i_nFile ),
45cdf0e10cSrcweir 	    aAssignedNode(),
46cdf0e10cSrcweir    		aBaseClasses(),
47cdf0e10cSrcweir    		aTemplateParameterTypes(),
48cdf0e10cSrcweir         aClasses(),
49cdf0e10cSrcweir         aEnums(),
50cdf0e10cSrcweir         aTypedefs(),
51cdf0e10cSrcweir         aOperations(),
52cdf0e10cSrcweir         aStaticOperations(),
53cdf0e10cSrcweir         aData(),
54cdf0e10cSrcweir         aStaticData(),
55cdf0e10cSrcweir         aFriendClasses(),
56cdf0e10cSrcweir         aFriendOperations(),
57cdf0e10cSrcweir         aKnownDerivatives(),
58cdf0e10cSrcweir         eClassKey(i_eClassKey),
59cdf0e10cSrcweir         eProtection(i_eProtection),
60cdf0e10cSrcweir 		eVirtuality(VIRTUAL_none)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     aAssignedNode.Assign_Entity(*this);
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
~Class()65cdf0e10cSrcweir Class::~Class()
66cdf0e10cSrcweir {
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir void
Add_BaseClass(const S_Classes_Base & i_rBaseClass)70cdf0e10cSrcweir Class::Add_BaseClass( const S_Classes_Base & i_rBaseClass )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	aBaseClasses.push_back(i_rBaseClass);
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir void
Add_TemplateParameterType(const String & i_sLocalName,Type_id i_nIdAsType)76cdf0e10cSrcweir Class::Add_TemplateParameterType( const String  &     i_sLocalName,
77cdf0e10cSrcweir                                   Type_id             i_nIdAsType )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir     aTemplateParameterTypes.push_back(
80cdf0e10cSrcweir             List_TplParam::value_type(i_sLocalName,i_nIdAsType) );
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir void
Add_LocalClass(const String & i_sLocalName,Cid i_nId)84cdf0e10cSrcweir Class::Add_LocalClass( const String  &     i_sLocalName,
85cdf0e10cSrcweir                        Cid                 i_nId )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir     aClasses.push_back( S_LocalCe(i_sLocalName, i_nId) );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir void
Add_LocalEnum(const String & i_sLocalName,Cid i_nId)91cdf0e10cSrcweir Class::Add_LocalEnum( const String  &     i_sLocalName,
92cdf0e10cSrcweir                       Cid                 i_nId )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     aEnums.push_back( S_LocalCe(i_sLocalName, i_nId) );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir void
Add_LocalTypedef(const String & i_sLocalName,Cid i_nId)98cdf0e10cSrcweir Class::Add_LocalTypedef( const String  &     i_sLocalName,
99cdf0e10cSrcweir                          Cid                 i_nId )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     aTypedefs.push_back( S_LocalCe(i_sLocalName, i_nId) );
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir void
Add_LocalOperation(const String & i_sLocalName,Cid i_nId)105cdf0e10cSrcweir Class::Add_LocalOperation( const String  &          i_sLocalName,
106cdf0e10cSrcweir                            Cid                      i_nId )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir     aOperations.push_back( S_LocalCe(i_sLocalName, i_nId) );
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir void
Add_LocalStaticOperation(const String & i_sLocalName,Cid i_nId)112cdf0e10cSrcweir Class::Add_LocalStaticOperation( const String  &     i_sLocalName,
113cdf0e10cSrcweir                                  Cid                 i_nId )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     aStaticOperations.push_back( S_LocalCe(i_sLocalName, i_nId) );
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir void
Add_LocalData(const String & i_sLocalName,Cid i_nId)119cdf0e10cSrcweir Class::Add_LocalData( const String  &     i_sLocalName,
120cdf0e10cSrcweir                       Cid                 i_nId )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     aData.push_back( S_LocalCe(i_sLocalName, i_nId) );
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir void
Add_LocalStaticData(const String & i_sLocalName,Cid i_nId)126cdf0e10cSrcweir Class::Add_LocalStaticData( const String  &     i_sLocalName,
127cdf0e10cSrcweir                             Cid                 i_nId )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     aStaticData.push_back( S_LocalCe(i_sLocalName, i_nId) );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 
133cdf0e10cSrcweir struct find_name
134cdf0e10cSrcweir {
find_nameary::cpp::find_name135cdf0e10cSrcweir                         find_name(
136cdf0e10cSrcweir                             const String &      i_name )
137cdf0e10cSrcweir                             :   sName(i_name) {}
138cdf0e10cSrcweir 
operator ()ary::cpp::find_name139cdf0e10cSrcweir     bool                operator()(
140cdf0e10cSrcweir                             const S_LocalCe &   i_lce ) const
141cdf0e10cSrcweir                             { return i_lce.sLocalName == sName; }
142cdf0e10cSrcweir   private:
143cdf0e10cSrcweir     String              sName;
144cdf0e10cSrcweir };
145cdf0e10cSrcweir 
146cdf0e10cSrcweir Ce_id
Search_Child(const String & i_key) const147cdf0e10cSrcweir Class::Search_Child(const String & i_key) const
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     Ce_id
150cdf0e10cSrcweir         ret = Ce_id(Search_LocalClass(i_key));
151cdf0e10cSrcweir     if (ret.IsValid())
152cdf0e10cSrcweir         return ret;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     CIterator_Locals
155cdf0e10cSrcweir         itret = std::find_if(aEnums.begin(), aEnums.end(), find_name(i_key));
156cdf0e10cSrcweir     if (itret != aEnums.end())
157cdf0e10cSrcweir         return (*itret).nId;
158cdf0e10cSrcweir     itret = std::find_if(aTypedefs.begin(), aTypedefs.end(), find_name(i_key));
159cdf0e10cSrcweir     if (itret != aTypedefs.end())
160cdf0e10cSrcweir         return (*itret).nId;
161cdf0e10cSrcweir     itret = std::find_if(aData.begin(), aData.end(), find_name(i_key));
162cdf0e10cSrcweir     if (itret != aData.end())
163cdf0e10cSrcweir         return (*itret).nId;
164cdf0e10cSrcweir     itret = std::find_if(aStaticData.begin(), aStaticData.end(), find_name(i_key));
165cdf0e10cSrcweir     if (itret != aStaticData.end())
166cdf0e10cSrcweir         return (*itret).nId;
167cdf0e10cSrcweir     return Ce_id(0);
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir Rid
Search_LocalClass(const String & i_sName) const171cdf0e10cSrcweir Class::Search_LocalClass( const String  & i_sName ) const
172cdf0e10cSrcweir {
173cdf0e10cSrcweir  	CIterator_Locals itFound = PosOfName(aClasses, i_sName);
174cdf0e10cSrcweir     if (itFound != aClasses.end())
175cdf0e10cSrcweir         return (*itFound).nId.Value();
176cdf0e10cSrcweir     return 0;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir const String  &
inq_LocalName() const180cdf0e10cSrcweir Class::inq_LocalName() const
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	return aEssentials.LocalName();
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir Cid
inq_Owner() const186cdf0e10cSrcweir Class::inq_Owner() const
187cdf0e10cSrcweir {
188cdf0e10cSrcweir 	return aEssentials.Owner();
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir loc::Le_id
inq_Location() const192cdf0e10cSrcweir Class::inq_Location() const
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	return aEssentials.Location();
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir void
do_Accept(csv::ProcessorIfc & io_processor) const198cdf0e10cSrcweir Class::do_Accept(csv::ProcessorIfc & io_processor) const
199cdf0e10cSrcweir {
200cdf0e10cSrcweir     csv::CheckedCall(io_processor,*this);
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir ClassId
get_AryClass() const204cdf0e10cSrcweir Class::get_AryClass() const
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	return class_id;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir Gid
inq_Id_Group() const210cdf0e10cSrcweir Class::inq_Id_Group() const
211cdf0e10cSrcweir {
212cdf0e10cSrcweir  	return static_cast<Gid>(Id());
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir const ary::cpp::CppEntity &
inq_RE_Group() const216cdf0e10cSrcweir Class::inq_RE_Group() const
217cdf0e10cSrcweir {
218cdf0e10cSrcweir  	return *this;
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir const group::SlotList &
inq_Slots() const222cdf0e10cSrcweir Class::inq_Slots() const
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     static const SlotAccessId aProjectSlotData[]
225cdf0e10cSrcweir             = { SLOT_Bases,
226cdf0e10cSrcweir                 SLOT_NestedClasses,
227cdf0e10cSrcweir                 SLOT_Enums,
228cdf0e10cSrcweir                 SLOT_Typedefs,
229cdf0e10cSrcweir                 SLOT_Operations,
230cdf0e10cSrcweir                 SLOT_StaticOperations,
231cdf0e10cSrcweir                 SLOT_Data,
232cdf0e10cSrcweir                 SLOT_StaticData,
233cdf0e10cSrcweir                 SLOT_FriendClasses,
234cdf0e10cSrcweir                 SLOT_FriendOperations };
235cdf0e10cSrcweir     static const std::vector< SlotAccessId >
236cdf0e10cSrcweir             aSlots( &aProjectSlotData[0],
237cdf0e10cSrcweir                       &aProjectSlotData[0]
238cdf0e10cSrcweir                         + sizeof aProjectSlotData / sizeof (SlotAccessId) );
239cdf0e10cSrcweir     return aSlots;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 
243cdf0e10cSrcweir DYN Slot *
inq_Create_Slot(SlotAccessId i_nSlot) const244cdf0e10cSrcweir Class::inq_Create_Slot( SlotAccessId i_nSlot ) const
245cdf0e10cSrcweir {
246cdf0e10cSrcweir     switch ( i_nSlot )
247cdf0e10cSrcweir     {
248cdf0e10cSrcweir         case SLOT_Bases:                return new Slot_BaseClass(aBaseClasses);
249cdf0e10cSrcweir         case SLOT_NestedClasses:        return new Slot_ListLocalCe(aClasses);
250cdf0e10cSrcweir         case SLOT_Enums:                return new Slot_ListLocalCe(aEnums);
251cdf0e10cSrcweir         case SLOT_Typedefs:             return new Slot_ListLocalCe(aTypedefs);
252cdf0e10cSrcweir         case SLOT_Operations:           return new Slot_ListLocalCe(aOperations);
253cdf0e10cSrcweir         case SLOT_StaticOperations:     return new Slot_ListLocalCe(aStaticOperations);
254cdf0e10cSrcweir         case SLOT_Data:                 return new Slot_ListLocalCe(aData);
255cdf0e10cSrcweir         case SLOT_StaticData:           return new Slot_ListLocalCe(aStaticData);
256cdf0e10cSrcweir         case SLOT_FriendClasses:        return new Slot_SequentialIds<Ce_id>(aFriendClasses);
257cdf0e10cSrcweir         case SLOT_FriendOperations:     return new Slot_SequentialIds<Ce_id>(aFriendOperations);
258cdf0e10cSrcweir         default:
259cdf0e10cSrcweir                                         return new Slot_Null;
260cdf0e10cSrcweir     }   // end switch
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir Class::CIterator_Locals
PosOfName(const List_LocalCe & i_rList,const String & i_sName) const264cdf0e10cSrcweir Class::PosOfName( const List_LocalCe &  i_rList,
265cdf0e10cSrcweir                   const String  &       i_sName ) const
266cdf0e10cSrcweir {
267cdf0e10cSrcweir     for ( CIterator_Locals ret = i_rList.begin();
268cdf0e10cSrcweir           ret != i_rList.end();
269cdf0e10cSrcweir           ++ret )
270cdf0e10cSrcweir     {
271cdf0e10cSrcweir      	if ( (*ret).sLocalName == i_sName )
272cdf0e10cSrcweir             return ret;
273cdf0e10cSrcweir     }
274cdf0e10cSrcweir     return i_rList.end();
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir }   //  namespace   cpp
278cdf0e10cSrcweir }   //  namespace   ary
279