Commit | Line | Data |
---|---|---|
d44e3c4f | 1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2016 Ericsson Telecom AB | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Godar, Marton | |
11 | * Raduly, Csaba | |
12 | * Szabo, Bence Janos | |
13 | * | |
14 | ******************************************************************************/ | |
970ed795 EL |
15 | #ifndef TTCN3MODULEINVENTORY_HH_ |
16 | #define TTCN3MODULEINVENTORY_HH_ | |
17 | ||
18 | #include "Mstring.hh" | |
19 | #include "List.hh" | |
20 | ||
21 | class TTCN3Module; | |
22 | class RootType; | |
23 | class SimpleType; | |
3abe9331 | 24 | class ComplexType; |
970ed795 EL |
25 | |
26 | /** | |
27 | * Type that contains generated TTCN-3 modules in a list | |
28 | * and performs some modifications: | |
29 | * | |
30 | * - conversion of the names of modules | |
31 | * - finding module name information for import statements | |
32 | * - reference resolving among parsed types | |
33 | * - name conversion on defined types | |
34 | * - and starting generation of TTCN-3 modules | |
35 | * | |
36 | */ | |
3abe9331 | 37 | class TTCN3ModuleInventory { |
970ed795 EL |
38 | /** |
39 | * contains all defined TTCN-3 modules | |
40 | */ | |
41 | List<TTCN3Module*> definedModules; | |
42 | ||
43 | /** | |
44 | * Member to help avoiding to print import twice or more times | |
45 | */ | |
46 | List<TTCN3Module*> writtenImports; | |
47 | ||
48 | /** | |
49 | * Next three members are used by name conversion part | |
50 | * as global variables | |
51 | */ | |
52 | List<QualifiedName> typenames; | |
53 | ||
54 | /** | |
55 | * Used to register errors during the processing phase | |
56 | * After this it is possible to check it | |
57 | * and if errors occur possible to stop converter | |
58 | */ | |
59 | static unsigned int num_errors; | |
60 | static unsigned int num_warnings; | |
61 | ||
3abe9331 | 62 | TTCN3ModuleInventory(const TTCN3ModuleInventory &); // not implemented |
63 | TTCN3ModuleInventory & operator=(const TTCN3ModuleInventory &); // not implemented | |
64 | TTCN3ModuleInventory(); // private due to singleton | |
65 | ~TTCN3ModuleInventory(); // private due to singleton | |
970ed795 EL |
66 | public: |
67 | ||
68 | static TTCN3ModuleInventory& getInstance(); // singleton access | |
69 | ||
70 | /** | |
71 | * Generation of a new module for the given xsd file | |
72 | */ | |
73 | TTCN3Module * addModule(const char * xsd_filename, XMLParser * a_parser); | |
74 | ||
75 | /** | |
76 | * Steps after all xsd files are parsed | |
77 | */ | |
3abe9331 | 78 | void modulenameConversion(); |
79 | void referenceResolving(); | |
80 | void nameConversion(); | |
81 | void finalModification(); | |
970ed795 EL |
82 | |
83 | /** | |
84 | * TTCN-3 module generating method | |
85 | * Generate TTCN-3 files | |
86 | */ | |
3abe9331 | 87 | void moduleGeneration(); |
970ed795 | 88 | |
3abe9331 | 89 | List<TTCN3Module*> & getModules() { |
90 | return definedModules; | |
91 | } | |
970ed795 | 92 | |
3abe9331 | 93 | List<TTCN3Module*> & getWrittenImports() { |
94 | return writtenImports; | |
95 | } | |
96 | ||
97 | List<QualifiedName> & getTypenames() { | |
98 | return typenames; | |
99 | } | |
970ed795 EL |
100 | |
101 | /** | |
102 | * Searching methods | |
103 | * Look for a simpleType (or element or attribute) or a complexType (or attributeGroup or group) | |
104 | */ | |
3abe9331 | 105 | RootType * lookup(const RootType * ref, const Mstring& reference, wanted w) const; |
106 | RootType * lookup(const SimpleType * reference, wanted w) const; | |
107 | RootType * lookup(const ComplexType * reference, wanted w) const; | |
108 | RootType * lookup(const Mstring& name, const Mstring& nsuri, | |
109 | const RootType *reference, wanted w) const; | |
110 | ||
111 | static unsigned int getNumErrors() { | |
112 | return num_errors; | |
113 | } | |
114 | ||
115 | static unsigned int getNumWarnings() { | |
116 | return num_warnings; | |
117 | } | |
118 | ||
119 | static void incrNumErrors() { | |
120 | ++num_errors; | |
121 | } | |
970ed795 | 122 | |
3abe9331 | 123 | static void incrNumWarnings() { |
124 | ++num_warnings; | |
125 | } | |
970ed795 | 126 | |
3abe9331 | 127 | void dump() const; |
970ed795 EL |
128 | }; |
129 | ||
130 | #endif /* TTCN3MODULEINVENTORY_HH_ */ |