Update ooo320-m1
[ooovba.git] / autodoc / source / ary / cpp / c_class.cxx
blob179675144d13cb50ed719e0e9874bf752bef781e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: c_class.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include <ary/cpp/c_class.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <slots.hxx>
37 #include "c_slots.hxx"
41 namespace ary
43 namespace cpp
46 Class::Class( const String & i_sLocalName,
47 Ce_id i_nOwner,
48 E_Protection i_eProtection,
49 loc::Le_id i_nFile,
50 E_ClassKey i_eClassKey )
51 : aEssentials( i_sLocalName,
52 i_nOwner,
53 i_nFile ),
54 aAssignedNode(),
55 aBaseClasses(),
56 aTemplateParameterTypes(),
57 aClasses(),
58 aEnums(),
59 aTypedefs(),
60 aOperations(),
61 aStaticOperations(),
62 aData(),
63 aStaticData(),
64 aFriendClasses(),
65 aFriendOperations(),
66 aKnownDerivatives(),
67 eClassKey(i_eClassKey),
68 eProtection(i_eProtection),
69 eVirtuality(VIRTUAL_none)
71 aAssignedNode.Assign_Entity(*this);
74 Class::~Class()
78 void
79 Class::Add_BaseClass( const S_Classes_Base & i_rBaseClass )
81 aBaseClasses.push_back(i_rBaseClass);
84 void
85 Class::Add_TemplateParameterType( const String & i_sLocalName,
86 Type_id i_nIdAsType )
88 aTemplateParameterTypes.push_back(
89 List_TplParam::value_type(i_sLocalName,i_nIdAsType) );
92 void
93 Class::Add_LocalClass( const String & i_sLocalName,
94 Cid i_nId )
96 aClasses.push_back( S_LocalCe(i_sLocalName, i_nId) );
99 void
100 Class::Add_LocalEnum( const String & i_sLocalName,
101 Cid i_nId )
103 aEnums.push_back( S_LocalCe(i_sLocalName, i_nId) );
106 void
107 Class::Add_LocalTypedef( const String & i_sLocalName,
108 Cid i_nId )
110 aTypedefs.push_back( S_LocalCe(i_sLocalName, i_nId) );
113 void
114 Class::Add_LocalOperation( const String & i_sLocalName,
115 Cid i_nId )
117 aOperations.push_back( S_LocalCe(i_sLocalName, i_nId) );
120 void
121 Class::Add_LocalStaticOperation( const String & i_sLocalName,
122 Cid i_nId )
124 aStaticOperations.push_back( S_LocalCe(i_sLocalName, i_nId) );
127 void
128 Class::Add_LocalData( const String & i_sLocalName,
129 Cid i_nId )
131 aData.push_back( S_LocalCe(i_sLocalName, i_nId) );
134 void
135 Class::Add_LocalStaticData( const String & i_sLocalName,
136 Cid i_nId )
138 aStaticData.push_back( S_LocalCe(i_sLocalName, i_nId) );
142 struct find_name
144 find_name(
145 const String & i_name )
146 : sName(i_name) {}
148 bool operator()(
149 const S_LocalCe & i_lce ) const
150 { return i_lce.sLocalName == sName; }
151 private:
152 String sName;
155 Ce_id
156 Class::Search_Child(const String & i_key) const
158 Ce_id
159 ret = Ce_id(Search_LocalClass(i_key));
160 if (ret.IsValid())
161 return ret;
163 CIterator_Locals
164 itret = std::find_if(aEnums.begin(), aEnums.end(), find_name(i_key));
165 if (itret != aEnums.end())
166 return (*itret).nId;
167 itret = std::find_if(aTypedefs.begin(), aTypedefs.end(), find_name(i_key));
168 if (itret != aTypedefs.end())
169 return (*itret).nId;
170 itret = std::find_if(aData.begin(), aData.end(), find_name(i_key));
171 if (itret != aData.end())
172 return (*itret).nId;
173 itret = std::find_if(aStaticData.begin(), aStaticData.end(), find_name(i_key));
174 if (itret != aStaticData.end())
175 return (*itret).nId;
176 return Ce_id(0);
180 Class::Search_LocalClass( const String & i_sName ) const
182 CIterator_Locals itFound = PosOfName(aClasses, i_sName);
183 if (itFound != aClasses.end())
184 return (*itFound).nId.Value();
185 return 0;
188 const String &
189 Class::inq_LocalName() const
191 return aEssentials.LocalName();
195 Class::inq_Owner() const
197 return aEssentials.Owner();
200 loc::Le_id
201 Class::inq_Location() const
203 return aEssentials.Location();
206 void
207 Class::do_Accept(csv::ProcessorIfc & io_processor) const
209 csv::CheckedCall(io_processor,*this);
212 ClassId
213 Class::get_AryClass() const
215 return class_id;
219 Class::inq_Id_Group() const
221 return static_cast<Gid>(Id());
224 const ary::cpp::CppEntity &
225 Class::inq_RE_Group() const
227 return *this;
230 const group::SlotList &
231 Class::inq_Slots() const
233 static const SlotAccessId aProjectSlotData[]
234 = { SLOT_Bases,
235 SLOT_NestedClasses,
236 SLOT_Enums,
237 SLOT_Typedefs,
238 SLOT_Operations,
239 SLOT_StaticOperations,
240 SLOT_Data,
241 SLOT_StaticData,
242 SLOT_FriendClasses,
243 SLOT_FriendOperations };
244 static const std::vector< SlotAccessId >
245 aSlots( &aProjectSlotData[0],
246 &aProjectSlotData[0]
247 + sizeof aProjectSlotData / sizeof (SlotAccessId) );
248 return aSlots;
252 DYN Slot *
253 Class::inq_Create_Slot( SlotAccessId i_nSlot ) const
255 switch ( i_nSlot )
257 case SLOT_Bases: return new Slot_BaseClass(aBaseClasses);
258 case SLOT_NestedClasses: return new Slot_ListLocalCe(aClasses);
259 case SLOT_Enums: return new Slot_ListLocalCe(aEnums);
260 case SLOT_Typedefs: return new Slot_ListLocalCe(aTypedefs);
261 case SLOT_Operations: return new Slot_ListLocalCe(aOperations);
262 case SLOT_StaticOperations: return new Slot_ListLocalCe(aStaticOperations);
263 case SLOT_Data: return new Slot_ListLocalCe(aData);
264 case SLOT_StaticData: return new Slot_ListLocalCe(aStaticData);
265 case SLOT_FriendClasses: return new Slot_SequentialIds<Ce_id>(aFriendClasses);
266 case SLOT_FriendOperations: return new Slot_SequentialIds<Ce_id>(aFriendOperations);
267 default:
268 return new Slot_Null;
269 } // end switch
272 Class::CIterator_Locals
273 Class::PosOfName( const List_LocalCe & i_rList,
274 const String & i_sName ) const
276 for ( CIterator_Locals ret = i_rList.begin();
277 ret != i_rList.end();
278 ++ret )
280 if ( (*ret).sLocalName == i_sName )
281 return ret;
283 return i_rList.end();
286 } // namespace cpp
287 } // namespace ary