e83c564e81000c4f9073b0f8e0bb7f2125bad45a
[deliverable/titan.core.git] / core / ASN_Null.hh
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 ASN_NULL_HH
9 #define ASN_NULL_HH
10
11 #include "Types.h"
12 #include "Basetype.hh"
13 #include "Template.hh"
14 #include "Optional.hh"
15 #include "Encdec.hh"
16 #include "BER.hh"
17
18 class Module_Param;
19
20 class ASN_NULL : public Base_Type {
21 friend boolean operator==(asn_null_type par_value,
22 const ASN_NULL& other_value);
23
24 boolean bound_flag;
25 public:
26 ASN_NULL();
27 ASN_NULL(asn_null_type other_value);
28 ASN_NULL(const ASN_NULL& other_value);
29
30 ASN_NULL& operator=(asn_null_type other_value);
31 ASN_NULL& operator=(const ASN_NULL& other_value);
32
33 boolean operator==(asn_null_type other_value) const;
34 boolean operator==(const ASN_NULL& other_value) const;
35 inline boolean operator!=(asn_null_type other_value) const
36 { return !(*this == other_value); }
37 inline boolean operator!=(const ASN_NULL& other_value) const
38 { return !(*this == other_value); }
39
40 inline boolean is_bound() const { return bound_flag; }
41 inline boolean is_value() const { return bound_flag; }
42 inline void clean_up() { bound_flag = FALSE; }
43
44 void log() const;
45
46 #ifdef TITAN_RUNTIME_2
47 boolean is_equal(const Base_Type* other_value) const { return *this == *(static_cast<const ASN_NULL*>(other_value)); }
48 void set_value(const Base_Type* other_value) { *this = *(static_cast<const ASN_NULL*>(other_value)); }
49 Base_Type* clone() const { return new ASN_NULL(*this); }
50 const TTCN_Typedescriptor_t* get_descriptor() const { return &ASN_NULL_descr_; }
51 #else
52 inline boolean is_present() const { return is_bound(); }
53 #endif
54
55 void set_param(Module_Param& param);
56
57 void encode_text(Text_Buf& text_buf) const;
58 void decode_text(Text_Buf& text_buf);
59
60 void encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
61 TTCN_EncDec::coding_t p_coding, ...) const;
62
63 void decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf,
64 TTCN_EncDec::coding_t p_coding, ...);
65
66 ASN_BER_TLV_t* BER_encode_TLV(const TTCN_Typedescriptor_t& p_td,
67 unsigned p_coding) const;
68
69 boolean BER_decode_TLV(const TTCN_Typedescriptor_t& p_td,
70 const ASN_BER_TLV_t& p_tlv, unsigned L_form);
71 int XER_encode(const XERdescriptor_t& p_td,
72 TTCN_Buffer& p_buf, unsigned int flavor, int indent) const;
73 int XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader,
74 unsigned int flavor);
75 };
76
77 extern boolean operator==(asn_null_type par_value, const ASN_NULL& other_value);
78 inline boolean operator!=(asn_null_type par_value, const ASN_NULL& other_value)
79 { return !(par_value == other_value); }
80
81 class ASN_NULL_template : public Base_Template {
82 struct {
83 unsigned int n_values;
84 ASN_NULL_template *list_value;
85 } value_list;
86
87 void copy_template(const ASN_NULL_template& other_value);
88
89 public:
90 ASN_NULL_template();
91 ASN_NULL_template(template_sel other_value);
92 ASN_NULL_template(asn_null_type other_value);
93 ASN_NULL_template(const ASN_NULL& other_value);
94 ASN_NULL_template(const OPTIONAL<ASN_NULL>& other_value);
95 ASN_NULL_template(const ASN_NULL_template& other_value);
96
97 ~ASN_NULL_template();
98 void clean_up();
99
100 ASN_NULL_template& operator=(template_sel other_value);
101 ASN_NULL_template& operator=(asn_null_type other_value);
102 ASN_NULL_template& operator=(const ASN_NULL& other_value);
103 ASN_NULL_template& operator=(const OPTIONAL<ASN_NULL>& other_value);
104 ASN_NULL_template& operator=(const ASN_NULL_template& other_value);
105
106 boolean match(asn_null_type other_value) const;
107 boolean match(const ASN_NULL& other_value) const;
108 asn_null_type valueof() const;
109
110 void set_type(template_sel template_type, unsigned int list_length);
111 ASN_NULL_template& list_item(unsigned int list_index);
112
113 void log() const;
114 void log_match(const ASN_NULL& match_value) const;
115
116 void set_param(Module_Param& param);
117
118 void encode_text(Text_Buf& text_buf) const;
119 void decode_text(Text_Buf& text_buf);
120
121 boolean is_present() const;
122 boolean match_omit() const;
123 #ifdef TITAN_RUNTIME_2
124 void valueofv(Base_Type* value) const { *(static_cast<ASN_NULL*>(value)) = valueof(); }
125 void set_value(template_sel other_value) { *this = other_value; }
126 void copy_value(const Base_Type* other_value) { *this = *(static_cast<const ASN_NULL*>(other_value)); }
127 Base_Template* clone() const { return new ASN_NULL_template(*this); }
128 const TTCN_Typedescriptor_t* get_descriptor() const { return &ASN_NULL_descr_; }
129 boolean matchv(const Base_Type* other_value) const { return match(*(static_cast<const ASN_NULL*>(other_value))); }
130 void log_matchv(const Base_Type* match_value) const { log_match(*(static_cast<const ASN_NULL*>(match_value))); }
131 #else
132 void check_restriction(template_res t_res, const char* t_name=NULL) const;
133 #endif
134 };
135
136 #endif // ASN_NULL_HH
This page took 0.034587 seconds and 4 git commands to generate.