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 ///////////////////////////////////////////////////////////////////////////////
11 #include "Optional.hh"
12 // the following are pulled in by Optional.hh:
13 //#include "Basetype.hh"
14 //#include "Template.hh"
20 /** Runtime class for object identifiers (objid)
23 class OBJID : public Base_Type {
24 /** No user serviceable parts. */
26 objid_struct *val_ptr;
28 void init_struct(int n_components);
31 /** Initializes the object identifier with a string containing the components
32 * separated by dots. */
33 void from_string(char* p_str);
36 typedef unsigned int objid_element;
38 OBJID(int init_n_components, ...);
39 OBJID(int init_n_components, const objid_element *init_components);
40 OBJID(const OBJID& other_value);
44 OBJID& operator=(const OBJID& other_value);
46 boolean operator==(const OBJID& other_value) const;
47 inline boolean operator!=(const OBJID& other_value) const
48 { return !(*this == other_value); }
50 objid_element& operator[](int index_value);
51 objid_element operator[](int index_value) const;
53 inline boolean is_bound() const { return val_ptr != NULL; }
54 inline boolean is_value() const { return val_ptr != NULL; }
58 int lengthof() const { return size_of(); } // for backward compatibility
60 operator const objid_element*() const;
62 static objid_element from_INTEGER(const INTEGER& p_int);
64 #ifdef TITAN_RUNTIME_2
65 boolean is_equal(const Base_Type* other_value) const { return *this == *(static_cast<const OBJID*>(other_value)); }
66 void set_value(const Base_Type* other_value) { *this = *(static_cast<const OBJID*>(other_value)); }
67 Base_Type* clone() const { return new OBJID(*this); }
68 const TTCN_Typedescriptor_t* get_descriptor() const { return &OBJID_descr_; }
70 inline boolean is_present() const { return is_bound(); }
74 void set_param(Module_Param& param);
75 void encode_text(Text_Buf& text_buf) const;
76 void decode_text(Text_Buf& text_buf);
78 void encode(const TTCN_Typedescriptor_t&, TTCN_Buffer&,
79 TTCN_EncDec::coding_t, ...) const;
81 void decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&,
82 TTCN_EncDec::coding_t, ...);
84 ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
85 unsigned p_coding) const;
87 boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td,
88 const ASN_BER_TLV_t& p_tlv, unsigned L_form);
89 int XER_encode(const XERdescriptor_t& p_td,
90 TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const;
91 int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
92 unsigned int flavor, embed_values_dec_struct_t*);
94 /** Encodes accordingly to the JSON encoding rules.
95 * Returns the length of the encoded data. */
96 int JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&) const;
98 /** Decodes accordingly to the JSON decoding rules.
99 * Returns the length of the encoded data. */
100 int JSON_decode(const TTCN_Typedescriptor_t&, JSON_Tokenizer&, boolean);
103 // objid template class
105 class OBJID_template : public Base_Template {
108 unsigned int n_values;
109 OBJID_template *list_value;
112 void copy_template(const OBJID_template& other_value);
116 OBJID_template(template_sel other_value);
117 OBJID_template(const OBJID& other_value);
118 OBJID_template(const OPTIONAL<OBJID>& other_value);
119 OBJID_template(const OBJID_template& other_value);
124 OBJID_template& operator=(template_sel other_value);
125 OBJID_template& operator=(const OBJID& other_value);
126 OBJID_template& operator=(const OPTIONAL<OBJID>& other_value);
127 OBJID_template& operator=(const OBJID_template& other_value);
129 boolean match(const OBJID& other_value) const;
130 const OBJID& valueof() const;
134 void set_type(template_sel template_type, unsigned int list_length);
135 OBJID_template& list_item(unsigned int list_index);
138 void log_match(const OBJID& match_value) const;
140 void set_param(Module_Param& param);
142 void encode_text(Text_Buf& text_buf) const;
143 void decode_text(Text_Buf& text_buf);
145 boolean is_present() const;
146 boolean match_omit() const;
147 #ifdef TITAN_RUNTIME_2
148 void valueofv(Base_Type* value) const { *(static_cast<OBJID*>(value)) = valueof(); }
149 void set_value(template_sel other_value) { *this = other_value; }
150 void copy_value(const Base_Type* other_value) { *this = *(static_cast<const OBJID*>(other_value)); }
151 Base_Template* clone() const { return new OBJID_template(*this); }
152 const TTCN_Typedescriptor_t* get_descriptor() const { return &OBJID_descr_; }
153 boolean matchv(const Base_Type* other_value) const { return match(*(static_cast<const OBJID*>(other_value))); }
154 void log_matchv(const Base_Type* match_value) const { log_match(*(static_cast<const OBJID*>(match_value))); }
156 void check_restriction(template_res t_res, const char* t_name=NULL) const;
160 typedef OBJID ASN_ROID;
161 typedef OBJID_template ASN_ROID_template;