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