1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
33 // NOT FULLY DEFINED SERVICES
35 #include <cosv/tpl/tpltools.hxx>
36 #include <ary/idl/i_attribute.hxx>
37 #include <ary/idl/i_constant.hxx>
38 #include <ary/idl/i_constgroup.hxx>
39 #include <ary/idl/i_enum.hxx>
40 #include <ary/idl/i_enumvalue.hxx>
41 #include <ary/idl/i_exception.hxx>
42 #include <ary/idl/i_function.hxx>
43 #include <ary/idl/i_interface.hxx>
44 #include <ary/idl/i_module.hxx>
45 #include <ary/idl/i_namelookup.hxx>
46 #include <ary/idl/i_property.hxx>
47 #include <ary/idl/i_service.hxx>
48 #include <ary/idl/i_singleton.hxx>
49 #include <ary/idl/i_siservice.hxx>
50 #include <ary/idl/i_sisingleton.hxx>
51 #include <ary/idl/i_struct.hxx>
52 #include <ary/idl/i_structelem.hxx>
53 #include <ary/idl/i_traits.hxx>
54 #include <ary/idl/i_typedef.hxx>
56 #include "ia_type.hxx"
58 #include "it_tplparam.hxx"
69 CeAdmin::lhf_Access_Module( Ce_id i_nId
)
70 { return ary_cast
<Module
>(Storage()[i_nId
]); }
73 CeAdmin::lhf_Put2Storage_and_AssignId( CodeEntity
& pass_io_rCe
)
74 { // This also assigns an ID to pass_io_rCe:
75 Storage().Store_Entity(pass_io_rCe
);
76 my_NameDictionary().Add_Name( pass_io_rCe
.LocalName(),
78 pass_io_rCe
.AryClass(),
79 pass_io_rCe
.Owner() );
83 CeAdmin::lhf_Store_NewEntity( DYN CodeEntity
& pass_io_rCe
,
86 lhf_Put2Storage_and_AssignId(pass_io_rCe
);
87 i_rOwner
.Add_Name(pass_io_rCe
.LocalName(), pass_io_rCe
.CeId());
91 CeAdmin::lhf_Store_NewEntity( DYN CodeEntity
& pass_io_rCe
,
92 Ce_id i_nOwnerModule
)
94 lhf_Store_NewEntity(pass_io_rCe
, lhf_Access_Module(i_nOwnerModule
));
99 CeAdmin::CeAdmin( NameLookup
& io_rNameDictionary
,
100 TypeAdmin
& io_rTypePilot
)
101 : pStorage(new Ce_Storage
),
103 pNameDictionary(&io_rNameDictionary
),
104 pTypePilot(&io_rTypePilot
)
106 Storage().Set_Reserved(
107 predefined::ce_GlobalNamespace
,
109 pGlobalNamespace
= &lhf_Access_Module(Ce_id(predefined::ce_GlobalNamespace
));
119 CeAdmin::CheckIn_Module( Ce_id i_nParentId
,
120 const String
& i_sName
)
122 Module
& rOwner
= lhf_Access_Module(i_nParentId
);
123 Ce_id nId
= rOwner
.Search_Name(i_sName
);
126 return lhf_Access_Module(nId
);
129 Module
& ret
= *new Module( i_sName
,
131 lhf_Store_NewEntity(ret
, rOwner
);
136 CeAdmin::Store_Service( Ce_id i_nOwner
,
137 const String
& i_sName
)
139 Service
& ret
= *new Service( i_sName
,
141 lhf_Store_NewEntity(ret
, i_nOwner
);
146 CeAdmin::Store_SglIfcService( Ce_id i_nOwner
,
147 const String
& i_sName
,
148 Type_id i_nBaseInterface
)
151 ret
= *new SglIfcService( i_sName
,
154 lhf_Store_NewEntity(ret
, i_nOwner
);
159 CeAdmin::Store_Interface( Ce_id i_nOwner
,
160 const String
& i_sName
,
163 Interface
& ret
= *new Interface( i_sName
,
165 lhf_Store_NewEntity(ret
, i_nOwner
);
166 if (i_nBase
.IsValid())
167 ret
.Add_Base(i_nBase
, 0);
172 CeAdmin::Store_Struct( Ce_id i_nOwner
,
173 const String
& i_sName
,
175 const String
& i_sTemplateParam
)
177 if (NOT i_sTemplateParam
.empty())
179 return lhf_Store_TplStruct( i_nOwner
,
185 Struct
& ret
= *new Struct( i_sName
,
190 lhf_Store_NewEntity(ret
, i_nOwner
);
196 CeAdmin::Store_Exception( Ce_id i_nOwner
,
197 const String
& i_sName
,
200 Exception
& ret
= *new Exception( i_sName
,
203 lhf_Store_NewEntity(ret
, i_nOwner
);
208 CeAdmin::Store_Enum( Ce_id i_nOwner
,
209 const String
& i_sName
)
211 Enum
& ret
= *new Enum( i_sName
,
213 lhf_Store_NewEntity(ret
, i_nOwner
);
218 CeAdmin::Store_Typedef( Ce_id i_nOwner
,
219 const String
& i_sName
,
220 Type_id i_nDefiningType
)
222 Typedef
& ret
= *new Typedef( i_sName
,
225 lhf_Store_NewEntity(ret
, i_nOwner
);
231 CeAdmin::Store_ConstantsGroup( Ce_id i_nOwner
,
232 const String
& i_sName
)
234 ConstantsGroup
& ret
= *new ConstantsGroup( i_sName
,
236 lhf_Store_NewEntity(ret
, i_nOwner
);
241 CeAdmin::Store_Singleton( Ce_id i_nOwner
,
242 const String
& i_sName
)
244 Singleton
& ret
= *new Singleton( i_sName
,
246 lhf_Store_NewEntity(ret
, i_nOwner
);
251 CeAdmin::Store_SglIfcSingleton( Ce_id i_nOwner
,
252 const String
& i_sName
,
253 Type_id i_nBaseInterface
)
256 ret
= *new SglIfcSingleton( i_sName
,
259 lhf_Store_NewEntity(ret
, i_nOwner
);
264 CeAdmin::Store_Constant( Ce_id i_nOwner
,
265 const String
& i_sName
,
267 const String
& i_sValue
)
270 rOwner
= ary_cast
<ConstantsGroup
>(Storage()[i_nOwner
]);
271 Constant
& ret
= *new Constant( i_sName
,
276 lhf_Put2Storage_and_AssignId(ret
);
277 rOwner
.Add_Constant(ret
.CeId());
282 CeAdmin::Store_Property( Ce_id i_nOwner
,
283 const String
& i_sName
,
285 Property::Stereotypes i_stereotypes
)
288 rOwner
= ary_cast
<Service
>(Storage()[i_nOwner
]);
289 Property
& ret
= *new Property( i_sName
,
294 lhf_Put2Storage_and_AssignId(ret
);
295 rOwner
.Add_Property(ret
.CeId());
300 CeAdmin::Store_Function( Ce_id i_nOwner
,
301 const String
& i_sName
,
302 Type_id i_nReturnType
,
306 rOwner
= ary_cast
<Interface
>(Storage()[i_nOwner
]);
307 Function
& ret
= *new Function( i_sName
,
312 lhf_Put2Storage_and_AssignId(ret
);
313 rOwner
.Add_Function(ret
.CeId());
318 CeAdmin::Store_ServiceConstructor( Ce_id i_nOwner
,
319 const String
& i_sName
)
322 rOwner
= ary_cast
<SglIfcService
>(Storage()[i_nOwner
]);
323 Function
& ret
= *new Function( i_sName
,
326 lhf_Put2Storage_and_AssignId(ret
);
327 rOwner
.Add_Constructor(ret
.CeId());
332 CeAdmin::Store_StructMember( Ce_id i_nOwner
,
333 const String
& i_sName
,
337 rOwner
= ary_cast
<Struct
>(Storage()[i_nOwner
]);
338 StructElement
& ret
= *new StructElement( i_sName
,
342 lhf_Put2Storage_and_AssignId(ret
);
343 rOwner
.Add_Member(ret
.CeId());
348 CeAdmin::Store_ExceptionMember( Ce_id i_nOwner
,
349 const String
& i_sName
,
353 rOwner
= ary_cast
<Exception
>(Storage()[i_nOwner
]);
354 StructElement
& ret
= *new StructElement( i_sName
,
358 lhf_Put2Storage_and_AssignId(ret
);
359 rOwner
.Add_Member(ret
.CeId());
364 CeAdmin::Store_EnumValue( Ce_id i_nOwner
,
365 const String
& i_sName
,
366 const String
& i_sValue
)
369 rOwner
= ary_cast
<Enum
>(Storage()[i_nOwner
]);
370 EnumValue
& ret
= *new EnumValue( i_sName
,
374 lhf_Put2Storage_and_AssignId(ret
);
375 rOwner
.Add_Value(ret
.CeId());
380 CeAdmin::Store_Attribute( Ce_id i_nOwner
,
381 const String
& i_sName
,
387 rOwner
= ary_cast
<Interface
>(Storage()[i_nOwner
]);
389 Attribute
& ret
= *new Attribute ( i_sName
,
395 lhf_Put2Storage_and_AssignId(ret
);
396 rOwner
.Add_Attribute(ret
.CeId());
401 CeAdmin::GlobalNamespace() const
403 csv_assert(pGlobalNamespace
);
404 return *pGlobalNamespace
;
408 CeAdmin::Find_Ce( Ce_id i_nId
) const
410 return Storage()[i_nId
];
415 CeAdmin::Find_Module( Ce_id i_nId
) const
417 return ary_cast
<Module
>(Storage()[i_nId
]);
421 CeAdmin::Search_Module( Ce_id i_nId
) const
423 if (NOT i_nId
.IsValid())
425 return ary_cast
<Module
>( & Storage()[i_nId
] );
429 CeAdmin::Find_Function( Ce_id i_nId
) const
431 return ary_cast
<Function
>(Storage()[i_nId
]);
435 CeAdmin::Find_Property( Ce_id i_nId
) const
437 return ary_cast
<Property
>(Storage()[i_nId
]);
441 CeAdmin::Find_EnumValue( Ce_id i_nId
) const
443 return ary_cast
<EnumValue
>(Storage()[i_nId
]);
447 CeAdmin::Find_Constant( Ce_id i_nId
) const
449 return ary_cast
<Constant
>(Storage()[i_nId
]);
452 const StructElement
&
453 CeAdmin::Find_StructElement( Ce_id i_nId
) const
455 return ary_cast
<StructElement
>(Storage()[i_nId
]);
459 CeAdmin::Get_Text( StringVector
& o_module
,
462 const CodeEntity
& i_ce
) const
464 const CodeEntity
* pCe
= &i_ce
;
465 csv::erase_container(o_module
);
469 switch ( pCe
->SightLevel() )
471 // Here are intentionally no breaks!
473 if ( is_type
<Function
>(*pCe
) )
474 o_member
= StreamLock(200)()
479 o_member
= pCe
->LocalName();
480 pCe
= & Storage()[pCe
->Owner()];
482 o_ce
= pCe
->LocalName();
483 pCe
= & Storage()[pCe
->NameRoom()];
485 get_ModuleText(o_module
,*pCe
);
493 CeAdmin::NameDictionary() const
495 return *pNameDictionary
;
500 CeAdmin::Get_AlphabeticalIndex( std::vector
<Ce_id
> & o_rResult
,
501 alphabetical_index::E_Letter i_cLetter
) const
503 const int C_nLowerUpperDiff
= 'a'-'A';
505 // Establishing filter:
508 UINT8 nLetter
= static_cast<UINT8
>(i_cLetter
);
509 memset(filter
, 0, 256);
511 if ( i_cLetter
!= alphabetical_index::non_alpha
)
512 filter
[nLetter
- C_nLowerUpperDiff
] = 1;
514 // Gather entities which start with i_cLetter:
515 o_rResult
.reserve(1000);
516 idl::Ce_Storage::c_iter
517 itEnd
= Storage().End();
518 for ( idl::Ce_Storage::c_iter it
= Storage().BeginUnreserved();
522 if ( filter
[ static_cast<UINT8
>(*(*it
).LocalName().c_str()) ] == 1 )
523 o_rResult
.push_back( (*it
).CeId() );
526 std::sort( o_rResult
.begin(),
528 IdSorter
<Ce_Compare
>() );
533 CeAdmin::GlobalNamespace()
535 csv_assert(pGlobalNamespace
);
536 return *pGlobalNamespace
;
540 CeAdmin::Find_Ce( Ce_id i_nId
)
542 return Storage()[i_nId
];
546 CeAdmin::get_ModuleText( StringVector
& o_module
,
547 const CodeEntity
& i_ce
) const
549 if (i_ce
.NameRoom().IsValid())
552 rParent
= Storage()[i_ce
.NameRoom()];
553 get_ModuleText(o_module
, rParent
);
554 o_module
.push_back(i_ce
.LocalName());
559 CeAdmin::lhf_Store_TplStruct( Ce_id i_nOwner
,
560 const String
& i_sName
,
562 const String
& i_sTemplateParam
)
564 csv_assert(NOT i_sTemplateParam
.empty());
567 rTpt
= pTypePilot
->Store_TemplateParamType(i_sTemplateParam
);
569 Struct
& ret
= *new Struct( i_sName
,
574 lhf_Store_NewEntity(ret
, i_nOwner
);
575 rTpt
.Set_StructId(ret
.CeId());
584 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */