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