Merge pull request #17 from BotondBaranyi/master
[deliverable/titan.core.git] / xsdconvert / TTCN3Module.hh
CommitLineData
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 TTCN3MODULE_HH_
9#define TTCN3MODULE_HH_
10
11#include "XMLParser.hh"
12#include "GeneralTypes.hh"
3abe9331 13#include "GeneralFunctions.hh"
14#include "TTCN3ModuleInventory.hh"
970ed795
EL
15
16class TTCN3ModuleInventory;
17class RootType;
18
51fa56b9 19//Used only in type substitution, when we have to change the type or a builtintype
20//due to type substitution
21struct typeNameDepList {
22 Mstring type;
23 List<SimpleType*> nameDepList;
24 //Used only with builtInTypes
25 ComplexType* typeSubsGroup;
26};
27
970ed795
EL
28/**
29 * Type that contains information about one TTCN-3 module
30 * and performs the generation of that module
31 *
32 * Types defined in the module are stored in a list
33 *
34 */
3abe9331 35class TTCN3Module {
970ed795
EL
36 /**
37 * this module is connected with this parser object
38 */
39 XMLParser * parser; // no responsibility for this member
40
41 /**
42 * Name of the XML schema that this module is originating from
43 */
44 Mstring schemaname;
45 /**
46 * Name of the TTCN-3 module (derived from targetNamespace)
47 */
48 Mstring modulename;
49 /**
50 * contains all main types defined in the module
51 */
52 List<RootType*>definedTypes;
53 /**
54 * Type of the currently processed main type
55 */
56 ConstructType actualXsdConstruct;
57
58 /**
59 * Attribute values of XML declaration
60 */
61 Mstring xsdVersion;
62 Mstring xsdEncoding;
63 int xsdStandalone;
64 /**
65 * Attribute values of <schema> tag
66 */
67 Mstring targetNamespace;
68 Mstring targetNamespace_connectedPrefix;
69 List<NamespaceType> declaredNamespaces;
70 FormValue elementFormDefault;
71 FormValue attributeFormDefault;
3abe9331 72 BlockValue blockDefault;
970ed795
EL
73
74 List<const TTCN3Module*> importedModules; // pointers not owned
75
51fa56b9 76 //Used only in type substitution, stores every possibly substituted type definitions
77 List<ComplexType*> storedTypeSubstitutions; //pointers not owned
78
79 //Used only in type substitution, stores every element that references a type
80 List<typeNameDepList> element_types;
81
970ed795
EL
82 List<Mstring> variant;
83
84 bool moduleNotIntoFile;
85 bool moduleNotIntoNameConversion;
86
3abe9331 87 TTCN3Module & operator=(const TTCN3Module &); // not implemented
88 TTCN3Module(const TTCN3Module &); // not implemented
970ed795 89public:
3abe9331 90 TTCN3Module(const char * a_filename, XMLParser * a_parser);
91 ~TTCN3Module();
92
93 void goodbyeParser() {
94 parser = 0;
95 }
96
97 void loadValuesFromXMLDeclaration(const char *a_version,
98 const char *a_encoding, int a_standalone);
99 void loadValuesFromSchemaTag(const Mstring& a_targetNamespace, List<NamespaceType> declaredNamespaces,
100 FormValue a_elementFormDefault,
101 FormValue a_attributeFormDefault,
102 BlockValue a_blockDefault);
103
3abe9331 104 void generate_TTCN3_fileinfo(FILE * file);
105 void generate_TTCN3_modulestart(FILE * file);
106 void generate_TTCN3_included_types(FILE * file);
107 void generate_TTCN3_import_statements(FILE * file);
108 void generate_TTCN3_types(FILE * file);
109 void generate_with_statement(FILE * file, List<NamespaceType> used_namespaces);
110
111 const Mstring & getSchemaname() const {
112 return schemaname;
113 }
114
115 const Mstring & getTargetNamespace() const {
116 return targetNamespace;
117 }
118
119 const Mstring & getTargetNamespaceConnector() const {
120 return targetNamespace_connectedPrefix;
121 }
122
123 const Mstring & getModulename() const {
124 return modulename;
125 }
126
127 void setSchemaname(const Mstring& name) {
128 schemaname = name;
129 }
130
131 void setTargetNamespace(const Mstring& tns) {
132 targetNamespace = tns;
133 }
134
135 FormValue getElementFormDefault() const {
136 return elementFormDefault;
137 }
138
139 void setElementFormDefault(FormValue value) {
140 elementFormDefault = value;
141 }
142
143 FormValue getAttributeFormDefault() const {
144 return attributeFormDefault;
145 }
146
147 void setAttributeFormDefault(FormValue value) {
148 attributeFormDefault = value;
149 }
150
151 BlockValue getBlockDefault() const {
152 return blockDefault;
153 }
154
155 ConstructType getActualXsdConstruct() const {
156 return actualXsdConstruct;
157 }
158
159 void setActualXsdConstruct(ConstructType c) {
160 actualXsdConstruct = c;
161 }
162
163 void addAnnotation();
164 void addMainType(const ConstructType typeOfMainType);
165 void addMainType(RootType * type){ definedTypes.push_back(type); }
166
167 bool hasDefinedMainType() const {
168 return !definedTypes.empty();
169 }
170 void replaceLastMainType(RootType * t);
171
172 const List<RootType*> & getDefinedTypes() const {
173 return definedTypes;
174 }
175
176 RootType & getLastMainType() {
177 return *definedTypes.back();
178 }
179
180 bool isnotIntoNameConversion() const {
181 return moduleNotIntoNameConversion;
182 }
183
184 void notIntoNameConversion() {
185 moduleNotIntoNameConversion = true;
186 }
187
188 bool isnotIntoFile() const {
189 return moduleNotIntoFile;
190 }
191
192 void notIntoFile() {
193 moduleNotIntoFile = true;
194 }
195
196 const List<NamespaceType> & getDeclaredNamespaces() const {
197 return declaredNamespaces;
198 }
199
200 void addImportedModule(const TTCN3Module *mod) {
201 importedModules.push_back(mod);
202 }
203
204 const List<const TTCN3Module*> & getImportedModules() const {
205 return importedModules;
206 }
970ed795 207
51fa56b9 208 List<ComplexType*> & getStoredTypeSubstitutions() {
209 return storedTypeSubstitutions;
210 }
211
212 void addStoredTypeSubstitution(ComplexType * type){
213 storedTypeSubstitutions.push_back(type);
214 }
215
216 List<typeNameDepList> & getElementTypes() {
217 return element_types;
218 }
219
220 void addElementType(const Mstring& type, SimpleType* st) {
221 List<typeNameDepList>::iterator it = element_types.begin();
222 for(; it; it = it->Next){
223 if(it->Data.type == type && st != NULL){
224 it->Data.nameDepList.push_back(st);
225 break;
226 }
227 }
228 //New type that has not been in the element_types before
229 if(it == NULL){
230 typeNameDepList list;
231 list.type = type;
232 list.typeSubsGroup = NULL;
233 if(st != NULL){
234 list.nameDepList.push_back(st);
235 }
236 element_types.push_back(list);
237 }
238 }
239
970ed795 240 /// Compute the TTCN-3 module name
3abe9331 241 void TargetNamespace2ModuleName();
970ed795 242
3abe9331 243 friend bool compareModules(TTCN3Module * lhs, TTCN3Module * rhs);
970ed795 244
3abe9331 245 void dump() const;
970ed795
EL
246};
247
3abe9331 248inline bool compareModules(TTCN3Module * lhs, TTCN3Module * rhs) {
970ed795
EL
249 return lhs->targetNamespace < rhs->targetNamespace;
250}
251
252#endif /* TTCN3MODULECONTAINER_HH_ */
This page took 0.033494 seconds and 5 git commands to generate.