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 #include <precomp.h>
23 #include "hfi_service.hxx"
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/idl/i_ce.hxx>
28 #include <ary/idl/ik_property.hxx>
29 #include <ary/idl/ik_service.hxx>
30 #include <toolkit/hf_docentry.hxx>
31 #include <toolkit/hf_linachain.hxx>
32 #include <toolkit/hf_navi_sub.hxx>
33 #include <toolkit/hf_title.hxx>
34 #include "hfi_doc.hxx"
35 #include "hfi_navibar.hxx"
36 #include "hfi_property.hxx"
37 #include "hfi_tag.hxx"
38 #include "hfi_typetext.hxx"
39 #include "hi_linkhelper.hxx"
40 
41 
42 
43 
44 extern const String
45     C_sCePrefix_Service("service");
46 
47 namespace
48 {
49 
50 const String
51     C_sList_IncludedServices("Services' Summary");
52 const String
53     C_sList_IncludedServices_Heading("Included Services - Summary");
54 const String
55     C_sList_IncludedServices_Label("ServicesSummary");
56 const String
57     C_sList_IncludedServicesDetails("Services' Details");
58 const String
59     C_sList_IncludedServicesDetails_Heading("Included Services - Details");
60 const String
61     C_sList_IncludedServicesDetails_Label("ServicesDetails");
62 const String
63     C_sList_ExportedInterfaces("Interfaces' Summary");
64 const String
65     C_sList_ExportedInterfaces_Heading("Exported Interfaces - Summary");
66 const String
67     C_sList_ExportedInterfaces_Label("InterfacesSummary");
68 const String
69     C_sList_ExportedInterfacesDetails("Interfaces' Details");
70 const String
71     C_sList_ExportedInterfacesDetails_Heading("Exported Interfaces - Details");
72 const String
73     C_sList_ExportedInterfacesDetails_Label("InterfacesDetails");
74 const String
75     C_sList_Properties("Properties' Summary");
76 const String
77     C_sList_Properties_Label("PropertiesSummary");
78 const String
79     C_sList_PropertiesDetails("Properties' Details");
80 const String
81     C_sList_PropertiesDetails_Label("PropertiesDetails");
82 
83 
84 enum E_SubListIndices
85 {
86     sli_IncludedServicesSummary = 0,
87     sli_InterfacesSummary = 1,
88     sli_PropertiesSummary = 2,
89     sli_IncludedServicesDetails = 3,
90     sli_InterfacesDetails = 4,
91     sli_PropertiesDetails = 5
92 };
93 
94 } //anonymous namespace
95 
96 
HF_IdlService(Environment & io_rEnv,Xml::Element & o_rOut)97 HF_IdlService::HF_IdlService( Environment &         io_rEnv,
98                               Xml::Element &        o_rOut )
99     :   HtmlFactory_Idl(io_rEnv, &o_rOut)
100 {
101 }
102 
~HF_IdlService()103 HF_IdlService::~HF_IdlService()
104 {
105 
106 }
107 
108 typedef ::ary::idl::ifc_service::attr
109     ServiceAttr;
110 typedef ::ary::Dyn_StdConstIterator< ::ary::idl::CommentedRelation >
111     dyn_comref_list;
112 
113 void
produce_CommentedRelations(const client & i_ce,comref_list & it_list,const String & i_summaryTitle,const String & i_summaryLabel,const String & i_detailsTitle,const String & i_detailsLabel,const E_DocType i_docType) const114 HF_IdlService::produce_CommentedRelations( const client &   i_ce,
115                                            comref_list &    it_list,
116                                            const String &   i_summaryTitle,
117                                            const String &   i_summaryLabel,
118                                            const String &   i_detailsTitle,
119                                            const String &   i_detailsLabel,
120                                            const E_DocType  i_docType ) const
121 {
122     csv_assert( it_list );
123 
124     bool bSummaryOnly = ( i_docType == doctype_summaryOnly );
125     HF_SubTitleTable aTable(
126                 CurOut(),
127                 bSummaryOnly ? i_summaryLabel : i_detailsLabel,
128                 bSummaryOnly ? i_summaryTitle : i_detailsTitle,
129                 2 );
130 
131     for ( ; it_list; ++it_list )
132     {
133         Xml::Element &
134             rRow = aTable.Add_Row();
135 
136         if ( bSummaryOnly )
137         {
138             produce_Link(rRow, (*it_list).Type());
139             produce_LinkSummary(i_ce, rRow, *it_list);
140         }
141         else
142         {
143             HF_IdlCommentedRelationElement
144                 aRelation( Env(), aTable, *it_list );
145             aRelation.Produce_byData( i_ce );
146         }
147     }   // end for
148 }
149 
150 void
Produce_byData(const client & i_ce) const151 HF_IdlService::Produce_byData( const client & i_ce ) const
152 {
153     Dyn<HF_NaviSubRow>
154         pNaviSubRow( &make_Navibar(i_ce) );
155 
156     HF_TitleTable
157         aTitle(CurOut());
158     HF_LinkedNameChain
159         aNameChain(aTitle.Add_Row());
160 
161     aNameChain.Produce_CompleteChain(Env().CurPosition(), nameChainLinker);
162     produce_Title(aTitle, C_sCePrefix_Service, i_ce);
163 
164     write_Docu(aTitle.Add_Row(), i_ce);
165     CurOut() << new Html::HorizontalLine();
166 
167     // produce ...
168     // - included services: summary
169     dyn_comref_list dpIncludedServices;
170     ServiceAttr::Get_IncludedServices(dpIncludedServices, i_ce);
171     if ( (*dpIncludedServices).operator bool() )
172     {
173         produce_CommentedRelations( i_ce, *dpIncludedServices,
174                          C_sList_IncludedServices_Heading,
175                          C_sList_IncludedServices_Label,
176                          C_sList_IncludedServicesDetails_Heading,
177                          C_sList_IncludedServicesDetails_Label,
178                          doctype_summaryOnly );
179         pNaviSubRow->SwitchOn(sli_IncludedServicesSummary);
180     }
181 
182     // - exported interfaces: summary
183     dyn_comref_list dpExportedInterfaces;
184     ServiceAttr::Get_ExportedInterfaces(dpExportedInterfaces, i_ce);
185     if ( (*dpExportedInterfaces).operator bool() )
186     {
187         produce_CommentedRelations( i_ce, *dpExportedInterfaces,
188                          C_sList_ExportedInterfaces_Heading,
189                          C_sList_ExportedInterfaces_Label,
190                          C_sList_ExportedInterfacesDetails_Heading,
191                          C_sList_ExportedInterfacesDetails_Label,
192                          doctype_summaryOnly );
193         pNaviSubRow->SwitchOn(sli_InterfacesSummary);
194     }
195 
196     // - supported properties: summary
197     dyn_ce_list dpProperties;
198     ServiceAttr::Get_Properties(dpProperties, i_ce);
199     if ( (*dpProperties).operator bool() )
200     {
201         produce_Members( *dpProperties,
202                          C_sList_Properties,
203                          C_sList_Properties_Label,
204                          C_sList_PropertiesDetails,
205                          C_sList_PropertiesDetails_Label,
206                          viewtype_summary );
207         pNaviSubRow->SwitchOn(sli_PropertiesSummary);
208     }
209 
210     // - included services: details
211     ServiceAttr::Get_IncludedServices(dpIncludedServices, i_ce);
212     if ( (*dpIncludedServices).operator bool() )
213     {
214         produce_CommentedRelations( i_ce, *dpIncludedServices,
215                          C_sList_IncludedServices_Heading,
216                          C_sList_IncludedServices_Label,
217                          C_sList_IncludedServicesDetails_Heading,
218                          C_sList_IncludedServicesDetails_Label,
219                          doctype_complete );
220         pNaviSubRow->SwitchOn(sli_IncludedServicesDetails);
221     }
222 
223     // - exported interfaces: details
224     ServiceAttr::Get_ExportedInterfaces(dpExportedInterfaces, i_ce);
225     if ( (*dpExportedInterfaces).operator bool() )
226     {
227         produce_CommentedRelations( i_ce, *dpExportedInterfaces,
228                          C_sList_ExportedInterfaces_Heading,
229                          C_sList_ExportedInterfaces_Label,
230                          C_sList_ExportedInterfacesDetails_Heading,
231                          C_sList_ExportedInterfacesDetails_Label,
232                          doctype_complete );
233         pNaviSubRow->SwitchOn(sli_InterfacesDetails);
234     }
235 
236     // supported properties: details
237     ServiceAttr::Get_Properties(dpProperties, i_ce);
238     if ( (*dpProperties).operator bool() )
239     {
240         produce_Members( *dpProperties,
241                          C_sList_Properties,
242                          C_sList_Properties_Label,
243                          C_sList_PropertiesDetails,
244                          C_sList_PropertiesDetails_Label,
245                          viewtype_details );
246         pNaviSubRow->SwitchOn(sli_PropertiesDetails);
247     }
248 
249     pNaviSubRow->Produce_Row();
250     CurOut() << new Xml::XmlCode("<br>&nbsp;");
251 }
252 
253 typedef ary::idl::ifc_property::attr    PropertyAttr;
254 
255 void
produce_SummaryDeclaration(Xml::Element & o_row,const client & i_property) const256 HF_IdlService::produce_SummaryDeclaration( Xml::Element &      o_row,
257 										   const client &      i_property ) const
258 {
259     // KORR_FUTURE
260     // Put this in to HF_IdlProperty!
261 
262     Xml::Element &
263         rCell = o_row
264                     >> *new Html::TableCell
265                         << new Html::ClassAttr( C_sCellStyle_SummaryLeft );
266 
267     if (PropertyAttr::HasAnyStereotype(i_property))
268     {
269         rCell << "[ ";
270         if (PropertyAttr::IsReadOnly(i_property))
271             rCell << "readonly ";
272         if (PropertyAttr::IsBound(i_property))
273             rCell << "bound ";
274         if (PropertyAttr::IsConstrained(i_property))
275             rCell << "constrained ";
276         if (PropertyAttr::IsMayBeAmbiguous(i_property))
277             rCell << "maybeambiguous ";
278         if (PropertyAttr::IsMayBeDefault(i_property))
279             rCell << "maybedefault ";
280         if (PropertyAttr::IsMayBeVoid(i_property))
281             rCell << "maybevoid ";
282         if (PropertyAttr::IsRemovable(i_property))
283             rCell << "removable ";
284         if (PropertyAttr::IsTransient(i_property))
285             rCell << "transient ";
286         rCell << "] ";
287     }   // end if
288 
289     HF_IdlTypeText
290         aType( Env(), rCell, true );
291     aType.Produce_byData( PropertyAttr::Type(i_property) );
292 
293     StreamLock aLocalLink(100);
294     aLocalLink() << "#" << i_property.LocalName();
295     rCell
296         << new Html::LineBreak
297         >> *new Html::Link( aLocalLink().c_str() )
298             << i_property.LocalName();
299 }
300 
301 DYN HF_NaviSubRow &
make_Navibar(const client & i_ce) const302 HF_IdlService::make_Navibar( const client & i_ce ) const
303 {
304     HF_IdlNavigationBar
305         aNaviBar(Env(), CurOut());
306     aNaviBar.Produce_CeMainRow(i_ce);
307 
308     DYN HF_NaviSubRow &
309         ret = aNaviBar.Add_SubRow();
310     ret.AddItem(C_sList_IncludedServices, C_sList_IncludedServices_Label, false);
311     ret.AddItem(C_sList_ExportedInterfaces, C_sList_ExportedInterfaces_Label, false);
312     ret.AddItem(C_sList_Properties, C_sList_Properties_Label, false);
313     ret.AddItem(C_sList_IncludedServicesDetails, C_sList_IncludedServicesDetails_Label, false);
314     ret.AddItem(C_sList_ExportedInterfacesDetails, C_sList_ExportedInterfacesDetails_Label, false);
315     ret.AddItem(C_sList_PropertiesDetails, C_sList_PropertiesDetails_Label, false);
316 
317     CurOut() << new Html::HorizontalLine();
318     return ret;
319 }
320 
321 void
produce_Link(Xml::Element & o_row,type_id i_type) const322 HF_IdlService::produce_Link( Xml::Element &     o_row,
323                              type_id            i_type ) const
324 {
325     Xml::Element &
326         rCell = o_row
327                 >> *new Html::TableCell
328                     << new Html::ClassAttr(C_sCellStyle_SummaryLeft);
329     HF_IdlTypeText
330         aText(Env(), rCell, true);
331     aText.Produce_byData(i_type);
332 }
333 
334 void
produce_LinkSummary(const client & i_ce,Xml::Element & o_row,const comref & i_commentedRef) const335 HF_IdlService::produce_LinkSummary( const client &  i_ce,
336                                     Xml::Element &  o_row,
337                                     const comref &  i_commentedRef ) const
338 {
339     Xml::Element &
340         rCell = o_row
341                 >> *new Html::TableCell
342                     << new Html::ClassAttr(C_sCellStyle_SummaryRight);
343 
344     HF_IdlCommentedRelationElement::produce_LinkDoc( Env(), i_ce, rCell, i_commentedRef, doctype_summaryOnly );
345 }
346 
347 void
produce_MemberDetails(HF_SubTitleTable & o_table,const client & i_ce) const348 HF_IdlService::produce_MemberDetails( HF_SubTitleTable &  o_table,
349                                       const client &      i_ce ) const
350 {
351     HF_IdlProperty
352         aProperty( Env(), o_table);
353     aProperty.Produce_byData( i_ce );
354 }
355 
356 
357 
358