| 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 _Common_Typestuff_HH |
| 9 | #define _Common_Typestuff_HH |
| 10 | |
| 11 | #include "Setting.hh" |
| 12 | |
| 13 | namespace Asn { |
| 14 | class TagCollection; |
| 15 | } // namespace Asn |
| 16 | |
| 17 | namespace Ttcn { |
| 18 | class WithAttribPath; |
| 19 | } |
| 20 | |
| 21 | namespace Common { |
| 22 | class CompField; |
| 23 | |
| 24 | /** |
| 25 | * \addtogroup AST_Type |
| 26 | * |
| 27 | * @{ |
| 28 | */ |
| 29 | |
| 30 | /** |
| 31 | * ExceptionSpecification |
| 32 | */ |
| 33 | class ExcSpec : public Node { |
| 34 | private: |
| 35 | Type *type; |
| 36 | Value *value; |
| 37 | /** Copy constructor not implemented */ |
| 38 | ExcSpec(const ExcSpec& p); |
| 39 | /** Assignment disabled */ |
| 40 | ExcSpec& operator=(const ExcSpec& p); |
| 41 | public: |
| 42 | ExcSpec(Type *p_type, Value *p_value); |
| 43 | virtual ~ExcSpec(); |
| 44 | virtual ExcSpec *clone() const; |
| 45 | virtual void set_my_scope(Scope *p_scope); |
| 46 | virtual void set_fullname(const string& p_fullname); |
| 47 | Type *get_type() const { return type; } |
| 48 | Value *get_value() const { return value; } |
| 49 | }; |
| 50 | |
| 51 | class CTs_EE_CTs; |
| 52 | class CTs; |
| 53 | class ExtAndExc; |
| 54 | class ExtAdds; |
| 55 | class ExtAddGrp; |
| 56 | class ExtAdd; |
| 57 | class CT; |
| 58 | class CT_CompsOf; |
| 59 | class CT_reg; |
| 60 | |
| 61 | /** |
| 62 | * ComponentTypeList |
| 63 | */ |
| 64 | class CTs : public Node { |
| 65 | private: |
| 66 | vector<CT> cts; |
| 67 | /** Copy constructor not implemented */ |
| 68 | CTs(const CTs& p); |
| 69 | /** Assignment disabled */ |
| 70 | CTs& operator=(const CTs& p); |
| 71 | public: |
| 72 | CTs() : Node(), cts() { } |
| 73 | virtual ~CTs(); |
| 74 | virtual CTs *clone() const; |
| 75 | virtual void set_fullname(const string& p_fullname); |
| 76 | virtual void set_my_scope(Scope *p_scope); |
| 77 | size_t get_nof_comps() const; |
| 78 | CompField* get_comp_byIndex(size_t n) const; |
| 79 | bool has_comp_withName(const Identifier& p_name) const; |
| 80 | CompField* get_comp_byName(const Identifier& p_name) const; |
| 81 | void tr_compsof(ReferenceChain *refch, bool is_set); |
| 82 | void add_ct(CT* p_ct); |
| 83 | virtual void dump(unsigned level) const; |
| 84 | }; |
| 85 | |
| 86 | /** |
| 87 | * ComponentTypeList ExtensionAndException ComponentTypeList |
| 88 | */ |
| 89 | class CTs_EE_CTs : public Node { |
| 90 | CTs *cts1; |
| 91 | ExtAndExc *ee; |
| 92 | CTs *cts2; |
| 93 | /** Pointer to the owner type */ |
| 94 | Type *my_type; |
| 95 | /** Indicates whether the uniqueness of components has been checked */ |
| 96 | bool checked; |
| 97 | /** Shortcut for all components */ |
| 98 | vector<CompField> comps_v; |
| 99 | /** Map for all components (indexed by component name) */ |
| 100 | map<string, CompField> comps_m; |
| 101 | /** Copy constructor not implemented */ |
| 102 | CTs_EE_CTs(const CTs_EE_CTs& p); |
| 103 | /** Assignment disabled */ |
| 104 | CTs_EE_CTs& operator=(const CTs_EE_CTs& p); |
| 105 | public: |
| 106 | CTs_EE_CTs(CTs *p_cts1, ExtAndExc *p_ee, CTs *p_cts2); |
| 107 | virtual ~CTs_EE_CTs(); |
| 108 | virtual CTs_EE_CTs *clone() const; |
| 109 | virtual void set_fullname(const string& p_fullname); |
| 110 | virtual void set_my_scope(Scope *p_scope); |
| 111 | void set_my_type(Type *p_my_type) { my_type = p_my_type; } |
| 112 | size_t get_nof_comps(); |
| 113 | size_t get_nof_root_comps(); |
| 114 | CompField* get_comp_byIndex(size_t n); |
| 115 | CompField* get_root_comp_byIndex(size_t n); |
| 116 | bool has_comp_withName(const Identifier& p_name); |
| 117 | CompField* get_comp_byName(const Identifier& p_name); |
| 118 | void tr_compsof(ReferenceChain *refch, bool in_ellipsis); |
| 119 | bool has_ellipsis() const { return ee != 0; } |
| 120 | bool needs_auto_tags(); |
| 121 | void add_auto_tags(); |
| 122 | /** Checks the uniqueness of components and builds the shortcut map and |
| 123 | * vectors */ |
| 124 | void chk(); |
| 125 | void chk_tags(); |
| 126 | virtual void dump(unsigned level) const; |
| 127 | private: |
| 128 | void chk_comp_field(CompField *cf, const char *type_name, |
| 129 | const char *comp_name); |
| 130 | void chk_tags_choice(); |
| 131 | void chk_tags_seq(); |
| 132 | void chk_tags_seq_comp(Asn::TagCollection& coll, CompField *cf, |
| 133 | bool is_mandatory); |
| 134 | void chk_tags_set(); |
| 135 | void get_multiple_tags(Asn::TagCollection& coll, Type *type); |
| 136 | }; |
| 137 | |
| 138 | /** |
| 139 | * ExtensionAddition (abstract class). |
| 140 | */ |
| 141 | class ExtAdd : public Node { |
| 142 | public: |
| 143 | virtual ExtAdd *clone() const = 0; |
| 144 | virtual size_t get_nof_comps() const = 0; |
| 145 | virtual CompField* get_comp_byIndex(size_t n) const = 0; |
| 146 | virtual bool has_comp_withName(const Identifier& p_name) const = 0; |
| 147 | virtual CompField* get_comp_byName(const Identifier& p_name) const = 0; |
| 148 | virtual void tr_compsof(ReferenceChain *refch, bool is_set) = 0; |
| 149 | }; |
| 150 | |
| 151 | /** |
| 152 | * ExtensionAdditionList |
| 153 | */ |
| 154 | class ExtAdds : public Node { |
| 155 | private: |
| 156 | vector<ExtAdd> eas; |
| 157 | /** Copy constructor not implemented */ |
| 158 | ExtAdds(const ExtAdds& p); |
| 159 | /** Assignment disabled */ |
| 160 | ExtAdds& operator=(const ExtAdds& p); |
| 161 | public: |
| 162 | ExtAdds() : Node(), eas() { } |
| 163 | virtual ~ExtAdds(); |
| 164 | virtual ExtAdds *clone() const; |
| 165 | virtual void set_fullname(const string& p_fullname); |
| 166 | virtual void set_my_scope(Scope *p_scope); |
| 167 | size_t get_nof_comps() const; |
| 168 | CompField* get_comp_byIndex(size_t n) const; |
| 169 | bool has_comp_withName(const Identifier& p_name) const; |
| 170 | CompField* get_comp_byName(const Identifier& p_name) const; |
| 171 | void tr_compsof(ReferenceChain *refch, bool is_set); |
| 172 | void add_ea(ExtAdd* p_ea); |
| 173 | virtual void dump(unsigned level) const; |
| 174 | }; |
| 175 | |
| 176 | /** |
| 177 | * ExtensionAndException |
| 178 | */ |
| 179 | class ExtAndExc : public Node { |
| 180 | private: |
| 181 | /** optional exception specification */ |
| 182 | ExcSpec *excSpec; |
| 183 | ExtAdds *eas; |
| 184 | /** Copy constructor not implemented */ |
| 185 | ExtAndExc(const ExtAndExc& p); |
| 186 | /** Assignment disabled */ |
| 187 | ExtAndExc& operator=(const ExtAndExc& p); |
| 188 | public: |
| 189 | ExtAndExc(ExcSpec *p_excSpec, ExtAdds *p_eas=0); |
| 190 | virtual ~ExtAndExc(); |
| 191 | virtual ExtAndExc *clone() const; |
| 192 | virtual void set_fullname(const string& p_fullname); |
| 193 | virtual void set_my_scope(Scope *p_scope); |
| 194 | size_t get_nof_comps() const { return eas->get_nof_comps(); } |
| 195 | CompField* get_comp_byIndex(size_t n) const |
| 196 | { return eas->get_comp_byIndex(n); } |
| 197 | bool has_comp_withName(const Identifier& p_name) const |
| 198 | { return eas->has_comp_withName(p_name); } |
| 199 | CompField* get_comp_byName(const Identifier& p_name) const |
| 200 | { return eas->get_comp_byName(p_name); } |
| 201 | void tr_compsof(ReferenceChain *refch, bool is_set) |
| 202 | { eas->tr_compsof(refch, is_set); } |
| 203 | void set_eas(ExtAdds *p_eas); |
| 204 | virtual void dump(unsigned level) const; |
| 205 | }; |
| 206 | |
| 207 | /** |
| 208 | * ExtensionAdditionGroup |
| 209 | */ |
| 210 | class ExtAddGrp : public ExtAdd { |
| 211 | private: |
| 212 | /** can be NULL if not present */ |
| 213 | Value *versionnumber; |
| 214 | CTs *cts; |
| 215 | /** Copy constructor not implemented */ |
| 216 | ExtAddGrp(const ExtAddGrp& p); |
| 217 | /** Assignment disabled */ |
| 218 | ExtAddGrp& operator=(const ExtAddGrp& p); |
| 219 | public: |
| 220 | ExtAddGrp(Value* p_versionnumber, CTs *p_cts); |
| 221 | virtual ~ExtAddGrp(); |
| 222 | virtual ExtAddGrp *clone() const; |
| 223 | virtual void set_fullname(const string& p_fullname); |
| 224 | virtual void set_my_scope(Scope *p_scope); |
| 225 | virtual size_t get_nof_comps() const; |
| 226 | virtual CompField* get_comp_byIndex(size_t n) const; |
| 227 | virtual bool has_comp_withName(const Identifier& p_name) const; |
| 228 | virtual CompField* get_comp_byName(const Identifier& p_name) const; |
| 229 | virtual void tr_compsof(ReferenceChain *refch, bool is_set); |
| 230 | virtual void dump(unsigned level) const; |
| 231 | }; |
| 232 | |
| 233 | /** |
| 234 | * ComponentType (abstract class). |
| 235 | */ |
| 236 | class CT : public ExtAdd, public Location { |
| 237 | public: |
| 238 | virtual CT *clone() const = 0; |
| 239 | }; |
| 240 | |
| 241 | /** |
| 242 | * ComponentType/regular (Contains only a Component). |
| 243 | */ |
| 244 | class CT_reg : public CT { |
| 245 | private: |
| 246 | CompField *comp; |
| 247 | /** Copy constructor not implemented */ |
| 248 | CT_reg(const CT_reg& p); |
| 249 | /** Assignment disabled */ |
| 250 | CT_reg& operator=(const CT_reg& p); |
| 251 | public: |
| 252 | CT_reg(CompField *p_comp); |
| 253 | virtual ~CT_reg(); |
| 254 | virtual CT_reg *clone() const; |
| 255 | virtual void set_fullname(const string& p_fullname); |
| 256 | virtual void set_my_scope(Scope *p_scope); |
| 257 | virtual size_t get_nof_comps() const; |
| 258 | virtual CompField* get_comp_byIndex(size_t n) const; |
| 259 | virtual bool has_comp_withName(const Identifier& p_name) const; |
| 260 | virtual CompField* get_comp_byName(const Identifier& p_name) const; |
| 261 | virtual void tr_compsof(ReferenceChain *refch, bool is_set); |
| 262 | virtual void dump(unsigned level) const; |
| 263 | }; |
| 264 | |
| 265 | /** |
| 266 | * ComponentsOf |
| 267 | */ |
| 268 | class CT_CompsOf : public CT { |
| 269 | private: |
| 270 | Type *compsoftype; |
| 271 | bool tr_compsof_ready; |
| 272 | CTs *cts; |
| 273 | /** Copy constructor not implemented */ |
| 274 | CT_CompsOf(const CT_CompsOf& p); |
| 275 | /** Assignment disabled */ |
| 276 | CT_CompsOf& operator=(const CT_CompsOf& p); |
| 277 | public: |
| 278 | CT_CompsOf(Type *p_compsoftype); |
| 279 | virtual ~CT_CompsOf(); |
| 280 | virtual CT_CompsOf *clone() const; |
| 281 | virtual void set_fullname(const string& p_fullname); |
| 282 | virtual void set_my_scope(Scope *p_scope); |
| 283 | virtual size_t get_nof_comps() const; |
| 284 | virtual CompField* get_comp_byIndex(size_t n) const; |
| 285 | virtual bool has_comp_withName(const Identifier& p_name) const; |
| 286 | virtual CompField* get_comp_byName(const Identifier& p_name) const; |
| 287 | virtual void tr_compsof(ReferenceChain *refch, bool is_set); |
| 288 | virtual void dump(unsigned level) const; |
| 289 | }; |
| 290 | |
| 291 | /** @} end of AST_Type group */ |
| 292 | |
| 293 | } // namespace Common |
| 294 | |
| 295 | #endif // _Common_Typestuff_HH |