Commit | Line | Data |
---|---|---|
d44e3c4f | 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 | |
7 | * | |
8 | * Contributors: | |
9 | * Balasko, Jeno | |
10 | * Baranyi, Botond | |
11 | * Beres, Szabolcs | |
12 | * Delic, Adam | |
13 | * Forstner, Matyas | |
14 | * Raduly, Csaba | |
15 | * Szabados, Kristof | |
16 | * Szabo, Bence Janos | |
17 | * Szabo, Janos Zoltan – initial implementation | |
18 | * Tatarka, Gabor | |
19 | * | |
20 | ******************************************************************************/ | |
970ed795 EL |
21 | #ifndef VERDICTTYPE_HH |
22 | #define VERDICTTYPE_HH | |
23 | ||
24 | #include "Basetype.hh" | |
25 | #include "Template.hh" | |
26 | #include "Optional.hh" | |
27 | ||
28 | class Module_Param; | |
29 | ||
30 | /// verdicttype value class | |
31 | ||
32 | class VERDICTTYPE: public Base_Type { | |
33 | friend class VERDICTTYPE_template; | |
34 | friend boolean operator==(verdicttype par_value, | |
35 | const VERDICTTYPE& other_value); | |
36 | ||
37 | verdicttype verdict_value; | |
38 | verdicttype str_to_verdict(const char *v, boolean silent = false); | |
39 | public: | |
40 | /** Default constructor. | |
41 | * Initialises \p verdict_value to UNBOUND_VERDICT, a private macro | |
42 | * outside the range of \p verdicttype enum. | |
43 | * | |
44 | * @post \p is_bound() would return \p false */ | |
45 | VERDICTTYPE(); | |
46 | VERDICTTYPE(verdicttype other_value); | |
47 | VERDICTTYPE(const VERDICTTYPE& other_value); | |
48 | ||
49 | VERDICTTYPE& operator=(verdicttype other_value); | |
50 | VERDICTTYPE& operator=(const VERDICTTYPE& other_value); | |
51 | ||
52 | boolean operator==(verdicttype other_value) const; | |
53 | boolean operator==(const VERDICTTYPE& other_value) const; | |
54 | inline boolean operator!=(verdicttype other_value) const | |
55 | { | |
56 | return !(*this == other_value); | |
57 | } | |
58 | inline boolean operator!=(const VERDICTTYPE& other_value) const | |
59 | { | |
60 | return !(*this == other_value); | |
61 | } | |
62 | ||
63 | operator verdicttype() const; | |
64 | ||
65 | inline boolean is_bound() const | |
66 | { | |
67 | return verdict_value >= NONE && verdict_value <= ERROR; | |
68 | } | |
69 | inline boolean is_value() const | |
70 | { | |
71 | return is_bound(); | |
72 | } | |
73 | void clean_up(); | |
74 | ||
75 | #ifdef TITAN_RUNTIME_2 | |
76 | boolean is_equal(const Base_Type* other_value) const {return *this == *(static_cast<const VERDICTTYPE*>(other_value));} | |
77 | void set_value(const Base_Type* other_value) {*this = *(static_cast<const VERDICTTYPE*>(other_value));} | |
78 | Base_Type* clone() const {return new VERDICTTYPE(*this);} | |
79 | const TTCN_Typedescriptor_t* get_descriptor() const {return &VERDICTTYPE_descr_;} | |
80 | #else | |
81 | inline boolean is_present() const { return is_bound(); } | |
82 | #endif | |
83 | ||
84 | void log() const; | |
85 | ||
86 | void set_param(Module_Param& param); | |
3abe9331 | 87 | Module_Param* get_param(Module_Param_Name& param_name) const; |
970ed795 EL |
88 | |
89 | void encode_text(Text_Buf& text_buf) const; | |
90 | void decode_text(Text_Buf& text_buf); | |
91 | ||
92 | void encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, | |
93 | TTCN_EncDec::coding_t p_coding, ...) const; | |
94 | ||
95 | void decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, | |
96 | TTCN_EncDec::coding_t p_coding, ...); | |
97 | ||
98 | int XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf, | |
af710487 | 99 | unsigned int flavor, int indent, embed_values_enc_struct_t*) const; |
970ed795 | 100 | int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, |
feade998 | 101 | unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*); |
970ed795 EL |
102 | |
103 | /** Encodes accordingly to the JSON encoding rules. | |
104 | * Returns the length of the encoded data. */ | |
105 | int JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&) const; | |
106 | ||
107 | /** Decodes accordingly to the JSON encoding rules. | |
108 | * Returns the length of the decoded data. */ | |
109 | int JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean); | |
110 | }; | |
111 | ||
112 | inline boolean operator==(verdicttype par_value, verdicttype other_value) | |
113 | { | |
114 | return (int) par_value == (int) other_value; | |
115 | } | |
116 | ||
117 | inline boolean operator!=(verdicttype par_value, verdicttype other_value) | |
118 | { | |
119 | return (int) par_value != (int) other_value; | |
120 | } | |
121 | ||
122 | extern boolean operator==(verdicttype par_value, const VERDICTTYPE& other_value); | |
123 | ||
124 | inline boolean operator!=(verdicttype par_value, const VERDICTTYPE& other_value) | |
125 | { | |
126 | return !(par_value == other_value); | |
127 | } | |
128 | ||
129 | // verdicttype template class | |
130 | ||
131 | class VERDICTTYPE_template: public Base_Template { | |
132 | union { | |
133 | verdicttype single_value; | |
134 | struct { | |
135 | unsigned int n_values; | |
136 | VERDICTTYPE_template *list_value; | |
137 | } value_list; | |
138 | }; | |
139 | ||
140 | void copy_value(const VERDICTTYPE& other_value); | |
141 | void copy_template(const VERDICTTYPE_template& other_value); | |
142 | ||
143 | public: | |
144 | VERDICTTYPE_template(); | |
145 | VERDICTTYPE_template(template_sel other_value); | |
146 | VERDICTTYPE_template(verdicttype other_value); | |
147 | VERDICTTYPE_template(const VERDICTTYPE& other_value); | |
148 | VERDICTTYPE_template(const OPTIONAL<VERDICTTYPE>& other_value); | |
149 | VERDICTTYPE_template(const VERDICTTYPE_template& other_value); | |
150 | ||
151 | ~VERDICTTYPE_template(); | |
152 | void clean_up(); | |
153 | ||
154 | VERDICTTYPE_template& operator=(template_sel other_value); | |
155 | VERDICTTYPE_template& operator=(verdicttype other_value); | |
156 | VERDICTTYPE_template& operator=(const VERDICTTYPE& other_value); | |
157 | VERDICTTYPE_template& operator=(const OPTIONAL<VERDICTTYPE>& other_value); | |
158 | VERDICTTYPE_template& operator=(const VERDICTTYPE_template& other_value); | |
159 | ||
3abe9331 | 160 | boolean match(verdicttype other_value, boolean legacy = FALSE) const; |
161 | boolean match(const VERDICTTYPE& other_value, boolean legacy = FALSE) const; | |
970ed795 EL |
162 | verdicttype valueof() const; |
163 | ||
164 | void set_type(template_sel template_type, unsigned int list_length); | |
165 | VERDICTTYPE_template& list_item(unsigned int list_index); | |
166 | ||
167 | void log() const; | |
3abe9331 | 168 | void log_match(const VERDICTTYPE& match_value, boolean legacy = FALSE) const; |
970ed795 EL |
169 | |
170 | void set_param(Module_Param& param); | |
3abe9331 | 171 | Module_Param* get_param(Module_Param_Name& param_name) const; |
970ed795 EL |
172 | |
173 | void encode_text(Text_Buf& text_buf) const; | |
174 | void decode_text(Text_Buf& text_buf); | |
175 | ||
3abe9331 | 176 | boolean is_present(boolean legacy = FALSE) const; |
177 | boolean match_omit(boolean legacy = FALSE) const; | |
970ed795 EL |
178 | #ifdef TITAN_RUNTIME_2 |
179 | void valueofv(Base_Type* value) const {*(static_cast<VERDICTTYPE*>(value)) = valueof();} | |
180 | void set_value(template_sel other_value) {*this = other_value;} | |
181 | void copy_value(const Base_Type* other_value) {*this = *(static_cast<const VERDICTTYPE*>(other_value));} | |
182 | Base_Template* clone() const {return new VERDICTTYPE_template(*this);} | |
183 | const TTCN_Typedescriptor_t* get_descriptor() const {return &VERDICTTYPE_descr_;} | |
3abe9331 | 184 | boolean matchv(const Base_Type* other_value, boolean legacy) const {return match(*(static_cast<const VERDICTTYPE*>(other_value)), legacy);} |
185 | void log_matchv(const Base_Type* match_value, boolean legacy) const {log_match(*(static_cast<const VERDICTTYPE*>(match_value)), legacy);} | |
970ed795 | 186 | #else |
3abe9331 | 187 | void check_restriction(template_res t_res, const char* t_name=NULL, boolean legacy = FALSE) const; |
970ed795 EL |
188 | #endif |
189 | }; | |
190 | ||
191 | #endif |