xref: /AOO41X/main/autodoc/source/ary/cpp/c_class.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <precomp.h>
29*cdf0e10cSrcweir #include <ary/cpp/c_class.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
33*cdf0e10cSrcweir #include <slots.hxx>
34*cdf0e10cSrcweir #include "c_slots.hxx"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir namespace ary
39*cdf0e10cSrcweir {
40*cdf0e10cSrcweir namespace cpp
41*cdf0e10cSrcweir {
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir Class::Class( const String  &     i_sLocalName,
44*cdf0e10cSrcweir               Ce_id               i_nOwner,
45*cdf0e10cSrcweir               E_Protection        i_eProtection,
46*cdf0e10cSrcweir               loc::Le_id          i_nFile,
47*cdf0e10cSrcweir               E_ClassKey          i_eClassKey )
48*cdf0e10cSrcweir     :   aEssentials( i_sLocalName,
49*cdf0e10cSrcweir                      i_nOwner,
50*cdf0e10cSrcweir                      i_nFile ),
51*cdf0e10cSrcweir 	    aAssignedNode(),
52*cdf0e10cSrcweir    		aBaseClasses(),
53*cdf0e10cSrcweir    		aTemplateParameterTypes(),
54*cdf0e10cSrcweir         aClasses(),
55*cdf0e10cSrcweir         aEnums(),
56*cdf0e10cSrcweir         aTypedefs(),
57*cdf0e10cSrcweir         aOperations(),
58*cdf0e10cSrcweir         aStaticOperations(),
59*cdf0e10cSrcweir         aData(),
60*cdf0e10cSrcweir         aStaticData(),
61*cdf0e10cSrcweir         aFriendClasses(),
62*cdf0e10cSrcweir         aFriendOperations(),
63*cdf0e10cSrcweir         aKnownDerivatives(),
64*cdf0e10cSrcweir         eClassKey(i_eClassKey),
65*cdf0e10cSrcweir         eProtection(i_eProtection),
66*cdf0e10cSrcweir 		eVirtuality(VIRTUAL_none)
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir     aAssignedNode.Assign_Entity(*this);
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir Class::~Class()
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir void
76*cdf0e10cSrcweir Class::Add_BaseClass( const S_Classes_Base & i_rBaseClass )
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	aBaseClasses.push_back(i_rBaseClass);
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir void
82*cdf0e10cSrcweir Class::Add_TemplateParameterType( const String  &     i_sLocalName,
83*cdf0e10cSrcweir                                   Type_id             i_nIdAsType )
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir     aTemplateParameterTypes.push_back(
86*cdf0e10cSrcweir             List_TplParam::value_type(i_sLocalName,i_nIdAsType) );
87*cdf0e10cSrcweir }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir void
90*cdf0e10cSrcweir Class::Add_LocalClass( const String  &     i_sLocalName,
91*cdf0e10cSrcweir                        Cid                 i_nId )
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir     aClasses.push_back( S_LocalCe(i_sLocalName, i_nId) );
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir void
97*cdf0e10cSrcweir Class::Add_LocalEnum( const String  &     i_sLocalName,
98*cdf0e10cSrcweir                       Cid                 i_nId )
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir     aEnums.push_back( S_LocalCe(i_sLocalName, i_nId) );
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir void
104*cdf0e10cSrcweir Class::Add_LocalTypedef( const String  &     i_sLocalName,
105*cdf0e10cSrcweir                          Cid                 i_nId )
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir     aTypedefs.push_back( S_LocalCe(i_sLocalName, i_nId) );
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir void
111*cdf0e10cSrcweir Class::Add_LocalOperation( const String  &          i_sLocalName,
112*cdf0e10cSrcweir                            Cid                      i_nId )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     aOperations.push_back( S_LocalCe(i_sLocalName, i_nId) );
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir void
118*cdf0e10cSrcweir Class::Add_LocalStaticOperation( const String  &     i_sLocalName,
119*cdf0e10cSrcweir                                  Cid                 i_nId )
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir     aStaticOperations.push_back( S_LocalCe(i_sLocalName, i_nId) );
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir void
125*cdf0e10cSrcweir Class::Add_LocalData( const String  &     i_sLocalName,
126*cdf0e10cSrcweir                       Cid                 i_nId )
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir     aData.push_back( S_LocalCe(i_sLocalName, i_nId) );
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir void
132*cdf0e10cSrcweir Class::Add_LocalStaticData( const String  &     i_sLocalName,
133*cdf0e10cSrcweir                             Cid                 i_nId )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     aStaticData.push_back( S_LocalCe(i_sLocalName, i_nId) );
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir struct find_name
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir                         find_name(
142*cdf0e10cSrcweir                             const String &      i_name )
143*cdf0e10cSrcweir                             :   sName(i_name) {}
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     bool                operator()(
146*cdf0e10cSrcweir                             const S_LocalCe &   i_lce ) const
147*cdf0e10cSrcweir                             { return i_lce.sLocalName == sName; }
148*cdf0e10cSrcweir   private:
149*cdf0e10cSrcweir     String              sName;
150*cdf0e10cSrcweir };
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir Ce_id
153*cdf0e10cSrcweir Class::Search_Child(const String & i_key) const
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir     Ce_id
156*cdf0e10cSrcweir         ret = Ce_id(Search_LocalClass(i_key));
157*cdf0e10cSrcweir     if (ret.IsValid())
158*cdf0e10cSrcweir         return ret;
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     CIterator_Locals
161*cdf0e10cSrcweir         itret = std::find_if(aEnums.begin(), aEnums.end(), find_name(i_key));
162*cdf0e10cSrcweir     if (itret != aEnums.end())
163*cdf0e10cSrcweir         return (*itret).nId;
164*cdf0e10cSrcweir     itret = std::find_if(aTypedefs.begin(), aTypedefs.end(), find_name(i_key));
165*cdf0e10cSrcweir     if (itret != aTypedefs.end())
166*cdf0e10cSrcweir         return (*itret).nId;
167*cdf0e10cSrcweir     itret = std::find_if(aData.begin(), aData.end(), find_name(i_key));
168*cdf0e10cSrcweir     if (itret != aData.end())
169*cdf0e10cSrcweir         return (*itret).nId;
170*cdf0e10cSrcweir     itret = std::find_if(aStaticData.begin(), aStaticData.end(), find_name(i_key));
171*cdf0e10cSrcweir     if (itret != aStaticData.end())
172*cdf0e10cSrcweir         return (*itret).nId;
173*cdf0e10cSrcweir     return Ce_id(0);
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir Rid
177*cdf0e10cSrcweir Class::Search_LocalClass( const String  & i_sName ) const
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir  	CIterator_Locals itFound = PosOfName(aClasses, i_sName);
180*cdf0e10cSrcweir     if (itFound != aClasses.end())
181*cdf0e10cSrcweir         return (*itFound).nId.Value();
182*cdf0e10cSrcweir     return 0;
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir const String  &
186*cdf0e10cSrcweir Class::inq_LocalName() const
187*cdf0e10cSrcweir {
188*cdf0e10cSrcweir 	return aEssentials.LocalName();
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir Cid
192*cdf0e10cSrcweir Class::inq_Owner() const
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir 	return aEssentials.Owner();
195*cdf0e10cSrcweir }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir loc::Le_id
198*cdf0e10cSrcweir Class::inq_Location() const
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir 	return aEssentials.Location();
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir void
204*cdf0e10cSrcweir Class::do_Accept(csv::ProcessorIfc & io_processor) const
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir     csv::CheckedCall(io_processor,*this);
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir ClassId
210*cdf0e10cSrcweir Class::get_AryClass() const
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir 	return class_id;
213*cdf0e10cSrcweir }
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir Gid
216*cdf0e10cSrcweir Class::inq_Id_Group() const
217*cdf0e10cSrcweir {
218*cdf0e10cSrcweir  	return static_cast<Gid>(Id());
219*cdf0e10cSrcweir }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir const ary::cpp::CppEntity &
222*cdf0e10cSrcweir Class::inq_RE_Group() const
223*cdf0e10cSrcweir {
224*cdf0e10cSrcweir  	return *this;
225*cdf0e10cSrcweir }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir const group::SlotList &
228*cdf0e10cSrcweir Class::inq_Slots() const
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir     static const SlotAccessId aProjectSlotData[]
231*cdf0e10cSrcweir             = { SLOT_Bases,
232*cdf0e10cSrcweir                 SLOT_NestedClasses,
233*cdf0e10cSrcweir                 SLOT_Enums,
234*cdf0e10cSrcweir                 SLOT_Typedefs,
235*cdf0e10cSrcweir                 SLOT_Operations,
236*cdf0e10cSrcweir                 SLOT_StaticOperations,
237*cdf0e10cSrcweir                 SLOT_Data,
238*cdf0e10cSrcweir                 SLOT_StaticData,
239*cdf0e10cSrcweir                 SLOT_FriendClasses,
240*cdf0e10cSrcweir                 SLOT_FriendOperations };
241*cdf0e10cSrcweir     static const std::vector< SlotAccessId >
242*cdf0e10cSrcweir             aSlots( &aProjectSlotData[0],
243*cdf0e10cSrcweir                       &aProjectSlotData[0]
244*cdf0e10cSrcweir                         + sizeof aProjectSlotData / sizeof (SlotAccessId) );
245*cdf0e10cSrcweir     return aSlots;
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir DYN Slot *
250*cdf0e10cSrcweir Class::inq_Create_Slot( SlotAccessId i_nSlot ) const
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir     switch ( i_nSlot )
253*cdf0e10cSrcweir     {
254*cdf0e10cSrcweir         case SLOT_Bases:                return new Slot_BaseClass(aBaseClasses);
255*cdf0e10cSrcweir         case SLOT_NestedClasses:        return new Slot_ListLocalCe(aClasses);
256*cdf0e10cSrcweir         case SLOT_Enums:                return new Slot_ListLocalCe(aEnums);
257*cdf0e10cSrcweir         case SLOT_Typedefs:             return new Slot_ListLocalCe(aTypedefs);
258*cdf0e10cSrcweir         case SLOT_Operations:           return new Slot_ListLocalCe(aOperations);
259*cdf0e10cSrcweir         case SLOT_StaticOperations:     return new Slot_ListLocalCe(aStaticOperations);
260*cdf0e10cSrcweir         case SLOT_Data:                 return new Slot_ListLocalCe(aData);
261*cdf0e10cSrcweir         case SLOT_StaticData:           return new Slot_ListLocalCe(aStaticData);
262*cdf0e10cSrcweir         case SLOT_FriendClasses:        return new Slot_SequentialIds<Ce_id>(aFriendClasses);
263*cdf0e10cSrcweir         case SLOT_FriendOperations:     return new Slot_SequentialIds<Ce_id>(aFriendOperations);
264*cdf0e10cSrcweir         default:
265*cdf0e10cSrcweir                                         return new Slot_Null;
266*cdf0e10cSrcweir     }   // end switch
267*cdf0e10cSrcweir }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir Class::CIterator_Locals
270*cdf0e10cSrcweir Class::PosOfName( const List_LocalCe &  i_rList,
271*cdf0e10cSrcweir                   const String  &       i_sName ) const
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir     for ( CIterator_Locals ret = i_rList.begin();
274*cdf0e10cSrcweir           ret != i_rList.end();
275*cdf0e10cSrcweir           ++ret )
276*cdf0e10cSrcweir     {
277*cdf0e10cSrcweir      	if ( (*ret).sLocalName == i_sName )
278*cdf0e10cSrcweir             return ret;
279*cdf0e10cSrcweir     }
280*cdf0e10cSrcweir     return i_rList.end();
281*cdf0e10cSrcweir }
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir }   //  namespace   cpp
284*cdf0e10cSrcweir }   //  namespace   ary
285