1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2015 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 ///////////////////////////////////////////////////////////////////////////////
18 * A class to represent a field of a compound type (sequence/record,
19 * set and choice/union).
21 class CompField : public Node, public Location {
23 /** The name of the field. Owned by the CompField. */
25 /** The type of the field. Owned. */
28 /** Default value or 0 if no default value. Owned. */
30 /** Raw attributes or 0. Owned */
32 /** Copy constructor not implemented */
33 CompField(const CompField& p);
34 /** Assignment disabled */
35 CompField& operator=(const CompField& p);
37 CompField(Identifier *p_name, Type *p_type, bool p_is_optional=false,
40 virtual CompField *clone() const;
41 virtual void set_fullname(const string& p_fullname);
42 void set_my_scope(Scope *p_scope);
43 const Identifier& get_name() const { return *name; }
44 Type *get_type() const { return type; }
45 RawAST* get_raw_attrib() const { return rawattrib; }
46 void set_raw_attrib(RawAST* r_attr);
47 bool get_is_optional() const { return is_optional; }
48 bool has_default() const { return defval != 0; }
49 Value *get_defval() const { return defval; }
50 virtual void dump(unsigned level) const;
54 * Class to represent a map of TTCN-3 StructFieldDef (BNF
55 * 23). Create a CompFieldMap and use add_comp(CompField *) to add
56 * each StructFieldDef (a.k.a. CompRef) into it! Finally, pass
57 * CompFieldMap* to constructors of record/set/union types!
59 class CompFieldMap : public Node {
61 /** Maps the name of the component to the actual component. */
62 map<string, CompField> m;
63 /** Contains pointers to the individual CompField s.
64 * The CompFieldMap owns the CompFields and will free them. */
66 /** Points to the owner type, which shall be a TTCN-3 record, set or
67 * union or an ASN.1 open type.
68 * The CompFieldMap does not own the type. */
70 /** Indicates whether the uniqueness of field identifiers has been
74 CompFieldMap(const CompFieldMap& p);
75 /** Assignment disabled */
76 CompFieldMap& operator=(const CompFieldMap& p);
78 CompFieldMap() : Node(), m(), v(), my_type(0), checked(false) {}
79 virtual ~CompFieldMap();
80 virtual CompFieldMap *clone() const;
81 virtual void set_fullname(const string& p_fullname);
82 virtual void set_my_scope(Scope *p_scope);
83 void set_my_type(Type *p_my_type) { my_type = p_my_type; }
84 void add_comp(CompField *comp);
85 size_t get_nof_comps() const { return v.size(); }
86 CompField* get_comp_byIndex(size_t n) const { return v[n]; }
87 bool has_comp_withName(const Identifier& p_name);
88 CompField* get_comp_byName(const Identifier& p_name);
90 const char *get_typetype_name() const;
91 /** Check the uniqueness of field identifiers.
92 * Builds the map \c m in the process. */
96 virtual void dump(unsigned level) const;
100 } /* namespace Common */
101 #endif /* COMPFIELD_HH_ */