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(); | |
af710487 | 30 | |
31 | /** Initializes the object identifier with a string containing the components | |
32 | * separated by dots. */ | |
33 | void from_string(char* p_str); | |
970ed795 EL |
34 | |
35 | public: | |
36 | typedef unsigned int objid_element; | |
37 | OBJID(); | |
38 | OBJID(int init_n_components, ...); | |
39 | OBJID(int init_n_components, const objid_element *init_components); | |
40 | OBJID(const OBJID& other_value); | |
41 | ||
42 | ~OBJID(); | |
43 | ||
44 | OBJID& operator=(const OBJID& other_value); | |
45 | ||
46 | boolean operator==(const OBJID& other_value) const; | |
47 | inline boolean operator!=(const OBJID& other_value) const | |
48 | { return !(*this == other_value); } | |
49 | ||
50 | objid_element& operator[](int index_value); | |
51 | objid_element operator[](int index_value) const; | |
52 | ||
53 | inline boolean is_bound() const { return val_ptr != NULL; } | |
54 | inline boolean is_value() const { return val_ptr != NULL; } | |
55 | void clean_up(); | |
56 | ||
57 | int size_of() const; | |
58 | int lengthof() const { return size_of(); } // for backward compatibility | |
59 | ||
60 | operator const objid_element*() const; | |
61 | ||
62 | static objid_element from_INTEGER(const INTEGER& p_int); | |
63 | ||
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_; } | |
69 | #else | |
70 | inline boolean is_present() const { return is_bound(); } | |
71 | #endif | |
72 | ||
73 | void log() const; | |
74 | void set_param(Module_Param& param); | |
75 | void encode_text(Text_Buf& text_buf) const; | |
76 | void decode_text(Text_Buf& text_buf); | |
77 | ||
78 | void encode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, | |
79 | TTCN_EncDec::coding_t, ...) const; | |
80 | ||
81 | void decode(const TTCN_Typedescriptor_t&, TTCN_Buffer&, | |
82 | TTCN_EncDec::coding_t, ...); | |
83 | ||
84 | ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, | |
85 | unsigned p_coding) const; | |
86 | ||
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, | |
af710487 | 90 | TTCN_Buffer& p_buf, unsigned int flavor, int indent, embed_values_enc_struct_t*) const; |
970ed795 | 91 | int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, |
af710487 | 92 | unsigned int flavor, embed_values_dec_struct_t*); |
93 | ||
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; | |
97 | ||
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); | |
970ed795 EL |
101 | }; |
102 | ||
103 | // objid template class | |
104 | ||
105 | class OBJID_template : public Base_Template { | |
106 | OBJID single_value; | |
107 | struct { | |
108 | unsigned int n_values; | |
109 | OBJID_template *list_value; | |
110 | } value_list; | |
111 | ||
112 | void copy_template(const OBJID_template& other_value); | |
113 | ||
114 | public: | |
115 | OBJID_template(); | |
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); | |
120 | ||
121 | ~OBJID_template(); | |
122 | void clean_up(); | |
123 | ||
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); | |
128 | ||
129 | boolean match(const OBJID& other_value) const; | |
130 | const OBJID& valueof() const; | |
131 | ||
132 | int size_of() const; | |
133 | ||
134 | void set_type(template_sel template_type, unsigned int list_length); | |
135 | OBJID_template& list_item(unsigned int list_index); | |
136 | ||
137 | void log() const; | |
138 | void log_match(const OBJID& match_value) const; | |
139 | ||
140 | void set_param(Module_Param& param); | |
141 | ||
142 | void encode_text(Text_Buf& text_buf) const; | |
143 | void decode_text(Text_Buf& text_buf); | |
144 | ||
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))); } | |
155 | #else | |
156 | void check_restriction(template_res t_res, const char* t_name=NULL) const; | |
157 | #endif | |
158 | }; | |
159 | ||
160 | typedef OBJID ASN_ROID; | |
161 | typedef OBJID_template ASN_ROID_template; | |
162 | ||
163 | #endif |