Typestuff.hh 10 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
/******************************************************************************
Lenard Nagy's avatar
Lenard Nagy committed
2
 * Copyright (c) 2000-2017 Ericsson Telecom AB
Elemer Lelik's avatar
Elemer Lelik committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Delic, Adam
 *   Forstner, Matyas
 *   Gecse, Roland
 *   Kovacs, Ferenc
 *   Raduly, Csaba
 *   Szabados, Kristof
 *   Szabo, Janos Zoltan – initial implementation
 *   Szalai, Gabor
 *   Tatarka, Gabor
 *   Zalanyi, Balazs Andor
 *
 ******************************************************************************/
Elemer Lelik's avatar
Elemer Lelik committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef _Common_Typestuff_HH
#define _Common_Typestuff_HH

#include "Setting.hh"

namespace Asn {
  class TagCollection;
} // namespace Asn

namespace Ttcn {
  class WithAttribPath;
}

namespace Common {
  class CompField;

  /**
   * \addtogroup AST_Type
   *
   * @{
   */

  /**
   * ExceptionSpecification
   */
  class ExcSpec : public Node {
  private:
    Type *type;
    Value *value;
    /** Copy constructor not implemented */
    ExcSpec(const ExcSpec& p);
    /** Assignment disabled */
    ExcSpec& operator=(const ExcSpec& p);
  public:
    ExcSpec(Type *p_type, Value *p_value);
    virtual ~ExcSpec();
    virtual ExcSpec *clone() const;
    virtual void set_my_scope(Scope *p_scope);
    virtual void set_fullname(const string& p_fullname);
    Type *get_type() const { return type; }
    Value *get_value() const { return value; }
  };

  class CTs_EE_CTs;
  class CTs;
  class ExtAndExc;
  class ExtAdds;
  class ExtAddGrp;
  class ExtAdd;
  class CT;
  class CT_CompsOf;
  class CT_reg;

  /**
   * ComponentTypeList
   */
  class CTs : public Node {
  private:
    vector<CT> cts;
    /** Copy constructor not implemented */
    CTs(const CTs& p);
    /** Assignment disabled */
    CTs& operator=(const CTs& p);
  public:
    CTs() : Node(), cts() { }
    virtual ~CTs();
    virtual CTs *clone() const;
    virtual void set_fullname(const string& p_fullname);
    virtual void set_my_scope(Scope *p_scope);
    size_t get_nof_comps() const;
    CompField* get_comp_byIndex(size_t n) const;
    bool has_comp_withName(const Identifier& p_name) const;
    CompField* get_comp_byName(const Identifier& p_name) const;
    void tr_compsof(ReferenceChain *refch, bool is_set);
    void add_ct(CT* p_ct);
    virtual void dump(unsigned level) const;
  };

  /**
   * ComponentTypeList ExtensionAndException ComponentTypeList
   */
  class CTs_EE_CTs : public Node {
    CTs *cts1;
    ExtAndExc *ee;
    CTs *cts2;
    /** Pointer to the owner type */
    Type *my_type;
    /** Indicates whether the uniqueness of components has been checked */
    bool checked;
    /** Shortcut for all components */
    vector<CompField> comps_v;
    /** Map for all components (indexed by component name) */
    map<string, CompField> comps_m;
    /** Copy constructor not implemented */
    CTs_EE_CTs(const CTs_EE_CTs& p);
    /** Assignment disabled */
    CTs_EE_CTs& operator=(const CTs_EE_CTs& p);
  public:
    CTs_EE_CTs(CTs *p_cts1, ExtAndExc *p_ee, CTs *p_cts2);
    virtual ~CTs_EE_CTs();
    virtual CTs_EE_CTs *clone() const;
    virtual void set_fullname(const string& p_fullname);
    virtual void set_my_scope(Scope *p_scope);
    void set_my_type(Type *p_my_type) { my_type = p_my_type; }
    size_t get_nof_comps();
    size_t get_nof_root_comps();
    CompField* get_comp_byIndex(size_t n);
    CompField* get_root_comp_byIndex(size_t n);
    bool has_comp_withName(const Identifier& p_name);
    CompField* get_comp_byName(const Identifier& p_name);
    void tr_compsof(ReferenceChain *refch, bool in_ellipsis);
133
    ExtAndExc* get_ext_and_exc() const { return ee; }
Elemer Lelik's avatar
Elemer Lelik committed
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    bool has_ellipsis() const { return ee != 0; }
    bool needs_auto_tags();
    void add_auto_tags();
    /** Checks the uniqueness of components and builds the shortcut map and
      * vectors */
    void chk();
    void chk_tags();
    virtual void dump(unsigned level) const;
  private:
    void chk_comp_field(CompField *cf, const char *type_name,
        const char *comp_name);
    void chk_tags_choice();
    void chk_tags_seq();
    void chk_tags_seq_comp(Asn::TagCollection& coll, CompField *cf,
        bool is_mandatory);
    void chk_tags_set();
    void get_multiple_tags(Asn::TagCollection& coll, Type *type);
  };

  /**
   * ExtensionAddition (abstract class).
   */
  class ExtAdd : public Node {
  public:
    virtual ExtAdd *clone() const = 0;
    virtual size_t get_nof_comps() const = 0;
    virtual CompField* get_comp_byIndex(size_t n) const = 0;
    virtual bool has_comp_withName(const Identifier& p_name) const = 0;
    virtual CompField* get_comp_byName(const Identifier& p_name) const = 0;
    virtual void tr_compsof(ReferenceChain *refch, bool is_set) = 0;
164
165
166
    virtual bool is_ext_attr_group() const { return false; }
    virtual int get_group_number() const { return 0; }
    virtual void set_group_number(int) {}
Elemer Lelik's avatar
Elemer Lelik committed
167
168
169
170
171
172
173
174
  };

  /**
   * ExtensionAdditionList
   */
  class ExtAdds : public Node {
  private:
    vector<ExtAdd> eas;
175
176
    // The number of ExtAddGrps
    int num_of_groups;
Elemer Lelik's avatar
Elemer Lelik committed
177
178
179
180
181
    /** Copy constructor not implemented */
    ExtAdds(const ExtAdds& p);
    /** Assignment disabled */
    ExtAdds& operator=(const ExtAdds& p);
  public:
182
    ExtAdds() : Node(), eas(), num_of_groups(0) { }
Elemer Lelik's avatar
Elemer Lelik committed
183
184
185
186
187
188
    virtual ~ExtAdds();
    virtual ExtAdds *clone() const;
    virtual void set_fullname(const string& p_fullname);
    virtual void set_my_scope(Scope *p_scope);
    size_t get_nof_comps() const;
    CompField* get_comp_byIndex(size_t n) const;
189
    int get_group_byIndex(size_t n) const;
Elemer Lelik's avatar
Elemer Lelik committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
    bool has_comp_withName(const Identifier& p_name) const;
    CompField* get_comp_byName(const Identifier& p_name) const;
    void tr_compsof(ReferenceChain *refch, bool is_set);
    void add_ea(ExtAdd* p_ea);
    virtual void dump(unsigned level) const;
  };

  /**
   * ExtensionAndException
   */
  class ExtAndExc : public Node {
  private:
    /** optional exception specification */
    ExcSpec *excSpec;
    ExtAdds *eas;
    /** Copy constructor not implemented */
    ExtAndExc(const ExtAndExc& p);
    /** Assignment disabled */
    ExtAndExc& operator=(const ExtAndExc& p);
  public:
    ExtAndExc(ExcSpec *p_excSpec, ExtAdds *p_eas=0);
    virtual ~ExtAndExc();
    virtual ExtAndExc *clone() const;
    virtual void set_fullname(const string& p_fullname);
    virtual void set_my_scope(Scope *p_scope);
    size_t get_nof_comps() const { return eas->get_nof_comps(); }
    CompField* get_comp_byIndex(size_t n) const
      { return eas->get_comp_byIndex(n); }
    bool has_comp_withName(const Identifier& p_name) const
      { return eas->has_comp_withName(p_name); }
    CompField* get_comp_byName(const Identifier& p_name) const
      { return eas->get_comp_byName(p_name); }
    void tr_compsof(ReferenceChain *refch, bool is_set)
      { eas->tr_compsof(refch, is_set); }
    void set_eas(ExtAdds *p_eas);
225
    ExtAdds * get_eas() const { return eas; }
Elemer Lelik's avatar
Elemer Lelik committed
226
227
228
229
230
231
232
233
234
235
236
    virtual void dump(unsigned level) const;
  };

  /**
   * ExtensionAdditionGroup
   */
  class ExtAddGrp : public ExtAdd {
  private:
    /** can be NULL if not present */
    Value *versionnumber;
    CTs *cts;
237
238
    // Needed for oer coding
    int groupnumber;
Elemer Lelik's avatar
Elemer Lelik committed
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
    /** Copy constructor not implemented */
    ExtAddGrp(const ExtAddGrp& p);
    /** Assignment disabled */
    ExtAddGrp& operator=(const ExtAddGrp& p);
  public:
    ExtAddGrp(Value* p_versionnumber, CTs *p_cts);
    virtual ~ExtAddGrp();
    virtual ExtAddGrp *clone() const;
    virtual void set_fullname(const string& p_fullname);
    virtual void set_my_scope(Scope *p_scope);
    virtual size_t get_nof_comps() const;
    virtual CompField* get_comp_byIndex(size_t n) const;
    virtual bool has_comp_withName(const Identifier& p_name) const;
    virtual CompField* get_comp_byName(const Identifier& p_name) const;
    virtual void tr_compsof(ReferenceChain *refch, bool is_set);
    virtual void dump(unsigned level) const;
255
256
257
258
    virtual bool is_ext_attr_group() const { return true; }
    virtual int get_group_number() const { return groupnumber; }
    virtual void set_group_number(int num) { groupnumber = num; }

Elemer Lelik's avatar
Elemer Lelik committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
  };

  /**
   * ComponentType (abstract class).
   */
  class CT : public ExtAdd, public Location {
  public:
    virtual CT *clone() const = 0;
  };

  /**
   * ComponentType/regular (Contains only a Component).
   */
  class CT_reg : public CT {
  private:
    CompField *comp;
    /** Copy constructor not implemented */
    CT_reg(const CT_reg& p);
    /** Assignment disabled */
    CT_reg& operator=(const CT_reg& p);
  public:
    CT_reg(CompField *p_comp);
    virtual ~CT_reg();
    virtual CT_reg *clone() const;
    virtual void set_fullname(const string& p_fullname);
    virtual void set_my_scope(Scope *p_scope);
    virtual size_t get_nof_comps() const;
    virtual CompField* get_comp_byIndex(size_t n) const;
    virtual bool has_comp_withName(const Identifier& p_name) const;
    virtual CompField* get_comp_byName(const Identifier& p_name) const;
    virtual void tr_compsof(ReferenceChain *refch, bool is_set);
    virtual void dump(unsigned level) const;
  };

  /**
   * ComponentsOf
   */
  class CT_CompsOf : public CT {
  private:
    Type *compsoftype;
    bool tr_compsof_ready;
    CTs *cts;
    /** Copy constructor not implemented */
    CT_CompsOf(const CT_CompsOf& p);
    /** Assignment disabled */
    CT_CompsOf& operator=(const CT_CompsOf& p);
  public:
    CT_CompsOf(Type *p_compsoftype);
    virtual ~CT_CompsOf();
    virtual CT_CompsOf *clone() const;
    virtual void set_fullname(const string& p_fullname);
    virtual void set_my_scope(Scope *p_scope);
    virtual size_t get_nof_comps() const;
    virtual CompField* get_comp_byIndex(size_t n) const;
    virtual bool has_comp_withName(const Identifier& p_name) const;
    virtual CompField* get_comp_byName(const Identifier& p_name) const;
    virtual void tr_compsof(ReferenceChain *refch, bool is_set);
    virtual void dump(unsigned level) const;
  };

  /** @} end of AST_Type group */

} // namespace Common

#endif // _Common_Typestuff_HH