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
17 * Szabo, Janos Zoltan – initial implementation
20 ******************************************************************************/
24 #include "Optional.hh"
25 // the following are pulled in by Optional.hh:
26 //#include "Basetype.hh"
27 //#include "Template.hh"
33 /** Runtime class for object identifiers (objid)
36 class OBJID : public Base_Type {
37 /** No user serviceable parts. */
39 objid_struct *val_ptr;
41 void init_struct(int n_components);
44 /** Initializes the object identifier with a string containing the components
45 * separated by dots. */
46 void from_string(char* p_str);
49 typedef unsigned int objid_element;
51 OBJID(int init_n_components, ...);
52 OBJID(int init_n_components, const objid_element *init_components);
53 OBJID(const OBJID& other_value);
57 OBJID& operator=(const OBJID& other_value);
59 boolean operator==(const OBJID& other_value) const;
60 inline boolean operator!=(const OBJID& other_value) const
61 { return !(*this == other_value); }
63 objid_element& operator[](int index_value);
64 objid_element operator[](int index_value) const;
66 inline boolean is_bound() const { return val_ptr != NULL; }
67 inline boolean is_value() const { return val_ptr != NULL; }
71 int lengthof() const { return size_of(); } // for backward compatibility
73 operator const objid_element*() const;
75 static objid_element from_INTEGER(const INTEGER& p_int);
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_; }
83 inline boolean is_present() const { return is_bound(); }
88 void set_param(Module_Param& param);
89 Module_Param* get_param(Module_Param_Name& param_name) const;
91 void encode_text(Text_Buf& text_buf) const;
92 void decode_text(Text_Buf& text_buf);
94 void encode(const TTCN_Typedescriptor_t&, TTCN_Buffer&,
95 TTCN_EncDec::coding_t, ...) const;
97 void decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&,
98 TTCN_EncDec::coding_t, ...);
100 ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
101 unsigned p_coding) const;
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,
106 TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const;
107 int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
108 unsigned int flavor, unsigned int flavor2, embed_values_dec_struct_t*);
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;
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);
119 // objid template class
121 class OBJID_template : public Base_Template {
124 unsigned int n_values;
125 OBJID_template *list_value;
128 void copy_template(const OBJID_template& other_value);
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);
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);
145 boolean match(const OBJID& other_value, boolean legacy = FALSE) const;
146 const OBJID& valueof() const;
150 void set_type(template_sel template_type, unsigned int list_length);
151 OBJID_template& list_item(unsigned int list_index);
154 void log_match(const OBJID& match_value, boolean legacy = FALSE) const;
156 void set_param(Module_Param& param);
157 Module_Param* get_param(Module_Param_Name& param_name) const;
159 void encode_text(Text_Buf& text_buf) const;
160 void decode_text(Text_Buf& text_buf);
162 boolean is_present(boolean legacy = FALSE) const;
163 boolean match_omit(boolean legacy = FALSE) const;
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_; }
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); }
173 void check_restriction(template_res t_res, const char* t_name=NULL, boolean legacy = FALSE) const;
177 typedef OBJID ASN_ROID;
178 typedef OBJID_template ASN_ROID_template;