| // This C++ source file was generated by the TTCN-3 compiler |
| // of the TTCN-3 Test Executor version CRL 113 200/6 R6A |
| // for Lénárd Nagy (elnrnag@elx78355y6x) on Thu Oct 24 10:29:40 2019 |
| |
| // Copyright (c) 2000-2019 Ericsson Telecom AB |
| |
| // Do not edit this file unless you know what you are doing. |
| |
| /* Including header files */ |
| |
| #include "Raw.hh" |
| |
| namespace Raw { |
| |
| /* Prototypes of static functions */ |
| |
| static void pre_init_module(); |
| static void post_init_module(); |
| |
| /* Literal string constants */ |
| |
| static const unsigned char os_0_octets[] = { 32, 0, 0, 0 }; |
| static const OCTETSTRING os_0(4, os_0_octets); |
| static const unsigned char module_checksum[] = { 0x03, 0xf7, 0xb6, 0x54, 0xea, 0x47, 0x9a, 0x6b, 0x0d, 0x8c, 0x1e, 0x8a, 0xf3, 0x5f, 0x6c, 0x35 }; |
| |
| /* Global variable definitions */ |
| |
| const XERdescriptor_t CAN__RAW__filter_can__id_xer_ = { {"can_id>\n", "can_id>\n"}, {8, 8}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; |
| const int CAN__RAW__filter_can__id_oer_ext_arr_[0] = {}; |
| const int CAN__RAW__filter_can__id_oer_p_[0] = {}; |
| const TTCN_OERdescriptor_t CAN__RAW__filter_can__id_oer_ = { -1, TRUE, 4, FALSE, 0, 0, CAN__RAW__filter_can__id_oer_ext_arr_, 0, CAN__RAW__filter_can__id_oer_p_}; |
| const TTCN_Typedescriptor_t CAN__RAW__filter_can__id_descr_ = { "@Raw.CAN_RAW_filter.can_id", &OCTETSTRING_ber_, &Can::CAN__id_raw_, &OCTETSTRING_text_, &CAN__RAW__filter_can__id_xer_, &OCTETSTRING_json_, &CAN__RAW__filter_can__id_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
| const XERdescriptor_t CAN__RAW__filter_can__mask_xer_ = { {"can_mask>\n", "can_mask>\n"}, {10, 10}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; |
| const int CAN__RAW__filter_can__mask_oer_ext_arr_[0] = {}; |
| const int CAN__RAW__filter_can__mask_oer_p_[0] = {}; |
| const TTCN_OERdescriptor_t CAN__RAW__filter_can__mask_oer_ = { -1, TRUE, 4, FALSE, 0, 0, CAN__RAW__filter_can__mask_oer_ext_arr_, 0, CAN__RAW__filter_can__mask_oer_p_}; |
| const TTCN_Typedescriptor_t CAN__RAW__filter_can__mask_descr_ = { "@Raw.CAN_RAW_filter.can_mask", &OCTETSTRING_ber_, &Can::CAN__id_raw_, &OCTETSTRING_text_, &CAN__RAW__filter_can__mask_xer_, &OCTETSTRING_json_, &CAN__RAW__filter_can__mask_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
| // No XER for CAN__RAW__filter |
| const TTCN_Typedescriptor_t CAN__RAW__filter_descr_ = { "@Raw.CAN_RAW_filter", NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
| static OCTETSTRING const_CAN__INV__FILTER; |
| const OCTETSTRING& CAN__INV__FILTER = const_CAN__INV__FILTER; |
| const TTCN_RAWdescriptor_t CAN__RAW__err__mask_raw_ = {32,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false}; |
| const XERdescriptor_t CAN__RAW__err__mask_xer_ = { {"CAN_RAW_err_mask>\n", "CAN_RAW_err_mask>\n"}, {18, 18}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; |
| const TTCN_OERdescriptor_t CAN__RAW__err__mask_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; |
| const TTCN_Typedescriptor_t CAN__RAW__err__mask_descr_ = { "@Raw.CAN_RAW_err_mask", &BITSTRING_ber_, &CAN__RAW__err__mask_raw_, NULL, &CAN__RAW__err__mask_xer_, &BITSTRING_json_, &CAN__RAW__err__mask_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
| // No XER for DisableEnable__enum |
| const TTCN_Typedescriptor_t DisableEnable__enum_descr_ = { "@Raw.DisableEnable_enum", NULL, NULL, NULL, NULL, &ENUMERATED_json_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; |
| const TTCN_Typedescriptor_t& CAN__RAW__loopback__enum_descr_ = DisableEnable__enum_descr_; |
| const TTCN_Typedescriptor_t& CAN__RAW__recv__own__msgs__enum_descr_ = DisableEnable__enum_descr_; |
| const TTCN_Typedescriptor_t& CAN__RAW__fd__frames__enum_descr_ = DisableEnable__enum_descr_; |
| const TTCN_Typedescriptor_t& CAN__RAW__join__filters__enum_descr_ = DisableEnable__enum_descr_; |
| TTCN_Module module_object("Raw", __DATE__, __TIME__, module_checksum, pre_init_module, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, post_init_module, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| |
| static const RuntimeVersionChecker ver_checker( current_runtime_version.requires_major_version_6, |
| current_runtime_version.requires_minor_version_6, |
| current_runtime_version.requires_patch_level_0, current_runtime_version.requires_runtime_1); |
| |
| /* Member functions of C++ classes */ |
| |
| CAN__RAW__filter::CAN__RAW__filter() |
| { |
| } |
| |
| CAN__RAW__filter::CAN__RAW__filter(const OCTETSTRING& par_can__id, |
| const OCTETSTRING& par_can__mask) |
| : field_can__id(par_can__id), |
| field_can__mask(par_can__mask) |
| { |
| } |
| |
| CAN__RAW__filter::CAN__RAW__filter(const CAN__RAW__filter& other_value) |
| { |
| if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Raw.CAN_RAW_filter."); |
| if (other_value.can__id().is_bound()) field_can__id = other_value.can__id(); |
| else field_can__id.clean_up(); |
| if (other_value.can__mask().is_bound()) field_can__mask = other_value.can__mask(); |
| else field_can__mask.clean_up(); |
| } |
| |
| void CAN__RAW__filter::clean_up() |
| { |
| field_can__id.clean_up(); |
| field_can__mask.clean_up(); |
| } |
| |
| const TTCN_Typedescriptor_t* CAN__RAW__filter::get_descriptor() const { return &CAN__RAW__filter_descr_; } |
| CAN__RAW__filter& CAN__RAW__filter::operator=(const CAN__RAW__filter& other_value) |
| { |
| if (this != &other_value) { |
| if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Raw.CAN_RAW_filter."); |
| if (other_value.can__id().is_bound()) field_can__id = other_value.can__id(); |
| else field_can__id.clean_up(); |
| if (other_value.can__mask().is_bound()) field_can__mask = other_value.can__mask(); |
| else field_can__mask.clean_up(); |
| } |
| return *this; |
| } |
| |
| boolean CAN__RAW__filter::operator==(const CAN__RAW__filter& other_value) const |
| { |
| return field_can__id==other_value.field_can__id |
| && field_can__mask==other_value.field_can__mask; |
| } |
| |
| boolean CAN__RAW__filter::is_bound() const |
| { |
| return (field_can__id.is_bound()) |
| || (field_can__mask.is_bound()); |
| } |
| boolean CAN__RAW__filter::is_value() const |
| { |
| return field_can__id.is_value() |
| && field_can__mask.is_value(); |
| } |
| void CAN__RAW__filter::log() const |
| { |
| if (!is_bound()) { |
| TTCN_Logger::log_event_unbound(); |
| return; |
| } |
| TTCN_Logger::log_event_str("{ can_id := "); |
| field_can__id.log(); |
| TTCN_Logger::log_event_str(", can_mask := "); |
| field_can__mask.log(); |
| TTCN_Logger::log_event_str(" }"); |
| } |
| |
| void CAN__RAW__filter::set_param(Module_Param& param) |
| { |
| param.basic_check(Module_Param::BC_VALUE, "record value"); |
| switch (param.get_type()) { |
| case Module_Param::MP_Value_List: |
| if (2<param.get_size()) { |
| param.error("record value of type @Raw.CAN_RAW_filter has 2 fields but list value has %d fields", (int)param.get_size()); |
| } |
| if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) can__id().set_param(*param.get_elem(0)); |
| if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) can__mask().set_param(*param.get_elem(1)); |
| break; |
| case Module_Param::MP_Assignment_List: { |
| Vector<bool> value_used(param.get_size()); |
| value_used.resize(param.get_size(), FALSE); |
| for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) { |
| Module_Param* const curr_param = param.get_elem(val_idx); |
| if (!strcmp(curr_param->get_id()->get_name(), "can_id")) { |
| if (curr_param->get_type()!=Module_Param::MP_NotUsed) { |
| can__id().set_param(*curr_param); |
| } |
| value_used[val_idx]=TRUE; |
| } |
| } |
| for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) { |
| Module_Param* const curr_param = param.get_elem(val_idx); |
| if (!strcmp(curr_param->get_id()->get_name(), "can_mask")) { |
| if (curr_param->get_type()!=Module_Param::MP_NotUsed) { |
| can__mask().set_param(*curr_param); |
| } |
| value_used[val_idx]=TRUE; |
| } |
| } |
| for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) { |
| Module_Param* const curr_param = param.get_elem(val_idx); |
| curr_param->error("Non existent field name in type @Raw.CAN_RAW_filter: %s", curr_param->get_id()->get_name()); |
| break; |
| } |
| } break; |
| default: |
| param.type_error("record value", "@Raw.CAN_RAW_filter"); |
| } |
| } |
| |
| void CAN__RAW__filter::set_implicit_omit() |
| { |
| if (can__id().is_bound()) can__id().set_implicit_omit(); |
| if (can__mask().is_bound()) can__mask().set_implicit_omit(); |
| } |
| |
| void CAN__RAW__filter::encode_text(Text_Buf& text_buf) const |
| { |
| field_can__id.encode_text(text_buf); |
| field_can__mask.encode_text(text_buf); |
| } |
| |
| void CAN__RAW__filter::decode_text(Text_Buf& text_buf) |
| { |
| field_can__id.decode_text(text_buf); |
| field_can__mask.decode_text(text_buf); |
| } |
| |
| struct CAN__RAW__filter_template::single_value_struct { |
| OCTETSTRING_template field_can__id; |
| OCTETSTRING_template field_can__mask; |
| }; |
| |
| void CAN__RAW__filter_template::set_specific() |
| { |
| if (template_selection != SPECIFIC_VALUE) { |
| template_sel old_selection = template_selection; |
| clean_up(); |
| single_value = new single_value_struct; |
| set_selection(SPECIFIC_VALUE); |
| if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { |
| single_value->field_can__id = ANY_VALUE; |
| single_value->field_can__mask = ANY_VALUE; |
| } |
| } |
| } |
| |
| void CAN__RAW__filter_template::copy_value(const CAN__RAW__filter& other_value) |
| { |
| single_value = new single_value_struct; |
| if (other_value.can__id().is_bound()) { |
| single_value->field_can__id = other_value.can__id(); |
| } else { |
| single_value->field_can__id.clean_up(); |
| } |
| if (other_value.can__mask().is_bound()) { |
| single_value->field_can__mask = other_value.can__mask(); |
| } else { |
| single_value->field_can__mask.clean_up(); |
| } |
| set_selection(SPECIFIC_VALUE); |
| } |
| |
| void CAN__RAW__filter_template::copy_template(const CAN__RAW__filter_template& other_value) |
| { |
| switch (other_value.template_selection) { |
| case SPECIFIC_VALUE: |
| single_value = new single_value_struct; |
| if (UNINITIALIZED_TEMPLATE != other_value.can__id().get_selection()) { |
| single_value->field_can__id = other_value.can__id(); |
| } else { |
| single_value->field_can__id.clean_up(); |
| } |
| if (UNINITIALIZED_TEMPLATE != other_value.can__mask().get_selection()) { |
| single_value->field_can__mask = other_value.can__mask(); |
| } else { |
| single_value->field_can__mask.clean_up(); |
| } |
| case OMIT_VALUE: |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| break; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| value_list.n_values = other_value.value_list.n_values; |
| value_list.list_value = new CAN__RAW__filter_template[value_list.n_values]; |
| for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) |
| value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); |
| break; |
| default: |
| TTCN_error("Copying an uninitialized/unsupported template of type @Raw.CAN_RAW_filter."); |
| break; |
| } |
| set_selection(other_value); |
| } |
| |
| CAN__RAW__filter_template::CAN__RAW__filter_template() |
| { |
| } |
| |
| CAN__RAW__filter_template::CAN__RAW__filter_template(template_sel other_value) |
| : Base_Template(other_value) |
| { |
| check_single_selection(other_value); |
| } |
| |
| CAN__RAW__filter_template::CAN__RAW__filter_template(const CAN__RAW__filter& other_value) |
| { |
| copy_value(other_value); |
| } |
| |
| CAN__RAW__filter_template::CAN__RAW__filter_template(const OPTIONAL<CAN__RAW__filter>& other_value) |
| { |
| switch (other_value.get_selection()) { |
| case OPTIONAL_PRESENT: |
| copy_value((const CAN__RAW__filter&)other_value); |
| break; |
| case OPTIONAL_OMIT: |
| set_selection(OMIT_VALUE); |
| break; |
| default: |
| TTCN_error("Creating a template of type @Raw.CAN_RAW_filter from an unbound optional field."); |
| } |
| } |
| |
| CAN__RAW__filter_template::CAN__RAW__filter_template(const CAN__RAW__filter_template& other_value) |
| : Base_Template() |
| { |
| copy_template(other_value); |
| } |
| |
| CAN__RAW__filter_template::~CAN__RAW__filter_template() |
| { |
| clean_up(); |
| } |
| |
| CAN__RAW__filter_template& CAN__RAW__filter_template::operator=(template_sel other_value) |
| { |
| check_single_selection(other_value); |
| clean_up(); |
| set_selection(other_value); |
| return *this; |
| } |
| |
| CAN__RAW__filter_template& CAN__RAW__filter_template::operator=(const CAN__RAW__filter& other_value) |
| { |
| clean_up(); |
| copy_value(other_value); |
| return *this; |
| } |
| |
| CAN__RAW__filter_template& CAN__RAW__filter_template::operator=(const OPTIONAL<CAN__RAW__filter>& other_value) |
| { |
| clean_up(); |
| switch (other_value.get_selection()) { |
| case OPTIONAL_PRESENT: |
| copy_value((const CAN__RAW__filter&)other_value); |
| break; |
| case OPTIONAL_OMIT: |
| set_selection(OMIT_VALUE); |
| break; |
| default: |
| TTCN_error("Assignment of an unbound optional field to a template of type @Raw.CAN_RAW_filter."); |
| } |
| return *this; |
| } |
| |
| CAN__RAW__filter_template& CAN__RAW__filter_template::operator=(const CAN__RAW__filter_template& other_value) |
| { |
| if (&other_value != this) { |
| clean_up(); |
| copy_template(other_value); |
| } |
| return *this; |
| } |
| |
| boolean CAN__RAW__filter_template::match(const CAN__RAW__filter& other_value, boolean legacy) const |
| { |
| if (!other_value.is_bound()) return FALSE; |
| switch (template_selection) { |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| return TRUE; |
| case OMIT_VALUE: |
| return FALSE; |
| case SPECIFIC_VALUE: |
| if(!other_value.can__id().is_bound()) return FALSE; |
| if(!single_value->field_can__id.match(other_value.can__id(), legacy))return FALSE; |
| if(!other_value.can__mask().is_bound()) return FALSE; |
| if(!single_value->field_can__mask.match(other_value.can__mask(), legacy))return FALSE; |
| return TRUE; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) |
| if (value_list.list_value[list_count].match(other_value, legacy)) return template_selection == VALUE_LIST; |
| return template_selection == COMPLEMENTED_LIST; |
| default: |
| TTCN_error("Matching an uninitialized/unsupported template of type @Raw.CAN_RAW_filter."); |
| } |
| return FALSE; |
| } |
| |
| boolean CAN__RAW__filter_template::is_bound() const |
| { |
| if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; |
| if (template_selection != SPECIFIC_VALUE) return TRUE; |
| return single_value->field_can__id.is_bound() |
| |
| ||single_value->field_can__mask.is_bound() |
| ; |
| } |
| |
| boolean CAN__RAW__filter_template::is_value() const |
| { |
| if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; |
| return single_value->field_can__id.is_value() |
| &&single_value->field_can__mask.is_value(); |
| } |
| |
| void CAN__RAW__filter_template::clean_up() |
| { |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| delete single_value; |
| break; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| delete [] value_list.list_value; |
| default: |
| break; |
| } |
| template_selection = UNINITIALIZED_TEMPLATE; |
| } |
| |
| CAN__RAW__filter CAN__RAW__filter_template::valueof() const |
| { |
| if (template_selection != SPECIFIC_VALUE || is_ifpresent) |
| TTCN_error("Performing a valueof or send operation on a non-specific template of type @Raw.CAN_RAW_filter."); |
| CAN__RAW__filter ret_val; |
| if (single_value->field_can__id.is_bound()) { |
| ret_val.can__id() = single_value->field_can__id.valueof(); |
| } |
| if (single_value->field_can__mask.is_bound()) { |
| ret_val.can__mask() = single_value->field_can__mask.valueof(); |
| } |
| return ret_val; |
| } |
| |
| void CAN__RAW__filter_template::set_type(template_sel template_type, unsigned int list_length) |
| { |
| if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) |
| TTCN_error("Setting an invalid list for a template of type @Raw.CAN_RAW_filter."); |
| clean_up(); |
| set_selection(template_type); |
| value_list.n_values = list_length; |
| value_list.list_value = new CAN__RAW__filter_template[list_length]; |
| } |
| |
| CAN__RAW__filter_template& CAN__RAW__filter_template::list_item(unsigned int list_index) const |
| { |
| if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) |
| TTCN_error("Accessing a list element of a non-list template of type @Raw.CAN_RAW_filter."); |
| if (list_index >= value_list.n_values) |
| TTCN_error("Index overflow in a value list template of type @Raw.CAN_RAW_filter."); |
| return value_list.list_value[list_index]; |
| } |
| |
| OCTETSTRING_template& CAN__RAW__filter_template::can__id() |
| { |
| set_specific(); |
| return single_value->field_can__id; |
| } |
| |
| const OCTETSTRING_template& CAN__RAW__filter_template::can__id() const |
| { |
| if (template_selection != SPECIFIC_VALUE) |
| TTCN_error("Accessing field can_id of a non-specific template of type @Raw.CAN_RAW_filter."); |
| return single_value->field_can__id; |
| } |
| |
| OCTETSTRING_template& CAN__RAW__filter_template::can__mask() |
| { |
| set_specific(); |
| return single_value->field_can__mask; |
| } |
| |
| const OCTETSTRING_template& CAN__RAW__filter_template::can__mask() const |
| { |
| if (template_selection != SPECIFIC_VALUE) |
| TTCN_error("Accessing field can_mask of a non-specific template of type @Raw.CAN_RAW_filter."); |
| return single_value->field_can__mask; |
| } |
| |
| int CAN__RAW__filter_template::size_of() const |
| { |
| if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Raw.CAN_RAW_filter which has an ifpresent attribute."); |
| switch (template_selection) |
| { |
| case SPECIFIC_VALUE: |
| return 2; |
| case VALUE_LIST: |
| { |
| if (value_list.n_values<1) |
| TTCN_error("Internal error: Performing sizeof() operation on a template of type @Raw.CAN_RAW_filter containing an empty list."); |
| int item_size = value_list.list_value[0].size_of(); |
| for (unsigned int l_idx = 1; l_idx < value_list.n_values; l_idx++) |
| { |
| if (value_list.list_value[l_idx].size_of()!=item_size) |
| TTCN_error("Performing sizeof() operation on a template of type @Raw.CAN_RAW_filter containing a value list with different sizes."); |
| } |
| return item_size; |
| } |
| case OMIT_VALUE: |
| TTCN_error("Performing sizeof() operation on a template of type @Raw.CAN_RAW_filter containing omit value."); |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| TTCN_error("Performing sizeof() operation on a template of type @Raw.CAN_RAW_filter containing */? value."); |
| case COMPLEMENTED_LIST: |
| TTCN_error("Performing sizeof() operation on a template of type @Raw.CAN_RAW_filter containing complemented list."); |
| default: |
| TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Raw.CAN_RAW_filter."); |
| } |
| return 0; |
| } |
| |
| void CAN__RAW__filter_template::log() const |
| { |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| TTCN_Logger::log_event_str("{ can_id := "); |
| single_value->field_can__id.log(); |
| TTCN_Logger::log_event_str(", can_mask := "); |
| single_value->field_can__mask.log(); |
| TTCN_Logger::log_event_str(" }"); |
| break; |
| case COMPLEMENTED_LIST: |
| TTCN_Logger::log_event_str("complement"); |
| case VALUE_LIST: |
| TTCN_Logger::log_char('('); |
| for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) { |
| if (list_count > 0) TTCN_Logger::log_event_str(", "); |
| value_list.list_value[list_count].log(); |
| } |
| TTCN_Logger::log_char(')'); |
| break; |
| default: |
| log_generic(); |
| } |
| log_ifpresent(); |
| } |
| |
| void CAN__RAW__filter_template::log_match(const CAN__RAW__filter& match_value, boolean legacy) const |
| { |
| if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){ |
| if(match(match_value, legacy)){ |
| TTCN_Logger::print_logmatch_buffer(); |
| TTCN_Logger::log_event_str(" matched"); |
| } else{ |
| if (template_selection == SPECIFIC_VALUE) { |
| size_t previous_size = TTCN_Logger::get_logmatch_buffer_len(); |
| if(!single_value->field_can__id.match(match_value.can__id(), legacy)){ |
| TTCN_Logger::log_logmatch_info(".can_id"); |
| single_value->field_can__id.log_match(match_value.can__id(), legacy); |
| TTCN_Logger::set_logmatch_buffer_len(previous_size); |
| } |
| if(!single_value->field_can__mask.match(match_value.can__mask(), legacy)){ |
| TTCN_Logger::log_logmatch_info(".can_mask"); |
| single_value->field_can__mask.log_match(match_value.can__mask(), legacy); |
| TTCN_Logger::set_logmatch_buffer_len(previous_size); |
| } |
| }else { |
| TTCN_Logger::print_logmatch_buffer(); |
| match_value.log(); |
| TTCN_Logger::log_event_str(" with "); |
| log(); |
| TTCN_Logger::log_event_str(" unmatched"); |
| } |
| } |
| return; |
| } |
| if (template_selection == SPECIFIC_VALUE) { |
| TTCN_Logger::log_event_str("{ can_id := "); |
| single_value->field_can__id.log_match(match_value.can__id(), legacy); |
| TTCN_Logger::log_event_str(", can_mask := "); |
| single_value->field_can__mask.log_match(match_value.can__mask(), legacy); |
| TTCN_Logger::log_event_str(" }"); |
| } else { |
| match_value.log(); |
| TTCN_Logger::log_event_str(" with "); |
| log(); |
| if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched"); |
| else TTCN_Logger::log_event_str(" unmatched"); |
| } |
| } |
| |
| void CAN__RAW__filter_template::encode_text(Text_Buf& text_buf) const |
| { |
| encode_text_base(text_buf); |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| single_value->field_can__id.encode_text(text_buf); |
| single_value->field_can__mask.encode_text(text_buf); |
| case OMIT_VALUE: |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| break; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| text_buf.push_int(value_list.n_values); |
| for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) |
| value_list.list_value[list_count].encode_text(text_buf); |
| break; |
| default: |
| TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type @Raw.CAN_RAW_filter."); |
| } |
| } |
| |
| void CAN__RAW__filter_template::decode_text(Text_Buf& text_buf) |
| { |
| clean_up(); |
| decode_text_base(text_buf); |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| single_value = new single_value_struct; |
| single_value->field_can__id.decode_text(text_buf); |
| single_value->field_can__mask.decode_text(text_buf); |
| case OMIT_VALUE: |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| break; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| value_list.n_values = text_buf.pull_int().get_val(); |
| value_list.list_value = new CAN__RAW__filter_template[value_list.n_values]; |
| for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) |
| value_list.list_value[list_count].decode_text(text_buf); |
| break; |
| default: |
| TTCN_error("Text decoder: An unknown/unsupported selection was received in a template of type @Raw.CAN_RAW_filter."); |
| } |
| } |
| |
| void CAN__RAW__filter_template::set_param(Module_Param& param) |
| { |
| param.basic_check(Module_Param::BC_TEMPLATE, "record template"); |
| switch (param.get_type()) { |
| case Module_Param::MP_Omit: |
| *this = OMIT_VALUE; |
| break; |
| case Module_Param::MP_Any: |
| *this = ANY_VALUE; |
| break; |
| case Module_Param::MP_AnyOrNone: |
| *this = ANY_OR_OMIT; |
| break; |
| case Module_Param::MP_List_Template: |
| case Module_Param::MP_ComplementList_Template: { |
| CAN__RAW__filter_template new_temp; |
| new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, param.get_size()); |
| for (size_t p_i=0; p_i<param.get_size(); p_i++) { |
| new_temp.list_item(p_i).set_param(*param.get_elem(p_i)); |
| } |
| *this = new_temp; |
| break; } |
| case Module_Param::MP_Value_List: |
| if (2<param.get_size()) { |
| param.error("record template of type @Raw.CAN_RAW_filter has 2 fields but list value has %d fields", (int)param.get_size()); |
| } |
| if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) can__id().set_param(*param.get_elem(0)); |
| if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) can__mask().set_param(*param.get_elem(1)); |
| break; |
| case Module_Param::MP_Assignment_List: { |
| Vector<bool> value_used(param.get_size()); |
| value_used.resize(param.get_size(), FALSE); |
| for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) { |
| Module_Param* const curr_param = param.get_elem(val_idx); |
| if (!strcmp(curr_param->get_id()->get_name(), "can_id")) { |
| if (curr_param->get_type()!=Module_Param::MP_NotUsed) { |
| can__id().set_param(*curr_param); |
| } |
| value_used[val_idx]=TRUE; |
| } |
| } |
| for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) { |
| Module_Param* const curr_param = param.get_elem(val_idx); |
| if (!strcmp(curr_param->get_id()->get_name(), "can_mask")) { |
| if (curr_param->get_type()!=Module_Param::MP_NotUsed) { |
| can__mask().set_param(*curr_param); |
| } |
| value_used[val_idx]=TRUE; |
| } |
| } |
| for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) { |
| Module_Param* const curr_param = param.get_elem(val_idx); |
| curr_param->error("Non existent field name in type @Raw.CAN_RAW_filter: %s", curr_param->get_id()->get_name()); |
| break; |
| } |
| } break; |
| default: |
| param.type_error("record template", "@Raw.CAN_RAW_filter"); |
| } |
| is_ifpresent = param.get_ifpresent(); |
| } |
| |
| void CAN__RAW__filter_template::check_restriction(template_res t_res, const char* t_name, boolean legacy) const |
| { |
| if (template_selection==UNINITIALIZED_TEMPLATE) return; |
| switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { |
| case TR_OMIT: |
| if (template_selection==OMIT_VALUE) return; |
| case TR_VALUE: |
| if (template_selection!=SPECIFIC_VALUE || is_ifpresent) break; |
| single_value->field_can__id.check_restriction(t_res, t_name ? t_name : "@Raw.CAN_RAW_filter"); |
| single_value->field_can__mask.check_restriction(t_res, t_name ? t_name : "@Raw.CAN_RAW_filter"); |
| return; |
| case TR_PRESENT: |
| if (!match_omit(legacy)) return; |
| break; |
| default: |
| return; |
| } |
| TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@Raw.CAN_RAW_filter"); |
| } |
| |
| boolean CAN__RAW__filter_template::is_present(boolean legacy) const |
| { |
| if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; |
| return !match_omit(legacy); |
| } |
| |
| boolean CAN__RAW__filter_template::match_omit(boolean legacy) const |
| { |
| if (is_ifpresent) return TRUE; |
| switch (template_selection) { |
| case OMIT_VALUE: |
| case ANY_OR_OMIT: |
| return TRUE; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| if (legacy) { |
| for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++) |
| if (value_list.list_value[l_idx].match_omit()) |
| return template_selection==VALUE_LIST; |
| return template_selection==COMPLEMENTED_LIST; |
| } // else fall through |
| default: |
| return FALSE; |
| } |
| return FALSE; |
| } |
| |
| DisableEnable__enum::DisableEnable__enum() |
| { |
| enum_value = UNBOUND_VALUE; |
| } |
| |
| DisableEnable__enum::DisableEnable__enum(int other_value) |
| { |
| if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @Raw.DisableEnable_enum with invalid numeric value %d.", other_value); |
| enum_value = (enum_type)other_value; |
| } |
| |
| DisableEnable__enum::DisableEnable__enum(enum_type other_value) |
| { |
| enum_value = other_value; |
| } |
| |
| DisableEnable__enum::DisableEnable__enum(const DisableEnable__enum& other_value) |
| : Base_Type() |
| { |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| enum_value = other_value.enum_value; |
| } |
| |
| DisableEnable__enum& DisableEnable__enum::operator=(int other_value) |
| { |
| if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @Raw.DisableEnable_enum.", other_value); |
| enum_value = (enum_type)other_value; |
| return *this; |
| } |
| |
| DisableEnable__enum& DisableEnable__enum::operator=(enum_type other_value) |
| { |
| enum_value = other_value; |
| return *this; |
| } |
| |
| DisableEnable__enum& DisableEnable__enum::operator=(const DisableEnable__enum& other_value) |
| { |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| enum_value = other_value.enum_value; |
| return *this; |
| } |
| |
| boolean DisableEnable__enum::operator==(enum_type other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| return enum_value == other_value; |
| } |
| |
| boolean DisableEnable__enum::operator==(const DisableEnable__enum& other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| return enum_value == other_value.enum_value; |
| } |
| |
| boolean DisableEnable__enum::operator<(enum_type other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| return enum_value < other_value; |
| } |
| |
| boolean DisableEnable__enum::operator<(const DisableEnable__enum& other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| return enum_value < other_value.enum_value; |
| } |
| |
| boolean DisableEnable__enum::operator>(enum_type other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| return enum_value > other_value; |
| } |
| |
| boolean DisableEnable__enum::operator>(const DisableEnable__enum& other_value) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| return enum_value > other_value.enum_value; |
| } |
| |
| const char *DisableEnable__enum::enum_to_str(enum_type enum_par) |
| { |
| switch (enum_par) { |
| case Disable: return "Disable"; |
| case Enable: return "Enable"; |
| default: return "<unknown>"; |
| } |
| } |
| |
| DisableEnable__enum::enum_type DisableEnable__enum::str_to_enum(const char *str_par) |
| { |
| if (!strcmp(str_par, "Disable")) return Disable; |
| else if (!strcmp(str_par, "Enable")) return Enable; |
| else return UNKNOWN_VALUE; |
| } |
| |
| boolean DisableEnable__enum::is_valid_enum(int int_par) |
| { |
| switch (int_par) { |
| case 0: |
| case 1: |
| return TRUE; |
| default: |
| return FALSE; |
| } |
| } |
| |
| int DisableEnable__enum::enum2int(enum_type enum_par) |
| { |
| if (enum_par==UNBOUND_VALUE || enum_par==UNKNOWN_VALUE) TTCN_error("The argument of function enum2int() is an %s value of enumerated type @Raw.DisableEnable_enum.", enum_par==UNBOUND_VALUE?"unbound":"invalid"); |
| return enum_par; |
| } |
| |
| int DisableEnable__enum::enum2int(const DisableEnable__enum& enum_par) |
| { |
| if (enum_par.enum_value==UNBOUND_VALUE || enum_par.enum_value==UNKNOWN_VALUE) TTCN_error("The argument of function enum2int() is an %s value of enumerated type @Raw.DisableEnable_enum.", enum_par==UNBOUND_VALUE?"unbound":"invalid"); |
| return enum_par.enum_value; |
| } |
| |
| void DisableEnable__enum::int2enum(int int_val) |
| { |
| if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @Raw.DisableEnable_enum.", int_val); |
| enum_value = (enum_type)int_val; |
| } |
| |
| DisableEnable__enum::operator DisableEnable__enum::enum_type() const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @Raw.DisableEnable_enum."); |
| return enum_value; |
| } |
| |
| void DisableEnable__enum::log() const |
| { |
| if (enum_value != UNBOUND_VALUE) TTCN_Logger::log_event_enum(enum_to_str(enum_value), enum_value); |
| else TTCN_Logger::log_event_unbound(); |
| } |
| |
| void DisableEnable__enum::set_param(Module_Param& param) |
| { |
| param.basic_check(Module_Param::BC_VALUE, "enumerated value"); |
| if (param.get_type()!=Module_Param::MP_Enumerated) param.type_error("enumerated value", "@Raw.DisableEnable_enum"); |
| enum_value = str_to_enum(param.get_enumerated()); |
| if (!is_valid_enum(enum_value)) { |
| param.error("Invalid enumerated value for type @Raw.DisableEnable_enum."); |
| } |
| } |
| |
| void DisableEnable__enum::encode_text(Text_Buf& text_buf) const |
| { |
| if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| text_buf.push_int(enum_value); |
| } |
| |
| void DisableEnable__enum::decode_text(Text_Buf& text_buf) |
| { |
| enum_value = (enum_type)text_buf.pull_int().get_val(); |
| if (!is_valid_enum(enum_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for enumerated type @Raw.DisableEnable_enum.", enum_value); |
| } |
| |
| void DisableEnable__enum_template::copy_template(const DisableEnable__enum_template& other_value) |
| { |
| set_selection(other_value); |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| single_value = other_value.single_value; |
| break; |
| case OMIT_VALUE: |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| break; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| value_list.n_values = other_value.value_list.n_values; |
| value_list.list_value = new DisableEnable__enum_template[value_list.n_values]; |
| for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) |
| value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]); |
| break; |
| default: |
| TTCN_error("Copying an uninitialized/unsupported template of enumerated type @Raw.DisableEnable_enum."); |
| } |
| } |
| |
| DisableEnable__enum_template::DisableEnable__enum_template() |
| { |
| } |
| |
| DisableEnable__enum_template::DisableEnable__enum_template(template_sel other_value) |
| : Base_Template(other_value) |
| { |
| check_single_selection(other_value); |
| } |
| |
| DisableEnable__enum_template::DisableEnable__enum_template(int other_value) |
| : Base_Template(SPECIFIC_VALUE) |
| { |
| if (!DisableEnable__enum::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @Raw.DisableEnable_enum with unknown numeric value %d.", other_value); |
| single_value = (DisableEnable__enum::enum_type)other_value; |
| } |
| |
| DisableEnable__enum_template::DisableEnable__enum_template(DisableEnable__enum::enum_type other_value) |
| : Base_Template(SPECIFIC_VALUE) |
| { |
| single_value = other_value; |
| } |
| |
| DisableEnable__enum_template::DisableEnable__enum_template(const DisableEnable__enum& other_value) |
| : Base_Template(SPECIFIC_VALUE) |
| { |
| if (other_value.enum_value == DisableEnable__enum::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @Raw.DisableEnable_enum."); |
| single_value = other_value.enum_value; |
| } |
| |
| DisableEnable__enum_template::DisableEnable__enum_template(const OPTIONAL<DisableEnable__enum>& other_value) |
| { |
| switch (other_value.get_selection()) { |
| case OPTIONAL_PRESENT: |
| set_selection(SPECIFIC_VALUE); |
| single_value = (DisableEnable__enum::enum_type)(const DisableEnable__enum&)other_value; |
| break; |
| case OPTIONAL_OMIT: |
| set_selection(OMIT_VALUE); |
| break; |
| default: |
| TTCN_error("Creating a template of enumerated type @Raw.DisableEnable_enum from an unbound optional field."); |
| } |
| } |
| |
| DisableEnable__enum_template::DisableEnable__enum_template(const DisableEnable__enum_template& other_value) |
| : Base_Template() |
| { |
| copy_template(other_value); |
| } |
| |
| DisableEnable__enum_template::~DisableEnable__enum_template() |
| { |
| clean_up(); |
| } |
| |
| boolean DisableEnable__enum_template::is_bound() const |
| { |
| if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; |
| return TRUE; |
| } |
| |
| boolean DisableEnable__enum_template::is_value() const |
| { |
| if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; |
| return single_value != DisableEnable__enum::UNBOUND_VALUE; |
| } |
| |
| void DisableEnable__enum_template::clean_up() |
| { |
| if (template_selection == VALUE_LIST || template_selection == COMPLEMENTED_LIST) delete [] value_list.list_value; |
| template_selection = UNINITIALIZED_TEMPLATE; |
| } |
| |
| DisableEnable__enum_template& DisableEnable__enum_template::operator=(template_sel other_value) |
| { |
| check_single_selection(other_value); |
| clean_up(); |
| set_selection(other_value); |
| return *this; |
| } |
| |
| DisableEnable__enum_template& DisableEnable__enum_template::operator=(int other_value) |
| { |
| if (!DisableEnable__enum::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @Raw.DisableEnable_enum.", other_value); |
| clean_up(); |
| set_selection(SPECIFIC_VALUE); |
| single_value = (DisableEnable__enum::enum_type)other_value; |
| return *this; |
| } |
| |
| DisableEnable__enum_template& DisableEnable__enum_template::operator=(DisableEnable__enum::enum_type other_value) |
| { |
| clean_up(); |
| set_selection(SPECIFIC_VALUE); |
| single_value = other_value; |
| return *this; |
| } |
| |
| DisableEnable__enum_template& DisableEnable__enum_template::operator=(const DisableEnable__enum& other_value) |
| { |
| if (other_value.enum_value == DisableEnable__enum::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Raw.DisableEnable_enum to a template."); |
| clean_up(); |
| set_selection(SPECIFIC_VALUE); |
| single_value = other_value.enum_value; |
| return *this; |
| } |
| |
| DisableEnable__enum_template& DisableEnable__enum_template::operator=(const OPTIONAL<DisableEnable__enum>& other_value) |
| { |
| clean_up(); |
| switch (other_value.get_selection()) { |
| case OPTIONAL_PRESENT: |
| set_selection(SPECIFIC_VALUE); |
| single_value = (DisableEnable__enum::enum_type)(const DisableEnable__enum&)other_value; |
| break; |
| case OPTIONAL_OMIT: |
| set_selection(OMIT_VALUE); |
| break; |
| default: |
| TTCN_error("Assignment of an unbound optional field to a template of enumerated type @Raw.DisableEnable_enum."); |
| } |
| return *this; |
| } |
| |
| DisableEnable__enum_template& DisableEnable__enum_template::operator=(const DisableEnable__enum_template& other_value) |
| { |
| if (&other_value != this) { |
| clean_up(); |
| copy_template(other_value); |
| } |
| return *this; |
| } |
| |
| boolean DisableEnable__enum_template::match(DisableEnable__enum::enum_type other_value, boolean) const |
| { |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| return single_value == other_value; |
| case OMIT_VALUE: |
| return FALSE; |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| return TRUE; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) |
| if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST; |
| return template_selection == COMPLEMENTED_LIST; |
| default: |
| TTCN_error("Matching an uninitialized/unsupported template of enumerated type @Raw.DisableEnable_enum."); |
| } |
| return FALSE; |
| } |
| |
| boolean DisableEnable__enum_template::match(const DisableEnable__enum& other_value, boolean) const |
| { |
| if (other_value.enum_value == DisableEnable__enum::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @Raw.DisableEnable_enum with an unbound value."); |
| return match(other_value.enum_value); |
| } |
| |
| DisableEnable__enum::enum_type DisableEnable__enum_template::valueof() const |
| { |
| if (template_selection != SPECIFIC_VALUE || is_ifpresent) TTCN_error("Performing a valueof or send operation on a non-specific template of enumerated type @Raw.DisableEnable_enum."); |
| return single_value; |
| } |
| |
| void DisableEnable__enum_template::set_type(template_sel template_type, unsigned int list_length) |
| { |
| if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error("Setting an invalid list type for a template of enumerated type @Raw.DisableEnable_enum."); |
| clean_up(); |
| set_selection(template_type); |
| value_list.n_values = list_length; |
| value_list.list_value = new DisableEnable__enum_template[list_length]; |
| } |
| |
| DisableEnable__enum_template& DisableEnable__enum_template::list_item(unsigned int list_index) |
| { |
| if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Accessing a list element in a non-list template of enumerated type @Raw.DisableEnable_enum."); |
| if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @Raw.DisableEnable_enum."); |
| return value_list.list_value[list_index]; |
| } |
| |
| void DisableEnable__enum_template::log() const |
| { |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| TTCN_Logger::log_event_enum(DisableEnable__enum::enum_to_str(single_value), single_value); |
| break; |
| case COMPLEMENTED_LIST: |
| TTCN_Logger::log_event_str("complement"); |
| case VALUE_LIST: |
| TTCN_Logger::log_char('('); |
| for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++) { |
| if (elem_count > 0) TTCN_Logger::log_event_str(", "); |
| value_list.list_value[elem_count].log(); |
| } |
| TTCN_Logger::log_char(')'); |
| break; |
| default: |
| log_generic(); |
| } |
| log_ifpresent(); |
| } |
| |
| void DisableEnable__enum_template::log_match(const DisableEnable__enum& match_value, boolean) const |
| { |
| match_value.log(); |
| TTCN_Logger::log_event_str(" with "); |
| log(); |
| if (match(match_value)) TTCN_Logger::log_event_str(" matched"); |
| else TTCN_Logger::log_event_str(" unmatched"); |
| } |
| |
| void DisableEnable__enum_template::encode_text(Text_Buf& text_buf) const |
| { |
| encode_text_base(text_buf); |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| text_buf.push_int(single_value); |
| case OMIT_VALUE: |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| break; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| text_buf.push_int(value_list.n_values); |
| for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++) |
| value_list.list_value[elem_count].encode_text(text_buf); |
| break; |
| default: |
| TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of enumerated type @Raw.DisableEnable_enum."); |
| } |
| } |
| |
| void DisableEnable__enum_template::decode_text(Text_Buf& text_buf) |
| { |
| clean_up(); |
| decode_text_base(text_buf); |
| switch (template_selection) { |
| case SPECIFIC_VALUE: |
| single_value = (DisableEnable__enum::enum_type)text_buf.pull_int().get_val(); |
| if (!DisableEnable__enum::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @Raw.DisableEnable_enum.", single_value); |
| case OMIT_VALUE: |
| case ANY_VALUE: |
| case ANY_OR_OMIT: |
| break; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| value_list.n_values = text_buf.pull_int().get_val(); |
| value_list.list_value = new DisableEnable__enum_template[value_list.n_values]; |
| for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++) |
| value_list.list_value[elem_count].decode_text(text_buf); |
| break; |
| default: |
| TTCN_error("Text decoder: An unknown/unsupported selection was received for a template of enumerated type @Raw.DisableEnable_enum."); |
| } |
| } |
| |
| boolean DisableEnable__enum_template::is_present(boolean legacy) const |
| { |
| if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; |
| return !match_omit(legacy); |
| } |
| |
| boolean DisableEnable__enum_template::match_omit(boolean legacy) const |
| { |
| if (is_ifpresent) return TRUE; |
| switch (template_selection) { |
| case OMIT_VALUE: |
| case ANY_OR_OMIT: |
| return TRUE; |
| case VALUE_LIST: |
| case COMPLEMENTED_LIST: |
| if (legacy) { |
| for (unsigned int i=0; i<value_list.n_values; i++) |
| if (value_list.list_value[i].match_omit()) |
| return template_selection==VALUE_LIST; |
| return template_selection==COMPLEMENTED_LIST; |
| } // else fall through |
| default: |
| return FALSE; |
| } |
| return FALSE; |
| } |
| |
| void DisableEnable__enum_template::set_param(Module_Param& param) |
| { |
| param.basic_check(Module_Param::BC_TEMPLATE, "enumerated template"); |
| Module_Param_Ptr m_p = ¶m; |
| switch (m_p->get_type()) { |
| case Module_Param::MP_Omit: |
| *this = OMIT_VALUE; |
| break; |
| case Module_Param::MP_Any: |
| *this = ANY_VALUE; |
| break; |
| case Module_Param::MP_AnyOrNone: |
| *this = ANY_OR_OMIT; |
| break; |
| case Module_Param::MP_List_Template: |
| case Module_Param::MP_ComplementList_Template: { |
| DisableEnable__enum_template new_temp; |
| new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, m_p->get_size()); |
| for (size_t p_i=0; p_i<m_p->get_size(); p_i++) { |
| new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i)); |
| } |
| *this = new_temp; |
| break; } |
| case Module_Param::MP_Enumerated: { |
| DisableEnable__enum::enum_type enum_val = DisableEnable__enum::str_to_enum(m_p->get_enumerated()); |
| if (!DisableEnable__enum::is_valid_enum(enum_val)) { |
| param.error("Invalid enumerated value for type @Raw.DisableEnable_enum."); |
| } |
| *this = enum_val; |
| } break; |
| default: |
| param.type_error("enumerated template", "@Raw.DisableEnable_enum"); |
| } |
| is_ifpresent = param.get_ifpresent(); |
| } |
| |
| void DisableEnable__enum_template::check_restriction(template_res t_res, const char* t_name, |
| boolean legacy) const |
| { |
| if (template_selection==UNINITIALIZED_TEMPLATE) return; |
| switch ((t_name&&(t_res==TR_VALUE))?TR_OMIT:t_res) { |
| case TR_VALUE: |
| if (!is_ifpresent && template_selection==SPECIFIC_VALUE) return; |
| break; |
| case TR_OMIT: |
| if (!is_ifpresent && (template_selection==OMIT_VALUE || template_selection==SPECIFIC_VALUE)) return; |
| break; |
| case TR_PRESENT: |
| if (!match_omit(legacy)) return; |
| break; |
| default: |
| return; |
| } |
| TTCN_error("Restriction `%s' on template of type %s violated.", get_res_name(t_res), t_name ? t_name : "@Raw.DisableEnable_enum"); |
| } |
| |
| |
| /* Bodies of static functions */ |
| |
| static void pre_init_module() |
| { |
| TTCN_Location current_location("../src/Raw.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Raw"); |
| Can::module_object.pre_init_module(); |
| current_location.update_lineno(33); |
| #line 33 "../src/Raw.ttcn" |
| const_CAN__INV__FILTER = os_0; |
| } |
| |
| static void post_init_module() |
| { |
| TTCN_Location current_location("../src/Raw.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Raw"); |
| Can::module_object.post_init_module(); |
| } |
| |
| |
| } /* end of namespace */ |