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);
32 typedef unsigned int objid_element;
34 OBJID(int init_n_components, ...);
35 OBJID(int init_n_components, const objid_element *init_components);
36 OBJID(const OBJID& other_value);
40 OBJID& operator=(const OBJID& other_value);
42 boolean operator==(const OBJID& other_value) const;
43 inline boolean operator!=(const OBJID& other_value) const
44 { return !(*this == other_value); }
46 objid_element& operator[](int index_value);
47 objid_element operator[](int index_value) const;
49 inline boolean is_bound() const { return val_ptr != NULL; }
50 inline boolean is_value() const { return val_ptr != NULL; }
54 int lengthof() const { return size_of(); } // for backward compatibility
56 operator const objid_element*() const;
58 static objid_element from_INTEGER(const INTEGER& p_int);
60 #ifdef TITAN_RUNTIME_2
61 boolean is_equal(const Base_Type* other_value) const { return *this == *(static_cast<const OBJID*>(other_value)); }
62 void set_value(const Base_Type* other_value) { *this = *(static_cast<const OBJID*>(other_value)); }
63 Base_Type* clone() const { return new OBJID(*this); }
64 const TTCN_Typedescriptor_t* get_descriptor() const { return &OBJID_descr_; }
66 inline boolean is_present() const { return is_bound(); }
70 void set_param(Module_Param& param);
71 void encode_text(Text_Buf& text_buf) const;
72 void decode_text(Text_Buf& text_buf);
74 void encode(const TTCN_Typedescriptor_t&, TTCN_Buffer&,
75 TTCN_EncDec::coding_t, ...) const;
77 void decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&,
78 TTCN_EncDec::coding_t, ...);
80 ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
81 unsigned p_coding) const;
83 boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td,
84 const ASN_BER_TLV_t& p_tlv, unsigned L_form);
85 int XER_encode(const XERdescriptor_t& p_td,
86 TTCN_Buffer& p_buf, unsigned int flavor, int indent) const;
87 int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
91 // objid template class
93 class OBJID_template : public Base_Template {
96 unsigned int n_values;
97 OBJID_template *list_value;
100 void copy_template(const OBJID_template& other_value);
104 OBJID_template(template_sel other_value);
105 OBJID_template(const OBJID& other_value);
106 OBJID_template(const OPTIONAL<OBJID>& other_value);
107 OBJID_template(const OBJID_template& other_value);
112 OBJID_template& operator=(template_sel other_value);
113 OBJID_template& operator=(const OBJID& other_value);
114 OBJID_template& operator=(const OPTIONAL<OBJID>& other_value);
115 OBJID_template& operator=(const OBJID_template& other_value);
117 boolean match(const OBJID& other_value) const;
118 const OBJID& valueof() const;
122 void set_type(template_sel template_type, unsigned int list_length);
123 OBJID_template& list_item(unsigned int list_index);
126 void log_match(const OBJID& match_value) const;
128 void set_param(Module_Param& param);
130 void encode_text(Text_Buf& text_buf) const;
131 void decode_text(Text_Buf& text_buf);
133 boolean is_present() const;
134 boolean match_omit() const;
135 #ifdef TITAN_RUNTIME_2
136 void valueofv(Base_Type* value) const { *(static_cast<OBJID*>(value)) = valueof(); }
137 void set_value(template_sel other_value) { *this = other_value; }
138 void copy_value(const Base_Type* other_value) { *this = *(static_cast<const OBJID*>(other_value)); }
139 Base_Template* clone() const { return new OBJID_template(*this); }
140 const TTCN_Typedescriptor_t* get_descriptor() const { return &OBJID_descr_; }
141 boolean matchv(const Base_Type* other_value) const { return match(*(static_cast<const OBJID*>(other_value))); }
142 void log_matchv(const Base_Type* match_value) const { log_match(*(static_cast<const OBJID*>(match_value))); }
144 void check_restriction(template_res t_res, const char* t_name=NULL) const;
148 typedef OBJID ASN_ROID;
149 typedef OBJID_template ASN_ROID_template;