1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ARY_IDL_I2S_CALCULATOR_HXX
29 #define ARY_IDL_I2S_CALCULATOR_HXX
30 
31 
32 // USED SERVICES
33     // BASE CLASSES
34 #include <cosv/tpl/processor.hxx>
35     // PARAMETERS
36 #include <ary/idl/i_types4idl.hxx>
37 
38 
39 namespace ary
40 {
41 namespace idl
42 {
43     class CeAdmin;
44     class Ce_Storage;
45     class TypeAdmin;
46     class Type_Storage;
47     class Module;
48     class ExplicitType;
49     class Function;
50     class Interface;
51     class Property;
52     class Typedef;
53     class Service;
54     class Singleton;
55     class SglIfcService;
56     class SglIfcSingleton;
57     class Struct;
58     class StructElement;
59     class Exception;
60     class Ce_2s;
61 }
62 }
63 
64 
65 
66 
67 
68 
69 namespace ary
70 {
71 namespace idl
72 {
73 
74 
75 enum E_2s_of_Service
76 {
77     service_2s_IncludingServices,
78     service_2s_InstantiatingSingletons
79 };
80 
81 enum E_2s_of_Interface
82 {
83     interface_2s_Derivations,
84     interface_2s_ExportingServices,
85     interface_2s_ExportingSingletons,
86     interface_2s_SynonymTypedefs,
87 //    interface_2s_UsingTypedefs,
88     interface_2s_AsReturns,
89 //    interface_2s_AsIndirectReturns,
90     interface_2s_AsParameters,
91 //    interface_2s_AsIndirectParameters,
92     interface_2s_AsDataTypes
93 };
94 
95 enum E_2s_of_Struct
96 {
97     struct_2s_Derivations,
98     struct_2s_SynonymTypedefs,
99 //    struct_2s_UsingTypedefs,
100     struct_2s_AsReturns,
101 //    struct_2s_AsIndirectReturns,
102     struct_2s_AsParameters,
103 //    struct_2s_AsIndirectParameters,
104     struct_2s_AsDataTypes
105 };
106 
107 enum E_2s_of_Enum
108 {
109     enum_2s_SynonymTypedefs,
110 //    enum_2s_UsingTypedefs,
111     enum_2s_AsReturns,
112 //    enum_2s_AsIndirectReturns,
113     enum_2s_AsParameters,
114 //    enum_2s_AsIndirectParameters,
115     enum_2s_AsDataTypes
116 };
117 
118 enum E_2s_of_Typedef
119 {
120     typedef_2s_SynonymTypedefs,
121 //    typedef_2s_UsingTypedefs,
122     typedef_2s_AsReturns,
123 //    typedef_2s_AsIndirectReturns,
124     typedef_2s_AsParameters,
125 //    typedef_2s_AsIndirectParameters,
126     typedef_2s_AsDataTypes
127 };
128 
129 enum E_2s_of_Exceptions
130 {
131     exception_2s_Derivations,
132     exception_2s_RaisingFunctions
133 };
134 
135 
136 
137 class SPInst_asHost :   public csv::ProcessorIfc,
138                         public csv::ConstProcessor<Service>,
139                         public csv::ConstProcessor<Interface>,
140                         public csv::ConstProcessor<Struct>,
141                         public csv::ConstProcessor<Exception>,
142                         public csv::ConstProcessor<Typedef>,
143                         public csv::ConstProcessor<Singleton>,
144                         public csv::ConstProcessor<Function>,
145                         public csv::ConstProcessor<StructElement>,
146                         public csv::ConstProcessor<Property>,
147                         public csv::ConstProcessor<SglIfcService>,
148                         public csv::ConstProcessor<SglIfcSingleton>
149 {
150 };
151 
152 
153 
154 
155 /** This class scans the parsed data and produces several
156     secondary data like cross references and alphabetical indices.
157 
158     In this declaration "Secondaries" or "2s" mean those secondary data.
159 
160     @see Ce_2s
161 */
162 class SecondariesCalculator : public SPInst_asHost
163 {
164   public:
165     // LIFECYCLE
166                         SecondariesCalculator(
167                             CeAdmin &           i_ces,
168                             TypeAdmin &         i_types );
169     virtual             ~SecondariesCalculator();
170 
171     // OPERATIONS
172     void                CheckAllInterfaceBases();
173     void                Connect_Types2Ces();
174     void                Gather_CrossReferences();
175     void                Make_Links2DeveloperManual(
176                             const String &      i_devman_reffilepath );
177 
178   private:
179     // Interface CeHost These are the points to gather cross
180     //   references:
181     virtual void        do_Process(
182                             const Service &     i_rData );
183     virtual void        do_Process(
184                             const Interface &   i_rData );
185     virtual void        do_Process(
186                             const Struct &      i_rData );
187     virtual void        do_Process(
188                             const Exception &   i_rData );
189     virtual void        do_Process(
190                             const Typedef &     i_rData );
191     virtual void        do_Process(
192                             const Singleton &   i_rData );
193     virtual void        do_Process(
194                             const Function &    i_rData );
195     virtual void        do_Process(
196                             const StructElement &
197                                                 i_rData );
198     virtual void        do_Process(
199                             const Property &    i_rData );
200     virtual void        do_Process(
201                             const SglIfcService &
202                                                 i_rData );
203     virtual void        do_Process(
204                             const SglIfcSingleton &
205                                                 i_rData );
206 
207     // Locals
208     const Ce_Storage &  my_CeStorage() const;
209     const Type_Storage &
210                         my_TypeStorage() const;
211     Ce_Storage &        my_CeStorage();
212     Type_Storage &      my_TypeStorage();
213 
214     template <class DEST>
215     DEST *              SearchCe4Type(
216                             Type_id             i_type );
217     Ce_id               lhf_Search_CeForType(
218                             const ExplicitType &
219                                                 i_rType ) const;
220     Ce_id               lhf_Search_CeFromTypeId(
221                             Type_id             i_nType ) const;
222     Service *           lhf_SearchService(
223                             Type_id             i_nServ );
224     Interface *         lhf_SearchInterface(
225                             Type_id             i_nIfc );
226     Struct *            lhf_SearchStruct(
227                             Type_id             i_nIfc );
228     Exception *         lhf_SearchException(
229                             Type_id             i_nIfc );
230     void                assign_CurLink(
231                             char *              i_text,
232                             const String &      i_link,
233                             const String &      i_linkUI,
234                             bool                i_isDescr,      /// @descr true: description, false: reference.
235                             int                 i_lineCount  );
236     void                gather_Synonyms();
237     void                recursive_AssignAsSynonym(
238                             Ce_id               i_synonymousTypedefsId,
239                             const Typedef &     i_TypedefToCheck );
240     void                recursive_AssignIncludingService(
241                             Ce_id               i_includingServicesId,
242                             const Service &     i_ServiceToCheckItsIncludes );
243     void                assign_AsDerivedInterface(
244                             const Interface &   i_rDerived );
245     void                assign_AsDerivedStruct(
246                             const Struct &      i_rDerived );
247     void                assign_AsDerivedException(
248                             const Exception &   i_rDerived );
249     void                assignImplementation_toAServicesInterfaces(
250                             Ce_id               i_nImpl,
251                             Ce_id               i_nService,
252                             E_2s_of_Interface   i_eList );
253     void                recursive_AssignImplementation_toExportedInterface(
254                             Ce_id               i_nService,
255                             Type_id             i_nExportedInterface,
256                             E_2s_of_Interface   i_eList );
257     void                recursive_AssignFunction_toCeAsReturn(
258                             Ce_id               i_nFunction,
259                             Type_id             i_nReturnType );
260     void                recursive_AssignFunction_toCeAsParameter(
261                             Ce_id               i_nFunction,
262                             Type_id             i_nParameterType );
263 
264     /** @param i_nDataElement
265         May be the ID of an struct element as well as an exception element
266         or a property.
267     */
268     void                recursive_AssignStructElement_toCeAsDataType(
269                             Ce_id               i_nDataElement,
270                             Type_id             i_nDataType );
271     void                insert_into2sList(
272                             CodeEntity &        o_out,
273                             int                 i_listIndex,
274                             Ce_id               i_nCe );
275     void                insert_into2sUnique(
276                             CodeEntity &        o_out,
277                             int                 i_listIndex,
278                             Ce_id               i_nCe );
279     /// Sorts secondary production lists alphabetical.
280     void                sort_All2s();
281 
282     void                Read_Links2DevManual(
283                             csv::bstream &      i_file );
284 
285     // DATA
286     CeAdmin *           pCes;
287     TypeAdmin *         pTypes;
288 };
289 
290 
291 
292 
293 }   // namespace idl
294 }   // namespace ary
295 #endif
296