Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (c) 2000-2014 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 | #ifndef COMPLEXTYPE_H_ | |
9 | #define COMPLEXTYPE_H_ | |
10 | ||
11 | #include "RootType.hh" | |
12 | ||
13 | class FieldType; | |
14 | class SimpleType; | |
15 | ||
16 | class EmbeddedType | |
17 | { | |
18 | public: | |
19 | int depth; | |
20 | bool valid; | |
21 | bool strictValid; | |
22 | unsigned long long int minOccurs; | |
23 | unsigned long long int maxOccurs; | |
24 | FieldType * order_attribute; | |
25 | ||
26 | explicit EmbeddedType (int a_depth=0, unsigned long long int a_minOccurs=1, unsigned long long int a_maxOccurs=1, | |
27 | FieldType * a_order_attribute=NULL) | |
28 | : depth(a_depth) | |
29 | , valid(true) | |
30 | , strictValid(true) | |
31 | , minOccurs(a_minOccurs) | |
32 | , maxOccurs(a_maxOccurs) | |
33 | , order_attribute(a_order_attribute) | |
34 | {} | |
35 | }; | |
36 | ||
37 | class GenerationType | |
38 | { | |
39 | public: | |
40 | FieldType * field; | |
41 | int depth; | |
42 | FieldType * order_attribute; | |
43 | FieldType * embed_values_attribute; | |
44 | int max_alt; | |
45 | ||
46 | explicit GenerationType (FieldType * a_field = NULL, int a_depth = 0, | |
47 | FieldType * a_order_attribute = NULL, FieldType * a_embed_values_attribute = NULL, int a_max_alt = 0) | |
48 | : field(a_field) | |
49 | , depth(a_depth) | |
50 | , order_attribute(a_order_attribute) | |
51 | , embed_values_attribute(a_embed_values_attribute) | |
52 | , max_alt(a_max_alt) | |
53 | {} | |
54 | }; | |
55 | ||
56 | class AttrBaseType | |
57 | { | |
58 | public: | |
59 | FieldType * base; | |
60 | int depth; | |
61 | bool valid; | |
62 | ||
63 | explicit AttrBaseType (FieldType * a_base = NULL, int a_depth = 0) | |
64 | : base(a_base) | |
65 | , depth(a_depth) | |
66 | , valid(true) | |
67 | {} | |
68 | }; | |
69 | ||
70 | ||
71 | /** | |
72 | * Type that contains information coming from XSD complexTypes, model group definitions | |
73 | * and attributeGroups | |
74 | * | |
75 | * Source in XSD: | |
76 | * | |
77 | * * <complexType>, <group> and <attributeGroup> element whose parent element is <schema> | |
78 | * | |
79 | * Result in TTCN-3: | |
80 | * | |
81 | * * TTCN-3 type | |
82 | * | |
83 | */ | |
84 | class ComplexType : public RootType | |
85 | { | |
86 | public: | |
87 | enum ComplexType_Mode | |
88 | { | |
89 | CT_simpletype_mode, | |
90 | CT_complextype_mode, | |
91 | CT_undefined_mode | |
92 | }; | |
93 | enum CT_fromST | |
94 | { | |
95 | fromTagUnion, | |
96 | fromTagNillable, | |
97 | fromTagComplexType | |
98 | }; | |
99 | enum Resolv_State { | |
100 | No, | |
101 | InProgress, | |
102 | Yes | |
103 | }; | |
104 | ||
105 | private: | |
106 | List<FieldType*> fields; | |
107 | List<FieldType*> fields_final; | |
108 | ||
109 | int actualLevel; | |
110 | Mstring actualPath; | |
111 | ||
112 | List<ComplexType_Mode> ctmode; | |
113 | List<GenerationType> fieldGenInfo; | |
114 | List<GenerationType> recGenInfo; | |
115 | List<AttrBaseType> attributeBases; | |
116 | List<EmbeddedType> embed_inSequence; | |
117 | List<EmbeddedType> embed_inChoice; | |
118 | List<EmbeddedType> embed_inAll; | |
119 | bool with_union; | |
120 | Resolv_State resolved; | |
121 | ||
122 | FieldType * generateField (); | |
123 | FieldType * generateAttribute (); | |
124 | FieldType * generateRecord (unsigned long long int a_minOccurs, unsigned long long int a_maxOccurs); | |
125 | FieldType * generateUnion (unsigned long long int a_minOccurs, unsigned long long int a_maxOccurs); | |
126 | ||
127 | void initialSettings (); | |
128 | ||
129 | void reference_resolving_funtion (List<FieldType*> & container); | |
130 | void sortAttributes (); | |
131 | void nameConversion_names (const List<NamespaceType> & ns); | |
132 | void nameConversion_types (const List<NamespaceType> & ns); | |
133 | void nameConversion_fields (const List<NamespaceType> & ns); | |
134 | void indent (FILE * file, int x) { for (int l = 0; l < x; ++l) fprintf(file, "\t"); } | |
135 | ||
136 | void printVariant (FILE * file); | |
137 | ||
138 | public: | |
139 | ComplexType (XMLParser * a_parser, TTCN3Module * a_module, ConstructType a_construct); | |
140 | ComplexType (const ComplexType & other); | |
141 | ComplexType (const SimpleType & other, CT_fromST c); | |
142 | ~ComplexType (); | |
143 | ||
144 | /** Virtual methods | |
145 | * inherited from RootType | |
146 | */ | |
147 | void loadWithValues (); | |
148 | void printToFile (FILE * file); | |
149 | ||
150 | void modifyValues (); | |
151 | void referenceResolving (); | |
152 | void nameConversion (NameConversionMode mode, const List<NamespaceType> & ns); | |
153 | void finalModification (); | |
154 | bool hasUnresolvedReference (); | |
155 | void dump (unsigned int depth) const ; | |
156 | ||
157 | void everything_into_fields_final (); | |
158 | ||
159 | void addToActualPath (const Mstring& text) {actualPath += text;} | |
160 | ||
161 | void setWithUnion (bool b) {with_union = b;} | |
162 | ||
163 | const List<EmbeddedType> & getEmbedInChoice () const {return embed_inChoice;} | |
164 | ||
165 | const List<FieldType*> & getFields () const {return fields;} | |
166 | const List<FieldType*> & getFieldsFinal () const {return fields_final;} | |
167 | bool getWithUnion () const {return with_union;} | |
168 | ||
169 | int getActualLevel () const {return actualLevel;} | |
170 | const Mstring & getActualPath () const {return actualPath;} | |
171 | ComplexType_Mode getMode() const { | |
172 | return ctmode.empty() ? CT_undefined_mode : ctmode.front(); | |
173 | } | |
174 | }; | |
175 | ||
176 | #endif /* COMPLEXTYPE_H_ */ |