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 OBJID_HH |
22 | #define OBJID_HH | |
23 | ||
24 | #include "Optional.hh" | |
25 | // the following are pulled in by Optional.hh: | |
26 | //#include "Basetype.hh" | |
27 | //#include "Template.hh" | |
28 | ||
29 | class Text_Buf; | |
30 | class Module_Param; | |
31 | class INTEGER; | |
32 | ||
33 | /** Runtime class for object identifiers (objid) | |
34 | * | |
35 | */ | |
36 | class OBJID : public Base_Type { | |
37 | /** No user serviceable parts. */ | |
38 | struct objid_struct; | |
39 | objid_struct *val_ptr; | |
40 | ||
41 | void init_struct(int n_components); | |
42 | void copy_value(); | |
af710487 | 43 | |
44 | /** Initializes the object identifier with a string containing the components | |
45 | * separated by dots. */ | |
46 | void from_string(char* p_str); | |
970ed795 EL |
47 | |
48 | public: | |
49 | typedef unsigned int objid_element; | |
50 | OBJID(); | |
51 | OBJID(int init_n_components, ...); | |
52 | OBJID(int init_n_components, const objid_element *init_components); | |
53 | OBJID(const OBJID& other_value); | |
54 | ||
55 | ~OBJID(); | |
56 | ||
57 | OBJID& operator=(const OBJID& other_value); | |
58 | ||
59 | boolean operator==(const OBJID& other_value) const; | |
60 | inline boolean operator!=(const OBJID& other_value) const | |
61 | { return !(*this == other_value); } | |
62 | ||
63 | objid_element& operator[](int index_value); | |
64 | objid_element operator[](int index_value) const; | |
65 | ||
66 | inline boolean is_bound() const { return val_ptr != NULL; } | |
67 | inline boolean is_value() const { return val_ptr != NULL; } | |
68 | void clean_up(); | |
69 | ||
70 | int size_of() const; | |
71 | int lengthof() const { return size_of(); } // for backward compatibility | |
72 | ||
73 | operator const objid_element*() const; | |
74 | ||
75 | static objid_element from_INTEGER(const INTEGER& p_int); | |
76 | ||
77 | #ifdef TITAN_RUNTIME_2 | |
78 | boolean is_equal(const Base_Type* other_value) const { return *this == *(static_cast<const OBJID*>(other_value)); } | |
79 | void set_value(const Base_Type* other_value) { *this = *(static_cast<const OBJID*>(other_value)); } | |
80 | Base_Type* clone() const { return new OBJID(*this); } | |
81 | const TTCN_Typedescriptor_t* get_descriptor() const { return &OBJID_descr_; } | |
82 | #else | |
83 | inline boolean is_present() const { return is_bound(); } | |
84 | #endif | |
85 | ||
86 | void log() const; | |
3abe9331 | 87 | |
970ed795 | 88 | void set_param(Module_Param& param); |
3abe9331 | 89 | Module_Param* get_param(Module_Param_Name& param_name) const; |
90 | ||
970ed795 EL |
91 | void encode_text(Text_Buf& text_buf) const; |
92 | void decode_text(Text_Buf& text_buf); | |
93 | ||
94 | void encode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, | |
95 | TTCN_EncDec::coding_t, ...) const; | |
96 | ||
97 | void decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, | |
98 | TTCN_EncDec::coding_t, ...); | |
99 | ||
100 | ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, | |
101 | unsigned p_coding) const; | |
102 | ||
103 | boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td, | |
104 | const ASN_BER_TLV_t& p_tlv, unsigned L_form); | |
105 | int XER_encode(const XERdescriptor_t& p_td, | |
af710487 | 106 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const; |
970ed795 | 107 | int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, |
feade998 | 108 | unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*); |
af710487 | 109 | |
110 | /** Encodes accordingly to the JSON encoding rules. | |
111 | * Returns the length of the encoded data. */ | |
112 | int JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&) const; | |
113 | ||
114 | /** Decodes accordingly to the JSON decoding rules. | |
115 | * Returns the length of the encoded data. */ | |
116 | int JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean); | |
970ed795 EL |
117 | }; |
118 | ||
119 | // objid template class | |
120 | ||
121 | class OBJID_template : public Base_Template { | |
122 | OBJID single_value; | |
123 | struct { | |
124 | unsigned int n_values; | |
125 | OBJID_template *list_value; | |
126 | } value_list; | |
127 | ||
128 | void copy_template(const OBJID_template& other_value); | |
129 | ||
130 | public: | |
131 | OBJID_template(); | |
132 | OBJID_template(template_sel other_value); | |
133 | OBJID_template(const OBJID& other_value); | |
134 | OBJID_template(const OPTIONAL<OBJID>& other_value); | |
135 | OBJID_template(const OBJID_template& other_value); | |
136 | ||
137 | ~OBJID_template(); | |
138 | void clean_up(); | |
139 | ||
140 | OBJID_template& operator=(template_sel other_value); | |
141 | OBJID_template& operator=(const OBJID& other_value); | |
142 | OBJID_template& operator=(const OPTIONAL<OBJID>& other_value); | |
143 | OBJID_template& operator=(const OBJID_template& other_value); | |
144 | ||
3abe9331 | 145 | boolean match(const OBJID& other_value, boolean legacy = FALSE) const; |
970ed795 EL |
146 | const OBJID& valueof() const; |
147 | ||
148 | int size_of() const; | |
149 | ||
150 | void set_type(template_sel template_type, unsigned int list_length); | |
151 | OBJID_template& list_item(unsigned int list_index); | |
152 | ||
153 | void log() const; | |
3abe9331 | 154 | void log_match(const OBJID& match_value, boolean legacy = FALSE) const; |
970ed795 EL |
155 | |
156 | void set_param(Module_Param& param); | |
3abe9331 | 157 | Module_Param* get_param(Module_Param_Name& param_name) const; |
970ed795 EL |
158 | |
159 | void encode_text(Text_Buf& text_buf) const; | |
160 | void decode_text(Text_Buf& text_buf); | |
161 | ||
3abe9331 | 162 | boolean is_present(boolean legacy = FALSE) const; |
163 | boolean match_omit(boolean legacy = FALSE) const; | |
970ed795 EL |
164 | #ifdef TITAN_RUNTIME_2 |
165 | void valueofv(Base_Type* value) const { *(static_cast<OBJID*>(value)) = valueof(); } | |
166 | void set_value(template_sel other_value) { *this = other_value; } | |
167 | void copy_value(const Base_Type* other_value) { *this = *(static_cast<const OBJID*>(other_value)); } | |
168 | Base_Template* clone() const { return new OBJID_template(*this); } | |
169 | const TTCN_Typedescriptor_t* get_descriptor() const { return &OBJID_descr_; } | |
3abe9331 | 170 | boolean matchv(const Base_Type* other_value, boolean legacy) const { return match(*(static_cast<const OBJID*>(other_value)), legacy); } |
171 | void log_matchv(const Base_Type* match_value, boolean legacy) const { log_match(*(static_cast<const OBJID*>(match_value)), legacy); } | |
970ed795 | 172 | #else |
3abe9331 | 173 | void check_restriction(template_res t_res, const char* t_name=NULL, boolean legacy = FALSE) const; |
970ed795 EL |
174 | #endif |
175 | }; | |
176 | ||
177 | typedef OBJID ASN_ROID; | |
178 | typedef OBJID_template ASN_ROID_template; | |
179 | ||
180 | #endif |