Commit | Line | Data |
---|---|---|
970ed795 EL |
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 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #ifndef OBJID_HH | |
9 | #define OBJID_HH | |
10 | ||
11 | #include "Optional.hh" | |
12 | // the following are pulled in by Optional.hh: | |
13 | //#include "Basetype.hh" | |
14 | //#include "Template.hh" | |
15 | ||
16 | class Text_Buf; | |
17 | class Module_Param; | |
18 | class INTEGER; | |
19 | ||
20 | /** Runtime class for object identifiers (objid) | |
21 | * | |
22 | */ | |
23 | class OBJID : public Base_Type { | |
24 | /** No user serviceable parts. */ | |
25 | struct objid_struct; | |
26 | objid_struct *val_ptr; | |
27 | ||
28 | void init_struct(int n_components); | |
29 | void copy_value(); | |
30 | ||
31 | public: | |
32 | typedef unsigned int objid_element; | |
33 | OBJID(); | |
34 | OBJID(int init_n_components, ...); | |
35 | OBJID(int init_n_components, const objid_element *init_components); | |
36 | OBJID(const OBJID& other_value); | |
37 | ||
38 | ~OBJID(); | |
39 | ||
40 | OBJID& operator=(const OBJID& other_value); | |
41 | ||
42 | boolean operator==(const OBJID& other_value) const; | |
43 | inline boolean operator!=(const OBJID& other_value) const | |
44 | { return !(*this == other_value); } | |
45 | ||
46 | objid_element& operator[](int index_value); | |
47 | objid_element operator[](int index_value) const; | |
48 | ||
49 | inline boolean is_bound() const { return val_ptr != NULL; } | |
50 | inline boolean is_value() const { return val_ptr != NULL; } | |
51 | void clean_up(); | |
52 | ||
53 | int size_of() const; | |
54 | int lengthof() const { return size_of(); } // for backward compatibility | |
55 | ||
56 | operator const objid_element*() const; | |
57 | ||
58 | static objid_element from_INTEGER(const INTEGER& p_int); | |
59 | ||
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_; } | |
65 | #else | |
66 | inline boolean is_present() const { return is_bound(); } | |
67 | #endif | |
68 | ||
69 | void log() const; | |
70 | void set_param(Module_Param& param); | |
71 | void encode_text(Text_Buf& text_buf) const; | |
72 | void decode_text(Text_Buf& text_buf); | |
73 | ||
74 | void encode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, | |
75 | TTCN_EncDec::coding_t, ...) const; | |
76 | ||
77 | void decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, | |
78 | TTCN_EncDec::coding_t, ...); | |
79 | ||
80 | ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, | |
81 | unsigned p_coding) const; | |
82 | ||
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, | |
88 | unsigned int flavor); | |
89 | }; | |
90 | ||
91 | // objid template class | |
92 | ||
93 | class OBJID_template : public Base_Template { | |
94 | OBJID single_value; | |
95 | struct { | |
96 | unsigned int n_values; | |
97 | OBJID_template *list_value; | |
98 | } value_list; | |
99 | ||
100 | void copy_template(const OBJID_template& other_value); | |
101 | ||
102 | public: | |
103 | OBJID_template(); | |
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); | |
108 | ||
109 | ~OBJID_template(); | |
110 | void clean_up(); | |
111 | ||
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); | |
116 | ||
117 | boolean match(const OBJID& other_value) const; | |
118 | const OBJID& valueof() const; | |
119 | ||
120 | int size_of() const; | |
121 | ||
122 | void set_type(template_sel template_type, unsigned int list_length); | |
123 | OBJID_template& list_item(unsigned int list_index); | |
124 | ||
125 | void log() const; | |
126 | void log_match(const OBJID& match_value) const; | |
127 | ||
128 | void set_param(Module_Param& param); | |
129 | ||
130 | void encode_text(Text_Buf& text_buf) const; | |
131 | void decode_text(Text_Buf& text_buf); | |
132 | ||
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))); } | |
143 | #else | |
144 | void check_restriction(template_res t_res, const char* t_name=NULL) const; | |
145 | #endif | |
146 | }; | |
147 | ||
148 | typedef OBJID ASN_ROID; | |
149 | typedef OBJID_template ASN_ROID_template; | |
150 | ||
151 | #endif |