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