// This C++ source file was generated by the TTCN-3 compiler // of the TTCN-3 Test Executor version 11.1.0 // The generation of user and time information were disabled by the -D flag. // Copyright (c) 2000-2025 Ericsson Telecom AB // Do not edit this file unless you know what you are doing. /* Including header files */ #include "StatsD_Checker.hh" namespace StatsD__Checker { /* Literal string constants */ extern const CHARSTRING cs_5(6, "-STATS"), cs_1(54, "Could not bind StatsD socket, check your configuration"), cs_0(21, "StatsD_Checker.ttcnpp"), cs_2(6, "enable"), cs_4(12, "stats report"), cs_3(11, "stats reset"); const unsigned char module_checksum[] = { 0x51, 0x2d, 0x70, 0xd4, 0xf9, 0xa4, 0xa4, 0xcf, 0xfc, 0x86, 0xe7, 0x49, 0xaa, 0x33, 0x34, 0x83 }; /* Global variable definitions */ BOOLEAN modulepar_mp__enable__stats; const BOOLEAN& mp__enable__stats = modulepar_mp__enable__stats; const XERdescriptor_t StatsDMetricKey_name_xer_ = { {"name>\n", "name>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_Typedescriptor_t StatsDMetricKey_name_descr_ = { "@StatsD_Checker.StatsDMetricKey.name", NULL, &CHARSTRING_raw_, &StatsD__Types::MetricName_text_, &StatsDMetricKey_name_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING StatsDMetricKey_name_default_coding("TEXT"); const XERdescriptor_t StatsDMetricKey_mtype_xer_ = { {"mtype>\n", "mtype>\n"}, {7, 7}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_Typedescriptor_t StatsDMetricKey_mtype_descr_ = { "@StatsD_Checker.StatsDMetricKey.mtype", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &StatsDMetricKey_mtype_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING StatsDMetricKey_mtype_default_coding("TEXT"); // No XER for StatsDMetricKey const TTCN_Typedescriptor_t StatsDMetricKey_descr_ = { "@StatsD_Checker.StatsDMetricKey", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; // No XER for StatsDMetricKeys const TTCN_Typedescriptor_t StatsDMetricKeys_descr_ = { "@StatsD_Checker.StatsDMetricKeys", NULL, NULL, NULL, NULL, NULL, NULL, NULL, &StatsDMetricKey_descr_, TTCN_Typedescriptor_t::DONTCARE }; const XERdescriptor_t StatsDExpect_name_xer_ = { {"name>\n", "name>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_Typedescriptor_t StatsDExpect_name_descr_ = { "@StatsD_Checker.StatsDExpect.name", NULL, &CHARSTRING_raw_, &StatsD__Types::MetricName_text_, &StatsDExpect_name_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING StatsDExpect_name_default_coding("TEXT"); const XERdescriptor_t StatsDExpect_mtype_xer_ = { {"mtype>\n", "mtype>\n"}, {7, 7}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_Typedescriptor_t StatsDExpect_mtype_descr_ = { "@StatsD_Checker.StatsDExpect.mtype", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &StatsDExpect_mtype_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING StatsDExpect_mtype_default_coding("TEXT"); const XERdescriptor_t StatsDExpect_min_xer_ = { {"min>\n", "min>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t StatsDExpect_min_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t StatsDExpect_min_descr_ = { "@StatsD_Checker.StatsDExpect.min", &INTEGER_ber_, &INTEGER_raw_, &StatsD__Types::MetricValue_text_, &StatsDExpect_min_xer_, &INTEGER_json_, &StatsDExpect_min_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING StatsDExpect_min_default_coding("TEXT"); const XERdescriptor_t StatsDExpect_max_xer_ = { {"max>\n", "max>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_OERdescriptor_t StatsDExpect_max_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL }; const TTCN_Typedescriptor_t StatsDExpect_max_descr_ = { "@StatsD_Checker.StatsDExpect.max", &INTEGER_ber_, &INTEGER_raw_, &StatsD__Types::MetricValue_text_, &StatsDExpect_max_xer_, &INTEGER_json_, &StatsDExpect_max_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; UNIVERSAL_CHARSTRING StatsDExpect_max_default_coding("TEXT"); // No XER for StatsDExpect const TTCN_Typedescriptor_t StatsDExpect_descr_ = { "@StatsD_Checker.StatsDExpect", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; // No XER for StatsDExpects const TTCN_Typedescriptor_t StatsDExpects_descr_ = { "@StatsD_Checker.StatsDExpects", NULL, NULL, NULL, NULL, NULL, NULL, NULL, &StatsDExpect_descr_, TTCN_Typedescriptor_t::DONTCARE }; // No XER for StatsDResultType const TTCN_Typedescriptor_t StatsDResultType_descr_ = { "@StatsD_Checker.StatsDResultType", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; const XERdescriptor_t StatsDExpectResult_idx_xer_ = { {"idx>\n", "idx>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE }; const TTCN_Typedescriptor_t StatsDExpectResult_idx_descr_ = { "@StatsD_Checker.StatsDExpectResult.idx", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &StatsDExpectResult_idx_xer_, &INTEGER_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; // No XER for StatsDExpectResult const TTCN_Typedescriptor_t StatsDExpectResult_descr_ = { "@StatsD_Checker.StatsDExpectResult", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE }; const TTCN_Typedescriptor_t& StatsD__Checker__CT_descr_ = COMPONENT_descr_; TELNETasp__PortType::TELNETasp__PT StatsD__Checker__CT_component_STATSVTY("STATSVTY"); STATSD__PROC__PT StatsD__Checker__CT_component_STATSD__PROC("STATSD_PROC"); StatsD__CodecPort::STATSD__CODEC__PT StatsD__Checker__CT_component_STATS("STATS"); FLOAT StatsD__Checker__CT_component_g__timeout; TIMER StatsD__Checker__CT_component_T__statsd("T_statsd"); const TTCN_Typedescriptor_t& StatsD__ConnHdlr_descr_ = COMPONENT_descr_; STATSD__PROC__PT StatsD__ConnHdlr_component_STATSD__PROC("STATSD_PROC"); FLOAT const_main__statsd__timeout_defval; const FLOAT& main__statsd__timeout_defval = const_main__statsd__timeout_defval; BOOLEAN const_f__statsd__checker__snapshot_since__last__snapshot_defval; const BOOLEAN& f__statsd__checker__snapshot_since__last__snapshot_defval = const_f__statsd__checker__snapshot_since__last__snapshot_defval; BOOLEAN const_f__compare__expect_use__snapshot_defval; const BOOLEAN& f__compare__expect_use__snapshot_defval = const_f__compare__expect_use__snapshot_defval; StatsD__Types::StatsDMetrics const_f__compare__expect_snapshot_defval; const StatsD__Types::StatsDMetrics& f__compare__expect_snapshot_defval = const_f__compare__expect_snapshot_defval; BOOLEAN const_f__statsd__checker__metric__expects_use__snapshot_defval; const BOOLEAN& f__statsd__checker__metric__expects_use__snapshot_defval = const_f__statsd__checker__metric__expects_use__snapshot_defval; StatsD__Types::StatsDMetrics const_f__statsd__checker__metric__expects_snapshot_defval; const StatsD__Types::StatsDMetrics& f__statsd__checker__metric__expects_snapshot_defval = const_f__statsd__checker__metric__expects_snapshot_defval; BOOLEAN const_f__statsd__checker__expect_wait__converge_defval; const BOOLEAN& f__statsd__checker__expect_wait__converge_defval = const_f__statsd__checker__expect_wait__converge_defval; BOOLEAN const_f__statsd__checker__expect_use__snapshot_defval; const BOOLEAN& f__statsd__checker__expect_use__snapshot_defval = const_f__statsd__checker__expect_use__snapshot_defval; StatsD__Types::StatsDMetrics const_f__statsd__checker__expect_snapshot_defval; const StatsD__Types::StatsDMetrics& f__statsd__checker__expect_snapshot_defval = const_f__statsd__checker__expect_snapshot_defval; FLOAT const_f__init__statsd_statsd__timeout_defval; const FLOAT& f__init__statsd_statsd__timeout_defval = const_f__init__statsd_statsd__timeout_defval; BOOLEAN const_f__statsd__snapshot_since__last__snapshot_defval; const BOOLEAN& f__statsd__snapshot_since__last__snapshot_defval = const_f__statsd__snapshot_since__last__snapshot_defval; BOOLEAN const_f__statsd__expect_wait__converge_defval; const BOOLEAN& f__statsd__expect_wait__converge_defval = const_f__statsd__expect_wait__converge_defval; BOOLEAN const_f__statsd__expect__from__snapshot_wait__converge_defval; const BOOLEAN& f__statsd__expect__from__snapshot_wait__converge_defval = const_f__statsd__expect__from__snapshot_wait__converge_defval; StatsD__Types::StatsDMetrics const_f__statsd__expect__from__snapshot_snapshot_defval; const StatsD__Types::StatsDMetrics& f__statsd__expect__from__snapshot_snapshot_defval = const_f__statsd__expect__from__snapshot_snapshot_defval; TTCN_Module module_object("StatsD_Checker", __DATE__, __TIME__, module_checksum, pre_init_module, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, post_init_module, set_module_param, NULL, log_module_param, init_comp_type, init_system_port, start_ptc_function, NULL); const RuntimeVersionChecker ver_checker( current_runtime_version.requires_major_version_11, current_runtime_version.requires_minor_version_1, current_runtime_version.requires_patch_level_0, current_runtime_version.requires_runtime_1); /* Member functions of C++ classes */ StatsDMetricKey::StatsDMetricKey() { } StatsDMetricKey::StatsDMetricKey(const CHARSTRING& par_name, const CHARSTRING& par_mtype) : field_name(par_name), field_mtype(par_mtype) { } StatsDMetricKey::StatsDMetricKey(const StatsDMetricKey& other_value) { if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @StatsD_Checker.StatsDMetricKey."); if (other_value.name().is_bound()) field_name = other_value.name(); else field_name.clean_up(); if (other_value.mtype().is_bound()) field_mtype = other_value.mtype(); else field_mtype.clean_up(); } void StatsDMetricKey::clean_up() { field_name.clean_up(); field_mtype.clean_up(); } const TTCN_Typedescriptor_t* StatsDMetricKey::get_descriptor() const { return &StatsDMetricKey_descr_; } StatsDMetricKey& StatsDMetricKey::operator=(const StatsDMetricKey& other_value) { if (this != &other_value) { if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @StatsD_Checker.StatsDMetricKey."); if (other_value.name().is_bound()) field_name = other_value.name(); else field_name.clean_up(); if (other_value.mtype().is_bound()) field_mtype = other_value.mtype(); else field_mtype.clean_up(); } return *this; } boolean StatsDMetricKey::operator==(const StatsDMetricKey& other_value) const { return field_name==other_value.field_name && field_mtype==other_value.field_mtype; } boolean StatsDMetricKey::is_bound() const { return (field_name.is_bound()) || (field_mtype.is_bound()); } boolean StatsDMetricKey::is_value() const { return field_name.is_value() && field_mtype.is_value(); } void StatsDMetricKey::log() const { if (!is_bound()) { TTCN_Logger::log_event_unbound(); return; } TTCN_Logger::log_event_str("{ name := "); field_name.log(); TTCN_Logger::log_event_str(", mtype := "); field_mtype.log(); TTCN_Logger::log_event_str(" }"); } void StatsDMetricKey::set_implicit_omit() { if (name().is_bound()) name().set_implicit_omit(); if (mtype().is_bound()) mtype().set_implicit_omit(); } void StatsDMetricKey::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 (20 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) name().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) mtype().set_param(*param.get_elem(1)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "name")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { name().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "mtype")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { mtype().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @StatsD_Checker.StatsDMetricKey: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@StatsD_Checker.StatsDMetricKey"); } } void StatsDMetricKey::encode_text(Text_Buf& text_buf) const { field_name.encode_text(text_buf); field_mtype.encode_text(text_buf); } void StatsDMetricKey::decode_text(Text_Buf& text_buf) { field_name.decode_text(text_buf); field_mtype.decode_text(text_buf); } struct StatsDMetricKey_template::single_value_struct { CHARSTRING_template field_name; CHARSTRING_template field_mtype; }; void StatsDMetricKey_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_name = ANY_VALUE; single_value->field_mtype = ANY_VALUE; } } } void StatsDMetricKey_template::copy_value(const StatsDMetricKey& other_value) { single_value = new single_value_struct; if (other_value.name().is_bound()) { single_value->field_name = other_value.name(); } else { single_value->field_name.clean_up(); } if (other_value.mtype().is_bound()) { single_value->field_mtype = other_value.mtype(); } else { single_value->field_mtype.clean_up(); } set_selection(SPECIFIC_VALUE); } void StatsDMetricKey_template::copy_template(const StatsDMetricKey_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.name().get_selection()) { single_value->field_name = other_value.name(); } else { single_value->field_name.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.mtype().get_selection()) { single_value->field_mtype = other_value.mtype(); } else { single_value->field_mtype.clean_up(); } case OMIT_VALUE: case ANY_VALUE: case ANY_OR_OMIT: break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: value_list.n_values = other_value.value_list.n_values; value_list.list_value = new StatsDMetricKey_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; case IMPLICATION_MATCH: implication_.precondition = new StatsDMetricKey_template(*other_value.implication_.precondition); implication_.implied_template = new StatsDMetricKey_template(*other_value.implication_.implied_template); break; case DYNAMIC_MATCH: dyn_match = other_value.dyn_match; dyn_match->ref_count++; break; default: TTCN_error("Copying an uninitialized/unsupported template of type @StatsD_Checker.StatsDMetricKey."); break; } set_selection(other_value); } StatsDMetricKey_template::StatsDMetricKey_template() { } StatsDMetricKey_template::StatsDMetricKey_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } StatsDMetricKey_template::StatsDMetricKey_template(const StatsDMetricKey& other_value) { copy_value(other_value); } StatsDMetricKey_template::StatsDMetricKey_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDMetricKey&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @StatsD_Checker.StatsDMetricKey from an unbound optional field."); } } StatsDMetricKey_template::StatsDMetricKey_template(StatsDMetricKey_template* p_precondition, StatsDMetricKey_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } StatsDMetricKey_template::StatsDMetricKey_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } StatsDMetricKey_template::StatsDMetricKey_template(const StatsDMetricKey_template& other_value) : Base_Template() { copy_template(other_value); } StatsDMetricKey_template::~StatsDMetricKey_template() { clean_up(); } StatsDMetricKey_template& StatsDMetricKey_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } StatsDMetricKey_template& StatsDMetricKey_template::operator=(const StatsDMetricKey& other_value) { clean_up(); copy_value(other_value); return *this; } StatsDMetricKey_template& StatsDMetricKey_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDMetricKey&)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 @StatsD_Checker.StatsDMetricKey."); } return *this; } StatsDMetricKey_template& StatsDMetricKey_template::operator=(const StatsDMetricKey_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean StatsDMetricKey_template::match(const StatsDMetricKey& 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.name().is_bound()) return FALSE; if(!single_value->field_name.match(other_value.name(), legacy))return FALSE; if(!other_value.mtype().is_bound()) return FALSE; if(!single_value->field_mtype.match(other_value.mtype(), 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; case CONJUNCTION_MATCH: for (unsigned int i = 0; i < value_list.n_values; i++) { if (!value_list.list_value[i].match(other_value)) { return FALSE; } } return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value); case DYNAMIC_MATCH: return dyn_match->ptr->match(other_value); default: TTCN_error("Matching an uninitialized/unsupported template of type @StatsD_Checker.StatsDMetricKey."); } return FALSE; } boolean StatsDMetricKey_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_name.is_bound() || single_value->field_mtype.is_bound(); } boolean StatsDMetricKey_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_name.is_value() && single_value->field_mtype.is_value(); } void StatsDMetricKey_template::clean_up() { switch (template_selection) { case SPECIFIC_VALUE: delete single_value; break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: delete [] value_list.list_value; break; case IMPLICATION_MATCH: delete implication_.precondition; delete implication_.implied_template; break; case DYNAMIC_MATCH: dyn_match->ref_count--; if (dyn_match->ref_count == 0) { delete dyn_match->ptr; delete dyn_match; } break; default: break; } template_selection = UNINITIALIZED_TEMPLATE; } StatsDMetricKey StatsDMetricKey_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 @StatsD_Checker.StatsDMetricKey."); StatsDMetricKey ret_val; if (single_value->field_name.is_bound()) { ret_val.name() = single_value->field_name.valueof(); } if (single_value->field_mtype.is_bound()) { ret_val.mtype() = single_value->field_mtype.valueof(); } return ret_val; } void StatsDMetricKey_template::set_type(template_sel template_type, unsigned int list_length) { if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH) TTCN_error("Setting an invalid list for a template of type @StatsD_Checker.StatsDMetricKey."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new StatsDMetricKey_template[list_length]; } StatsDMetricKey_template& StatsDMetricKey_template::list_item(unsigned int list_index) const { if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH) TTCN_error("Accessing a list element of a non-list template of type @StatsD_Checker.StatsDMetricKey."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @StatsD_Checker.StatsDMetricKey."); return value_list.list_value[list_index]; } CHARSTRING_template& StatsDMetricKey_template::name() { set_specific(); return single_value->field_name; } const CHARSTRING_template& StatsDMetricKey_template::name() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field name of a non-specific template of type @StatsD_Checker.StatsDMetricKey."); return single_value->field_name; } CHARSTRING_template& StatsDMetricKey_template::mtype() { set_specific(); return single_value->field_mtype; } const CHARSTRING_template& StatsDMetricKey_template::mtype() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field mtype of a non-specific template of type @StatsD_Checker.StatsDMetricKey."); return single_value->field_mtype; } int StatsDMetricKey_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDMetricKey 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 @StatsD_Checker.StatsDMetricKey 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 @StatsD_Checker.StatsDMetricKey containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDMetricKey containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDMetricKey containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDMetricKey containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDMetricKey containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDMetricKey containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDMetricKey containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @StatsD_Checker.StatsDMetricKey."); } return 0; } void StatsDMetricKey_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ name := "); single_value->field_name.log(); TTCN_Logger::log_event_str(", mtype := "); single_value->field_mtype.log(); TTCN_Logger::log_event_str(" }"); break; case COMPLEMENTED_LIST: TTCN_Logger::log_event_str("complement"); case CONJUNCTION_MATCH: if (template_selection == CONJUNCTION_MATCH) { TTCN_Logger::log_event_str("conjunct"); } 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; case IMPLICATION_MATCH: implication_.precondition->log(); TTCN_Logger::log_event_str(" implies "); implication_.implied_template->log(); break; case DYNAMIC_MATCH: TTCN_Logger::log_event_str("@dynamic template"); break; default: log_generic(); } log_ifpresent(); } void StatsDMetricKey_template::log_match(const StatsDMetricKey& 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_name.match(match_value.name(), legacy)){ TTCN_Logger::log_logmatch_info(".name"); single_value->field_name.log_match(match_value.name(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_mtype.match(match_value.mtype(), legacy)){ TTCN_Logger::log_logmatch_info(".mtype"); single_value->field_mtype.log_match(match_value.mtype(), 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("{ name := "); single_value->field_name.log_match(match_value.name(), legacy); TTCN_Logger::log_event_str(", mtype := "); single_value->field_mtype.log_match(match_value.mtype(), 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 StatsDMetricKey_template::set_implicit_omit() { if (template_selection != SPECIFIC_VALUE) return; if (name().is_bound()) name().set_implicit_omit(); if (mtype().is_bound()) mtype().set_implicit_omit(); } void StatsDMetricKey_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_name.encode_text(text_buf); single_value->field_mtype.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 @StatsD_Checker.StatsDMetricKey."); } } void StatsDMetricKey_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_name.decode_text(text_buf); single_value->field_mtype.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 StatsDMetricKey_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 @StatsD_Checker.StatsDMetricKey."); } } void StatsDMetricKey_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: case Module_Param::MP_ConjunctList_Template: { StatsDMetricKey_template new_temp; new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size()); for (size_t p_i=0; p_i0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) name().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) mtype().set_param(*param.get_elem(1)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "name")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { name().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "mtype")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { mtype().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @StatsD_Checker.StatsDMetricKey: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { StatsDMetricKey_template* precondition = new StatsDMetricKey_template; precondition->set_param(*param.get_elem(0)); StatsDMetricKey_template* implied_template = new StatsDMetricKey_template; implied_template->set_param(*param.get_elem(1)); *this = StatsDMetricKey_template(precondition, implied_template); } break; default: param.type_error("record template", "@StatsD_Checker.StatsDMetricKey"); } is_ifpresent = param.get_ifpresent(); } void StatsDMetricKey_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_name.check_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDMetricKey"); single_value->field_mtype.check_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDMetricKey"); 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 : "@StatsD_Checker.StatsDMetricKey"); } boolean StatsDMetricKey_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean StatsDMetricKey_template::match_omit(boolean legacy) const { if (is_ifpresent) return TRUE; switch (template_selection) { case OMIT_VALUE: case ANY_OR_OMIT: return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match_omit() || implication_.implied_template->match_omit(); case VALUE_LIST: case COMPLEMENTED_LIST: if (legacy) { for (unsigned int l_idx=0; l_idxval_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); if (((const StatsDMetricKeys*)right_ptr)->val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); if (((const StatsDMetricKeys*)left_ptr)->val_ptr->value_elements[left_index] != NULL){ if (((const StatsDMetricKeys*)right_ptr)->val_ptr->value_elements[right_index] != NULL){ return *((const StatsDMetricKeys*)left_ptr)->val_ptr->value_elements[left_index] == *((const StatsDMetricKeys*)right_ptr)->val_ptr->value_elements[right_index]; } else return FALSE; } else { return ((const StatsDMetricKeys*)right_ptr)->val_ptr->value_elements[right_index] == NULL; } } StatsDMetricKeys::StatsDMetricKeys() { val_ptr = NULL; } StatsDMetricKeys::StatsDMetricKeys(null_type) { val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = 0; val_ptr->value_elements = NULL; } StatsDMetricKeys::StatsDMetricKeys(const StatsDMetricKeys& other_value) { if (!other_value.is_bound()) TTCN_error("Copying an unbound value of type @StatsD_Checker.StatsDMetricKeys."); val_ptr = other_value.val_ptr; val_ptr->ref_count++; } StatsDMetricKeys::~StatsDMetricKeys() { clean_up(); if (val_ptr != NULL) val_ptr = NULL; } void StatsDMetricKeys::clean_up() { if (val_ptr != NULL) { if (val_ptr->ref_count > 1) { val_ptr->ref_count--; val_ptr = NULL; } else if (val_ptr->ref_count == 1) { for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) if (val_ptr->value_elements[elem_count] != NULL) delete val_ptr->value_elements[elem_count]; free_pointers((void**)val_ptr->value_elements); delete val_ptr; val_ptr = NULL; } else TTCN_error("Internal error: Invalid reference counter in a record of/set of value."); } } StatsDMetricKeys& StatsDMetricKeys::operator=(null_type) { clean_up(); val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = 0; val_ptr->value_elements = NULL; return *this; } StatsDMetricKeys& StatsDMetricKeys::operator=(const StatsDMetricKeys& other_value) { if (other_value.val_ptr == NULL) TTCN_error("Assigning an unbound value of type @StatsD_Checker.StatsDMetricKeys."); if (this != &other_value) { clean_up(); val_ptr = other_value.val_ptr; val_ptr->ref_count++; } return *this; } boolean StatsDMetricKeys::operator==(null_type) const { if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); return val_ptr->n_elements == 0 ; } boolean StatsDMetricKeys::operator==(const StatsDMetricKeys& other_value) const { if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); if (val_ptr == other_value.val_ptr) return TRUE; return compare_set_of(this, val_ptr->n_elements, &other_value, (other_value.val_ptr)->n_elements, compare_function); } StatsDMetricKey& StatsDMetricKeys::operator[](int index_value) { if (index_value < 0) TTCN_error("Accessing an element of type @StatsD_Checker.StatsDMetricKeys using a negative index: %d.", index_value); if (val_ptr == NULL) { val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = 0; val_ptr->value_elements = NULL; } else if (val_ptr->ref_count > 1) { struct recordof_setof_struct *new_val_ptr = new recordof_setof_struct; new_val_ptr->ref_count = 1; new_val_ptr->n_elements = (index_value >= val_ptr->n_elements) ? index_value + 1 : val_ptr->n_elements; new_val_ptr->value_elements = (StatsDMetricKey**)allocate_pointers(new_val_ptr->n_elements); for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++){ if (val_ptr->value_elements[elem_count] != NULL){ new_val_ptr->value_elements[elem_count] = new StatsDMetricKey(*(val_ptr->value_elements[elem_count])); } } clean_up(); val_ptr = new_val_ptr; } if (index_value >= val_ptr->n_elements) set_size(index_value + 1); if (val_ptr->value_elements[index_value] == NULL) { val_ptr->value_elements[index_value] = new StatsDMetricKey; } return *val_ptr->value_elements[index_value]; } StatsDMetricKey& StatsDMetricKeys::operator[](const INTEGER& index_value) { index_value.must_bound("Using an unbound integer value for indexing a value of type @StatsD_Checker.StatsDMetricKeys."); return (*this)[(int)index_value]; } const StatsDMetricKey& StatsDMetricKeys::operator[](int index_value) const { if (val_ptr == NULL) TTCN_error("Accessing an element in an unbound value of type @StatsD_Checker.StatsDMetricKeys."); if (index_value < 0) TTCN_error("Accessing an element of type @StatsD_Checker.StatsDMetricKeys using a negative index: %d.", index_value); if (index_value >= val_ptr->n_elements) TTCN_error("Index overflow in a value of type @StatsD_Checker.StatsDMetricKeys: The index is %d, but the value has only %d elements.", index_value, val_ptr->n_elements); return (val_ptr->value_elements[index_value] == NULL) ? UNBOUND_ELEM : *val_ptr->value_elements[index_value]; } const StatsDMetricKey& StatsDMetricKeys::operator[](const INTEGER& index_value) const { index_value.must_bound("Using an unbound integer value for indexing a value of type @StatsD_Checker.StatsDMetricKeys."); return (*this)[(int)index_value]; } StatsDMetricKeys StatsDMetricKeys::operator<<=(int rotate_count) const { return *this >>= (-rotate_count); } StatsDMetricKeys StatsDMetricKeys::operator<<=(const INTEGER& rotate_count) const { rotate_count.must_bound("Unbound integer operand of rotate left operator."); return *this >>= (int)(-rotate_count); } StatsDMetricKeys StatsDMetricKeys::operator>>=(const INTEGER& rotate_count) const { rotate_count.must_bound("Unbound integer operand of rotate right operator."); return *this >>= (int)rotate_count; } StatsDMetricKeys StatsDMetricKeys::operator>>=(int rotate_count) const { if (val_ptr == NULL) TTCN_error("Performing rotation operation on an unbound value of type @StatsD_Checker.StatsDMetricKeys."); if (val_ptr->n_elements == 0) return *this; int rc; if (rotate_count>=0) rc = rotate_count % val_ptr->n_elements; else rc = val_ptr->n_elements - ((-rotate_count) % val_ptr->n_elements); if (rc == 0) return *this; StatsDMetricKeys ret_val; ret_val.set_size(val_ptr->n_elements); for (int i=0; in_elements; i++) { if (val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[(i+rc)%val_ptr->n_elements] =new StatsDMetricKey(*val_ptr->value_elements[i]); } } return ret_val; } StatsDMetricKeys StatsDMetricKeys::operator+(const StatsDMetricKeys& other_value) const { if (val_ptr == NULL || other_value.val_ptr == NULL) TTCN_error("Unbound operand of @StatsD_Checker.StatsDMetricKeys concatenation."); if (val_ptr->n_elements == 0) return other_value; if (other_value.val_ptr->n_elements == 0) return *this; StatsDMetricKeys ret_val; ret_val.set_size(val_ptr->n_elements+other_value.val_ptr->n_elements); for (int i=0; in_elements; i++) { if (val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[i] = new StatsDMetricKey(*val_ptr->value_elements[i]); } } for (int i=0; in_elements; i++) { if (other_value.val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[i+val_ptr->n_elements] = new StatsDMetricKey(*other_value.val_ptr->value_elements[i]); } } return ret_val; } StatsDMetricKeys StatsDMetricKeys::substr(int index, int returncount) const { if (val_ptr == NULL) TTCN_error("The first argument of substr() is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); check_substr_arguments(val_ptr->n_elements, index, returncount, "@StatsD_Checker.StatsDMetricKeys","element"); StatsDMetricKeys ret_val; ret_val.set_size(returncount); for (int i=0; ivalue_elements[i+index] != NULL) { ret_val.val_ptr->value_elements[i] = new StatsDMetricKey(*val_ptr->value_elements[i+index]); } } return ret_val; } StatsDMetricKeys StatsDMetricKeys::replace(int index, int len, const StatsDMetricKeys& repl) const { if (val_ptr == NULL) TTCN_error("The first argument of replace() is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); if (repl.val_ptr == NULL) TTCN_error("The fourth argument of replace() is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); check_replace_arguments(val_ptr->n_elements, index, len, "@StatsD_Checker.StatsDMetricKeys","element"); StatsDMetricKeys ret_val; ret_val.set_size(val_ptr->n_elements + repl.val_ptr->n_elements - len); for (int i = 0; i < index; i++) { if (val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[i] = new StatsDMetricKey(*val_ptr->value_elements[i]); } } for (int i = 0; i < repl.val_ptr->n_elements; i++) { if (repl.val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[i+index] = new StatsDMetricKey(*repl.val_ptr->value_elements[i]); } } for (int i = 0; i < val_ptr->n_elements - index - len; i++) { if (val_ptr->value_elements[index+i+len] != NULL) { ret_val.val_ptr->value_elements[index+i+repl.val_ptr->n_elements] = new StatsDMetricKey(*val_ptr->value_elements[index+i+len]); } } return ret_val; } StatsDMetricKeys StatsDMetricKeys::replace(int index, int len, const StatsDMetricKeys_template& repl) const { if (!repl.is_value()) TTCN_error("The fourth argument of function replace() is a template with non-specific value."); return replace(index, len, repl.valueof()); } void StatsDMetricKeys::set_size(int new_size) { if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a value of type @StatsD_Checker.StatsDMetricKeys."); if (val_ptr == NULL) { val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = 0; val_ptr->value_elements = NULL; } else if (val_ptr->ref_count > 1) { struct recordof_setof_struct *new_val_ptr = new recordof_setof_struct; new_val_ptr->ref_count = 1; new_val_ptr->n_elements = (new_size < val_ptr->n_elements) ? new_size : val_ptr->n_elements; new_val_ptr->value_elements = (StatsDMetricKey**)allocate_pointers(new_val_ptr->n_elements); for (int elem_count = 0; elem_count < new_val_ptr->n_elements; elem_count++) { if (val_ptr->value_elements[elem_count] != NULL){ new_val_ptr->value_elements[elem_count] = new StatsDMetricKey(*(val_ptr->value_elements[elem_count])); } } clean_up(); val_ptr = new_val_ptr; } if (new_size > val_ptr->n_elements) { val_ptr->value_elements = (StatsDMetricKey**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size); #ifdef TITAN_MEMORY_DEBUG_SET_RECORD_OF if((val_ptr->n_elements/1000)!=(new_size/1000)) TTCN_warning("New size of type @StatsD_Checker.StatsDMetricKeys: %d",new_size); #endif val_ptr->n_elements = new_size; } else if (new_size < val_ptr->n_elements) { for (int elem_count = new_size; elem_count < val_ptr->n_elements; elem_count++) if (val_ptr->value_elements[elem_count] != NULL)delete val_ptr->value_elements[elem_count]; val_ptr->value_elements = (StatsDMetricKey**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size); val_ptr->n_elements = new_size; } } boolean StatsDMetricKeys::is_value() const { if (val_ptr == NULL) return FALSE; for(int i = 0; i < val_ptr->n_elements; ++i) { if (val_ptr->value_elements[i] == NULL || !val_ptr->value_elements[i]->is_value()) return FALSE; } return TRUE; } int StatsDMetricKeys::size_of() const { if (val_ptr == NULL) TTCN_error("Performing sizeof operation on an unbound value of type @StatsD_Checker.StatsDMetricKeys."); return val_ptr->n_elements; } int StatsDMetricKeys::lengthof() const { if (val_ptr == NULL) TTCN_error("Performing lengthof operation on an unbound value of type @StatsD_Checker.StatsDMetricKeys."); for (int my_length=val_ptr->n_elements; my_length>0; my_length--) if (val_ptr->value_elements[my_length-1] != NULL) return my_length; return 0; } void StatsDMetricKeys::log() const { if (val_ptr == NULL) {; TTCN_Logger::log_event_unbound(); return; } switch (val_ptr->n_elements) { case 0: TTCN_Logger::log_event_str("{ }"); break; default: TTCN_Logger::log_event_str("{ "); for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) { if (elem_count > 0) TTCN_Logger::log_event_str(", "); (*this)[elem_count].log(); } TTCN_Logger::log_event_str(" }"); } } void StatsDMetricKeys::set_implicit_omit() { if (val_ptr == NULL) return; for (int i = 0; i < val_ptr->n_elements; i++) { if (val_ptr->value_elements[i] != NULL) val_ptr->value_elements[i]->set_implicit_omit(); } } void StatsDMetricKeys::set_param(Module_Param& param) { param.basic_check(Module_Param::BC_VALUE|Module_Param::BC_LIST, "set of value"); switch (param.get_operation_type()) { case Module_Param::OT_ASSIGN: if (param.get_type()==Module_Param::MP_Value_List && param.get_size()==0) { *this = NULL_VALUE; return; } switch (param.get_type()) { case Module_Param::MP_Value_List: set_size(param.get_size()); for (size_t i=0; iget_type()!=Module_Param::MP_NotUsed) { (*this)[i].set_param(*curr); if (!(*this)[i].is_bound()) { delete val_ptr->value_elements[i]; val_ptr->value_elements[i] = NULL; } } } break; case Module_Param::MP_Indexed_List: for (size_t i=0; iget_id()->get_index()].set_param(*curr); if (!(*this)[curr->get_id()->get_index()].is_bound()) { delete val_ptr->value_elements[curr->get_id()->get_index()]; val_ptr->value_elements[curr->get_id()->get_index()] = NULL; } } break; default: param.type_error("set of value", "@StatsD_Checker.StatsDMetricKeys"); } break; case Module_Param::OT_CONCAT: switch (param.get_type()) { case Module_Param::MP_Value_List: { if (!is_bound()) *this = NULL_VALUE; int start_idx = lengthof(); for (size_t i=0; iget_type()!=Module_Param::MP_NotUsed)) { (*this)[start_idx+(int)i].set_param(*curr); } } } break; case Module_Param::MP_Indexed_List: param.error("Cannot concatenate an indexed value list"); break; default: param.type_error("set of value", "@StatsD_Checker.StatsDMetricKeys"); } break; default: TTCN_error("Internal error: Unknown operation type."); } } void StatsDMetricKeys::encode_text(Text_Buf& text_buf) const { if (val_ptr == NULL) TTCN_error("Text encoder: Encoding an unbound value of type @StatsD_Checker.StatsDMetricKeys."); text_buf.push_int(val_ptr->n_elements); for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) (*this)[elem_count].encode_text(text_buf); } void StatsDMetricKeys::decode_text(Text_Buf& text_buf) { clean_up(); val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = text_buf.pull_int().get_val(); if (val_ptr->n_elements < 0) TTCN_error("Text decoder: Negative size was received for a value of type @StatsD_Checker.StatsDMetricKeys."); val_ptr->value_elements = (StatsDMetricKey**)allocate_pointers(val_ptr->n_elements); for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) { val_ptr->value_elements[elem_count] = new StatsDMetricKey; val_ptr->value_elements[elem_count]->decode_text(text_buf); } } void StatsDMetricKeys_template::copy_value(const StatsDMetricKeys& other_value) { if (!other_value.is_bound()) TTCN_error("Initialization of a template of type @StatsD_Checker.StatsDMetricKeys with an unbound value."); single_value.n_elements = other_value.size_of(); single_value.value_elements = (StatsDMetricKey_template**)allocate_pointers(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) { if (other_value[elem_count].is_bound()) { single_value.value_elements[elem_count] = new StatsDMetricKey_template(other_value[elem_count]); } else { single_value.value_elements[elem_count] = new StatsDMetricKey_template; } } set_selection(SPECIFIC_VALUE); } void StatsDMetricKeys_template::copy_template(const StatsDMetricKeys_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value.n_elements = other_value.single_value.n_elements; single_value.value_elements = (StatsDMetricKey_template**)allocate_pointers(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) { if (UNINITIALIZED_TEMPLATE != other_value.single_value.value_elements[elem_count]->get_selection()) { single_value.value_elements[elem_count] = new StatsDMetricKey_template(*other_value.single_value.value_elements[elem_count]); } else { single_value.value_elements[elem_count] = new StatsDMetricKey_template; } } case OMIT_VALUE: case ANY_VALUE: case ANY_OR_OMIT: break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: value_list.n_values = other_value.value_list.n_values; value_list.list_value = new StatsDMetricKeys_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; case SUPERSET_MATCH: case SUBSET_MATCH: value_set.n_items = other_value.value_set.n_items; value_set.set_items = new StatsDMetricKey_template[value_set.n_items]; for (unsigned int set_count = 0; set_count < value_set.n_items; set_count++) value_set.set_items[set_count] = other_value.value_set.set_items[set_count]; break; case IMPLICATION_MATCH: implication_.precondition = new StatsDMetricKeys_template(*other_value.implication_.precondition); implication_.implied_template = new StatsDMetricKeys_template(*other_value.implication_.implied_template); break; case DYNAMIC_MATCH: dyn_match = other_value.dyn_match; dyn_match->ref_count++; break; default: TTCN_error("Copying an uninitialized/unsupported template of type @StatsD_Checker.StatsDMetricKeys."); break; } set_selection(other_value); } boolean StatsDMetricKeys_template::match_function_specific(const Base_Type *value_ptr, int value_index, const Restricted_Length_Template *template_ptr, int template_index, boolean legacy) { if (value_index >= 0) return ((const StatsDMetricKeys_template*)template_ptr)->single_value.value_elements[template_index]->match((*(const StatsDMetricKeys*)value_ptr)[value_index], legacy); else return ((const StatsDMetricKeys_template*)template_ptr)->single_value.value_elements[template_index]->is_any_or_omit(); } boolean StatsDMetricKeys_template::match_function_set(const Base_Type *value_ptr, int value_index, const Restricted_Length_Template *template_ptr, int template_index, boolean legacy) { if (value_index >= 0) return ((const StatsDMetricKeys_template*)template_ptr)->value_set.set_items[template_index].match((*(const StatsDMetricKeys*)value_ptr)[value_index], legacy); else return ((const StatsDMetricKeys_template*)template_ptr)->value_set.set_items[template_index].is_any_or_omit(); } void StatsDMetricKeys_template::log_function(const Base_Type *value_ptr, const Restricted_Length_Template *template_ptr, int index_value, int index_template, boolean legacy) { if (value_ptr == NULL) { if (template_ptr != NULL) { ((const StatsDMetricKeys_template*)template_ptr)->single_value.value_elements[index_template]->log(); } } else if (template_ptr == NULL) { (*(const StatsDMetricKeys*)value_ptr)[index_value].log(); } else { ((const StatsDMetricKeys_template*)template_ptr)->single_value.value_elements[index_template]->log_match((*(const StatsDMetricKeys*)value_ptr)[index_value], legacy); } } StatsDMetricKeys_template::StatsDMetricKeys_template() { } StatsDMetricKeys_template::StatsDMetricKeys_template(template_sel other_value) : Restricted_Length_Template(other_value) { check_single_selection(other_value); } StatsDMetricKeys_template::StatsDMetricKeys_template(null_type) : Restricted_Length_Template(SPECIFIC_VALUE) { single_value.n_elements = 0; single_value.value_elements = NULL; } StatsDMetricKeys_template::StatsDMetricKeys_template(const StatsDMetricKeys& other_value) { copy_value(other_value); } StatsDMetricKeys_template::StatsDMetricKeys_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDMetricKeys&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @StatsD_Checker.StatsDMetricKeys from an unbound optional field."); } } StatsDMetricKeys_template::StatsDMetricKeys_template(StatsDMetricKeys_template* p_precondition, StatsDMetricKeys_template* p_implied_template) : Restricted_Length_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } StatsDMetricKeys_template::StatsDMetricKeys_template(Dynamic_Match_Interface* p_dyn_match) : Restricted_Length_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } StatsDMetricKeys_template::StatsDMetricKeys_template(const StatsDMetricKeys_template& other_value) : Restricted_Length_Template() { copy_template(other_value); } StatsDMetricKeys_template::~StatsDMetricKeys_template() { clean_up(); } void StatsDMetricKeys_template::clean_up() { switch (template_selection) { case SPECIFIC_VALUE: for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) delete single_value.value_elements[elem_count]; free_pointers((void**)single_value.value_elements); break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: delete [] value_list.list_value; break; break; case SUPERSET_MATCH: case SUBSET_MATCH: delete [] value_set.set_items; break; case IMPLICATION_MATCH: delete implication_.precondition; delete implication_.implied_template; break; case DYNAMIC_MATCH: dyn_match->ref_count--; if (dyn_match->ref_count == 0) { delete dyn_match->ptr; delete dyn_match; } break; default: break; } template_selection = UNINITIALIZED_TEMPLATE; } StatsDMetricKeys_template& StatsDMetricKeys_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } StatsDMetricKeys_template& StatsDMetricKeys_template::operator=(null_type) { clean_up(); set_selection(SPECIFIC_VALUE); single_value.n_elements = 0; single_value.value_elements = NULL; return *this; } StatsDMetricKeys_template& StatsDMetricKeys_template::operator=(const StatsDMetricKeys& other_value) { clean_up(); copy_value(other_value); return *this; } StatsDMetricKeys_template& StatsDMetricKeys_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDMetricKeys&)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 @StatsD_Checker.StatsDMetricKeys."); } return *this; } StatsDMetricKeys_template& StatsDMetricKeys_template::operator=(const StatsDMetricKeys_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } StatsDMetricKey_template& StatsDMetricKeys_template::operator[](int index_value) { if (index_value < 0) TTCN_error("Accessing an element of a template for type @StatsD_Checker.StatsDMetricKeys using a negative index: %d.", index_value); switch (template_selection) { case SPECIFIC_VALUE: if(index_value < single_value.n_elements) break; // no break case OMIT_VALUE: case ANY_VALUE: case ANY_OR_OMIT: case UNINITIALIZED_TEMPLATE: set_size(index_value + 1); break; default: TTCN_error("Accessing an element of a non-specific template for type @StatsD_Checker.StatsDMetricKeys."); break; } return *single_value.value_elements[index_value]; } StatsDMetricKey_template& StatsDMetricKeys_template::operator[](const INTEGER& index_value) { index_value.must_bound("Using an unbound integer value for indexing a template of type @StatsD_Checker.StatsDMetricKeys."); return (*this)[(int)index_value]; } const StatsDMetricKey_template& StatsDMetricKeys_template::operator[](int index_value) const { if (index_value < 0) TTCN_error("Accessing an element of a template for type @StatsD_Checker.StatsDMetricKeys using a negative index: %d.", index_value); if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing an element of a non-specific template for type @StatsD_Checker.StatsDMetricKeys."); if (index_value >= single_value.n_elements) TTCN_error("Index overflow in a template of type @StatsD_Checker.StatsDMetricKeys: The index is %d, but the template has only %d elements.", index_value, single_value.n_elements); return *single_value.value_elements[index_value]; } const StatsDMetricKey_template& StatsDMetricKeys_template::operator[](const INTEGER& index_value) const { index_value.must_bound("Using an unbound integer value for indexing a template of type @StatsD_Checker.StatsDMetricKeys."); return (*this)[(int)index_value]; } void StatsDMetricKeys_template::set_size(int new_size) { if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a template of type @StatsD_Checker.StatsDMetricKeys."); template_sel old_selection = template_selection; if (old_selection != SPECIFIC_VALUE) { clean_up(); set_selection(SPECIFIC_VALUE); single_value.n_elements = 0; single_value.value_elements = NULL; } if (new_size > single_value.n_elements) { single_value.value_elements = (StatsDMetricKey_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size); if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { for (int elem_count = single_value.n_elements; elem_count < new_size; elem_count++) single_value.value_elements[elem_count] = new StatsDMetricKey_template(ANY_VALUE); } else { for (int elem_count = single_value.n_elements; elem_count < new_size; elem_count++) single_value.value_elements[elem_count] = new StatsDMetricKey_template; } single_value.n_elements = new_size; } else if (new_size < single_value.n_elements) { for (int elem_count = new_size; elem_count < single_value.n_elements; elem_count++) delete single_value.value_elements[elem_count]; single_value.value_elements = (StatsDMetricKey_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size); single_value.n_elements = new_size; } } int StatsDMetricKeys_template::n_elem() const { switch (template_selection) { case SPECIFIC_VALUE: return single_value.n_elements; break; case VALUE_LIST: return value_list.n_values; break; default: TTCN_error("Performing n_elem"); } } int StatsDMetricKeys_template::size_of(boolean is_size) const { const char* op_name = is_size ? "size" : "length"; int min_size; boolean has_any_or_none; if (is_ifpresent) TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDMetricKeys which has an ifpresent attribute.", op_name); switch (template_selection) { case SPECIFIC_VALUE: { min_size = 0; has_any_or_none = FALSE; int elem_count = single_value.n_elements; if (!is_size) { while (elem_count>0 && !single_value.value_elements[elem_count-1]->is_bound()) elem_count--; } for (int i=0; iget_selection()) { case OMIT_VALUE: TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDMetricKeys containing omit element.", op_name); case ANY_OR_OMIT: has_any_or_none = TRUE; break; default: min_size++; break; } } } break; case SUPERSET_MATCH: case SUBSET_MATCH: { min_size = 0; has_any_or_none = FALSE; int elem_count = value_set.n_items; if (!is_size) { while (elem_count>0 && !value_set.set_items[elem_count-1].is_bound()) elem_count--; } for (int i=0; ilength_restriction.range_length.min_length){ TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDMetricKeys with no exact size.", op_name); } else TTCN_error("Performing %sof() operation on an invalid template of type @StatsD_Checker.StatsDMetricKeys. Maximum size (%d) contradicts the length restriction (%d..%d).", op_name, max_size, length_restriction.range_length.min_length, length_restriction.range_length.max_length); default: TTCN_error("Internal error: Template has invalid length restriction type."); } } } } break; case OMIT_VALUE: TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDMetricKeys containing omit value.", op_name); case ANY_VALUE: case ANY_OR_OMIT: min_size = 0; has_any_or_none = TRUE; break; case VALUE_LIST: { if (value_list.n_values<1) TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDMetricKeys containing an empty list.", op_name); int item_size = value_list.list_value[0].size_of(is_size); for (unsigned int i = 1; i < value_list.n_values; i++) { if (value_list.list_value[i].size_of(is_size)!=item_size) TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDMetricKeys containing a value list with different sizes.", op_name); } min_size = item_size; has_any_or_none = FALSE; break; } case COMPLEMENTED_LIST: TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDMetricKeys containing complemented list.", op_name); default: TTCN_error("Performing %sof() operation on an uninitialized/unsupported template of type @StatsD_Checker.StatsDMetricKeys.", op_name); } return check_section_is_single(min_size, has_any_or_none, op_name, "a", "template of type @StatsD_Checker.StatsDMetricKeys"); } boolean StatsDMetricKeys_template::match(const StatsDMetricKeys& other_value, boolean legacy) const { if (!other_value.is_bound()) return FALSE; int value_length = other_value.size_of(); if (!match_length(value_length)) return FALSE; switch (template_selection) { case SPECIFIC_VALUE: return match_set_of(&other_value, value_length, this, single_value.n_elements, match_function_specific, legacy); 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, legacy)) return template_selection == VALUE_LIST; return template_selection == COMPLEMENTED_LIST; case SUPERSET_MATCH: case SUBSET_MATCH: return match_set_of(&other_value, value_length, this, value_set.n_items, match_function_set, legacy); case CONJUNCTION_MATCH: for (unsigned int i = 0; i < value_list.n_values; i++) { if (!value_list.list_value[i].match(other_value)) { return FALSE; } } return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value); case DYNAMIC_MATCH: return dyn_match->ptr->match(other_value); default: TTCN_error("Matching with an uninitialized/unsupported template of type @StatsD_Checker.StatsDMetricKeys."); } return FALSE; } boolean StatsDMetricKeys_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) if (!single_value.value_elements[elem_count]->is_value()) return FALSE; return TRUE; } StatsDMetricKeys StatsDMetricKeys_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 @StatsD_Checker.StatsDMetricKeys."); StatsDMetricKeys ret_val; ret_val.set_size(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) if (single_value.value_elements[elem_count]->is_bound()) { ret_val[elem_count] = single_value.value_elements[elem_count]->valueof(); } return ret_val; } StatsDMetricKeys StatsDMetricKeys_template::substr(int index, int returncount) const { if (!is_value()) TTCN_error("The first argument of function substr() is a template with non-specific value."); return valueof().substr(index, returncount); } StatsDMetricKeys StatsDMetricKeys_template::replace(int index, int len, const StatsDMetricKeys_template& repl) const { if (!is_value()) TTCN_error("The first argument of function replace() is a template with non-specific value."); if (!repl.is_value()) TTCN_error("The fourth argument of function replace() is a template with non-specific value."); return valueof().replace(index, len, repl.valueof()); } StatsDMetricKeys StatsDMetricKeys_template::replace(int index, int len, const StatsDMetricKeys& repl) const { if (!is_value()) TTCN_error("The first argument of function replace() is a template with non-specific value."); return valueof().replace(index, len, repl); } void StatsDMetricKeys_template::set_type(template_sel template_type, unsigned int list_length) { clean_up(); switch (template_type) { case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: value_list.n_values = list_length; value_list.list_value = new StatsDMetricKeys_template[list_length]; break; case SUPERSET_MATCH: case SUBSET_MATCH: value_set.n_items = list_length; value_set.set_items = new StatsDMetricKey_template[list_length]; break; default: TTCN_error("Internal error: Setting an invalid type for a template of type @StatsD_Checker.StatsDMetricKeys."); } set_selection(template_type); } StatsDMetricKeys_template& StatsDMetricKeys_template::list_item(unsigned int list_index) { if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST && template_selection != CONJUNCTION_MATCH) TTCN_error("Internal error: Accessing a list element of a non-list template of type @StatsD_Checker.StatsDMetricKeys."); if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of type @StatsD_Checker.StatsDMetricKeys."); return value_list.list_value[list_index]; } StatsDMetricKey_template& StatsDMetricKeys_template::set_item(unsigned int set_index) { if (template_selection != SUPERSET_MATCH && template_selection != SUBSET_MATCH) TTCN_error("Internal error: Accessing a set element of a non-set template of type @StatsD_Checker.StatsDMetricKeys."); if (set_index >= value_set.n_items) TTCN_error("Internal error: Index overflow in a set template of type @StatsD_Checker.StatsDMetricKeys."); return value_set.set_items[set_index]; } void StatsDMetricKeys_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: if (single_value.n_elements > 0) { TTCN_Logger::log_event_str("{ "); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) { if (elem_count > 0) TTCN_Logger::log_event_str(", "); single_value.value_elements[elem_count]->log(); } TTCN_Logger::log_event_str(" }"); } else TTCN_Logger::log_event_str("{ }"); break; case COMPLEMENTED_LIST: TTCN_Logger::log_event_str("complement"); case CONJUNCTION_MATCH: if (template_selection == CONJUNCTION_MATCH) { TTCN_Logger::log_event_str("conjunct"); } 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; case SUPERSET_MATCH: case SUBSET_MATCH: TTCN_Logger::log_event("%s(", template_selection == SUPERSET_MATCH ? "superset" : "subset"); for (unsigned int set_count = 0; set_count < value_set.n_items; set_count++) { if (set_count > 0) TTCN_Logger::log_event_str(", "); value_set.set_items[set_count].log(); } TTCN_Logger::log_char(')'); break; case IMPLICATION_MATCH: implication_.precondition->log(); TTCN_Logger::log_event_str(" implies "); implication_.implied_template->log(); break; case DYNAMIC_MATCH: TTCN_Logger::log_event_str("@dynamic template"); break; default: log_generic(); } log_restricted(); log_ifpresent(); } void StatsDMetricKeys_template::log_match(const StatsDMetricKeys& 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{ size_t previous_size = TTCN_Logger::get_logmatch_buffer_len(); if (template_selection == SPECIFIC_VALUE) log_match_heuristics(&match_value, match_value.size_of(), this, single_value.n_elements, match_function_specific, log_function, legacy); else{ if(previous_size != 0){ TTCN_Logger::print_logmatch_buffer(); TTCN_Logger::set_logmatch_buffer_len(previous_size); TTCN_Logger::log_event_str(":="); } match_value.log(); TTCN_Logger::log_event_str(" with "); log(); TTCN_Logger::log_event_str(" unmatched"); } } return; } 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"); if (template_selection == SPECIFIC_VALUE) log_match_heuristics(&match_value, match_value.size_of(), this, single_value.n_elements, match_function_specific, log_function, legacy); } } void StatsDMetricKeys_template::encode_text(Text_Buf& text_buf) const { encode_text_restricted(text_buf); switch (template_selection) { case SPECIFIC_VALUE: text_buf.push_int(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) single_value.value_elements[elem_count]->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; case SUPERSET_MATCH: case SUBSET_MATCH: text_buf.push_int(value_set.n_items); for (unsigned int set_count = 0; set_count < value_set.n_items; set_count++) value_set.set_items[set_count].encode_text(text_buf); break; default: TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type @StatsD_Checker.StatsDMetricKeys."); } } void StatsDMetricKeys_template::decode_text(Text_Buf& text_buf) { clean_up(); decode_text_restricted(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value.n_elements = text_buf.pull_int().get_val(); if (single_value.n_elements < 0) TTCN_error("Text decoder: Negative size was received for a template of type @StatsD_Checker.StatsDMetricKeys."); single_value.value_elements = (StatsDMetricKey_template**)allocate_pointers(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) { single_value.value_elements[elem_count] = new StatsDMetricKey_template; single_value.value_elements[elem_count]->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 StatsDMetricKeys_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; case SUPERSET_MATCH: case SUBSET_MATCH: value_set.n_items = text_buf.pull_int().get_val(); value_set.set_items = new StatsDMetricKey_template[value_set.n_items]; for (unsigned int set_count = 0; set_count < value_set.n_items; set_count++) value_set.set_items[set_count].decode_text(text_buf); break; default: TTCN_error("Text decoder: An unknown/unsupported selection was received for a template of type @StatsD_Checker.StatsDMetricKeys."); } } boolean StatsDMetricKeys_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean StatsDMetricKeys_template::match_omit(boolean legacy) const { if (is_ifpresent) return TRUE; switch (template_selection) { case OMIT_VALUE: case ANY_OR_OMIT: return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match_omit() || implication_.implied_template->match_omit(); case VALUE_LIST: case COMPLEMENTED_LIST: if (legacy) { for (unsigned int i=0; iset_implicit_omit(); } } void StatsDMetricKeys_template::set_param(Module_Param& param) { param.basic_check(Module_Param::BC_TEMPLATE|Module_Param::BC_LIST, "set of 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: case Module_Param::MP_ConjunctList_Template: { StatsDMetricKeys_template temp; temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size()); for (size_t p_i=0; p_iget_id()->get_index())].set_param(*param.get_elem(p_i)); } break; case Module_Param::MP_Value_List: set_size(param.get_size()); for (size_t p_i=0; p_iget_type()!=Module_Param::MP_NotUsed) { (*this)[p_i].set_param(*param.get_elem(p_i)); } } break; case Module_Param::MP_Superset_Template: case Module_Param::MP_Subset_Template: set_type(param.get_type()==Module_Param::MP_Superset_Template ? SUPERSET_MATCH : SUBSET_MATCH, param.get_size()); for (size_t p_i=0; p_iset_param(*param.get_elem(0)); StatsDMetricKeys_template* implied_template = new StatsDMetricKeys_template; implied_template->set_param(*param.get_elem(1)); *this = StatsDMetricKeys_template(precondition, implied_template); } break; default: param.type_error("set of template", "@StatsD_Checker.StatsDMetricKeys"); } is_ifpresent = param.get_ifpresent(); set_length_range(param); } void StatsDMetricKeys_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; for (int i=0; icheck_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDMetricKeys"); 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 : "@StatsD_Checker.StatsDMetricKeys"); } boolean StatsDMetricKeys_template::get_istemplate_kind(const char* type) const { if (!strcmp(type, "AnyElement")) { if (template_selection != SPECIFIC_VALUE) { return FALSE; } for (int i = 0; i < single_value.n_elements; i++) { if (single_value.value_elements[i]->get_selection() == ANY_VALUE) { return TRUE; } } return FALSE; } else if (!strcmp(type, "AnyElementsOrNone")) { if (template_selection != SPECIFIC_VALUE) { return FALSE; } for (int i = 0; i < single_value.n_elements; i++) { if (single_value.value_elements[i]->get_selection() == ANY_OR_OMIT) { return TRUE; } } return FALSE; } else if (!strcmp(type, "permutation")) { return FALSE; } else if (!strcmp(type, "length")) { return length_restriction_type != NO_LENGTH_RESTRICTION; } else { return Base_Template::get_istemplate_kind(type); } } StatsDExpect::StatsDExpect() { } StatsDExpect::StatsDExpect(const CHARSTRING& par_name, const CHARSTRING& par_mtype, const INTEGER& par_min, const INTEGER& par_max) : field_name(par_name), field_mtype(par_mtype), field_min(par_min), field_max(par_max) { } StatsDExpect::StatsDExpect(const StatsDExpect& other_value) { if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @StatsD_Checker.StatsDExpect."); if (other_value.name().is_bound()) field_name = other_value.name(); else field_name.clean_up(); if (other_value.mtype().is_bound()) field_mtype = other_value.mtype(); else field_mtype.clean_up(); if (other_value.min().is_bound()) field_min = other_value.min(); else field_min.clean_up(); if (other_value.max().is_bound()) field_max = other_value.max(); else field_max.clean_up(); } void StatsDExpect::clean_up() { field_name.clean_up(); field_mtype.clean_up(); field_min.clean_up(); field_max.clean_up(); } const TTCN_Typedescriptor_t* StatsDExpect::get_descriptor() const { return &StatsDExpect_descr_; } StatsDExpect& StatsDExpect::operator=(const StatsDExpect& other_value) { if (this != &other_value) { if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @StatsD_Checker.StatsDExpect."); if (other_value.name().is_bound()) field_name = other_value.name(); else field_name.clean_up(); if (other_value.mtype().is_bound()) field_mtype = other_value.mtype(); else field_mtype.clean_up(); if (other_value.min().is_bound()) field_min = other_value.min(); else field_min.clean_up(); if (other_value.max().is_bound()) field_max = other_value.max(); else field_max.clean_up(); } return *this; } boolean StatsDExpect::operator==(const StatsDExpect& other_value) const { return field_name==other_value.field_name && field_mtype==other_value.field_mtype && field_min==other_value.field_min && field_max==other_value.field_max; } boolean StatsDExpect::is_bound() const { return (field_name.is_bound()) || (field_mtype.is_bound()) || (field_min.is_bound()) || (field_max.is_bound()); } boolean StatsDExpect::is_value() const { return field_name.is_value() && field_mtype.is_value() && field_min.is_value() && field_max.is_value(); } void StatsDExpect::log() const { if (!is_bound()) { TTCN_Logger::log_event_unbound(); return; } TTCN_Logger::log_event_str("{ name := "); field_name.log(); TTCN_Logger::log_event_str(", mtype := "); field_mtype.log(); TTCN_Logger::log_event_str(", min := "); field_min.log(); TTCN_Logger::log_event_str(", max := "); field_max.log(); TTCN_Logger::log_event_str(" }"); } void StatsDExpect::set_implicit_omit() { if (name().is_bound()) name().set_implicit_omit(); if (mtype().is_bound()) mtype().set_implicit_omit(); if (min().is_bound()) min().set_implicit_omit(); if (max().is_bound()) max().set_implicit_omit(); } void StatsDExpect::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 (40 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) name().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) mtype().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) min().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) max().set_param(*param.get_elem(3)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "name")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { name().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "mtype")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { mtype().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "min")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { min().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "max")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { max().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @StatsD_Checker.StatsDExpect: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@StatsD_Checker.StatsDExpect"); } } void StatsDExpect::encode_text(Text_Buf& text_buf) const { field_name.encode_text(text_buf); field_mtype.encode_text(text_buf); field_min.encode_text(text_buf); field_max.encode_text(text_buf); } void StatsDExpect::decode_text(Text_Buf& text_buf) { field_name.decode_text(text_buf); field_mtype.decode_text(text_buf); field_min.decode_text(text_buf); field_max.decode_text(text_buf); } struct StatsDExpect_template::single_value_struct { CHARSTRING_template field_name; CHARSTRING_template field_mtype; INTEGER_template field_min; INTEGER_template field_max; }; void StatsDExpect_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_name = ANY_VALUE; single_value->field_mtype = ANY_VALUE; single_value->field_min = ANY_VALUE; single_value->field_max = ANY_VALUE; } } } void StatsDExpect_template::copy_value(const StatsDExpect& other_value) { single_value = new single_value_struct; if (other_value.name().is_bound()) { single_value->field_name = other_value.name(); } else { single_value->field_name.clean_up(); } if (other_value.mtype().is_bound()) { single_value->field_mtype = other_value.mtype(); } else { single_value->field_mtype.clean_up(); } if (other_value.min().is_bound()) { single_value->field_min = other_value.min(); } else { single_value->field_min.clean_up(); } if (other_value.max().is_bound()) { single_value->field_max = other_value.max(); } else { single_value->field_max.clean_up(); } set_selection(SPECIFIC_VALUE); } void StatsDExpect_template::copy_template(const StatsDExpect_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.name().get_selection()) { single_value->field_name = other_value.name(); } else { single_value->field_name.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.mtype().get_selection()) { single_value->field_mtype = other_value.mtype(); } else { single_value->field_mtype.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.min().get_selection()) { single_value->field_min = other_value.min(); } else { single_value->field_min.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.max().get_selection()) { single_value->field_max = other_value.max(); } else { single_value->field_max.clean_up(); } case OMIT_VALUE: case ANY_VALUE: case ANY_OR_OMIT: break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: value_list.n_values = other_value.value_list.n_values; value_list.list_value = new StatsDExpect_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; case IMPLICATION_MATCH: implication_.precondition = new StatsDExpect_template(*other_value.implication_.precondition); implication_.implied_template = new StatsDExpect_template(*other_value.implication_.implied_template); break; case DYNAMIC_MATCH: dyn_match = other_value.dyn_match; dyn_match->ref_count++; break; default: TTCN_error("Copying an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpect."); break; } set_selection(other_value); } StatsDExpect_template::StatsDExpect_template() { } StatsDExpect_template::StatsDExpect_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } StatsDExpect_template::StatsDExpect_template(const StatsDExpect& other_value) { copy_value(other_value); } StatsDExpect_template::StatsDExpect_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDExpect&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @StatsD_Checker.StatsDExpect from an unbound optional field."); } } StatsDExpect_template::StatsDExpect_template(StatsDExpect_template* p_precondition, StatsDExpect_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } StatsDExpect_template::StatsDExpect_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } StatsDExpect_template::StatsDExpect_template(const StatsDExpect_template& other_value) : Base_Template() { copy_template(other_value); } StatsDExpect_template::~StatsDExpect_template() { clean_up(); } StatsDExpect_template& StatsDExpect_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } StatsDExpect_template& StatsDExpect_template::operator=(const StatsDExpect& other_value) { clean_up(); copy_value(other_value); return *this; } StatsDExpect_template& StatsDExpect_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDExpect&)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 @StatsD_Checker.StatsDExpect."); } return *this; } StatsDExpect_template& StatsDExpect_template::operator=(const StatsDExpect_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean StatsDExpect_template::match(const StatsDExpect& 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.name().is_bound()) return FALSE; if(!single_value->field_name.match(other_value.name(), legacy))return FALSE; if(!other_value.mtype().is_bound()) return FALSE; if(!single_value->field_mtype.match(other_value.mtype(), legacy))return FALSE; if(!other_value.min().is_bound()) return FALSE; if(!single_value->field_min.match(other_value.min(), legacy))return FALSE; if(!other_value.max().is_bound()) return FALSE; if(!single_value->field_max.match(other_value.max(), 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; case CONJUNCTION_MATCH: for (unsigned int i = 0; i < value_list.n_values; i++) { if (!value_list.list_value[i].match(other_value)) { return FALSE; } } return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value); case DYNAMIC_MATCH: return dyn_match->ptr->match(other_value); default: TTCN_error("Matching an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpect."); } return FALSE; } boolean StatsDExpect_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_name.is_bound() || single_value->field_mtype.is_bound() || single_value->field_min.is_bound() || single_value->field_max.is_bound(); } boolean StatsDExpect_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_name.is_value() && single_value->field_mtype.is_value() && single_value->field_min.is_value() && single_value->field_max.is_value(); } void StatsDExpect_template::clean_up() { switch (template_selection) { case SPECIFIC_VALUE: delete single_value; break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: delete [] value_list.list_value; break; case IMPLICATION_MATCH: delete implication_.precondition; delete implication_.implied_template; break; case DYNAMIC_MATCH: dyn_match->ref_count--; if (dyn_match->ref_count == 0) { delete dyn_match->ptr; delete dyn_match; } break; default: break; } template_selection = UNINITIALIZED_TEMPLATE; } StatsDExpect StatsDExpect_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 @StatsD_Checker.StatsDExpect."); StatsDExpect ret_val; if (single_value->field_name.is_bound()) { ret_val.name() = single_value->field_name.valueof(); } if (single_value->field_mtype.is_bound()) { ret_val.mtype() = single_value->field_mtype.valueof(); } if (single_value->field_min.is_bound()) { ret_val.min() = single_value->field_min.valueof(); } if (single_value->field_max.is_bound()) { ret_val.max() = single_value->field_max.valueof(); } return ret_val; } void StatsDExpect_template::set_type(template_sel template_type, unsigned int list_length) { if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH) TTCN_error("Setting an invalid list for a template of type @StatsD_Checker.StatsDExpect."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new StatsDExpect_template[list_length]; } StatsDExpect_template& StatsDExpect_template::list_item(unsigned int list_index) const { if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH) TTCN_error("Accessing a list element of a non-list template of type @StatsD_Checker.StatsDExpect."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @StatsD_Checker.StatsDExpect."); return value_list.list_value[list_index]; } CHARSTRING_template& StatsDExpect_template::name() { set_specific(); return single_value->field_name; } const CHARSTRING_template& StatsDExpect_template::name() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field name of a non-specific template of type @StatsD_Checker.StatsDExpect."); return single_value->field_name; } CHARSTRING_template& StatsDExpect_template::mtype() { set_specific(); return single_value->field_mtype; } const CHARSTRING_template& StatsDExpect_template::mtype() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field mtype of a non-specific template of type @StatsD_Checker.StatsDExpect."); return single_value->field_mtype; } INTEGER_template& StatsDExpect_template::min() { set_specific(); return single_value->field_min; } const INTEGER_template& StatsDExpect_template::min() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field min of a non-specific template of type @StatsD_Checker.StatsDExpect."); return single_value->field_min; } INTEGER_template& StatsDExpect_template::max() { set_specific(); return single_value->field_max; } const INTEGER_template& StatsDExpect_template::max() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field max of a non-specific template of type @StatsD_Checker.StatsDExpect."); return single_value->field_max; } int StatsDExpect_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpect which has an ifpresent attribute."); switch (template_selection) { case SPECIFIC_VALUE: return 4; case VALUE_LIST: { if (value_list.n_values<1) TTCN_error("Internal error: Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpect 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 @StatsD_Checker.StatsDExpect containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpect containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpect containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpect containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpect containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpect containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpect containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpect."); } return 0; } void StatsDExpect_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ name := "); single_value->field_name.log(); TTCN_Logger::log_event_str(", mtype := "); single_value->field_mtype.log(); TTCN_Logger::log_event_str(", min := "); single_value->field_min.log(); TTCN_Logger::log_event_str(", max := "); single_value->field_max.log(); TTCN_Logger::log_event_str(" }"); break; case COMPLEMENTED_LIST: TTCN_Logger::log_event_str("complement"); case CONJUNCTION_MATCH: if (template_selection == CONJUNCTION_MATCH) { TTCN_Logger::log_event_str("conjunct"); } 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; case IMPLICATION_MATCH: implication_.precondition->log(); TTCN_Logger::log_event_str(" implies "); implication_.implied_template->log(); break; case DYNAMIC_MATCH: TTCN_Logger::log_event_str("@dynamic template"); break; default: log_generic(); } log_ifpresent(); } void StatsDExpect_template::log_match(const StatsDExpect& 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_name.match(match_value.name(), legacy)){ TTCN_Logger::log_logmatch_info(".name"); single_value->field_name.log_match(match_value.name(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_mtype.match(match_value.mtype(), legacy)){ TTCN_Logger::log_logmatch_info(".mtype"); single_value->field_mtype.log_match(match_value.mtype(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_min.match(match_value.min(), legacy)){ TTCN_Logger::log_logmatch_info(".min"); single_value->field_min.log_match(match_value.min(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_max.match(match_value.max(), legacy)){ TTCN_Logger::log_logmatch_info(".max"); single_value->field_max.log_match(match_value.max(), 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("{ name := "); single_value->field_name.log_match(match_value.name(), legacy); TTCN_Logger::log_event_str(", mtype := "); single_value->field_mtype.log_match(match_value.mtype(), legacy); TTCN_Logger::log_event_str(", min := "); single_value->field_min.log_match(match_value.min(), legacy); TTCN_Logger::log_event_str(", max := "); single_value->field_max.log_match(match_value.max(), 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 StatsDExpect_template::set_implicit_omit() { if (template_selection != SPECIFIC_VALUE) return; if (name().is_bound()) name().set_implicit_omit(); if (mtype().is_bound()) mtype().set_implicit_omit(); if (min().is_bound()) min().set_implicit_omit(); if (max().is_bound()) max().set_implicit_omit(); } void StatsDExpect_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_name.encode_text(text_buf); single_value->field_mtype.encode_text(text_buf); single_value->field_min.encode_text(text_buf); single_value->field_max.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 @StatsD_Checker.StatsDExpect."); } } void StatsDExpect_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_name.decode_text(text_buf); single_value->field_mtype.decode_text(text_buf); single_value->field_min.decode_text(text_buf); single_value->field_max.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 StatsDExpect_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 @StatsD_Checker.StatsDExpect."); } } void StatsDExpect_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: case Module_Param::MP_ConjunctList_Template: { StatsDExpect_template new_temp; new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size()); for (size_t p_i=0; p_i0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) name().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) mtype().set_param(*param.get_elem(1)); if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) min().set_param(*param.get_elem(2)); if (param.get_size()>3 && param.get_elem(3)->get_type()!=Module_Param::MP_NotUsed) max().set_param(*param.get_elem(3)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "name")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { name().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "mtype")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { mtype().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "min")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { min().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "max")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { max().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @StatsD_Checker.StatsDExpect: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { StatsDExpect_template* precondition = new StatsDExpect_template; precondition->set_param(*param.get_elem(0)); StatsDExpect_template* implied_template = new StatsDExpect_template; implied_template->set_param(*param.get_elem(1)); *this = StatsDExpect_template(precondition, implied_template); } break; default: param.type_error("record template", "@StatsD_Checker.StatsDExpect"); } is_ifpresent = param.get_ifpresent(); } void StatsDExpect_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_name.check_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDExpect"); single_value->field_mtype.check_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDExpect"); single_value->field_min.check_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDExpect"); single_value->field_max.check_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDExpect"); 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 : "@StatsD_Checker.StatsDExpect"); } boolean StatsDExpect_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean StatsDExpect_template::match_omit(boolean legacy) const { if (is_ifpresent) return TRUE; switch (template_selection) { case OMIT_VALUE: case ANY_OR_OMIT: return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match_omit() || implication_.implied_template->match_omit(); case VALUE_LIST: case COMPLEMENTED_LIST: if (legacy) { for (unsigned int l_idx=0; l_idxval_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @StatsD_Checker.StatsDExpects."); if (((const StatsDExpects*)right_ptr)->val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @StatsD_Checker.StatsDExpects."); if (((const StatsDExpects*)left_ptr)->val_ptr->value_elements[left_index] != NULL){ if (((const StatsDExpects*)right_ptr)->val_ptr->value_elements[right_index] != NULL){ return *((const StatsDExpects*)left_ptr)->val_ptr->value_elements[left_index] == *((const StatsDExpects*)right_ptr)->val_ptr->value_elements[right_index]; } else return FALSE; } else { return ((const StatsDExpects*)right_ptr)->val_ptr->value_elements[right_index] == NULL; } } StatsDExpects::StatsDExpects() { val_ptr = NULL; } StatsDExpects::StatsDExpects(null_type) { val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = 0; val_ptr->value_elements = NULL; } StatsDExpects::StatsDExpects(const StatsDExpects& other_value) { if (!other_value.is_bound()) TTCN_error("Copying an unbound value of type @StatsD_Checker.StatsDExpects."); val_ptr = other_value.val_ptr; val_ptr->ref_count++; } StatsDExpects::~StatsDExpects() { clean_up(); if (val_ptr != NULL) val_ptr = NULL; } void StatsDExpects::clean_up() { if (val_ptr != NULL) { if (val_ptr->ref_count > 1) { val_ptr->ref_count--; val_ptr = NULL; } else if (val_ptr->ref_count == 1) { for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) if (val_ptr->value_elements[elem_count] != NULL) delete val_ptr->value_elements[elem_count]; free_pointers((void**)val_ptr->value_elements); delete val_ptr; val_ptr = NULL; } else TTCN_error("Internal error: Invalid reference counter in a record of/set of value."); } } StatsDExpects& StatsDExpects::operator=(null_type) { clean_up(); val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = 0; val_ptr->value_elements = NULL; return *this; } StatsDExpects& StatsDExpects::operator=(const StatsDExpects& other_value) { if (other_value.val_ptr == NULL) TTCN_error("Assigning an unbound value of type @StatsD_Checker.StatsDExpects."); if (this != &other_value) { clean_up(); val_ptr = other_value.val_ptr; val_ptr->ref_count++; } return *this; } boolean StatsDExpects::operator==(null_type) const { if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @StatsD_Checker.StatsDExpects."); return val_ptr->n_elements == 0 ; } boolean StatsDExpects::operator==(const StatsDExpects& other_value) const { if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @StatsD_Checker.StatsDExpects."); if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @StatsD_Checker.StatsDExpects."); if (val_ptr == other_value.val_ptr) return TRUE; return compare_set_of(this, val_ptr->n_elements, &other_value, (other_value.val_ptr)->n_elements, compare_function); } StatsDExpect& StatsDExpects::operator[](int index_value) { if (index_value < 0) TTCN_error("Accessing an element of type @StatsD_Checker.StatsDExpects using a negative index: %d.", index_value); if (val_ptr == NULL) { val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = 0; val_ptr->value_elements = NULL; } else if (val_ptr->ref_count > 1) { struct recordof_setof_struct *new_val_ptr = new recordof_setof_struct; new_val_ptr->ref_count = 1; new_val_ptr->n_elements = (index_value >= val_ptr->n_elements) ? index_value + 1 : val_ptr->n_elements; new_val_ptr->value_elements = (StatsDExpect**)allocate_pointers(new_val_ptr->n_elements); for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++){ if (val_ptr->value_elements[elem_count] != NULL){ new_val_ptr->value_elements[elem_count] = new StatsDExpect(*(val_ptr->value_elements[elem_count])); } } clean_up(); val_ptr = new_val_ptr; } if (index_value >= val_ptr->n_elements) set_size(index_value + 1); if (val_ptr->value_elements[index_value] == NULL) { val_ptr->value_elements[index_value] = new StatsDExpect; } return *val_ptr->value_elements[index_value]; } StatsDExpect& StatsDExpects::operator[](const INTEGER& index_value) { index_value.must_bound("Using an unbound integer value for indexing a value of type @StatsD_Checker.StatsDExpects."); return (*this)[(int)index_value]; } const StatsDExpect& StatsDExpects::operator[](int index_value) const { if (val_ptr == NULL) TTCN_error("Accessing an element in an unbound value of type @StatsD_Checker.StatsDExpects."); if (index_value < 0) TTCN_error("Accessing an element of type @StatsD_Checker.StatsDExpects using a negative index: %d.", index_value); if (index_value >= val_ptr->n_elements) TTCN_error("Index overflow in a value of type @StatsD_Checker.StatsDExpects: The index is %d, but the value has only %d elements.", index_value, val_ptr->n_elements); return (val_ptr->value_elements[index_value] == NULL) ? UNBOUND_ELEM : *val_ptr->value_elements[index_value]; } const StatsDExpect& StatsDExpects::operator[](const INTEGER& index_value) const { index_value.must_bound("Using an unbound integer value for indexing a value of type @StatsD_Checker.StatsDExpects."); return (*this)[(int)index_value]; } StatsDExpects StatsDExpects::operator<<=(int rotate_count) const { return *this >>= (-rotate_count); } StatsDExpects StatsDExpects::operator<<=(const INTEGER& rotate_count) const { rotate_count.must_bound("Unbound integer operand of rotate left operator."); return *this >>= (int)(-rotate_count); } StatsDExpects StatsDExpects::operator>>=(const INTEGER& rotate_count) const { rotate_count.must_bound("Unbound integer operand of rotate right operator."); return *this >>= (int)rotate_count; } StatsDExpects StatsDExpects::operator>>=(int rotate_count) const { if (val_ptr == NULL) TTCN_error("Performing rotation operation on an unbound value of type @StatsD_Checker.StatsDExpects."); if (val_ptr->n_elements == 0) return *this; int rc; if (rotate_count>=0) rc = rotate_count % val_ptr->n_elements; else rc = val_ptr->n_elements - ((-rotate_count) % val_ptr->n_elements); if (rc == 0) return *this; StatsDExpects ret_val; ret_val.set_size(val_ptr->n_elements); for (int i=0; in_elements; i++) { if (val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[(i+rc)%val_ptr->n_elements] =new StatsDExpect(*val_ptr->value_elements[i]); } } return ret_val; } StatsDExpects StatsDExpects::operator+(const StatsDExpects& other_value) const { if (val_ptr == NULL || other_value.val_ptr == NULL) TTCN_error("Unbound operand of @StatsD_Checker.StatsDExpects concatenation."); if (val_ptr->n_elements == 0) return other_value; if (other_value.val_ptr->n_elements == 0) return *this; StatsDExpects ret_val; ret_val.set_size(val_ptr->n_elements+other_value.val_ptr->n_elements); for (int i=0; in_elements; i++) { if (val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[i] = new StatsDExpect(*val_ptr->value_elements[i]); } } for (int i=0; in_elements; i++) { if (other_value.val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[i+val_ptr->n_elements] = new StatsDExpect(*other_value.val_ptr->value_elements[i]); } } return ret_val; } StatsDExpects StatsDExpects::substr(int index, int returncount) const { if (val_ptr == NULL) TTCN_error("The first argument of substr() is an unbound value of type @StatsD_Checker.StatsDExpects."); check_substr_arguments(val_ptr->n_elements, index, returncount, "@StatsD_Checker.StatsDExpects","element"); StatsDExpects ret_val; ret_val.set_size(returncount); for (int i=0; ivalue_elements[i+index] != NULL) { ret_val.val_ptr->value_elements[i] = new StatsDExpect(*val_ptr->value_elements[i+index]); } } return ret_val; } StatsDExpects StatsDExpects::replace(int index, int len, const StatsDExpects& repl) const { if (val_ptr == NULL) TTCN_error("The first argument of replace() is an unbound value of type @StatsD_Checker.StatsDExpects."); if (repl.val_ptr == NULL) TTCN_error("The fourth argument of replace() is an unbound value of type @StatsD_Checker.StatsDExpects."); check_replace_arguments(val_ptr->n_elements, index, len, "@StatsD_Checker.StatsDExpects","element"); StatsDExpects ret_val; ret_val.set_size(val_ptr->n_elements + repl.val_ptr->n_elements - len); for (int i = 0; i < index; i++) { if (val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[i] = new StatsDExpect(*val_ptr->value_elements[i]); } } for (int i = 0; i < repl.val_ptr->n_elements; i++) { if (repl.val_ptr->value_elements[i] != NULL) { ret_val.val_ptr->value_elements[i+index] = new StatsDExpect(*repl.val_ptr->value_elements[i]); } } for (int i = 0; i < val_ptr->n_elements - index - len; i++) { if (val_ptr->value_elements[index+i+len] != NULL) { ret_val.val_ptr->value_elements[index+i+repl.val_ptr->n_elements] = new StatsDExpect(*val_ptr->value_elements[index+i+len]); } } return ret_val; } StatsDExpects StatsDExpects::replace(int index, int len, const StatsDExpects_template& repl) const { if (!repl.is_value()) TTCN_error("The fourth argument of function replace() is a template with non-specific value."); return replace(index, len, repl.valueof()); } void StatsDExpects::set_size(int new_size) { if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a value of type @StatsD_Checker.StatsDExpects."); if (val_ptr == NULL) { val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = 0; val_ptr->value_elements = NULL; } else if (val_ptr->ref_count > 1) { struct recordof_setof_struct *new_val_ptr = new recordof_setof_struct; new_val_ptr->ref_count = 1; new_val_ptr->n_elements = (new_size < val_ptr->n_elements) ? new_size : val_ptr->n_elements; new_val_ptr->value_elements = (StatsDExpect**)allocate_pointers(new_val_ptr->n_elements); for (int elem_count = 0; elem_count < new_val_ptr->n_elements; elem_count++) { if (val_ptr->value_elements[elem_count] != NULL){ new_val_ptr->value_elements[elem_count] = new StatsDExpect(*(val_ptr->value_elements[elem_count])); } } clean_up(); val_ptr = new_val_ptr; } if (new_size > val_ptr->n_elements) { val_ptr->value_elements = (StatsDExpect**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size); #ifdef TITAN_MEMORY_DEBUG_SET_RECORD_OF if((val_ptr->n_elements/1000)!=(new_size/1000)) TTCN_warning("New size of type @StatsD_Checker.StatsDExpects: %d",new_size); #endif val_ptr->n_elements = new_size; } else if (new_size < val_ptr->n_elements) { for (int elem_count = new_size; elem_count < val_ptr->n_elements; elem_count++) if (val_ptr->value_elements[elem_count] != NULL)delete val_ptr->value_elements[elem_count]; val_ptr->value_elements = (StatsDExpect**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size); val_ptr->n_elements = new_size; } } boolean StatsDExpects::is_value() const { if (val_ptr == NULL) return FALSE; for(int i = 0; i < val_ptr->n_elements; ++i) { if (val_ptr->value_elements[i] == NULL || !val_ptr->value_elements[i]->is_value()) return FALSE; } return TRUE; } int StatsDExpects::size_of() const { if (val_ptr == NULL) TTCN_error("Performing sizeof operation on an unbound value of type @StatsD_Checker.StatsDExpects."); return val_ptr->n_elements; } int StatsDExpects::lengthof() const { if (val_ptr == NULL) TTCN_error("Performing lengthof operation on an unbound value of type @StatsD_Checker.StatsDExpects."); for (int my_length=val_ptr->n_elements; my_length>0; my_length--) if (val_ptr->value_elements[my_length-1] != NULL) return my_length; return 0; } void StatsDExpects::log() const { if (val_ptr == NULL) {; TTCN_Logger::log_event_unbound(); return; } switch (val_ptr->n_elements) { case 0: TTCN_Logger::log_event_str("{ }"); break; default: TTCN_Logger::log_event_str("{ "); for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) { if (elem_count > 0) TTCN_Logger::log_event_str(", "); (*this)[elem_count].log(); } TTCN_Logger::log_event_str(" }"); } } void StatsDExpects::set_implicit_omit() { if (val_ptr == NULL) return; for (int i = 0; i < val_ptr->n_elements; i++) { if (val_ptr->value_elements[i] != NULL) val_ptr->value_elements[i]->set_implicit_omit(); } } void StatsDExpects::set_param(Module_Param& param) { param.basic_check(Module_Param::BC_VALUE|Module_Param::BC_LIST, "set of value"); switch (param.get_operation_type()) { case Module_Param::OT_ASSIGN: if (param.get_type()==Module_Param::MP_Value_List && param.get_size()==0) { *this = NULL_VALUE; return; } switch (param.get_type()) { case Module_Param::MP_Value_List: set_size(param.get_size()); for (size_t i=0; iget_type()!=Module_Param::MP_NotUsed) { (*this)[i].set_param(*curr); if (!(*this)[i].is_bound()) { delete val_ptr->value_elements[i]; val_ptr->value_elements[i] = NULL; } } } break; case Module_Param::MP_Indexed_List: for (size_t i=0; iget_id()->get_index()].set_param(*curr); if (!(*this)[curr->get_id()->get_index()].is_bound()) { delete val_ptr->value_elements[curr->get_id()->get_index()]; val_ptr->value_elements[curr->get_id()->get_index()] = NULL; } } break; default: param.type_error("set of value", "@StatsD_Checker.StatsDExpects"); } break; case Module_Param::OT_CONCAT: switch (param.get_type()) { case Module_Param::MP_Value_List: { if (!is_bound()) *this = NULL_VALUE; int start_idx = lengthof(); for (size_t i=0; iget_type()!=Module_Param::MP_NotUsed)) { (*this)[start_idx+(int)i].set_param(*curr); } } } break; case Module_Param::MP_Indexed_List: param.error("Cannot concatenate an indexed value list"); break; default: param.type_error("set of value", "@StatsD_Checker.StatsDExpects"); } break; default: TTCN_error("Internal error: Unknown operation type."); } } void StatsDExpects::encode_text(Text_Buf& text_buf) const { if (val_ptr == NULL) TTCN_error("Text encoder: Encoding an unbound value of type @StatsD_Checker.StatsDExpects."); text_buf.push_int(val_ptr->n_elements); for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) (*this)[elem_count].encode_text(text_buf); } void StatsDExpects::decode_text(Text_Buf& text_buf) { clean_up(); val_ptr = new recordof_setof_struct; val_ptr->ref_count = 1; val_ptr->n_elements = text_buf.pull_int().get_val(); if (val_ptr->n_elements < 0) TTCN_error("Text decoder: Negative size was received for a value of type @StatsD_Checker.StatsDExpects."); val_ptr->value_elements = (StatsDExpect**)allocate_pointers(val_ptr->n_elements); for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++) { val_ptr->value_elements[elem_count] = new StatsDExpect; val_ptr->value_elements[elem_count]->decode_text(text_buf); } } void StatsDExpects_template::copy_value(const StatsDExpects& other_value) { if (!other_value.is_bound()) TTCN_error("Initialization of a template of type @StatsD_Checker.StatsDExpects with an unbound value."); single_value.n_elements = other_value.size_of(); single_value.value_elements = (StatsDExpect_template**)allocate_pointers(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) { if (other_value[elem_count].is_bound()) { single_value.value_elements[elem_count] = new StatsDExpect_template(other_value[elem_count]); } else { single_value.value_elements[elem_count] = new StatsDExpect_template; } } set_selection(SPECIFIC_VALUE); } void StatsDExpects_template::copy_template(const StatsDExpects_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value.n_elements = other_value.single_value.n_elements; single_value.value_elements = (StatsDExpect_template**)allocate_pointers(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) { if (UNINITIALIZED_TEMPLATE != other_value.single_value.value_elements[elem_count]->get_selection()) { single_value.value_elements[elem_count] = new StatsDExpect_template(*other_value.single_value.value_elements[elem_count]); } else { single_value.value_elements[elem_count] = new StatsDExpect_template; } } case OMIT_VALUE: case ANY_VALUE: case ANY_OR_OMIT: break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: value_list.n_values = other_value.value_list.n_values; value_list.list_value = new StatsDExpects_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; case SUPERSET_MATCH: case SUBSET_MATCH: value_set.n_items = other_value.value_set.n_items; value_set.set_items = new StatsDExpect_template[value_set.n_items]; for (unsigned int set_count = 0; set_count < value_set.n_items; set_count++) value_set.set_items[set_count] = other_value.value_set.set_items[set_count]; break; case IMPLICATION_MATCH: implication_.precondition = new StatsDExpects_template(*other_value.implication_.precondition); implication_.implied_template = new StatsDExpects_template(*other_value.implication_.implied_template); break; case DYNAMIC_MATCH: dyn_match = other_value.dyn_match; dyn_match->ref_count++; break; default: TTCN_error("Copying an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpects."); break; } set_selection(other_value); } boolean StatsDExpects_template::match_function_specific(const Base_Type *value_ptr, int value_index, const Restricted_Length_Template *template_ptr, int template_index, boolean legacy) { if (value_index >= 0) return ((const StatsDExpects_template*)template_ptr)->single_value.value_elements[template_index]->match((*(const StatsDExpects*)value_ptr)[value_index], legacy); else return ((const StatsDExpects_template*)template_ptr)->single_value.value_elements[template_index]->is_any_or_omit(); } boolean StatsDExpects_template::match_function_set(const Base_Type *value_ptr, int value_index, const Restricted_Length_Template *template_ptr, int template_index, boolean legacy) { if (value_index >= 0) return ((const StatsDExpects_template*)template_ptr)->value_set.set_items[template_index].match((*(const StatsDExpects*)value_ptr)[value_index], legacy); else return ((const StatsDExpects_template*)template_ptr)->value_set.set_items[template_index].is_any_or_omit(); } void StatsDExpects_template::log_function(const Base_Type *value_ptr, const Restricted_Length_Template *template_ptr, int index_value, int index_template, boolean legacy) { if (value_ptr == NULL) { if (template_ptr != NULL) { ((const StatsDExpects_template*)template_ptr)->single_value.value_elements[index_template]->log(); } } else if (template_ptr == NULL) { (*(const StatsDExpects*)value_ptr)[index_value].log(); } else { ((const StatsDExpects_template*)template_ptr)->single_value.value_elements[index_template]->log_match((*(const StatsDExpects*)value_ptr)[index_value], legacy); } } StatsDExpects_template::StatsDExpects_template() { } StatsDExpects_template::StatsDExpects_template(template_sel other_value) : Restricted_Length_Template(other_value) { check_single_selection(other_value); } StatsDExpects_template::StatsDExpects_template(null_type) : Restricted_Length_Template(SPECIFIC_VALUE) { single_value.n_elements = 0; single_value.value_elements = NULL; } StatsDExpects_template::StatsDExpects_template(const StatsDExpects& other_value) { copy_value(other_value); } StatsDExpects_template::StatsDExpects_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDExpects&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @StatsD_Checker.StatsDExpects from an unbound optional field."); } } StatsDExpects_template::StatsDExpects_template(StatsDExpects_template* p_precondition, StatsDExpects_template* p_implied_template) : Restricted_Length_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } StatsDExpects_template::StatsDExpects_template(Dynamic_Match_Interface* p_dyn_match) : Restricted_Length_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } StatsDExpects_template::StatsDExpects_template(const StatsDExpects_template& other_value) : Restricted_Length_Template() { copy_template(other_value); } StatsDExpects_template::~StatsDExpects_template() { clean_up(); } void StatsDExpects_template::clean_up() { switch (template_selection) { case SPECIFIC_VALUE: for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) delete single_value.value_elements[elem_count]; free_pointers((void**)single_value.value_elements); break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: delete [] value_list.list_value; break; break; case SUPERSET_MATCH: case SUBSET_MATCH: delete [] value_set.set_items; break; case IMPLICATION_MATCH: delete implication_.precondition; delete implication_.implied_template; break; case DYNAMIC_MATCH: dyn_match->ref_count--; if (dyn_match->ref_count == 0) { delete dyn_match->ptr; delete dyn_match; } break; default: break; } template_selection = UNINITIALIZED_TEMPLATE; } StatsDExpects_template& StatsDExpects_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } StatsDExpects_template& StatsDExpects_template::operator=(null_type) { clean_up(); set_selection(SPECIFIC_VALUE); single_value.n_elements = 0; single_value.value_elements = NULL; return *this; } StatsDExpects_template& StatsDExpects_template::operator=(const StatsDExpects& other_value) { clean_up(); copy_value(other_value); return *this; } StatsDExpects_template& StatsDExpects_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDExpects&)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 @StatsD_Checker.StatsDExpects."); } return *this; } StatsDExpects_template& StatsDExpects_template::operator=(const StatsDExpects_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } StatsDExpect_template& StatsDExpects_template::operator[](int index_value) { if (index_value < 0) TTCN_error("Accessing an element of a template for type @StatsD_Checker.StatsDExpects using a negative index: %d.", index_value); switch (template_selection) { case SPECIFIC_VALUE: if(index_value < single_value.n_elements) break; // no break case OMIT_VALUE: case ANY_VALUE: case ANY_OR_OMIT: case UNINITIALIZED_TEMPLATE: set_size(index_value + 1); break; default: TTCN_error("Accessing an element of a non-specific template for type @StatsD_Checker.StatsDExpects."); break; } return *single_value.value_elements[index_value]; } StatsDExpect_template& StatsDExpects_template::operator[](const INTEGER& index_value) { index_value.must_bound("Using an unbound integer value for indexing a template of type @StatsD_Checker.StatsDExpects."); return (*this)[(int)index_value]; } const StatsDExpect_template& StatsDExpects_template::operator[](int index_value) const { if (index_value < 0) TTCN_error("Accessing an element of a template for type @StatsD_Checker.StatsDExpects using a negative index: %d.", index_value); if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing an element of a non-specific template for type @StatsD_Checker.StatsDExpects."); if (index_value >= single_value.n_elements) TTCN_error("Index overflow in a template of type @StatsD_Checker.StatsDExpects: The index is %d, but the template has only %d elements.", index_value, single_value.n_elements); return *single_value.value_elements[index_value]; } const StatsDExpect_template& StatsDExpects_template::operator[](const INTEGER& index_value) const { index_value.must_bound("Using an unbound integer value for indexing a template of type @StatsD_Checker.StatsDExpects."); return (*this)[(int)index_value]; } void StatsDExpects_template::set_size(int new_size) { if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a template of type @StatsD_Checker.StatsDExpects."); template_sel old_selection = template_selection; if (old_selection != SPECIFIC_VALUE) { clean_up(); set_selection(SPECIFIC_VALUE); single_value.n_elements = 0; single_value.value_elements = NULL; } if (new_size > single_value.n_elements) { single_value.value_elements = (StatsDExpect_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size); if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) { for (int elem_count = single_value.n_elements; elem_count < new_size; elem_count++) single_value.value_elements[elem_count] = new StatsDExpect_template(ANY_VALUE); } else { for (int elem_count = single_value.n_elements; elem_count < new_size; elem_count++) single_value.value_elements[elem_count] = new StatsDExpect_template; } single_value.n_elements = new_size; } else if (new_size < single_value.n_elements) { for (int elem_count = new_size; elem_count < single_value.n_elements; elem_count++) delete single_value.value_elements[elem_count]; single_value.value_elements = (StatsDExpect_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size); single_value.n_elements = new_size; } } int StatsDExpects_template::n_elem() const { switch (template_selection) { case SPECIFIC_VALUE: return single_value.n_elements; break; case VALUE_LIST: return value_list.n_values; break; default: TTCN_error("Performing n_elem"); } } int StatsDExpects_template::size_of(boolean is_size) const { const char* op_name = is_size ? "size" : "length"; int min_size; boolean has_any_or_none; if (is_ifpresent) TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDExpects which has an ifpresent attribute.", op_name); switch (template_selection) { case SPECIFIC_VALUE: { min_size = 0; has_any_or_none = FALSE; int elem_count = single_value.n_elements; if (!is_size) { while (elem_count>0 && !single_value.value_elements[elem_count-1]->is_bound()) elem_count--; } for (int i=0; iget_selection()) { case OMIT_VALUE: TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDExpects containing omit element.", op_name); case ANY_OR_OMIT: has_any_or_none = TRUE; break; default: min_size++; break; } } } break; case SUPERSET_MATCH: case SUBSET_MATCH: { min_size = 0; has_any_or_none = FALSE; int elem_count = value_set.n_items; if (!is_size) { while (elem_count>0 && !value_set.set_items[elem_count-1].is_bound()) elem_count--; } for (int i=0; ilength_restriction.range_length.min_length){ TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDExpects with no exact size.", op_name); } else TTCN_error("Performing %sof() operation on an invalid template of type @StatsD_Checker.StatsDExpects. Maximum size (%d) contradicts the length restriction (%d..%d).", op_name, max_size, length_restriction.range_length.min_length, length_restriction.range_length.max_length); default: TTCN_error("Internal error: Template has invalid length restriction type."); } } } } break; case OMIT_VALUE: TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDExpects containing omit value.", op_name); case ANY_VALUE: case ANY_OR_OMIT: min_size = 0; has_any_or_none = TRUE; break; case VALUE_LIST: { if (value_list.n_values<1) TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDExpects containing an empty list.", op_name); int item_size = value_list.list_value[0].size_of(is_size); for (unsigned int i = 1; i < value_list.n_values; i++) { if (value_list.list_value[i].size_of(is_size)!=item_size) TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDExpects containing a value list with different sizes.", op_name); } min_size = item_size; has_any_or_none = FALSE; break; } case COMPLEMENTED_LIST: TTCN_error("Performing %sof() operation on a template of type @StatsD_Checker.StatsDExpects containing complemented list.", op_name); default: TTCN_error("Performing %sof() operation on an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpects.", op_name); } return check_section_is_single(min_size, has_any_or_none, op_name, "a", "template of type @StatsD_Checker.StatsDExpects"); } boolean StatsDExpects_template::match(const StatsDExpects& other_value, boolean legacy) const { if (!other_value.is_bound()) return FALSE; int value_length = other_value.size_of(); if (!match_length(value_length)) return FALSE; switch (template_selection) { case SPECIFIC_VALUE: return match_set_of(&other_value, value_length, this, single_value.n_elements, match_function_specific, legacy); 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, legacy)) return template_selection == VALUE_LIST; return template_selection == COMPLEMENTED_LIST; case SUPERSET_MATCH: case SUBSET_MATCH: return match_set_of(&other_value, value_length, this, value_set.n_items, match_function_set, legacy); case CONJUNCTION_MATCH: for (unsigned int i = 0; i < value_list.n_values; i++) { if (!value_list.list_value[i].match(other_value)) { return FALSE; } } return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value); case DYNAMIC_MATCH: return dyn_match->ptr->match(other_value); default: TTCN_error("Matching with an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpects."); } return FALSE; } boolean StatsDExpects_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) if (!single_value.value_elements[elem_count]->is_value()) return FALSE; return TRUE; } StatsDExpects StatsDExpects_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 @StatsD_Checker.StatsDExpects."); StatsDExpects ret_val; ret_val.set_size(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) if (single_value.value_elements[elem_count]->is_bound()) { ret_val[elem_count] = single_value.value_elements[elem_count]->valueof(); } return ret_val; } StatsDExpects StatsDExpects_template::substr(int index, int returncount) const { if (!is_value()) TTCN_error("The first argument of function substr() is a template with non-specific value."); return valueof().substr(index, returncount); } StatsDExpects StatsDExpects_template::replace(int index, int len, const StatsDExpects_template& repl) const { if (!is_value()) TTCN_error("The first argument of function replace() is a template with non-specific value."); if (!repl.is_value()) TTCN_error("The fourth argument of function replace() is a template with non-specific value."); return valueof().replace(index, len, repl.valueof()); } StatsDExpects StatsDExpects_template::replace(int index, int len, const StatsDExpects& repl) const { if (!is_value()) TTCN_error("The first argument of function replace() is a template with non-specific value."); return valueof().replace(index, len, repl); } void StatsDExpects_template::set_type(template_sel template_type, unsigned int list_length) { clean_up(); switch (template_type) { case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: value_list.n_values = list_length; value_list.list_value = new StatsDExpects_template[list_length]; break; case SUPERSET_MATCH: case SUBSET_MATCH: value_set.n_items = list_length; value_set.set_items = new StatsDExpect_template[list_length]; break; default: TTCN_error("Internal error: Setting an invalid type for a template of type @StatsD_Checker.StatsDExpects."); } set_selection(template_type); } StatsDExpects_template& StatsDExpects_template::list_item(unsigned int list_index) { if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST && template_selection != CONJUNCTION_MATCH) TTCN_error("Internal error: Accessing a list element of a non-list template of type @StatsD_Checker.StatsDExpects."); if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of type @StatsD_Checker.StatsDExpects."); return value_list.list_value[list_index]; } StatsDExpect_template& StatsDExpects_template::set_item(unsigned int set_index) { if (template_selection != SUPERSET_MATCH && template_selection != SUBSET_MATCH) TTCN_error("Internal error: Accessing a set element of a non-set template of type @StatsD_Checker.StatsDExpects."); if (set_index >= value_set.n_items) TTCN_error("Internal error: Index overflow in a set template of type @StatsD_Checker.StatsDExpects."); return value_set.set_items[set_index]; } void StatsDExpects_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: if (single_value.n_elements > 0) { TTCN_Logger::log_event_str("{ "); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) { if (elem_count > 0) TTCN_Logger::log_event_str(", "); single_value.value_elements[elem_count]->log(); } TTCN_Logger::log_event_str(" }"); } else TTCN_Logger::log_event_str("{ }"); break; case COMPLEMENTED_LIST: TTCN_Logger::log_event_str("complement"); case CONJUNCTION_MATCH: if (template_selection == CONJUNCTION_MATCH) { TTCN_Logger::log_event_str("conjunct"); } 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; case SUPERSET_MATCH: case SUBSET_MATCH: TTCN_Logger::log_event("%s(", template_selection == SUPERSET_MATCH ? "superset" : "subset"); for (unsigned int set_count = 0; set_count < value_set.n_items; set_count++) { if (set_count > 0) TTCN_Logger::log_event_str(", "); value_set.set_items[set_count].log(); } TTCN_Logger::log_char(')'); break; case IMPLICATION_MATCH: implication_.precondition->log(); TTCN_Logger::log_event_str(" implies "); implication_.implied_template->log(); break; case DYNAMIC_MATCH: TTCN_Logger::log_event_str("@dynamic template"); break; default: log_generic(); } log_restricted(); log_ifpresent(); } void StatsDExpects_template::log_match(const StatsDExpects& 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{ size_t previous_size = TTCN_Logger::get_logmatch_buffer_len(); if (template_selection == SPECIFIC_VALUE) log_match_heuristics(&match_value, match_value.size_of(), this, single_value.n_elements, match_function_specific, log_function, legacy); else{ if(previous_size != 0){ TTCN_Logger::print_logmatch_buffer(); TTCN_Logger::set_logmatch_buffer_len(previous_size); TTCN_Logger::log_event_str(":="); } match_value.log(); TTCN_Logger::log_event_str(" with "); log(); TTCN_Logger::log_event_str(" unmatched"); } } return; } 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"); if (template_selection == SPECIFIC_VALUE) log_match_heuristics(&match_value, match_value.size_of(), this, single_value.n_elements, match_function_specific, log_function, legacy); } } void StatsDExpects_template::encode_text(Text_Buf& text_buf) const { encode_text_restricted(text_buf); switch (template_selection) { case SPECIFIC_VALUE: text_buf.push_int(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) single_value.value_elements[elem_count]->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; case SUPERSET_MATCH: case SUBSET_MATCH: text_buf.push_int(value_set.n_items); for (unsigned int set_count = 0; set_count < value_set.n_items; set_count++) value_set.set_items[set_count].encode_text(text_buf); break; default: TTCN_error("Text encoder: Encoding an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpects."); } } void StatsDExpects_template::decode_text(Text_Buf& text_buf) { clean_up(); decode_text_restricted(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value.n_elements = text_buf.pull_int().get_val(); if (single_value.n_elements < 0) TTCN_error("Text decoder: Negative size was received for a template of type @StatsD_Checker.StatsDExpects."); single_value.value_elements = (StatsDExpect_template**)allocate_pointers(single_value.n_elements); for (int elem_count = 0; elem_count < single_value.n_elements; elem_count++) { single_value.value_elements[elem_count] = new StatsDExpect_template; single_value.value_elements[elem_count]->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 StatsDExpects_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; case SUPERSET_MATCH: case SUBSET_MATCH: value_set.n_items = text_buf.pull_int().get_val(); value_set.set_items = new StatsDExpect_template[value_set.n_items]; for (unsigned int set_count = 0; set_count < value_set.n_items; set_count++) value_set.set_items[set_count].decode_text(text_buf); break; default: TTCN_error("Text decoder: An unknown/unsupported selection was received for a template of type @StatsD_Checker.StatsDExpects."); } } boolean StatsDExpects_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean StatsDExpects_template::match_omit(boolean legacy) const { if (is_ifpresent) return TRUE; switch (template_selection) { case OMIT_VALUE: case ANY_OR_OMIT: return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match_omit() || implication_.implied_template->match_omit(); case VALUE_LIST: case COMPLEMENTED_LIST: if (legacy) { for (unsigned int i=0; iset_implicit_omit(); } } void StatsDExpects_template::set_param(Module_Param& param) { param.basic_check(Module_Param::BC_TEMPLATE|Module_Param::BC_LIST, "set of 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: case Module_Param::MP_ConjunctList_Template: { StatsDExpects_template temp; temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size()); for (size_t p_i=0; p_iget_id()->get_index())].set_param(*param.get_elem(p_i)); } break; case Module_Param::MP_Value_List: set_size(param.get_size()); for (size_t p_i=0; p_iget_type()!=Module_Param::MP_NotUsed) { (*this)[p_i].set_param(*param.get_elem(p_i)); } } break; case Module_Param::MP_Superset_Template: case Module_Param::MP_Subset_Template: set_type(param.get_type()==Module_Param::MP_Superset_Template ? SUPERSET_MATCH : SUBSET_MATCH, param.get_size()); for (size_t p_i=0; p_iset_param(*param.get_elem(0)); StatsDExpects_template* implied_template = new StatsDExpects_template; implied_template->set_param(*param.get_elem(1)); *this = StatsDExpects_template(precondition, implied_template); } break; default: param.type_error("set of template", "@StatsD_Checker.StatsDExpects"); } is_ifpresent = param.get_ifpresent(); set_length_range(param); } void StatsDExpects_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; for (int i=0; icheck_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDExpects"); 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 : "@StatsD_Checker.StatsDExpects"); } boolean StatsDExpects_template::get_istemplate_kind(const char* type) const { if (!strcmp(type, "AnyElement")) { if (template_selection != SPECIFIC_VALUE) { return FALSE; } for (int i = 0; i < single_value.n_elements; i++) { if (single_value.value_elements[i]->get_selection() == ANY_VALUE) { return TRUE; } } return FALSE; } else if (!strcmp(type, "AnyElementsOrNone")) { if (template_selection != SPECIFIC_VALUE) { return FALSE; } for (int i = 0; i < single_value.n_elements; i++) { if (single_value.value_elements[i]->get_selection() == ANY_OR_OMIT) { return TRUE; } } return FALSE; } else if (!strcmp(type, "permutation")) { return FALSE; } else if (!strcmp(type, "length")) { return length_restriction_type != NO_LENGTH_RESTRICTION; } else { return Base_Template::get_istemplate_kind(type); } } StatsDResultType::StatsDResultType() { enum_value = UNBOUND_VALUE; } StatsDResultType::StatsDResultType(int other_value) { if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @StatsD_Checker.StatsDResultType with invalid numeric value %d.", other_value); enum_value = (enum_type)other_value; } StatsDResultType::StatsDResultType(enum_type other_value) { enum_value = other_value; } StatsDResultType::StatsDResultType(const StatsDResultType& other_value) : Base_Type() { if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); enum_value = other_value.enum_value; } StatsDResultType& StatsDResultType::operator=(int other_value) { if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @StatsD_Checker.StatsDResultType.", other_value); enum_value = (enum_type)other_value; return *this; } StatsDResultType& StatsDResultType::operator=(enum_type other_value) { enum_value = other_value; return *this; } StatsDResultType& StatsDResultType::operator=(const StatsDResultType& other_value) { if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); enum_value = other_value.enum_value; return *this; } boolean StatsDResultType::operator==(int other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @StatsD_Checker.StatsDResultType comparison is an unknown numeric value %d", other_value); return enum_value == other_value; } boolean StatsDResultType::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 @StatsD_Checker.StatsDResultType."); return enum_value == other_value; } boolean StatsDResultType::operator==(const StatsDResultType& other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); return enum_value == other_value.enum_value; } boolean StatsDResultType::operator<(int other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @StatsD_Checker.StatsDResultType comparison is an unknown numeric value %d", other_value); return enum_value < other_value; } boolean StatsDResultType::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 @StatsD_Checker.StatsDResultType."); return enum_value < other_value; } boolean StatsDResultType::operator<(const StatsDResultType& other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); return enum_value < other_value.enum_value; } boolean StatsDResultType::operator>(int other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @StatsD_Checker.StatsDResultType comparison is an unknown numeric value %d", other_value); return enum_value > other_value; } boolean StatsDResultType::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 @StatsD_Checker.StatsDResultType."); return enum_value > other_value; } boolean StatsDResultType::operator>(const StatsDResultType& other_value) const { if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); return enum_value > other_value.enum_value; } const char *StatsDResultType::enum_to_str(enum_type enum_par) { switch (enum_par) { case e__Matched: return "e_Matched"; case e__Mismatched: return "e_Mismatched"; case e__NotFound: return "e_NotFound"; default: return ""; } } StatsDResultType::enum_type StatsDResultType::str_to_enum(const char *str_par, const int* int_par, const int* int_par2) { if (int_par == NULL && int_par2 == NULL) { if (!strcmp(str_par, "e_Matched")) return e__Matched; if (!strcmp(str_par, "e_Mismatched")) return e__Mismatched; if (!strcmp(str_par, "e_NotFound")) return e__NotFound; } return UNKNOWN_VALUE; } boolean StatsDResultType::is_valid_enum(int int_par) { switch (int_par) { case 0: case 1: case 2: return TRUE; default: return FALSE; } } int StatsDResultType::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 @StatsD_Checker.StatsDResultType.", enum_par==UNBOUND_VALUE?"unbound":"invalid"); return enum_par; } int StatsDResultType::enum2int(const StatsDResultType& 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 @StatsD_Checker.StatsDResultType.", enum_par==UNBOUND_VALUE?"unbound":"invalid"); return enum_par.enum_value; } void StatsDResultType::int2enum(int int_val) { if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @StatsD_Checker.StatsDResultType.", int_val); enum_value = (enum_type)int_val; } StatsDResultType::operator StatsDResultType::enum_type() const { if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @StatsD_Checker.StatsDResultType."); return enum_value; } void StatsDResultType::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 StatsDResultType::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", "@StatsD_Checker.StatsDResultType"); enum_value = str_to_enum(param.get_enumerated(), param.get_enumerated_value()); if (!is_valid_enum(enum_value)) { param.error("Invalid enumerated value for type @StatsD_Checker.StatsDResultType."); } } void StatsDResultType::encode_text(Text_Buf& text_buf) const { if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); text_buf.push_int(enum_value); } void StatsDResultType::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 @StatsD_Checker.StatsDResultType.", enum_value); } void StatsDResultType_template::copy_template(const StatsDResultType_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: case CONJUNCTION_MATCH: value_list.n_values = other_value.value_list.n_values; value_list.list_value = new StatsDResultType_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; case IMPLICATION_MATCH: implication_.precondition = new StatsDResultType_template(*other_value.implication_.precondition); implication_.implied_template = new StatsDResultType_template(*other_value.implication_.implied_template); break; case DYNAMIC_MATCH: dyn_match = other_value.dyn_match; dyn_match->ref_count++; break; default: TTCN_error("Copying an uninitialized/unsupported template of enumerated type @StatsD_Checker.StatsDResultType."); } } StatsDResultType_template::StatsDResultType_template() { } StatsDResultType_template::StatsDResultType_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } StatsDResultType_template::StatsDResultType_template(int other_value) : Base_Template(SPECIFIC_VALUE) { if (!StatsDResultType::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @StatsD_Checker.StatsDResultType with unknown numeric value %d.", other_value); single_value = (StatsDResultType::enum_type)other_value; } StatsDResultType_template::StatsDResultType_template(StatsDResultType::enum_type other_value) : Base_Template(SPECIFIC_VALUE) { single_value = other_value; } StatsDResultType_template::StatsDResultType_template(const StatsDResultType& other_value) : Base_Template(SPECIFIC_VALUE) { if (other_value.enum_value == StatsDResultType::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @StatsD_Checker.StatsDResultType."); single_value = other_value.enum_value; } StatsDResultType_template::StatsDResultType_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: set_selection(SPECIFIC_VALUE); single_value = (StatsDResultType::enum_type)(const StatsDResultType&)other_value; break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of enumerated type @StatsD_Checker.StatsDResultType from an unbound optional field."); } } StatsDResultType_template::StatsDResultType_template(StatsDResultType_template* p_precondition, StatsDResultType_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } StatsDResultType_template::StatsDResultType_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } StatsDResultType_template::StatsDResultType_template(const StatsDResultType_template& other_value) : Base_Template() { copy_template(other_value); } StatsDResultType_template::~StatsDResultType_template() { clean_up(); } boolean StatsDResultType_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; return TRUE; } boolean StatsDResultType_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value != StatsDResultType::UNBOUND_VALUE; } void StatsDResultType_template::clean_up() { switch (template_selection) { case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: delete [] value_list.list_value; break; case IMPLICATION_MATCH: delete implication_.precondition; delete implication_.implied_template; break; case DYNAMIC_MATCH: dyn_match->ref_count--; if (dyn_match->ref_count == 0) { delete dyn_match->ptr; delete dyn_match; } break; default: break; } template_selection = UNINITIALIZED_TEMPLATE; } StatsDResultType_template& StatsDResultType_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } StatsDResultType_template& StatsDResultType_template::operator=(int other_value) { if (!StatsDResultType::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @StatsD_Checker.StatsDResultType.", other_value); clean_up(); set_selection(SPECIFIC_VALUE); single_value = (StatsDResultType::enum_type)other_value; return *this; } StatsDResultType_template& StatsDResultType_template::operator=(StatsDResultType::enum_type other_value) { clean_up(); set_selection(SPECIFIC_VALUE); single_value = other_value; return *this; } StatsDResultType_template& StatsDResultType_template::operator=(const StatsDResultType& other_value) { if (other_value.enum_value == StatsDResultType::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @StatsD_Checker.StatsDResultType to a template."); clean_up(); set_selection(SPECIFIC_VALUE); single_value = other_value.enum_value; return *this; } StatsDResultType_template& StatsDResultType_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: set_selection(SPECIFIC_VALUE); single_value = (StatsDResultType::enum_type)(const StatsDResultType&)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 @StatsD_Checker.StatsDResultType."); } return *this; } StatsDResultType_template& StatsDResultType_template::operator=(const StatsDResultType_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean StatsDResultType_template::match(StatsDResultType::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; case CONJUNCTION_MATCH: for (unsigned int i = 0; i < value_list.n_values; i++) { if (!value_list.list_value[i].match(other_value)) { return FALSE; } } return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value); case DYNAMIC_MATCH: return dyn_match->ptr->match(other_value); default: TTCN_error("Matching an uninitialized/unsupported template of enumerated type @StatsD_Checker.StatsDResultType."); } return FALSE; } boolean StatsDResultType_template::match(const StatsDResultType& other_value, boolean) const { if (other_value.enum_value == StatsDResultType::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @StatsD_Checker.StatsDResultType with an unbound value."); return match(other_value.enum_value); } StatsDResultType::enum_type StatsDResultType_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 @StatsD_Checker.StatsDResultType."); return single_value; } void StatsDResultType_template::set_type(template_sel template_type, unsigned int list_length) { clean_up(); switch (template_type) { case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new StatsDResultType_template[list_length]; break; default: TTCN_error("Setting an invalid type for a template of enumerated type @StatsD_Checker.StatsDResultType."); } } StatsDResultType_template& StatsDResultType_template::list_item(unsigned int list_index) { if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST && template_selection != CONJUNCTION_MATCH) TTCN_error("Accessing a list element in a non-list template of enumerated type @StatsD_Checker.StatsDResultType."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @StatsD_Checker.StatsDResultType."); return value_list.list_value[list_index]; } void StatsDResultType_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_enum(StatsDResultType::enum_to_str(single_value), single_value); break; case COMPLEMENTED_LIST: TTCN_Logger::log_event_str("complement"); case CONJUNCTION_MATCH: if (template_selection == CONJUNCTION_MATCH) { TTCN_Logger::log_event_str("conjunct"); } 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; case IMPLICATION_MATCH: implication_.precondition->log(); TTCN_Logger::log_event_str(" implies "); implication_.implied_template->log(); break; case DYNAMIC_MATCH: TTCN_Logger::log_event_str("@dynamic template"); break; default: log_generic(); } log_ifpresent(); } void StatsDResultType_template::log_match(const StatsDResultType& 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 StatsDResultType_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 @StatsD_Checker.StatsDResultType."); } } void StatsDResultType_template::decode_text(Text_Buf& text_buf) { clean_up(); decode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value = (StatsDResultType::enum_type)text_buf.pull_int().get_val(); if (!StatsDResultType::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @StatsD_Checker.StatsDResultType.", 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 StatsDResultType_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 @StatsD_Checker.StatsDResultType."); } } boolean StatsDResultType_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean StatsDResultType_template::match_omit(boolean legacy) const { if (is_ifpresent) return TRUE; switch (template_selection) { case OMIT_VALUE: case ANY_OR_OMIT: return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match_omit() || implication_.implied_template->match_omit(); case VALUE_LIST: case COMPLEMENTED_LIST: if (legacy) { for (unsigned int i=0; iget_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: case Module_Param::MP_ConjunctList_Template: { StatsDResultType_template new_temp; new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (m_p->get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), m_p->get_size()); for (size_t p_i=0; p_iget_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: { StatsDResultType::enum_type enum_val = StatsDResultType::str_to_enum(m_p->get_enumerated(), m_p->get_enumerated_value()); if (!StatsDResultType::is_valid_enum(enum_val)) { param.error("Invalid enumerated value for type @StatsD_Checker.StatsDResultType."); } *this = enum_val; } break; case Module_Param::MP_Implication_Template: { StatsDResultType_template* precondition = new StatsDResultType_template; precondition->set_param(*m_p->get_elem(0)); StatsDResultType_template* implied_template = new StatsDResultType_template; implied_template->set_param(*m_p->get_elem(1)); *this = StatsDResultType_template(precondition, implied_template); } break; default: param.type_error("enumerated template", "@StatsD_Checker.StatsDResultType"); } is_ifpresent = param.get_ifpresent(); } void StatsDResultType_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 : "@StatsD_Checker.StatsDResultType"); } StatsDExpectResult::StatsDExpectResult() { } StatsDExpectResult::StatsDExpectResult(const StatsDResultType& par_kind, const INTEGER& par_idx) : field_kind(par_kind), field_idx(par_idx) { } StatsDExpectResult::StatsDExpectResult(const StatsDExpectResult& other_value) { if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @StatsD_Checker.StatsDExpectResult."); if (other_value.kind().is_bound()) field_kind = other_value.kind(); else field_kind.clean_up(); if (other_value.idx().is_bound()) field_idx = other_value.idx(); else field_idx.clean_up(); } void StatsDExpectResult::clean_up() { field_kind.clean_up(); field_idx.clean_up(); } const TTCN_Typedescriptor_t* StatsDExpectResult::get_descriptor() const { return &StatsDExpectResult_descr_; } StatsDExpectResult& StatsDExpectResult::operator=(const StatsDExpectResult& other_value) { if (this != &other_value) { if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @StatsD_Checker.StatsDExpectResult."); if (other_value.kind().is_bound()) field_kind = other_value.kind(); else field_kind.clean_up(); if (other_value.idx().is_bound()) field_idx = other_value.idx(); else field_idx.clean_up(); } return *this; } boolean StatsDExpectResult::operator==(const StatsDExpectResult& other_value) const { return field_kind==other_value.field_kind && field_idx==other_value.field_idx; } boolean StatsDExpectResult::is_bound() const { return (field_kind.is_bound()) || (field_idx.is_bound()); } boolean StatsDExpectResult::is_value() const { return field_kind.is_value() && field_idx.is_value(); } void StatsDExpectResult::log() const { if (!is_bound()) { TTCN_Logger::log_event_unbound(); return; } TTCN_Logger::log_event_str("{ kind := "); field_kind.log(); TTCN_Logger::log_event_str(", idx := "); field_idx.log(); TTCN_Logger::log_event_str(" }"); } void StatsDExpectResult::set_implicit_omit() { if (kind().is_bound()) kind().set_implicit_omit(); if (idx().is_bound()) idx().set_implicit_omit(); } void StatsDExpectResult::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 (20 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) kind().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) idx().set_param(*param.get_elem(1)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "kind")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { kind().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "idx")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { idx().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @StatsD_Checker.StatsDExpectResult: %s", curr_param->get_id()->get_name()); break; } } break; default: param.type_error("record value", "@StatsD_Checker.StatsDExpectResult"); } } void StatsDExpectResult::encode_text(Text_Buf& text_buf) const { field_kind.encode_text(text_buf); field_idx.encode_text(text_buf); } void StatsDExpectResult::decode_text(Text_Buf& text_buf) { field_kind.decode_text(text_buf); field_idx.decode_text(text_buf); } struct StatsDExpectResult_template::single_value_struct { StatsDResultType_template field_kind; INTEGER_template field_idx; }; void StatsDExpectResult_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_kind = ANY_VALUE; single_value->field_idx = ANY_VALUE; } } } void StatsDExpectResult_template::copy_value(const StatsDExpectResult& other_value) { single_value = new single_value_struct; if (other_value.kind().is_bound()) { single_value->field_kind = other_value.kind(); } else { single_value->field_kind.clean_up(); } if (other_value.idx().is_bound()) { single_value->field_idx = other_value.idx(); } else { single_value->field_idx.clean_up(); } set_selection(SPECIFIC_VALUE); } void StatsDExpectResult_template::copy_template(const StatsDExpectResult_template& other_value) { switch (other_value.template_selection) { case SPECIFIC_VALUE: single_value = new single_value_struct; if (UNINITIALIZED_TEMPLATE != other_value.kind().get_selection()) { single_value->field_kind = other_value.kind(); } else { single_value->field_kind.clean_up(); } if (UNINITIALIZED_TEMPLATE != other_value.idx().get_selection()) { single_value->field_idx = other_value.idx(); } else { single_value->field_idx.clean_up(); } case OMIT_VALUE: case ANY_VALUE: case ANY_OR_OMIT: break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: value_list.n_values = other_value.value_list.n_values; value_list.list_value = new StatsDExpectResult_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; case IMPLICATION_MATCH: implication_.precondition = new StatsDExpectResult_template(*other_value.implication_.precondition); implication_.implied_template = new StatsDExpectResult_template(*other_value.implication_.implied_template); break; case DYNAMIC_MATCH: dyn_match = other_value.dyn_match; dyn_match->ref_count++; break; default: TTCN_error("Copying an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpectResult."); break; } set_selection(other_value); } StatsDExpectResult_template::StatsDExpectResult_template() { } StatsDExpectResult_template::StatsDExpectResult_template(template_sel other_value) : Base_Template(other_value) { check_single_selection(other_value); } StatsDExpectResult_template::StatsDExpectResult_template(const StatsDExpectResult& other_value) { copy_value(other_value); } StatsDExpectResult_template::StatsDExpectResult_template(const OPTIONAL& other_value) { switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDExpectResult&)other_value); break; case OPTIONAL_OMIT: set_selection(OMIT_VALUE); break; default: TTCN_error("Creating a template of type @StatsD_Checker.StatsDExpectResult from an unbound optional field."); } } StatsDExpectResult_template::StatsDExpectResult_template(StatsDExpectResult_template* p_precondition, StatsDExpectResult_template* p_implied_template) : Base_Template(IMPLICATION_MATCH) { implication_.precondition = p_precondition; implication_.implied_template = p_implied_template; } StatsDExpectResult_template::StatsDExpectResult_template(Dynamic_Match_Interface* p_dyn_match) : Base_Template(DYNAMIC_MATCH) { dyn_match = new dynmatch_struct; dyn_match->ptr = p_dyn_match; dyn_match->ref_count = 1; } StatsDExpectResult_template::StatsDExpectResult_template(const StatsDExpectResult_template& other_value) : Base_Template() { copy_template(other_value); } StatsDExpectResult_template::~StatsDExpectResult_template() { clean_up(); } StatsDExpectResult_template& StatsDExpectResult_template::operator=(template_sel other_value) { check_single_selection(other_value); clean_up(); set_selection(other_value); return *this; } StatsDExpectResult_template& StatsDExpectResult_template::operator=(const StatsDExpectResult& other_value) { clean_up(); copy_value(other_value); return *this; } StatsDExpectResult_template& StatsDExpectResult_template::operator=(const OPTIONAL& other_value) { clean_up(); switch (other_value.get_selection()) { case OPTIONAL_PRESENT: copy_value((const StatsDExpectResult&)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 @StatsD_Checker.StatsDExpectResult."); } return *this; } StatsDExpectResult_template& StatsDExpectResult_template::operator=(const StatsDExpectResult_template& other_value) { if (&other_value != this) { clean_up(); copy_template(other_value); } return *this; } boolean StatsDExpectResult_template::match(const StatsDExpectResult& 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.kind().is_bound()) return FALSE; if(!single_value->field_kind.match(other_value.kind(), legacy))return FALSE; if(!other_value.idx().is_bound()) return FALSE; if(!single_value->field_idx.match(other_value.idx(), 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; case CONJUNCTION_MATCH: for (unsigned int i = 0; i < value_list.n_values; i++) { if (!value_list.list_value[i].match(other_value)) { return FALSE; } } return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match(other_value) || implication_.implied_template->match(other_value); case DYNAMIC_MATCH: return dyn_match->ptr->match(other_value); default: TTCN_error("Matching an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpectResult."); } return FALSE; } boolean StatsDExpectResult_template::is_bound() const { if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE; if (template_selection != SPECIFIC_VALUE) return TRUE; return single_value->field_kind.is_bound() || single_value->field_idx.is_bound(); } boolean StatsDExpectResult_template::is_value() const { if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE; return single_value->field_kind.is_value() && single_value->field_idx.is_value(); } void StatsDExpectResult_template::clean_up() { switch (template_selection) { case SPECIFIC_VALUE: delete single_value; break; case VALUE_LIST: case COMPLEMENTED_LIST: case CONJUNCTION_MATCH: delete [] value_list.list_value; break; case IMPLICATION_MATCH: delete implication_.precondition; delete implication_.implied_template; break; case DYNAMIC_MATCH: dyn_match->ref_count--; if (dyn_match->ref_count == 0) { delete dyn_match->ptr; delete dyn_match; } break; default: break; } template_selection = UNINITIALIZED_TEMPLATE; } StatsDExpectResult StatsDExpectResult_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 @StatsD_Checker.StatsDExpectResult."); StatsDExpectResult ret_val; if (single_value->field_kind.is_bound()) { ret_val.kind() = single_value->field_kind.valueof(); } if (single_value->field_idx.is_bound()) { ret_val.idx() = single_value->field_idx.valueof(); } return ret_val; } void StatsDExpectResult_template::set_type(template_sel template_type, unsigned int list_length) { if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST&& template_type != CONJUNCTION_MATCH) TTCN_error("Setting an invalid list for a template of type @StatsD_Checker.StatsDExpectResult."); clean_up(); set_selection(template_type); value_list.n_values = list_length; value_list.list_value = new StatsDExpectResult_template[list_length]; } StatsDExpectResult_template& StatsDExpectResult_template::list_item(unsigned int list_index) const { if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST&& template_selection != CONJUNCTION_MATCH) TTCN_error("Accessing a list element of a non-list template of type @StatsD_Checker.StatsDExpectResult."); if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of type @StatsD_Checker.StatsDExpectResult."); return value_list.list_value[list_index]; } StatsDResultType_template& StatsDExpectResult_template::kind() { set_specific(); return single_value->field_kind; } const StatsDResultType_template& StatsDExpectResult_template::kind() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field kind of a non-specific template of type @StatsD_Checker.StatsDExpectResult."); return single_value->field_kind; } INTEGER_template& StatsDExpectResult_template::idx() { set_specific(); return single_value->field_idx; } const INTEGER_template& StatsDExpectResult_template::idx() const { if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field idx of a non-specific template of type @StatsD_Checker.StatsDExpectResult."); return single_value->field_idx; } int StatsDExpectResult_template::size_of() const { if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpectResult 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 @StatsD_Checker.StatsDExpectResult 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 @StatsD_Checker.StatsDExpectResult containing a value list with different sizes."); } return item_size; } case OMIT_VALUE: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpectResult containing omit value."); case ANY_VALUE: case ANY_OR_OMIT: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpectResult containing */? value."); case COMPLEMENTED_LIST: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpectResult containing complemented list."); case CONJUNCTION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpectResult containing a conjunction list match."); case IMPLICATION_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpectResult containing an implication match."); case DYNAMIC_MATCH: TTCN_error("Performing sizeof() operation on a template of type @StatsD_Checker.StatsDExpectResult containing a dynamic match."); default: TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @StatsD_Checker.StatsDExpectResult."); } return 0; } void StatsDExpectResult_template::log() const { switch (template_selection) { case SPECIFIC_VALUE: TTCN_Logger::log_event_str("{ kind := "); single_value->field_kind.log(); TTCN_Logger::log_event_str(", idx := "); single_value->field_idx.log(); TTCN_Logger::log_event_str(" }"); break; case COMPLEMENTED_LIST: TTCN_Logger::log_event_str("complement"); case CONJUNCTION_MATCH: if (template_selection == CONJUNCTION_MATCH) { TTCN_Logger::log_event_str("conjunct"); } 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; case IMPLICATION_MATCH: implication_.precondition->log(); TTCN_Logger::log_event_str(" implies "); implication_.implied_template->log(); break; case DYNAMIC_MATCH: TTCN_Logger::log_event_str("@dynamic template"); break; default: log_generic(); } log_ifpresent(); } void StatsDExpectResult_template::log_match(const StatsDExpectResult& 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_kind.match(match_value.kind(), legacy)){ TTCN_Logger::log_logmatch_info(".kind"); single_value->field_kind.log_match(match_value.kind(), legacy); TTCN_Logger::set_logmatch_buffer_len(previous_size); } if(!single_value->field_idx.match(match_value.idx(), legacy)){ TTCN_Logger::log_logmatch_info(".idx"); single_value->field_idx.log_match(match_value.idx(), 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("{ kind := "); single_value->field_kind.log_match(match_value.kind(), legacy); TTCN_Logger::log_event_str(", idx := "); single_value->field_idx.log_match(match_value.idx(), 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 StatsDExpectResult_template::set_implicit_omit() { if (template_selection != SPECIFIC_VALUE) return; if (kind().is_bound()) kind().set_implicit_omit(); if (idx().is_bound()) idx().set_implicit_omit(); } void StatsDExpectResult_template::encode_text(Text_Buf& text_buf) const { encode_text_base(text_buf); switch (template_selection) { case SPECIFIC_VALUE: single_value->field_kind.encode_text(text_buf); single_value->field_idx.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 @StatsD_Checker.StatsDExpectResult."); } } void StatsDExpectResult_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_kind.decode_text(text_buf); single_value->field_idx.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 StatsDExpectResult_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 @StatsD_Checker.StatsDExpectResult."); } } void StatsDExpectResult_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: case Module_Param::MP_ConjunctList_Template: { StatsDExpectResult_template new_temp; new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : (param.get_type() == Module_Param::MP_ConjunctList_Template ? CONJUNCTION_MATCH : COMPLEMENTED_LIST), param.get_size()); for (size_t p_i=0; p_i0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) kind().set_param(*param.get_elem(0)); if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) idx().set_param(*param.get_elem(1)); break; case Module_Param::MP_Assignment_List: { Vector value_used(param.get_size()); value_used.resize(param.get_size(), FALSE); for (size_t val_idx=0; val_idxget_id()->get_name(), "kind")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { kind().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxget_id()->get_name(), "idx")) { if (curr_param->get_type()!=Module_Param::MP_NotUsed) { idx().set_param(*curr_param); } value_used[val_idx]=TRUE; } } for (size_t val_idx=0; val_idxerror("Non existent field name in type @StatsD_Checker.StatsDExpectResult: %s", curr_param->get_id()->get_name()); break; } } break; case Module_Param::MP_Implication_Template: { StatsDExpectResult_template* precondition = new StatsDExpectResult_template; precondition->set_param(*param.get_elem(0)); StatsDExpectResult_template* implied_template = new StatsDExpectResult_template; implied_template->set_param(*param.get_elem(1)); *this = StatsDExpectResult_template(precondition, implied_template); } break; default: param.type_error("record template", "@StatsD_Checker.StatsDExpectResult"); } is_ifpresent = param.get_ifpresent(); } void StatsDExpectResult_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_kind.check_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDExpectResult"); single_value->field_idx.check_restriction(t_res, t_name ? t_name : "@StatsD_Checker.StatsDExpectResult"); 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 : "@StatsD_Checker.StatsDExpectResult"); } boolean StatsDExpectResult_template::is_present(boolean legacy) const { if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE; return !match_omit(legacy); } boolean StatsDExpectResult_template::match_omit(boolean legacy) const { if (is_ifpresent) return TRUE; switch (template_selection) { case OMIT_VALUE: case ANY_OR_OMIT: return TRUE; case IMPLICATION_MATCH: return !implication_.precondition->match_omit() || implication_.implied_template->match_omit(); case VALUE_LIST: case COMPLEMENTED_LIST: if (legacy) { for (unsigned int l_idx=0; l_idxnext_item = NULL; if (proc_queue_tail != NULL) proc_queue_tail->next_item = new_item; else proc_queue_head = new_item; proc_queue_tail = new_item; } void STATSD__PROC__PT::remove_proc_queue_head() { switch (proc_queue_head->item_selection) { case CALL_0: delete proc_queue_head->call_0; break; case CALL_1: delete proc_queue_head->call_1; break; case CALL_2: delete proc_queue_head->call_2; break; case REPLY_0: delete proc_queue_head->reply_0; break; case REPLY_1: delete proc_queue_head->reply_1; break; case REPLY_2: delete proc_queue_head->reply_2; break; default: TTCN_error("Internal error: Invalid signature selector in the queue of port %s.", port_name); } proc_queue_item *next_item = proc_queue_head->next_item; delete proc_queue_head; proc_queue_head = next_item; if (next_item == NULL) proc_queue_tail = NULL; TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::extract__op, port_name, 0, ++proc_head_count, CHARSTRING(0,NULL), CHARSTRING(0,NULL));} void STATSD__PROC__PT::clear_queue() { while (proc_queue_head != NULL) remove_proc_queue_head(); } STATSD__PROC__PT::STATSD__PROC__PT(const char *par_port_name) : PORT(par_port_name) { proc_queue_head = NULL; proc_queue_tail = NULL; } STATSD__PROC__PT::~STATSD__PROC__PT() { clear_queue(); } void STATSD__PROC__PT::call(const STATSD__reset_template& call_template, const COMPONENT& destination_component, FLOAT* timestamp_redirect) { if (!is_started) TTCN_error("Calling a signature on port %s, which is not started.", port_name); if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of call operation."); const STATSD__reset_call& call_tmp = call_template.create_call(); const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMOUT:TTCN_Logger::PORTEVENT_PCOUT; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_send(port_name,TitanLoggerApiSimple::Port__oper::call__op, destination_component, CHARSTRING(0,NULL),(TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PMOUT, TRUE), call_tmp.log(), TTCN_Logger::end_event_log2str())); } if (destination_component == SYSTEM_COMPREF) TTCN_error("Internal port %s cannot send call to system.", port_name); else { Text_Buf text_buf; prepare_call(text_buf, "@StatsD_Checker.STATSD_reset"); call_tmp.encode_text(text_buf); send_data(text_buf, destination_component); } } void STATSD__PROC__PT::call(const STATSD__reset_template& call_template, size_t nof_components, const COMPONENT* destination_components, FLOAT* timestamp_redirect) { for (size_t i = 0; i < nof_components; ++i) call(call_template, destination_components[i], timestamp_redirect); } void STATSD__PROC__PT::call(const STATSD__reset_template& call_template, boolean broadcast, FLOAT* timestamp_redirect) { if (broadcast) { if (!is_started) TTCN_error("Calling a signature on port %s, which is not started.", port_name); Text_Buf text_buf; prepare_call(text_buf, "@StatsD_Checker.STATSD_reset"); const STATSD__reset_call& call_tmp = call_template.create_call(); call_tmp.encode_text(text_buf); send_data_broadcast(text_buf, PORT::OMT_CALL, (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PCOUT, TRUE), call_tmp.log(), TTCN_Logger::end_event_log2str())); } else call(call_template, COMPONENT(get_default_destination()), timestamp_redirect); } void STATSD__PROC__PT::call(const STATSD__snapshot_template& call_template, const COMPONENT& destination_component, FLOAT* timestamp_redirect) { if (!is_started) TTCN_error("Calling a signature on port %s, which is not started.", port_name); if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of call operation."); const STATSD__snapshot_call& call_tmp = call_template.create_call(); const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMOUT:TTCN_Logger::PORTEVENT_PCOUT; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_send(port_name,TitanLoggerApiSimple::Port__oper::call__op, destination_component, CHARSTRING(0,NULL),(TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PMOUT, TRUE), call_tmp.log(), TTCN_Logger::end_event_log2str())); } if (destination_component == SYSTEM_COMPREF) TTCN_error("Internal port %s cannot send call to system.", port_name); else { Text_Buf text_buf; prepare_call(text_buf, "@StatsD_Checker.STATSD_snapshot"); call_tmp.encode_text(text_buf); send_data(text_buf, destination_component); } } void STATSD__PROC__PT::call(const STATSD__snapshot_template& call_template, size_t nof_components, const COMPONENT* destination_components, FLOAT* timestamp_redirect) { for (size_t i = 0; i < nof_components; ++i) call(call_template, destination_components[i], timestamp_redirect); } void STATSD__PROC__PT::call(const STATSD__snapshot_template& call_template, boolean broadcast, FLOAT* timestamp_redirect) { if (broadcast) { if (!is_started) TTCN_error("Calling a signature on port %s, which is not started.", port_name); Text_Buf text_buf; prepare_call(text_buf, "@StatsD_Checker.STATSD_snapshot"); const STATSD__snapshot_call& call_tmp = call_template.create_call(); call_tmp.encode_text(text_buf); send_data_broadcast(text_buf, PORT::OMT_CALL, (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PCOUT, TRUE), call_tmp.log(), TTCN_Logger::end_event_log2str())); } else call(call_template, COMPONENT(get_default_destination()), timestamp_redirect); } void STATSD__PROC__PT::call(const STATSD__expect_template& call_template, const COMPONENT& destination_component, FLOAT* timestamp_redirect) { if (!is_started) TTCN_error("Calling a signature on port %s, which is not started.", port_name); if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of call operation."); const STATSD__expect_call& call_tmp = call_template.create_call(); const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMOUT:TTCN_Logger::PORTEVENT_PCOUT; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_send(port_name,TitanLoggerApiSimple::Port__oper::call__op, destination_component, CHARSTRING(0,NULL),(TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PMOUT, TRUE), call_tmp.log(), TTCN_Logger::end_event_log2str())); } if (destination_component == SYSTEM_COMPREF) TTCN_error("Internal port %s cannot send call to system.", port_name); else { Text_Buf text_buf; prepare_call(text_buf, "@StatsD_Checker.STATSD_expect"); call_tmp.encode_text(text_buf); send_data(text_buf, destination_component); } } void STATSD__PROC__PT::call(const STATSD__expect_template& call_template, size_t nof_components, const COMPONENT* destination_components, FLOAT* timestamp_redirect) { for (size_t i = 0; i < nof_components; ++i) call(call_template, destination_components[i], timestamp_redirect); } void STATSD__PROC__PT::call(const STATSD__expect_template& call_template, boolean broadcast, FLOAT* timestamp_redirect) { if (broadcast) { if (!is_started) TTCN_error("Calling a signature on port %s, which is not started.", port_name); Text_Buf text_buf; prepare_call(text_buf, "@StatsD_Checker.STATSD_expect"); const STATSD__expect_call& call_tmp = call_template.create_call(); call_tmp.encode_text(text_buf); send_data_broadcast(text_buf, PORT::OMT_CALL, (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PCOUT, TRUE), call_tmp.log(), TTCN_Logger::end_event_log2str())); } else call(call_template, COMPONENT(get_default_destination()), timestamp_redirect); } void STATSD__PROC__PT::reply(const STATSD__reset_template& reply_template, const COMPONENT& destination_component, FLOAT* timestamp_redirect) { if (!is_started) TTCN_error("Replying to a signature on port %s, which is not started.", port_name); if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of reply operation."); const STATSD__reset_reply& reply_tmp = reply_template.create_reply(); const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMOUT:TTCN_Logger::PORTEVENT_PCOUT; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_send(port_name, TitanLoggerApiSimple::Port__oper::reply__op, destination_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PMOUT, TRUE), reply_tmp.log(), TTCN_Logger::end_event_log2str())); } if (destination_component == SYSTEM_COMPREF) TTCN_error("Internal port %s cannot send reply to system.", port_name); else { Text_Buf text_buf; prepare_reply(text_buf, "@StatsD_Checker.STATSD_reset"); reply_tmp.encode_text(text_buf); send_data(text_buf, destination_component); } } void STATSD__PROC__PT::reply(const STATSD__reset_template& reply_template, size_t nof_components, const COMPONENT* destination_components, FLOAT* timestamp_redirect) { for (size_t i = 0; i < nof_components; ++i) reply(reply_template, destination_components[i], timestamp_redirect); } void STATSD__PROC__PT::reply(const STATSD__reset_template& reply_template, boolean broadcast, FLOAT* timestamp_redirect) { if (broadcast) { if (!is_started) TTCN_error("Replying to a call on port %s, which is not started.", port_name); Text_Buf text_buf; prepare_reply(text_buf, "@StatsD_Checker.STATSD_reset"); const STATSD__reset_reply& reply_tmp = reply_template.create_reply(); reply_tmp.encode_text(text_buf); send_data_broadcast(text_buf, PORT::OMT_REPLY, (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PCOUT, TRUE), reply_tmp.log(), TTCN_Logger::end_event_log2str())); } else reply(reply_template, COMPONENT(get_default_destination()), timestamp_redirect); } void STATSD__PROC__PT::reply(const STATSD__snapshot_template& reply_template, const COMPONENT& destination_component, FLOAT* timestamp_redirect) { if (!is_started) TTCN_error("Replying to a signature on port %s, which is not started.", port_name); if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of reply operation."); const STATSD__snapshot_reply& reply_tmp = reply_template.create_reply(); const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMOUT:TTCN_Logger::PORTEVENT_PCOUT; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_send(port_name, TitanLoggerApiSimple::Port__oper::reply__op, destination_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PMOUT, TRUE), reply_tmp.log(), TTCN_Logger::end_event_log2str())); } if (destination_component == SYSTEM_COMPREF) TTCN_error("Internal port %s cannot send reply to system.", port_name); else { Text_Buf text_buf; prepare_reply(text_buf, "@StatsD_Checker.STATSD_snapshot"); reply_tmp.encode_text(text_buf); send_data(text_buf, destination_component); } } void STATSD__PROC__PT::reply(const STATSD__snapshot_template& reply_template, size_t nof_components, const COMPONENT* destination_components, FLOAT* timestamp_redirect) { for (size_t i = 0; i < nof_components; ++i) reply(reply_template, destination_components[i], timestamp_redirect); } void STATSD__PROC__PT::reply(const STATSD__snapshot_template& reply_template, boolean broadcast, FLOAT* timestamp_redirect) { if (broadcast) { if (!is_started) TTCN_error("Replying to a call on port %s, which is not started.", port_name); Text_Buf text_buf; prepare_reply(text_buf, "@StatsD_Checker.STATSD_snapshot"); const STATSD__snapshot_reply& reply_tmp = reply_template.create_reply(); reply_tmp.encode_text(text_buf); send_data_broadcast(text_buf, PORT::OMT_REPLY, (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PCOUT, TRUE), reply_tmp.log(), TTCN_Logger::end_event_log2str())); } else reply(reply_template, COMPONENT(get_default_destination()), timestamp_redirect); } void STATSD__PROC__PT::reply(const STATSD__expect_template& reply_template, const COMPONENT& destination_component, FLOAT* timestamp_redirect) { if (!is_started) TTCN_error("Replying to a signature on port %s, which is not started.", port_name); if (!destination_component.is_bound()) TTCN_error("Unbound component reference in the to clause of reply operation."); const STATSD__expect_reply& reply_tmp = reply_template.create_reply(); const TTCN_Logger::Severity log_sev = destination_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMOUT:TTCN_Logger::PORTEVENT_PCOUT; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_send(port_name, TitanLoggerApiSimple::Port__oper::reply__op, destination_component, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PMOUT, TRUE), reply_tmp.log(), TTCN_Logger::end_event_log2str())); } if (destination_component == SYSTEM_COMPREF) TTCN_error("Internal port %s cannot send reply to system.", port_name); else { Text_Buf text_buf; prepare_reply(text_buf, "@StatsD_Checker.STATSD_expect"); reply_tmp.encode_text(text_buf); send_data(text_buf, destination_component); } } void STATSD__PROC__PT::reply(const STATSD__expect_template& reply_template, size_t nof_components, const COMPONENT* destination_components, FLOAT* timestamp_redirect) { for (size_t i = 0; i < nof_components; ++i) reply(reply_template, destination_components[i], timestamp_redirect); } void STATSD__PROC__PT::reply(const STATSD__expect_template& reply_template, boolean broadcast, FLOAT* timestamp_redirect) { if (broadcast) { if (!is_started) TTCN_error("Replying to a call on port %s, which is not started.", port_name); Text_Buf text_buf; prepare_reply(text_buf, "@StatsD_Checker.STATSD_expect"); const STATSD__expect_reply& reply_tmp = reply_template.create_reply(); reply_tmp.encode_text(text_buf); send_data_broadcast(text_buf, PORT::OMT_REPLY, (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PCOUT, TRUE), reply_tmp.log(), TTCN_Logger::end_event_log2str())); } else reply(reply_template, COMPONENT(get_default_destination()), timestamp_redirect); } alt_status STATSD__PROC__PT::getcall(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else switch (proc_queue_head->item_selection) { case CALL_0: case CALL_1: case CALL_2: { if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS, "Matching on port %s succeeded.", port_name); const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::call__op, proc_queue_head->sender_component, FALSE, CHARSTRING(0, NULL), msg_head_count+1); } remove_proc_queue_head(); return ALT_YES; } default: TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: First entity in the queue is not a call.", port_name); return ALT_NO; } } alt_status STATSD__PROC__PT::check_getcall(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else switch (proc_queue_head->item_selection) { case CALL_0: case CALL_1: case CALL_2: { if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS, "Matching on port %s succeeded.", port_name); const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::call__op, proc_queue_head->sender_component, TRUE, CHARSTRING(0, NULL), msg_head_count+1); } return ALT_YES; } default: TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: First entity in the queue is not a call.", port_name); return ALT_NO; } } alt_status STATSD__PROC__PT::getcall(const STATSD__reset_template& getcall_template, const COMPONENT_template& sender_template, const STATSD__reset_call_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::sender__does__not__match__from__clause, (TTCN_Logger::begin_event(log_sev, TRUE), sender_template.log_match(proc_queue_head->sender_component), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else if (proc_queue_head->item_selection != CALL_0) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a call for signature @StatsD_Checker.STATSD_reset.", port_name); return ALT_NO; } else if (!getcall_template.match_call(*proc_queue_head->call_0)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__call__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getcall_template.log_match_call(*proc_queue_head->call_0), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->call_0); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getcall_template.log_match_call(*proc_queue_head->call_0); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::call__op, proc_queue_head->sender_component, FALSE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->call_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } remove_proc_queue_head(); return ALT_YES; } } alt_status STATSD__PROC__PT::check_getcall(const STATSD__reset_template& getcall_template, const COMPONENT_template& sender_template, const STATSD__reset_call_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::sender__does__not__match__from__clause, (TTCN_Logger::begin_event(log_sev, TRUE), sender_template.log_match(proc_queue_head->sender_component), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else if (proc_queue_head->item_selection != CALL_0) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a call for signature @StatsD_Checker.STATSD_reset.", port_name); return ALT_NO; } else if (!getcall_template.match_call(*proc_queue_head->call_0)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__call__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getcall_template.log_match_call(*proc_queue_head->call_0), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->call_0); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getcall_template.log_match_call(*proc_queue_head->call_0); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::call__op, proc_queue_head->sender_component, TRUE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->call_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } return ALT_YES; } } alt_status STATSD__PROC__PT::getcall(const STATSD__snapshot_template& getcall_template, const COMPONENT_template& sender_template, const STATSD__snapshot_call_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::sender__does__not__match__from__clause, (TTCN_Logger::begin_event(log_sev, TRUE), sender_template.log_match(proc_queue_head->sender_component), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else if (proc_queue_head->item_selection != CALL_1) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a call for signature @StatsD_Checker.STATSD_snapshot.", port_name); return ALT_NO; } else if (!getcall_template.match_call(*proc_queue_head->call_1)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__call__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getcall_template.log_match_call(*proc_queue_head->call_1), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->call_1); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getcall_template.log_match_call(*proc_queue_head->call_1); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::call__op, proc_queue_head->sender_component, FALSE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->call_1->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } remove_proc_queue_head(); return ALT_YES; } } alt_status STATSD__PROC__PT::check_getcall(const STATSD__snapshot_template& getcall_template, const COMPONENT_template& sender_template, const STATSD__snapshot_call_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::sender__does__not__match__from__clause, (TTCN_Logger::begin_event(log_sev, TRUE), sender_template.log_match(proc_queue_head->sender_component), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else if (proc_queue_head->item_selection != CALL_1) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a call for signature @StatsD_Checker.STATSD_snapshot.", port_name); return ALT_NO; } else if (!getcall_template.match_call(*proc_queue_head->call_1)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__call__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getcall_template.log_match_call(*proc_queue_head->call_1), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->call_1); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getcall_template.log_match_call(*proc_queue_head->call_1); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::call__op, proc_queue_head->sender_component, TRUE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->call_1->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } return ALT_YES; } } alt_status STATSD__PROC__PT::getcall(const STATSD__expect_template& getcall_template, const COMPONENT_template& sender_template, const STATSD__expect_call_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::sender__does__not__match__from__clause, (TTCN_Logger::begin_event(log_sev, TRUE), sender_template.log_match(proc_queue_head->sender_component), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else if (proc_queue_head->item_selection != CALL_2) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a call for signature @StatsD_Checker.STATSD_expect.", port_name); return ALT_NO; } else if (!getcall_template.match_call(*proc_queue_head->call_2)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__call__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getcall_template.log_match_call(*proc_queue_head->call_2), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->call_2); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getcall_template.log_match_call(*proc_queue_head->call_2); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::call__op, proc_queue_head->sender_component, FALSE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->call_2->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } remove_proc_queue_head(); return ALT_YES; } } alt_status STATSD__PROC__PT::check_getcall(const STATSD__expect_template& getcall_template, const COMPONENT_template& sender_template, const STATSD__expect_call_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::sender__does__not__match__from__clause, (TTCN_Logger::begin_event(log_sev, TRUE), sender_template.log_match(proc_queue_head->sender_component), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else if (proc_queue_head->item_selection != CALL_2) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a call for signature @StatsD_Checker.STATSD_expect.", port_name); return ALT_NO; } else if (!getcall_template.match_call(*proc_queue_head->call_2)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__call__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getcall_template.log_match_call(*proc_queue_head->call_2), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->call_2); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getcall_template.log_match_call(*proc_queue_head->call_2); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::call__op, proc_queue_head->sender_component, TRUE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->call_2->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } return ALT_YES; } } alt_status STATSD__PROC__PT::getreply(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else switch (proc_queue_head->item_selection) { case REPLY_0: case REPLY_1: case REPLY_2: { if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS, "Matching on port %s succeeded.", port_name); const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::reply__op, proc_queue_head->sender_component, FALSE, CHARSTRING(0, NULL), msg_head_count+1); } remove_proc_queue_head(); return ALT_YES; } default: TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: First entity in the queue is not a reply.", port_name); return ALT_NO; } } alt_status STATSD__PROC__PT::check_getreply(const COMPONENT_template& sender_template, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else switch (proc_queue_head->item_selection) { case REPLY_0: case REPLY_1: case REPLY_2: { if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS, "Matching on port %s succeeded.", port_name); const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::reply__op, proc_queue_head->sender_component, TRUE, CHARSTRING(0, NULL), msg_head_count+1); } return ALT_YES; } default: TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: First entity in the queue is not a reply.", port_name); return ALT_NO; } } alt_status STATSD__PROC__PT::getreply(const STATSD__reset_template& getreply_template, const COMPONENT_template& sender_template, const STATSD__reset_reply_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else if (proc_queue_head->item_selection != REPLY_0) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a reply for signature @StatsD_Checker.STATSD_reset.", port_name); return ALT_NO; } else if (!getreply_template.match_reply(*proc_queue_head->reply_0)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__reply__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getreply_template.log_match_reply(*proc_queue_head->reply_0), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->reply_0); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getreply_template.log_match_reply(*proc_queue_head->reply_0); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::reply__op, proc_queue_head->sender_component, FALSE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->reply_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } remove_proc_queue_head(); return ALT_YES; } } alt_status STATSD__PROC__PT::check_getreply(const STATSD__reset_template& getreply_template, const COMPONENT_template& sender_template, const STATSD__reset_reply_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else if (proc_queue_head->item_selection != REPLY_0) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a reply for signature @StatsD_Checker.STATSD_reset.", port_name); return ALT_NO; } else if (!getreply_template.match_reply(*proc_queue_head->reply_0)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__reply__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getreply_template.log_match_reply(*proc_queue_head->reply_0), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->reply_0); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getreply_template.log_match_reply(*proc_queue_head->reply_0); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::reply__op, proc_queue_head->sender_component, TRUE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->reply_0->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } return ALT_YES; } } alt_status STATSD__PROC__PT::getreply(const STATSD__snapshot_template& getreply_template, const COMPONENT_template& sender_template, const STATSD__snapshot_reply_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (getreply_template.return_value().get_selection() == ANY_OR_OMIT) TTCN_error("Getreply operation using '*' as return value matching template"); if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else if (proc_queue_head->item_selection != REPLY_1) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a reply for signature @StatsD_Checker.STATSD_snapshot.", port_name); return ALT_NO; } else if (!getreply_template.match_reply(*proc_queue_head->reply_1)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__reply__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getreply_template.log_match_reply(*proc_queue_head->reply_1), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->reply_1); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getreply_template.log_match_reply(*proc_queue_head->reply_1); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::reply__op, proc_queue_head->sender_component, FALSE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->reply_1->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } remove_proc_queue_head(); return ALT_YES; } } alt_status STATSD__PROC__PT::check_getreply(const STATSD__snapshot_template& getreply_template, const COMPONENT_template& sender_template, const STATSD__snapshot_reply_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (getreply_template.return_value().get_selection() == ANY_OR_OMIT) TTCN_error("Check-getreply operation using '*' as return value matching template"); if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else if (proc_queue_head->item_selection != REPLY_1) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a reply for signature @StatsD_Checker.STATSD_snapshot.", port_name); return ALT_NO; } else if (!getreply_template.match_reply(*proc_queue_head->reply_1)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__reply__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getreply_template.log_match_reply(*proc_queue_head->reply_1), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->reply_1); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getreply_template.log_match_reply(*proc_queue_head->reply_1); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::reply__op, proc_queue_head->sender_component, TRUE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->reply_1->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } return ALT_YES; } } alt_status STATSD__PROC__PT::getreply(const STATSD__expect_template& getreply_template, const COMPONENT_template& sender_template, const STATSD__expect_reply_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (getreply_template.return_value().get_selection() == ANY_OR_OMIT) TTCN_error("Getreply operation using '*' as return value matching template"); if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else if (proc_queue_head->item_selection != REPLY_2) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a reply for signature @StatsD_Checker.STATSD_expect.", port_name); return ALT_NO; } else if (!getreply_template.match_reply(*proc_queue_head->reply_2)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__reply__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getreply_template.log_match_reply(*proc_queue_head->reply_2), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->reply_2); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getreply_template.log_match_reply(*proc_queue_head->reply_2); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::reply__op, proc_queue_head->sender_component, FALSE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->reply_2->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } remove_proc_queue_head(); return ALT_YES; } } alt_status STATSD__PROC__PT::check_getreply(const STATSD__expect_template& getreply_template, const COMPONENT_template& sender_template, const STATSD__expect_reply_redirect& param_ref, COMPONENT *sender_ptr, FLOAT* timestamp_redirect, Index_Redirect*) { if (getreply_template.return_value().get_selection() == ANY_OR_OMIT) TTCN_error("Check-getreply operation using '*' as return value matching template"); if (proc_queue_head == NULL) { if (is_started) return ALT_MAYBE; else { TTCN_Logger::log(TTCN_Logger::MATCHING_PROBLEM, "Matching on port %s failed: Port is not started and the queue is empty.", port_name); return ALT_NO; } } else if (!sender_template.match(proc_queue_head->sender_component)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s failed: Sender of the first entity in the queue does not match the from clause: ", port_name); sender_template.log_match(proc_queue_head->sender_component); TTCN_Logger::end_event(); } return ALT_NO; } else if (proc_queue_head->item_selection != REPLY_2) { TTCN_Logger::log(proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMUNSUCC:TTCN_Logger::MATCHING_PCUNSUCC, "Matching on port %s failed: The first entity in the queue is not a reply for signature @StatsD_Checker.STATSD_expect.", port_name); return ALT_NO; } else if (!getreply_template.match_reply(*proc_queue_head->reply_2)) { const TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF ? TTCN_Logger::MATCHING_PMUNSUCC : TTCN_Logger::MATCHING_PCUNSUCC; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_matching_failure(TitanLoggerApiSimple::PortType::procedure__, port_name, proc_queue_head->sender_component, TitanLoggerApiSimple::MatchingFailureType_reason::parameters__of__reply__do__not__match__template, (TTCN_Logger::begin_event(log_sev, TRUE), getreply_template.log_match_reply(*proc_queue_head->reply_2), TTCN_Logger::end_event_log2str())); } return ALT_NO; } else { param_ref.set_parameters(*proc_queue_head->reply_2); if (sender_ptr != NULL) *sender_ptr = proc_queue_head->sender_component; TTCN_Logger::Severity log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::MATCHING_PMSUCCESS:TTCN_Logger::MATCHING_PCSUCCESS; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::begin_event(log_sev); TTCN_Logger::log_event("Matching on port %s succeeded: ", port_name); getreply_template.log_match_reply(*proc_queue_head->reply_2); TTCN_Logger::end_event(); } log_sev = proc_queue_head->sender_component==SYSTEM_COMPREF?TTCN_Logger::PORTEVENT_PMIN:TTCN_Logger::PORTEVENT_PCIN; if (TTCN_Logger::log_this_event(log_sev)) { TTCN_Logger::log_procport_recv(port_name, TitanLoggerApiSimple::Port__oper::reply__op, proc_queue_head->sender_component, TRUE, (TTCN_Logger::begin_event(log_sev, TRUE), proc_queue_head->reply_2->log(), TTCN_Logger::end_event_log2str()), msg_head_count+1); } return ALT_YES; } } void STATSD__PROC__PT::incoming_call(const STATSD__reset_call& incoming_par, component sender_component) { if (!is_started) { if (is_halted) { TTCN_warning("A call that arrived on port %s has been discarded, because the port is not started.", port_name); return; } else { TTCN_error("Port %s is not started but a call has arrived on it.", port_name); } } proc_tail_count++; if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) { TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__call, port_name, sender_component, proc_tail_count, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PQUEUE, TRUE), TTCN_Logger::log_char(' '), incoming_par.log(), TTCN_Logger::end_event_log2str())); } proc_queue_item *new_item = new proc_queue_item; new_item->item_selection = CALL_0; new_item->call_0 = new STATSD__reset_call(incoming_par); new_item->sender_component = sender_component; append_to_proc_queue(new_item); } void STATSD__PROC__PT::incoming_call(const STATSD__snapshot_call& incoming_par, component sender_component) { if (!is_started) { if (is_halted) { TTCN_warning("A call that arrived on port %s has been discarded, because the port is not started.", port_name); return; } else { TTCN_error("Port %s is not started but a call has arrived on it.", port_name); } } proc_tail_count++; if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) { TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__call, port_name, sender_component, proc_tail_count, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PQUEUE, TRUE), TTCN_Logger::log_char(' '), incoming_par.log(), TTCN_Logger::end_event_log2str())); } proc_queue_item *new_item = new proc_queue_item; new_item->item_selection = CALL_1; new_item->call_1 = new STATSD__snapshot_call(incoming_par); new_item->sender_component = sender_component; append_to_proc_queue(new_item); } void STATSD__PROC__PT::incoming_call(const STATSD__expect_call& incoming_par, component sender_component) { if (!is_started) { if (is_halted) { TTCN_warning("A call that arrived on port %s has been discarded, because the port is not started.", port_name); return; } else { TTCN_error("Port %s is not started but a call has arrived on it.", port_name); } } proc_tail_count++; if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) { TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__call, port_name, sender_component, proc_tail_count, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PQUEUE, TRUE), TTCN_Logger::log_char(' '), incoming_par.log(), TTCN_Logger::end_event_log2str())); } proc_queue_item *new_item = new proc_queue_item; new_item->item_selection = CALL_2; new_item->call_2 = new STATSD__expect_call(incoming_par); new_item->sender_component = sender_component; append_to_proc_queue(new_item); } void STATSD__PROC__PT::incoming_reply(const STATSD__reset_reply& incoming_par, component sender_component) { if (!is_started) { if (is_halted) { TTCN_warning("A reply that arrived on port %s has been discarded, because the port is not started.", port_name); return; } else { TTCN_error("Port %s is not started but a reply has arrived on it.", port_name); } } proc_tail_count++; if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) { TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__reply, port_name, sender_component, proc_tail_count, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PQUEUE, TRUE), TTCN_Logger::log_char(' '), incoming_par.log(), TTCN_Logger::end_event_log2str())); } proc_queue_item *new_item = new proc_queue_item; new_item->item_selection = REPLY_0; new_item->reply_0 = new STATSD__reset_reply(incoming_par); new_item->sender_component = sender_component; append_to_proc_queue(new_item); } void STATSD__PROC__PT::incoming_reply(const STATSD__snapshot_reply& incoming_par, component sender_component) { if (!is_started) { if (is_halted) { TTCN_warning("A reply that arrived on port %s has been discarded, because the port is not started.", port_name); return; } else { TTCN_error("Port %s is not started but a reply has arrived on it.", port_name); } } proc_tail_count++; if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) { TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__reply, port_name, sender_component, proc_tail_count, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PQUEUE, TRUE), TTCN_Logger::log_char(' '), incoming_par.log(), TTCN_Logger::end_event_log2str())); } proc_queue_item *new_item = new proc_queue_item; new_item->item_selection = REPLY_1; new_item->reply_1 = new STATSD__snapshot_reply(incoming_par); new_item->sender_component = sender_component; append_to_proc_queue(new_item); } void STATSD__PROC__PT::incoming_reply(const STATSD__expect_reply& incoming_par, component sender_component) { if (!is_started) { if (is_halted) { TTCN_warning("A reply that arrived on port %s has been discarded, because the port is not started.", port_name); return; } else { TTCN_error("Port %s is not started but a reply has arrived on it.", port_name); } } proc_tail_count++; if (TTCN_Logger::log_this_event(TTCN_Logger::PORTEVENT_PQUEUE)) { TTCN_Logger::log_port_queue(TitanLoggerApiSimple::Port__Queue_operation::enqueue__reply, port_name, sender_component, proc_tail_count, CHARSTRING(0, NULL), (TTCN_Logger::begin_event(TTCN_Logger::PORTEVENT_PQUEUE, TRUE), TTCN_Logger::log_char(' '), incoming_par.log(), TTCN_Logger::end_event_log2str())); } proc_queue_item *new_item = new proc_queue_item; new_item->item_selection = REPLY_2; new_item->reply_2 = new STATSD__expect_reply(incoming_par); new_item->sender_component = sender_component; append_to_proc_queue(new_item); } boolean STATSD__PROC__PT::process_call(const char *signature_name, Text_Buf& incoming_buf, component sender_component) { if (!strcmp(signature_name, "@StatsD_Checker.STATSD_reset")) { STATSD__reset_call incoming_par; incoming_par.decode_text(incoming_buf); incoming_call(incoming_par, sender_component); return TRUE; } else if (!strcmp(signature_name, "@StatsD_Checker.STATSD_snapshot")) { STATSD__snapshot_call incoming_par; incoming_par.decode_text(incoming_buf); incoming_call(incoming_par, sender_component); return TRUE; } else if (!strcmp(signature_name, "@StatsD_Checker.STATSD_expect")) { STATSD__expect_call incoming_par; incoming_par.decode_text(incoming_buf); incoming_call(incoming_par, sender_component); return TRUE; } else return FALSE; } boolean STATSD__PROC__PT::process_reply(const char *signature_name, Text_Buf& incoming_buf, component sender_component) { if (!strcmp(signature_name, "@StatsD_Checker.STATSD_reset")) { STATSD__reset_reply incoming_par; incoming_par.decode_text(incoming_buf); incoming_reply(incoming_par, sender_component); return TRUE; } else if (!strcmp(signature_name, "@StatsD_Checker.STATSD_snapshot")) { STATSD__snapshot_reply incoming_par; incoming_par.decode_text(incoming_buf); incoming_reply(incoming_par, sender_component); return TRUE; } else if (!strcmp(signature_name, "@StatsD_Checker.STATSD_expect")) { STATSD__expect_reply incoming_par; incoming_par.decode_text(incoming_buf); incoming_reply(incoming_par, sender_component); return TRUE; } else return FALSE; } /* Bodies of functions, altsteps and testcases */ boolean operator==(null_type, const StatsDMetricKeys& other_value) { if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @StatsD_Checker.StatsDMetricKeys."); return other_value.val_ptr->n_elements == 0; } StatsDMetricKey_template ts__StatsDMetricKey(const CHARSTRING_template& name, const CHARSTRING_template& mtype) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 53, TTCN_Location::LOCATION_TEMPLATE, "ts_StatsDMetricKey"); StatsDMetricKey_template ret_val; ret_val.name() = name; ret_val.mtype() = mtype; return ret_val; } boolean operator==(null_type, const StatsDExpects& other_value) { if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @StatsD_Checker.StatsDExpects."); return other_value.val_ptr->n_elements == 0; } void main_(const CHARSTRING& statsd__host, const INTEGER& statsd__port, const FLOAT& statsd__timeout) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 103, TTCN_Location::LOCATION_FUNCTION, "main"); current_location.update_lineno(104); /* StatsD_Checker.ttcnpp, line 104 */ COMPONENT vc__conn; current_location.update_lineno(105); /* StatsD_Checker.ttcnpp, line 105 */ StatsDMetricKeys keys; current_location.update_lineno(106); /* StatsD_Checker.ttcnpp, line 106 */ BOOLEAN since__last__snapshot; current_location.update_lineno(107); /* StatsD_Checker.ttcnpp, line 107 */ StatsDExpects expects; current_location.update_lineno(108); /* StatsD_Checker.ttcnpp, line 108 */ BOOLEAN wait__converge; current_location.update_lineno(109); /* StatsD_Checker.ttcnpp, line 109 */ BOOLEAN use__snapshot; current_location.update_lineno(110); /* StatsD_Checker.ttcnpp, line 110 */ StatsD__Types::StatsDMetrics snapshot; current_location.update_lineno(111); /* StatsD_Checker.ttcnpp, line 111 */ Socket__API__Definitions::Result res; current_location.update_lineno(113); /* StatsD_Checker.ttcnpp, line 113 */ StatsD__Checker__CT_component_g__timeout = statsd__timeout; for ( ; ; ) { current_location.update_lineno(115); /* StatsD_Checker.ttcnpp, line 115 */ if (!(!(mp__enable__stats))) break; current_location.update_lineno(116); /* StatsD_Checker.ttcnpp, line 116 */ TTCN_Logger::log_str(TTCN_USER, "StatsD checker disabled by modulepar"); current_location.update_lineno(117); /* StatsD_Checker.ttcnpp, line 117 */ Osmocom__Types::f__sleep(3.6e3); } current_location.update_lineno(120); /* StatsD_Checker.ttcnpp, line 120 */ { Map_Params tmp_1(0); TTCN_Runtime::map_port(self, StatsD__Checker__CT_component_STATS.get_name(), SYSTEM_COMPREF, "STATS", tmp_1); } current_location.update_lineno(121); /* StatsD_Checker.ttcnpp, line 121 */ Socket__API__Definitions::ProtoTuple tmp_3; tmp_3.udp() = NULL_VALUE; res = StatsD__CodecPort__CtrlFunct::f__IPL4__listen(StatsD__Checker__CT_component_STATS, statsd__host, statsd__port, tmp_3, NULL_VALUE); current_location.update_lineno(122); /* StatsD_Checker.ttcnpp, line 122 */ { boolean tmp_7; { boolean tmp_4 = res.is_bound(); if(tmp_4) { const OPTIONAL< INTEGER >& tmp_5 = res.connId(); switch (tmp_5.get_selection()) { case OPTIONAL_UNBOUND: tmp_4 = FALSE; break; case OPTIONAL_OMIT: tmp_4 = FALSE; break; default: { const INTEGER& tmp_6 = (const INTEGER&) tmp_5; tmp_4 = tmp_6.is_present(); break;} } } tmp_7 = (!(tmp_4)); } if (tmp_7) { current_location.update_lineno(123); /* StatsD_Checker.ttcnpp, line 123 */ Misc__Helpers::f__shutdown(cs_0, 123, FAIL, cs_1); } } current_location.update_lineno(129); /* StatsD_Checker.ttcnpp, line 129 */ { Map_Params tmp_8(0); TTCN_Runtime::map_port(self, StatsD__Checker__CT_component_STATSVTY.get_name(), SYSTEM_COMPREF, "STATSVTY", tmp_8); } current_location.update_lineno(130); /* StatsD_Checker.ttcnpp, line 130 */ Osmocom__VTY__Functions::f__vty__set__prompts(StatsD__Checker__CT_component_STATSVTY, Osmocom__VTY__Functions::f__vty__set__prompts_prompt__prefix_defval); current_location.update_lineno(131); /* StatsD_Checker.ttcnpp, line 131 */ Osmocom__VTY__Functions::f__vty__transceive(StatsD__Checker__CT_component_STATSVTY, cs_2, Osmocom__VTY__Functions::f__vty__transceive_strict_defval); current_location.update_lineno(134); /* StatsD_Checker.ttcnpp, line 134 */ Osmocom__VTY__Functions::f__vty__transceive(StatsD__Checker__CT_component_STATSVTY, cs_3, Osmocom__VTY__Functions::f__vty__transceive_strict_defval); for ( ; ; ) { current_location.update_lineno(138); /* StatsD_Checker.ttcnpp, line 138 */ { tmp_9: alt_status tmp_9_alt_flag_0 = ALT_MAYBE; alt_status tmp_9_alt_flag_1 = ALT_MAYBE; alt_status tmp_9_alt_flag_2 = ALT_MAYBE; alt_status tmp_9_default_flag = ALT_MAYBE; boolean first_run = TRUE; TTCN_Snapshot::take_new(FALSE); for ( ; ; ) { if (tmp_9_alt_flag_0 == ALT_MAYBE) { current_location.update_lineno(139); /* StatsD_Checker.ttcnpp, line 139 */ tmp_9_alt_flag_0 = StatsD__Checker__CT_component_STATSD__PROC.getcall(STATSD__reset_template(NULL_VALUE), any_compref, STATSD__reset_call_redirect(), &(vc__conn), NULL, NULL); if (tmp_9_alt_flag_0 == ALT_YES) { current_location.update_lineno(141); /* StatsD_Checker.ttcnpp, line 141 */ Osmocom__VTY__Functions::f__vty__transceive(StatsD__Checker__CT_component_STATSVTY, cs_3, Osmocom__VTY__Functions::f__vty__transceive_strict_defval); current_location.update_lineno(142); /* StatsD_Checker.ttcnpp, line 142 */ StatsD__Checker__CT_component_STATSD__PROC.reply(STATSD__reset_template(NULL_VALUE), COMPONENT(vc__conn), NULL); break; } } if (tmp_9_alt_flag_1 == ALT_MAYBE) { current_location.update_lineno(148); /* StatsD_Checker.ttcnpp, line 148 */ { STATSD__snapshot_template tmp_10; tmp_10.keys() = ANY_VALUE; tmp_10.since__last__snapshot() = ANY_VALUE; tmp_9_alt_flag_1 = StatsD__Checker__CT_component_STATSD__PROC.getcall(tmp_10, any_compref, STATSD__snapshot_call_redirect(&(keys), &(since__last__snapshot)), &(vc__conn), NULL, NULL); } if (tmp_9_alt_flag_1 == ALT_YES) { current_location.update_lineno(149); /* StatsD_Checker.ttcnpp, line 149 */ snapshot = f__statsd__checker__snapshot(keys, since__last__snapshot); current_location.update_lineno(150); /* StatsD_Checker.ttcnpp, line 150 */ { STATSD__snapshot_template tmp_12; tmp_12.keys() = keys; tmp_12.since__last__snapshot() = since__last__snapshot; StatsD__Checker__CT_component_STATSD__PROC.reply(tmp_12.set_value_template(snapshot), COMPONENT(vc__conn), NULL); } break; } } if (tmp_9_alt_flag_2 == ALT_MAYBE) { current_location.update_lineno(152); /* StatsD_Checker.ttcnpp, line 152 */ { STATSD__expect_template tmp_13; tmp_13.expects() = ANY_VALUE; tmp_13.wait__converge() = ANY_VALUE; tmp_13.use__snapshot() = ANY_VALUE; tmp_13.snapshot() = ANY_VALUE; tmp_9_alt_flag_2 = StatsD__Checker__CT_component_STATSD__PROC.getcall(tmp_13, any_compref, STATSD__expect_call_redirect(&(expects), &(wait__converge), &(use__snapshot), &(snapshot)), &(vc__conn), NULL, NULL); } if (tmp_9_alt_flag_2 == ALT_YES) { current_location.update_lineno(153); /* StatsD_Checker.ttcnpp, line 153 */ BOOLEAN success(f__statsd__checker__expect(expects, wait__converge, use__snapshot, snapshot)); current_location.update_lineno(154); /* StatsD_Checker.ttcnpp, line 154 */ { STATSD__expect_template tmp_14; tmp_14.expects() = expects; tmp_14.wait__converge() = wait__converge; tmp_14.use__snapshot() = use__snapshot; tmp_14.snapshot() = snapshot; StatsD__Checker__CT_component_STATSD__PROC.reply(tmp_14.set_value_template(success), COMPONENT(vc__conn), NULL); } break; } } if (tmp_9_default_flag == ALT_MAYBE) { tmp_9_default_flag = TTCN_Default::try_altsteps(first_run); if (tmp_9_default_flag == ALT_YES || tmp_9_default_flag == ALT_BREAK) break; else if (tmp_9_default_flag == ALT_REPEAT) goto tmp_9; } current_location.update_lineno(138); /* StatsD_Checker.ttcnpp, line 138 */ if (tmp_9_alt_flag_0 == ALT_NO && tmp_9_alt_flag_1 == ALT_NO && tmp_9_alt_flag_2 == ALT_NO && tmp_9_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file StatsD_Checker.ttcnpp between lines 138 and 156."); TTCN_Snapshot::take_new(TRUE); first_run = FALSE; } } } } void start_main_(const COMPONENT& component_reference, const CHARSTRING& statsd__host, const INTEGER& statsd__port, const FLOAT& statsd__timeout) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function main("); statsd__host.log(); TTCN_Logger::log_event_str(", "); statsd__port.log(); TTCN_Logger::log_event_str(", "); statsd__timeout.log(); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "main", text_buf); statsd__host.encode_text(text_buf); statsd__port.encode_text(text_buf); statsd__timeout.encode_text(text_buf); TTCN_Runtime::send_start_component(text_buf); } BOOLEAN f__statsd__metrics__update__value(StatsD__Types::StatsDMetrics& metrics, General__Types::Booleans& seen, const StatsD__Types::StatsDMetric& it) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 161, TTCN_Location::LOCATION_FUNCTION, "f_statsd_metrics_update_value"); { current_location.update_lineno(163); /* StatsD_Checker.ttcnpp, line 163 */ INTEGER i(0); current_location.update_lineno(163); /* StatsD_Checker.ttcnpp, line 163 */ for ( ; ; ) { current_location.update_lineno(163); /* StatsD_Checker.ttcnpp, line 163 */ if (!(i < metrics.lengthof())) break; { current_location.update_lineno(164); /* StatsD_Checker.ttcnpp, line 164 */ { boolean tmp_16; tmp_16 = (const_cast< const StatsD__Types::StatsDMetric&>(it).name() != const_cast< const StatsD__Types::StatsDMetrics&>(metrics)[i].name()); if (!tmp_16) tmp_16 = (const_cast< const StatsD__Types::StatsDMetric&>(it).mtype() != const_cast< const StatsD__Types::StatsDMetrics&>(metrics)[i].mtype()); if (tmp_16) { current_location.update_lineno(165); /* StatsD_Checker.ttcnpp, line 165 */ goto tmp_15; } } current_location.update_lineno(167); /* StatsD_Checker.ttcnpp, line 167 */ metrics[i] = it; current_location.update_lineno(168); /* StatsD_Checker.ttcnpp, line 168 */ if (const_cast< const General__Types::Booleans&>(seen)[i]) { current_location.update_lineno(169); /* StatsD_Checker.ttcnpp, line 169 */ return FALSE; } else { current_location.update_lineno(171); /* StatsD_Checker.ttcnpp, line 171 */ seen[i] = TRUE; current_location.update_lineno(172); /* StatsD_Checker.ttcnpp, line 172 */ return TRUE; } } tmp_15: current_location.update_lineno(163); /* StatsD_Checker.ttcnpp, line 163 */ { INTEGER tmp_19; ++i; } } } current_location.update_lineno(175); /* StatsD_Checker.ttcnpp, line 175 */ return FALSE; } StatsD__Types::StatsDMetrics f__statsd__checker__snapshot(const StatsDMetricKeys& keys, const BOOLEAN& since__last__snapshot) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 179, TTCN_Location::LOCATION_FUNCTION, "f_statsd_checker_snapshot"); current_location.update_lineno(180); /* StatsD_Checker.ttcnpp, line 180 */ StatsD__Types::StatsDMessage msg; current_location.update_lineno(181); /* StatsD_Checker.ttcnpp, line 181 */ StatsD__Types::StatsDMetrics metrics(NULL_VALUE); current_location.update_lineno(182); /* StatsD_Checker.ttcnpp, line 182 */ General__Types::Booleans seen(NULL_VALUE); current_location.update_lineno(183); /* StatsD_Checker.ttcnpp, line 183 */ INTEGER seen__remain(0); { current_location.update_lineno(185); /* StatsD_Checker.ttcnpp, line 185 */ INTEGER i(0); current_location.update_lineno(185); /* StatsD_Checker.ttcnpp, line 185 */ for ( ; ; ) { current_location.update_lineno(185); /* StatsD_Checker.ttcnpp, line 185 */ if (!(i < keys.lengthof())) break; current_location.update_lineno(186); /* StatsD_Checker.ttcnpp, line 186 */ { StatsD__Types::StatsDMetrics tmp_20; { StatsD__Types::StatsDMetrics tmp_21; tmp_21.set_size(1); tmp_21[0] = StatsD__Types::ts__StatsDMetric(CHARSTRING_template(const_cast< const StatsDMetricKeys&>(keys)[i].name()), INTEGER_template(0), CHARSTRING_template(const_cast< const StatsDMetricKeys&>(keys)[i].mtype()), StatsD__Types::ts__StatsDMetric_srate_defval).valueof(); tmp_20 = (metrics + tmp_21); } metrics = tmp_20; } current_location.update_lineno(187); /* StatsD_Checker.ttcnpp, line 187 */ { General__Types::Booleans tmp_22; { General__Types::Booleans tmp_23; tmp_23.set_size(1); tmp_23[0] = FALSE; tmp_22 = (seen + tmp_23); } seen = tmp_22; } current_location.update_lineno(188); /* StatsD_Checker.ttcnpp, line 188 */ { INTEGER tmp_24; ++seen__remain; } current_location.update_lineno(185); /* StatsD_Checker.ttcnpp, line 185 */ { INTEGER tmp_25; ++i; } } } current_location.update_lineno(191); /* StatsD_Checker.ttcnpp, line 191 */ if ((!(since__last__snapshot))) { current_location.update_lineno(192); /* StatsD_Checker.ttcnpp, line 192 */ StatsD__Checker__CT_component_STATS.clear(); } current_location.update_lineno(195); /* StatsD_Checker.ttcnpp, line 195 */ Osmocom__VTY__Functions::f__vty__transceive(StatsD__Checker__CT_component_STATSVTY, cs_4, Osmocom__VTY__Functions::f__vty__transceive_strict_defval); current_location.update_lineno(198); /* StatsD_Checker.ttcnpp, line 198 */ StatsD__Checker__CT_component_T__statsd.start(StatsD__Checker__CT_component_g__timeout); for ( ; ; ) { current_location.update_lineno(199); /* StatsD_Checker.ttcnpp, line 199 */ if (!(seen__remain > 0)) break; current_location.update_lineno(200); /* StatsD_Checker.ttcnpp, line 200 */ StatsD__CodecPort::StatsD__RecvFrom rf; current_location.update_lineno(201); /* StatsD_Checker.ttcnpp, line 201 */ { tmp_26: alt_status tmp_26_alt_flag_0 = ALT_MAYBE; alt_status tmp_26_alt_flag_1 = ALT_MAYBE; alt_status tmp_26_default_flag = ALT_MAYBE; boolean first_run = TRUE; TTCN_Snapshot::take_new(FALSE); for ( ; ; ) { if (tmp_26_alt_flag_0 == ALT_MAYBE) { current_location.update_lineno(202); /* StatsD_Checker.ttcnpp, line 202 */ tmp_26_alt_flag_0 = StatsD__Checker__CT_component_STATS.receive(StatsD__CodecPort::tr__StatsD__RecvFrom(INTEGER_template(ANY_VALUE), StatsD__Types::StatsDMessage_template(ANY_VALUE)), &(rf), any_compref, NULL, NULL, NULL); if (tmp_26_alt_flag_0 == ALT_YES) { current_location.update_lineno(203); /* StatsD_Checker.ttcnpp, line 203 */ msg = const_cast< const StatsD__CodecPort::StatsD__RecvFrom&>(rf).msg(); break; } } if (tmp_26_alt_flag_1 == ALT_MAYBE) { current_location.update_lineno(205); /* StatsD_Checker.ttcnpp, line 205 */ tmp_26_alt_flag_1 = StatsD__Checker__CT_component_T__statsd.timeout(NULL); if (tmp_26_alt_flag_1 == ALT_YES) { { current_location.update_lineno(206); /* StatsD_Checker.ttcnpp, line 206 */ INTEGER i(0); current_location.update_lineno(206); /* StatsD_Checker.ttcnpp, line 206 */ for ( ; ; ) { current_location.update_lineno(206); /* StatsD_Checker.ttcnpp, line 206 */ if (!(i < metrics.lengthof())) break; current_location.update_lineno(208); /* StatsD_Checker.ttcnpp, line 208 */ if ((!(const_cast< const General__Types::Booleans&>(seen)[i]))) { current_location.update_lineno(209); /* StatsD_Checker.ttcnpp, line 209 */ try { TTCN_Logger::begin_event(TTCN_USER); TTCN_Logger::log_event_str("Timeout waiting for "); const_cast< const StatsD__Types::StatsDMetrics&>(metrics)[i].name().log(); TTCN_Logger::end_event(); } catch (...) { TTCN_Logger::finish_event(); throw; } } current_location.update_lineno(206); /* StatsD_Checker.ttcnpp, line 206 */ { INTEGER tmp_28; ++i; } } } current_location.update_lineno(212); /* StatsD_Checker.ttcnpp, line 212 */ Misc__Helpers::f__shutdown(cs_0, 212, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Timeout waiting for metrics: "),keys.log(),seen.log(),TTCN_Logger::end_event_log2str())); break; } } if (tmp_26_default_flag == ALT_MAYBE) { tmp_26_default_flag = TTCN_Default::try_altsteps(first_run); if (tmp_26_default_flag == ALT_YES || tmp_26_default_flag == ALT_BREAK) break; else if (tmp_26_default_flag == ALT_REPEAT) goto tmp_26; } current_location.update_lineno(201); /* StatsD_Checker.ttcnpp, line 201 */ if (tmp_26_alt_flag_0 == ALT_NO && tmp_26_alt_flag_1 == ALT_NO && tmp_26_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file StatsD_Checker.ttcnpp between lines 201 and 215."); TTCN_Snapshot::take_new(TRUE); first_run = FALSE; } } { current_location.update_lineno(217); /* StatsD_Checker.ttcnpp, line 217 */ INTEGER i(0); current_location.update_lineno(217); /* StatsD_Checker.ttcnpp, line 217 */ for ( ; ; ) { current_location.update_lineno(217); /* StatsD_Checker.ttcnpp, line 217 */ if (!(i < msg.lengthof())) break; current_location.update_lineno(218); /* StatsD_Checker.ttcnpp, line 218 */ StatsD__Types::StatsDMetric metric(const_cast< const StatsD__Types::StatsDMessage&>(msg)[i]); current_location.update_lineno(219); /* StatsD_Checker.ttcnpp, line 219 */ if (f__statsd__metrics__update__value(metrics, seen, metric)) { current_location.update_lineno(220); /* StatsD_Checker.ttcnpp, line 220 */ { INTEGER tmp_29; --seen__remain; } } current_location.update_lineno(217); /* StatsD_Checker.ttcnpp, line 217 */ { INTEGER tmp_30; ++i; } } } } current_location.update_lineno(224); /* StatsD_Checker.ttcnpp, line 224 */ StatsD__Checker__CT_component_T__statsd.stop(); current_location.update_lineno(226); /* StatsD_Checker.ttcnpp, line 226 */ return metrics; } void start_f__statsd__checker__snapshot(const COMPONENT& component_reference, const StatsDMetricKeys& keys, const BOOLEAN& since__last__snapshot) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_checker_snapshot("); keys.log(); TTCN_Logger::log_event_str(", "); since__last__snapshot.log(); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "f_statsd_checker_snapshot", text_buf); keys.encode_text(text_buf); since__last__snapshot.encode_text(text_buf); TTCN_Runtime::send_start_component(text_buf); } BOOLEAN get__val__from__snapshot(INTEGER& val, const StatsD__Types::StatsDMetric& metric, const StatsD__Types::StatsDMetrics& snapshot) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 229, TTCN_Location::LOCATION_FUNCTION, "get_val_from_snapshot"); { current_location.update_lineno(231); /* StatsD_Checker.ttcnpp, line 231 */ INTEGER i(0); current_location.update_lineno(231); /* StatsD_Checker.ttcnpp, line 231 */ for ( ; ; ) { current_location.update_lineno(231); /* StatsD_Checker.ttcnpp, line 231 */ if (!(i < snapshot.lengthof())) break; { current_location.update_lineno(232); /* StatsD_Checker.ttcnpp, line 232 */ { boolean tmp_32; tmp_32 = (const_cast< const StatsD__Types::StatsDMetric&>(metric).name() != const_cast< const StatsD__Types::StatsDMetrics&>(snapshot)[i].name()); if (!tmp_32) tmp_32 = (const_cast< const StatsD__Types::StatsDMetric&>(metric).mtype() != const_cast< const StatsD__Types::StatsDMetrics&>(snapshot)[i].mtype()); if (tmp_32) { current_location.update_lineno(233); /* StatsD_Checker.ttcnpp, line 233 */ goto tmp_31; } } current_location.update_lineno(235); /* StatsD_Checker.ttcnpp, line 235 */ val = const_cast< const StatsD__Types::StatsDMetrics&>(snapshot)[i].val(); current_location.update_lineno(236); /* StatsD_Checker.ttcnpp, line 236 */ return TRUE; } tmp_31: current_location.update_lineno(231); /* StatsD_Checker.ttcnpp, line 231 */ { INTEGER tmp_34; ++i; } } } current_location.update_lineno(238); /* StatsD_Checker.ttcnpp, line 238 */ return FALSE; } BOOLEAN f__compare__expect(const StatsD__Types::StatsDMetric& metric, const StatsDExpect& expect, const BOOLEAN& use__snapshot, const StatsD__Types::StatsDMetrics& snapshot) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 242, TTCN_Location::LOCATION_FUNCTION, "f_compare_expect"); current_location.update_lineno(246); /* StatsD_Checker.ttcnpp, line 246 */ INTEGER val(0); current_location.update_lineno(247); /* StatsD_Checker.ttcnpp, line 247 */ { boolean tmp_35; tmp_35 = (const_cast< const StatsD__Types::StatsDMetric&>(metric).name() != const_cast< const StatsDExpect&>(expect).name()); if (!tmp_35) tmp_35 = (const_cast< const StatsD__Types::StatsDMetric&>(metric).mtype() != const_cast< const StatsDExpect&>(expect).mtype()); if (tmp_35) { current_location.update_lineno(248); /* StatsD_Checker.ttcnpp, line 248 */ return FALSE; } } current_location.update_lineno(250); /* StatsD_Checker.ttcnpp, line 250 */ if (use__snapshot) { current_location.update_lineno(251); /* StatsD_Checker.ttcnpp, line 251 */ INTEGER prev__val(0); current_location.update_lineno(252); /* StatsD_Checker.ttcnpp, line 252 */ if ((!(get__val__from__snapshot(prev__val, metric, snapshot)))) { current_location.update_lineno(253); /* StatsD_Checker.ttcnpp, line 253 */ Misc__Helpers::f__shutdown(cs_0, 253, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Metric "),const_cast< const StatsD__Types::StatsDMetric&>(metric).name().log(),TTCN_Logger::log_event_str(" not found in snapshot "),snapshot.log(),TTCN_Logger::end_event_log2str())); } current_location.update_lineno(256); /* StatsD_Checker.ttcnpp, line 256 */ val = (const_cast< const StatsD__Types::StatsDMetric&>(metric).val() - prev__val); } else { current_location.update_lineno(258); /* StatsD_Checker.ttcnpp, line 258 */ val = const_cast< const StatsD__Types::StatsDMetric&>(metric).val(); } current_location.update_lineno(261); /* StatsD_Checker.ttcnpp, line 261 */ { boolean tmp_38; tmp_38 = (val < const_cast< const StatsDExpect&>(expect).min()); if (!tmp_38) tmp_38 = (val > const_cast< const StatsDExpect&>(expect).max()); if (tmp_38) { current_location.update_lineno(262); /* StatsD_Checker.ttcnpp, line 262 */ return FALSE; } } current_location.update_lineno(264); /* StatsD_Checker.ttcnpp, line 264 */ return TRUE; } StatsDExpectResult f__statsd__checker__metric__expects(const StatsDExpects& expects, const StatsD__Types::StatsDMetric& metric, const BOOLEAN& use__snapshot, const StatsD__Types::StatsDMetrics& snapshot) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 267, TTCN_Location::LOCATION_FUNCTION, "f_statsd_checker_metric_expects"); current_location.update_lineno(272); /* StatsD_Checker.ttcnpp, line 272 */ StatsDExpectResult result; result.kind() = StatsDResultType::e__NotFound; result.idx() = -1; { current_location.update_lineno(277); /* StatsD_Checker.ttcnpp, line 277 */ INTEGER i(0); current_location.update_lineno(277); /* StatsD_Checker.ttcnpp, line 277 */ for ( ; ; ) { current_location.update_lineno(277); /* StatsD_Checker.ttcnpp, line 277 */ if (!(i < expects.lengthof())) break; { current_location.update_lineno(278); /* StatsD_Checker.ttcnpp, line 278 */ StatsDExpect exp(const_cast< const StatsDExpects&>(expects)[i]); current_location.update_lineno(279); /* StatsD_Checker.ttcnpp, line 279 */ if ((const_cast< const StatsDExpect&>(exp).name() != const_cast< const StatsD__Types::StatsDMetric&>(metric).name())) { current_location.update_lineno(280); /* StatsD_Checker.ttcnpp, line 280 */ goto tmp_39; } current_location.update_lineno(282); /* StatsD_Checker.ttcnpp, line 282 */ if ((!(f__compare__expect(metric, exp, use__snapshot, snapshot)))) { current_location.update_lineno(283); /* StatsD_Checker.ttcnpp, line 283 */ try { TTCN_Logger::begin_event(TTCN_USER); TTCN_Logger::log_event_str("EXP mismatch: "); metric.log(); TTCN_Logger::log_event_str(" vs exp "); exp.log(); TTCN_Logger::log_event_str(" | use_snapshot="); use__snapshot.log(); TTCN_Logger::log_event_str(", snapshot="); snapshot.log(); TTCN_Logger::end_event(); } catch (...) { TTCN_Logger::finish_event(); throw; } current_location.update_lineno(284); /* StatsD_Checker.ttcnpp, line 284 */ result.kind() = StatsDResultType::e__Mismatched; result.idx() = i; current_location.update_lineno(288); /* StatsD_Checker.ttcnpp, line 288 */ break; } else { current_location.update_lineno(290); /* StatsD_Checker.ttcnpp, line 290 */ try { TTCN_Logger::begin_event(TTCN_USER); TTCN_Logger::log_event_str("EXP match: "); metric.log(); TTCN_Logger::log_event_str(" vs exp "); exp.log(); TTCN_Logger::end_event(); } catch (...) { TTCN_Logger::finish_event(); throw; } current_location.update_lineno(291); /* StatsD_Checker.ttcnpp, line 291 */ result.kind() = StatsDResultType::e__Matched; result.idx() = i; current_location.update_lineno(295); /* StatsD_Checker.ttcnpp, line 295 */ break; } } tmp_39: current_location.update_lineno(277); /* StatsD_Checker.ttcnpp, line 277 */ { INTEGER tmp_42; ++i; } } } current_location.update_lineno(298); /* StatsD_Checker.ttcnpp, line 298 */ return result; } BOOLEAN using__poll__mode() { TTCN_Location current_location("StatsD_Checker.ttcnpp", 301, TTCN_Location::LOCATION_FUNCTION, "using_poll_mode"); current_location.update_lineno(304); /* StatsD_Checker.ttcnpp, line 304 */ return TRUE; } void start_using__poll__mode(const COMPONENT& component_reference) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function using_poll_mode("); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "using_poll_mode", text_buf); TTCN_Runtime::send_start_component(text_buf); } void poll__stats__report() { TTCN_Location current_location("StatsD_Checker.ttcnpp", 310, TTCN_Location::LOCATION_FUNCTION, "poll_stats_report"); current_location.update_lineno(313); /* StatsD_Checker.ttcnpp, line 313 */ Osmocom__VTY__Functions::f__vty__transceive(StatsD__Checker__CT_component_STATSVTY, cs_4, Osmocom__VTY__Functions::f__vty__transceive_strict_defval); } void start_poll__stats__report(const COMPONENT& component_reference) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function poll_stats_report("); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "poll_stats_report", text_buf); TTCN_Runtime::send_start_component(text_buf); } BOOLEAN f__statsd__checker__expect(const StatsDExpects& expects, const BOOLEAN& wait__converge, const BOOLEAN& use__snapshot, const StatsD__Types::StatsDMetrics& snapshot) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 319, TTCN_Location::LOCATION_FUNCTION, "f_statsd_checker_expect"); current_location.update_lineno(323); /* StatsD_Checker.ttcnpp, line 323 */ DEFAULT t; current_location.update_lineno(324); /* StatsD_Checker.ttcnpp, line 324 */ StatsD__Types::StatsDMessage msg; current_location.update_lineno(325); /* StatsD_Checker.ttcnpp, line 325 */ StatsDExpectResult res; current_location.update_lineno(326); /* StatsD_Checker.ttcnpp, line 326 */ General__Types::Booleans matched(NULL_VALUE); current_location.update_lineno(327); /* StatsD_Checker.ttcnpp, line 327 */ INTEGER matched__remain(0); current_location.update_lineno(328); /* StatsD_Checker.ttcnpp, line 328 */ BOOLEAN poll(using__poll__mode()); current_location.update_lineno(329); /* StatsD_Checker.ttcnpp, line 329 */ TIMER T__poll__converge("T_poll_converge"); { current_location.update_lineno(331); /* StatsD_Checker.ttcnpp, line 331 */ INTEGER i(0); current_location.update_lineno(331); /* StatsD_Checker.ttcnpp, line 331 */ for ( ; ; ) { current_location.update_lineno(331); /* StatsD_Checker.ttcnpp, line 331 */ if (!(i < expects.lengthof())) break; current_location.update_lineno(332); /* StatsD_Checker.ttcnpp, line 332 */ { General__Types::Booleans tmp_43; { General__Types::Booleans tmp_44; tmp_44.set_size(1); tmp_44[0] = FALSE; tmp_43 = (matched + tmp_44); } matched = tmp_43; } current_location.update_lineno(333); /* StatsD_Checker.ttcnpp, line 333 */ { INTEGER tmp_45; ++matched__remain; } current_location.update_lineno(331); /* StatsD_Checker.ttcnpp, line 331 */ { INTEGER tmp_46; ++i; } } } current_location.update_lineno(337); /* StatsD_Checker.ttcnpp, line 337 */ StatsD__Checker__CT_component_STATS.clear(); current_location.update_lineno(339); /* StatsD_Checker.ttcnpp, line 339 */ if (poll) { current_location.update_lineno(340); /* StatsD_Checker.ttcnpp, line 340 */ poll__stats__report(); } current_location.update_lineno(343); /* StatsD_Checker.ttcnpp, line 343 */ StatsD__Checker__CT_component_T__statsd.start(StatsD__Checker__CT_component_g__timeout); for ( ; ; ) { current_location.update_lineno(344); /* StatsD_Checker.ttcnpp, line 344 */ if (!(matched__remain > 0)) break; current_location.update_lineno(345); /* StatsD_Checker.ttcnpp, line 345 */ StatsD__CodecPort::StatsD__RecvFrom rf; current_location.update_lineno(346); /* StatsD_Checker.ttcnpp, line 346 */ { tmp_47: alt_status tmp_47_alt_flag_0 = ALT_MAYBE; alt_status tmp_47_alt_flag_1 = ALT_UNCHECKED; alt_status tmp_47_alt_flag_2 = ALT_MAYBE; alt_status tmp_47_default_flag = ALT_MAYBE; boolean first_run = TRUE; TTCN_Snapshot::take_new(FALSE); for ( ; ; ) { if (tmp_47_alt_flag_0 == ALT_MAYBE) { current_location.update_lineno(347); /* StatsD_Checker.ttcnpp, line 347 */ tmp_47_alt_flag_0 = StatsD__Checker__CT_component_STATS.receive(StatsD__CodecPort::tr__StatsD__RecvFrom(INTEGER_template(ANY_VALUE), StatsD__Types::StatsDMessage_template(ANY_VALUE)), &(rf), any_compref, NULL, NULL, NULL); if (tmp_47_alt_flag_0 == ALT_YES) { current_location.update_lineno(348); /* StatsD_Checker.ttcnpp, line 348 */ msg = const_cast< const StatsD__CodecPort::StatsD__RecvFrom&>(rf).msg(); current_location.update_lineno(349); /* StatsD_Checker.ttcnpp, line 349 */ if ((poll && wait__converge)) { current_location.update_lineno(350); /* StatsD_Checker.ttcnpp, line 350 */ T__poll__converge.stop(); current_location.update_lineno(351); /* StatsD_Checker.ttcnpp, line 351 */ T__poll__converge.start(1.0); } break; } } if (tmp_47_alt_flag_1 == ALT_UNCHECKED) { current_location.update_lineno(354); /* StatsD_Checker.ttcnpp, line 354 */ if ((poll && wait__converge)) tmp_47_alt_flag_1 = ALT_MAYBE; else tmp_47_alt_flag_1 = ALT_NO; } if (tmp_47_alt_flag_1 == ALT_MAYBE) { current_location.update_lineno(354); /* StatsD_Checker.ttcnpp, line 354 */ tmp_47_alt_flag_1 = T__poll__converge.timeout(NULL); if (tmp_47_alt_flag_1 == ALT_YES) { current_location.update_lineno(355); /* StatsD_Checker.ttcnpp, line 355 */ poll__stats__report(); current_location.update_lineno(356); /* StatsD_Checker.ttcnpp, line 356 */ goto tmp_47; } } if (tmp_47_alt_flag_2 == ALT_MAYBE) { current_location.update_lineno(358); /* StatsD_Checker.ttcnpp, line 358 */ tmp_47_alt_flag_2 = StatsD__Checker__CT_component_T__statsd.timeout(NULL); if (tmp_47_alt_flag_2 == ALT_YES) { { current_location.update_lineno(359); /* StatsD_Checker.ttcnpp, line 359 */ INTEGER i(0); current_location.update_lineno(359); /* StatsD_Checker.ttcnpp, line 359 */ for ( ; ; ) { current_location.update_lineno(359); /* StatsD_Checker.ttcnpp, line 359 */ if (!(i < expects.lengthof())) break; current_location.update_lineno(361); /* StatsD_Checker.ttcnpp, line 361 */ if ((!(const_cast< const General__Types::Booleans&>(matched)[i]))) { current_location.update_lineno(362); /* StatsD_Checker.ttcnpp, line 362 */ try { TTCN_Logger::begin_event(TTCN_USER); TTCN_Logger::log_event_str("Timeout waiting for "); const_cast< const StatsDExpects&>(expects)[i].name().log(); TTCN_Logger::log_event_str(" (min: "); const_cast< const StatsDExpects&>(expects)[i].min().log(); TTCN_Logger::log_event_str(", max: "); const_cast< const StatsDExpects&>(expects)[i].max().log(); TTCN_Logger::log_char(')'); TTCN_Logger::end_event(); } catch (...) { TTCN_Logger::finish_event(); throw; } } current_location.update_lineno(359); /* StatsD_Checker.ttcnpp, line 359 */ { INTEGER tmp_49; ++i; } } } current_location.update_lineno(366); /* StatsD_Checker.ttcnpp, line 366 */ TTCN_Runtime::setverdict(FAIL,(TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Timeout waiting for metrics"),TTCN_Logger::end_event_log2str())); current_location.update_lineno(367); /* StatsD_Checker.ttcnpp, line 367 */ return FALSE; } } if (tmp_47_default_flag == ALT_MAYBE) { tmp_47_default_flag = TTCN_Default::try_altsteps(first_run); if (tmp_47_default_flag == ALT_YES || tmp_47_default_flag == ALT_BREAK) break; else if (tmp_47_default_flag == ALT_REPEAT) goto tmp_47; } current_location.update_lineno(346); /* StatsD_Checker.ttcnpp, line 346 */ if (tmp_47_alt_flag_0 == ALT_NO && tmp_47_alt_flag_1 == ALT_NO && tmp_47_alt_flag_2 == ALT_NO && tmp_47_default_flag == ALT_NO) TTCN_error("None of the branches can be chosen in the alt statement in file StatsD_Checker.ttcnpp between lines 346 and 369."); TTCN_Snapshot::take_new(TRUE); first_run = FALSE; } } { current_location.update_lineno(371); /* StatsD_Checker.ttcnpp, line 371 */ INTEGER i(0); current_location.update_lineno(371); /* StatsD_Checker.ttcnpp, line 371 */ for ( ; ; ) { current_location.update_lineno(371); /* StatsD_Checker.ttcnpp, line 371 */ if (!(i < msg.lengthof())) break; { current_location.update_lineno(372); /* StatsD_Checker.ttcnpp, line 372 */ StatsD__Types::StatsDMetric metric(const_cast< const StatsD__Types::StatsDMessage&>(msg)[i]); current_location.update_lineno(373); /* StatsD_Checker.ttcnpp, line 373 */ res = f__statsd__checker__metric__expects(expects, metric, use__snapshot, snapshot); current_location.update_lineno(374); /* StatsD_Checker.ttcnpp, line 374 */ if ((const_cast< const StatsDExpectResult&>(res).kind() == StatsDResultType::e__NotFound)) { current_location.update_lineno(375); /* StatsD_Checker.ttcnpp, line 375 */ goto tmp_50; } current_location.update_lineno(377); /* StatsD_Checker.ttcnpp, line 377 */ if ((const_cast< const StatsDExpectResult&>(res).kind() == StatsDResultType::e__Mismatched)) { current_location.update_lineno(378); /* StatsD_Checker.ttcnpp, line 378 */ { boolean tmp_52; tmp_52 = wait__converge; if (tmp_52) tmp_52 = (!(const_cast< const General__Types::Booleans&>(matched)[const_cast< const StatsDExpectResult&>(res).idx()])); if (tmp_52) { current_location.update_lineno(379); /* StatsD_Checker.ttcnpp, line 379 */ try { TTCN_Logger::begin_event(TTCN_USER); TTCN_Logger::log_event_str("Waiting convergence: Ignoring metric mismatch metric="); metric.log(); TTCN_Logger::log_event_str(" expect="); const_cast< const StatsDExpects&>(expects)[const_cast< const StatsDExpectResult&>(res).idx()].log(); TTCN_Logger::end_event(); } catch (...) { TTCN_Logger::finish_event(); throw; } current_location.update_lineno(380); /* StatsD_Checker.ttcnpp, line 380 */ goto tmp_50; } } current_location.update_lineno(382); /* StatsD_Checker.ttcnpp, line 382 */ try { TTCN_Logger::begin_event(TTCN_USER); TTCN_Logger::log_event_str("Metric: "); metric.log(); TTCN_Logger::end_event(); } catch (...) { TTCN_Logger::finish_event(); throw; } current_location.update_lineno(383); /* StatsD_Checker.ttcnpp, line 383 */ try { TTCN_Logger::begin_event(TTCN_USER); TTCN_Logger::log_event_str("Expect: "); const_cast< const StatsDExpects&>(expects)[const_cast< const StatsDExpectResult&>(res).idx()].log(); TTCN_Logger::end_event(); } catch (...) { TTCN_Logger::finish_event(); throw; } current_location.update_lineno(384); /* StatsD_Checker.ttcnpp, line 384 */ TTCN_Runtime::setverdict(FAIL,(TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Metric failed expectation "),metric.log(),TTCN_Logger::log_event_str(" vs "),const_cast< const StatsDExpects&>(expects)[const_cast< const StatsDExpectResult&>(res).idx()].log(),TTCN_Logger::end_event_log2str())); current_location.update_lineno(385); /* StatsD_Checker.ttcnpp, line 385 */ return FALSE; } current_location.update_lineno(387); /* StatsD_Checker.ttcnpp, line 387 */ if ((const_cast< const StatsDExpectResult&>(res).kind() == StatsDResultType::e__Matched)) { current_location.update_lineno(388); /* StatsD_Checker.ttcnpp, line 388 */ if ((!(const_cast< const General__Types::Booleans&>(matched)[const_cast< const StatsDExpectResult&>(res).idx()]))) { current_location.update_lineno(389); /* StatsD_Checker.ttcnpp, line 389 */ matched[const_cast< const StatsDExpectResult&>(res).idx()] = TRUE; current_location.update_lineno(390); /* StatsD_Checker.ttcnpp, line 390 */ { INTEGER tmp_54; --matched__remain; } } current_location.update_lineno(392); /* StatsD_Checker.ttcnpp, line 392 */ goto tmp_50; } } tmp_50: current_location.update_lineno(371); /* StatsD_Checker.ttcnpp, line 371 */ { INTEGER tmp_55; ++i; } } } } current_location.update_lineno(396); /* StatsD_Checker.ttcnpp, line 396 */ T__poll__converge.stop(); current_location.update_lineno(397); /* StatsD_Checker.ttcnpp, line 397 */ StatsD__Checker__CT_component_T__statsd.stop(); current_location.update_lineno(398); /* StatsD_Checker.ttcnpp, line 398 */ return TRUE; } void start_f__statsd__checker__expect(const COMPONENT& component_reference, const StatsDExpects& expects, const BOOLEAN& wait__converge, const BOOLEAN& use__snapshot, const StatsD__Types::StatsDMetrics& snapshot) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_checker_expect("); expects.log(); TTCN_Logger::log_event_str(", "); wait__converge.log(); TTCN_Logger::log_event_str(", "); use__snapshot.log(); TTCN_Logger::log_event_str(", "); snapshot.log(); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "f_statsd_checker_expect", text_buf); expects.encode_text(text_buf); wait__converge.encode_text(text_buf); use__snapshot.encode_text(text_buf); snapshot.encode_text(text_buf); TTCN_Runtime::send_start_component(text_buf); } void f__init__statsd(const CHARSTRING& id, COMPONENT& vc__STATSD, const CHARSTRING& local__addr, const INTEGER& local__port, const FLOAT& statsd__timeout) { CHARSTRING id_shadow(id); TTCN_Location current_location("StatsD_Checker.ttcnpp", 401, TTCN_Location::LOCATION_FUNCTION, "f_init_statsd"); current_location.update_lineno(402); /* StatsD_Checker.ttcnpp, line 402 */ { CHARSTRING tmp_56; tmp_56 = (id_shadow + cs_5); id_shadow = tmp_56; } current_location.update_lineno(404); /* StatsD_Checker.ttcnpp, line 404 */ vc__STATSD = TTCN_Runtime::create_component("StatsD_Checker", "StatsD_Checker_CT", id_shadow, NULL, FALSE); current_location.update_lineno(405); /* StatsD_Checker.ttcnpp, line 405 */ start_main_(vc__STATSD, local__addr, local__port, statsd__timeout); } void f__statsd__reset() { TTCN_Location current_location("StatsD_Checker.ttcnpp", 410, TTCN_Location::LOCATION_FUNCTION, "f_statsd_reset"); current_location.update_lineno(411); /* StatsD_Checker.ttcnpp, line 411 */ if ((!(mp__enable__stats))) { current_location.update_lineno(412); /* StatsD_Checker.ttcnpp, line 412 */ return; } current_location.update_lineno(415); /* StatsD_Checker.ttcnpp, line 415 */ StatsD__ConnHdlr_component_STATSD__PROC.call(STATSD__reset_template(NULL_VALUE), FALSE, NULL); { alt_status tmp_58_alt_flag_0 = ALT_MAYBE; current_location.update_lineno(415); /* StatsD_Checker.ttcnpp, line 415 */ TTCN_Snapshot::take_new(FALSE); for ( ; ; ) { if (tmp_58_alt_flag_0 == ALT_MAYBE) { current_location.update_lineno(416); /* StatsD_Checker.ttcnpp, line 416 */ tmp_58_alt_flag_0 = StatsD__ConnHdlr_component_STATSD__PROC.getreply(STATSD__reset_template(NULL_VALUE), any_compref, STATSD__reset_reply_redirect(), NULL, NULL, NULL); if (tmp_58_alt_flag_0 == ALT_YES) break; } current_location.update_lineno(415); /* StatsD_Checker.ttcnpp, line 415 */ if (tmp_58_alt_flag_0 == ALT_NO) TTCN_error("None of the branches can be chosen in the response and exception handling part of call statement in file StatsD_Checker.ttcnpp between lines 415 and 417."); TTCN_Snapshot::take_new(TRUE); } } } void start_f__statsd__reset(const COMPONENT& component_reference) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_reset("); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "f_statsd_reset", text_buf); TTCN_Runtime::send_start_component(text_buf); } StatsDMetricKeys f__statsd__keys__from__expect(const StatsDExpects& expects) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 421, TTCN_Location::LOCATION_FUNCTION, "f_statsd_keys_from_expect"); current_location.update_lineno(423); /* StatsD_Checker.ttcnpp, line 423 */ StatsDMetricKeys keys(NULL_VALUE); { current_location.update_lineno(424); /* StatsD_Checker.ttcnpp, line 424 */ INTEGER i(0); current_location.update_lineno(424); /* StatsD_Checker.ttcnpp, line 424 */ for ( ; ; ) { current_location.update_lineno(424); /* StatsD_Checker.ttcnpp, line 424 */ if (!(i < expects.lengthof())) break; current_location.update_lineno(425); /* StatsD_Checker.ttcnpp, line 425 */ { StatsDMetricKeys tmp_59; { StatsDMetricKeys tmp_60; tmp_60.set_size(1); tmp_60[0] = ts__StatsDMetricKey(CHARSTRING_template(const_cast< const StatsDExpects&>(expects)[i].name()), CHARSTRING_template(const_cast< const StatsDExpects&>(expects)[i].mtype())).valueof(); tmp_59 = (keys + tmp_60); } keys = tmp_59; } current_location.update_lineno(424); /* StatsD_Checker.ttcnpp, line 424 */ { INTEGER tmp_61; ++i; } } } current_location.update_lineno(427); /* StatsD_Checker.ttcnpp, line 427 */ return keys; } StatsD__Types::StatsDMetrics f__statsd__snapshot(const StatsDMetricKeys& keys, const BOOLEAN& since__last__snapshot) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 432, TTCN_Location::LOCATION_FUNCTION, "f_statsd_snapshot"); current_location.update_lineno(433); /* StatsD_Checker.ttcnpp, line 433 */ StatsD__Types::StatsDMetrics snapshot; current_location.update_lineno(434); /* StatsD_Checker.ttcnpp, line 434 */ if ((!(mp__enable__stats))) { current_location.update_lineno(435); /* StatsD_Checker.ttcnpp, line 435 */ return NULL_VALUE; } current_location.update_lineno(438); /* StatsD_Checker.ttcnpp, line 438 */ { STATSD__snapshot_template tmp_62; tmp_62.keys() = keys; tmp_62.since__last__snapshot() = since__last__snapshot; StatsD__ConnHdlr_component_STATSD__PROC.call(tmp_62, FALSE, NULL); } { alt_status tmp_63_alt_flag_0 = ALT_MAYBE; current_location.update_lineno(438); /* StatsD_Checker.ttcnpp, line 438 */ TTCN_Snapshot::take_new(FALSE); for ( ; ; ) { if (tmp_63_alt_flag_0 == ALT_MAYBE) { current_location.update_lineno(439); /* StatsD_Checker.ttcnpp, line 439 */ { STATSD__snapshot_template tmp_64; tmp_64.keys() = keys; tmp_64.since__last__snapshot() = since__last__snapshot; tmp_63_alt_flag_0 = StatsD__ConnHdlr_component_STATSD__PROC.getreply(tmp_64.set_value_template(StatsD__Types::StatsDMetrics_template(ANY_VALUE)), any_compref, STATSD__snapshot_reply_redirect(&(snapshot)), NULL, NULL, NULL); } if (tmp_63_alt_flag_0 == ALT_YES) break; } current_location.update_lineno(438); /* StatsD_Checker.ttcnpp, line 438 */ if (tmp_63_alt_flag_0 == ALT_NO) TTCN_error("None of the branches can be chosen in the response and exception handling part of call statement in file StatsD_Checker.ttcnpp between lines 438 and 440."); TTCN_Snapshot::take_new(TRUE); } } current_location.update_lineno(441); /* StatsD_Checker.ttcnpp, line 441 */ return snapshot; } void start_f__statsd__snapshot(const COMPONENT& component_reference, const StatsDMetricKeys& keys, const BOOLEAN& since__last__snapshot) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_snapshot("); keys.log(); TTCN_Logger::log_event_str(", "); since__last__snapshot.log(); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "f_statsd_snapshot", text_buf); keys.encode_text(text_buf); since__last__snapshot.encode_text(text_buf); TTCN_Runtime::send_start_component(text_buf); } BOOLEAN f__statsd__expect(const StatsDExpects& expects, const BOOLEAN& wait__converge) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 444, TTCN_Location::LOCATION_FUNCTION, "f_statsd_expect"); current_location.update_lineno(445); /* StatsD_Checker.ttcnpp, line 445 */ BOOLEAN res; current_location.update_lineno(447); /* StatsD_Checker.ttcnpp, line 447 */ if ((!(mp__enable__stats))) { current_location.update_lineno(448); /* StatsD_Checker.ttcnpp, line 448 */ return TRUE; } current_location.update_lineno(451); /* StatsD_Checker.ttcnpp, line 451 */ { STATSD__expect_template tmp_65; tmp_65.expects() = expects; tmp_65.wait__converge() = wait__converge; tmp_65.use__snapshot() = FALSE; tmp_65.snapshot() = NULL_VALUE; StatsD__ConnHdlr_component_STATSD__PROC.call(tmp_65, FALSE, NULL); } { alt_status tmp_66_alt_flag_0 = ALT_MAYBE; current_location.update_lineno(451); /* StatsD_Checker.ttcnpp, line 451 */ TTCN_Snapshot::take_new(FALSE); for ( ; ; ) { if (tmp_66_alt_flag_0 == ALT_MAYBE) { current_location.update_lineno(452); /* StatsD_Checker.ttcnpp, line 452 */ { STATSD__expect_template tmp_67; tmp_67.expects() = expects; tmp_67.wait__converge() = wait__converge; tmp_67.use__snapshot() = FALSE; tmp_67.snapshot() = NULL_VALUE; tmp_66_alt_flag_0 = StatsD__ConnHdlr_component_STATSD__PROC.getreply(tmp_67.set_value_template(BOOLEAN_template(ANY_VALUE)), any_compref, STATSD__expect_reply_redirect(&(res)), NULL, NULL, NULL); } if (tmp_66_alt_flag_0 == ALT_YES) break; } current_location.update_lineno(451); /* StatsD_Checker.ttcnpp, line 451 */ if (tmp_66_alt_flag_0 == ALT_NO) TTCN_error("None of the branches can be chosen in the response and exception handling part of call statement in file StatsD_Checker.ttcnpp between lines 451 and 453."); TTCN_Snapshot::take_new(TRUE); } } current_location.update_lineno(454); /* StatsD_Checker.ttcnpp, line 454 */ return res; } void start_f__statsd__expect(const COMPONENT& component_reference, const StatsDExpects& expects, const BOOLEAN& wait__converge) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_expect("); expects.log(); TTCN_Logger::log_event_str(", "); wait__converge.log(); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "f_statsd_expect", text_buf); expects.encode_text(text_buf); wait__converge.encode_text(text_buf); TTCN_Runtime::send_start_component(text_buf); } BOOLEAN f__statsd__expect__from__snapshot(const StatsDExpects& expects, const BOOLEAN& wait__converge, const StatsD__Types::StatsDMetrics& snapshot) { TTCN_Location current_location("StatsD_Checker.ttcnpp", 457, TTCN_Location::LOCATION_FUNCTION, "f_statsd_expect_from_snapshot"); current_location.update_lineno(459); /* StatsD_Checker.ttcnpp, line 459 */ BOOLEAN res; current_location.update_lineno(461); /* StatsD_Checker.ttcnpp, line 461 */ if ((!(mp__enable__stats))) { current_location.update_lineno(462); /* StatsD_Checker.ttcnpp, line 462 */ return TRUE; } current_location.update_lineno(465); /* StatsD_Checker.ttcnpp, line 465 */ { STATSD__expect_template tmp_68; tmp_68.expects() = expects; tmp_68.wait__converge() = wait__converge; tmp_68.use__snapshot() = TRUE; tmp_68.snapshot() = snapshot; StatsD__ConnHdlr_component_STATSD__PROC.call(tmp_68, FALSE, NULL); } { alt_status tmp_69_alt_flag_0 = ALT_MAYBE; current_location.update_lineno(465); /* StatsD_Checker.ttcnpp, line 465 */ TTCN_Snapshot::take_new(FALSE); for ( ; ; ) { if (tmp_69_alt_flag_0 == ALT_MAYBE) { current_location.update_lineno(466); /* StatsD_Checker.ttcnpp, line 466 */ { STATSD__expect_template tmp_70; tmp_70.expects() = expects; tmp_70.wait__converge() = wait__converge; tmp_70.use__snapshot() = TRUE; tmp_70.snapshot() = snapshot; tmp_69_alt_flag_0 = StatsD__ConnHdlr_component_STATSD__PROC.getreply(tmp_70.set_value_template(BOOLEAN_template(ANY_VALUE)), any_compref, STATSD__expect_reply_redirect(&(res)), NULL, NULL, NULL); } if (tmp_69_alt_flag_0 == ALT_YES) break; } current_location.update_lineno(465); /* StatsD_Checker.ttcnpp, line 465 */ if (tmp_69_alt_flag_0 == ALT_NO) TTCN_error("None of the branches can be chosen in the response and exception handling part of call statement in file StatsD_Checker.ttcnpp between lines 465 and 467."); TTCN_Snapshot::take_new(TRUE); } } current_location.update_lineno(468); /* StatsD_Checker.ttcnpp, line 468 */ return res; } void start_f__statsd__expect__from__snapshot(const COMPONENT& component_reference, const StatsDExpects& expects, const BOOLEAN& wait__converge, const StatsD__Types::StatsDMetrics& snapshot) { TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_expect_from_snapshot("); expects.log(); TTCN_Logger::log_event_str(", "); wait__converge.log(); TTCN_Logger::log_event_str(", "); snapshot.log(); TTCN_Logger::log_event_str(") on component "); component_reference.log(); TTCN_Logger::log_char('.'); TTCN_Logger::end_event(); Text_Buf text_buf; TTCN_Runtime::prepare_start_component(component_reference, "StatsD_Checker", "f_statsd_expect_from_snapshot", text_buf); expects.encode_text(text_buf); wait__converge.encode_text(text_buf); snapshot.encode_text(text_buf); TTCN_Runtime::send_start_component(text_buf); } /* Bodies of static functions */ void pre_init_module() { TTCN_Location current_location("StatsD_Checker.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "StatsD_Checker"); StatsD__CodecPort__CtrlFunct::module_object.pre_init_module(); Osmocom__VTY__Functions::module_object.pre_init_module(); current_location.update_lineno(44); /* StatsD_Checker.ttcnpp, line 44 */ modulepar_mp__enable__stats = TRUE; module_object.add_modulepar("mp_enable_stats"); module_object.add_function("main", (genericfunc_t)&main_, (genericfunc_t)&start_main_); module_object.add_function("f_statsd_metrics_update_value", (genericfunc_t)&f__statsd__metrics__update__value, NULL); module_object.add_function("f_statsd_checker_snapshot", (genericfunc_t)&f__statsd__checker__snapshot, (genericfunc_t)&start_f__statsd__checker__snapshot); module_object.add_function("get_val_from_snapshot", (genericfunc_t)&get__val__from__snapshot, NULL); module_object.add_function("f_compare_expect", (genericfunc_t)&f__compare__expect, NULL); module_object.add_function("f_statsd_checker_metric_expects", (genericfunc_t)&f__statsd__checker__metric__expects, NULL); module_object.add_function("using_poll_mode", (genericfunc_t)&using__poll__mode, (genericfunc_t)&start_using__poll__mode); module_object.add_function("poll_stats_report", (genericfunc_t)&poll__stats__report, (genericfunc_t)&start_poll__stats__report); module_object.add_function("f_statsd_checker_expect", (genericfunc_t)&f__statsd__checker__expect, (genericfunc_t)&start_f__statsd__checker__expect); module_object.add_function("f_init_statsd", (genericfunc_t)&f__init__statsd, NULL); module_object.add_function("f_statsd_reset", (genericfunc_t)&f__statsd__reset, (genericfunc_t)&start_f__statsd__reset); module_object.add_function("f_statsd_keys_from_expect", (genericfunc_t)&f__statsd__keys__from__expect, NULL); module_object.add_function("f_statsd_snapshot", (genericfunc_t)&f__statsd__snapshot, (genericfunc_t)&start_f__statsd__snapshot); module_object.add_function("f_statsd_expect", (genericfunc_t)&f__statsd__expect, (genericfunc_t)&start_f__statsd__expect); module_object.add_function("f_statsd_expect_from_snapshot", (genericfunc_t)&f__statsd__expect__from__snapshot, (genericfunc_t)&start_f__statsd__expect__from__snapshot); } void post_init_module() { TTCN_Location current_location("StatsD_Checker.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "StatsD_Checker"); StatsD__CodecPort__CtrlFunct::module_object.post_init_module(); Osmocom__VTY__Functions::module_object.post_init_module(); current_location.update_lineno(103); /* StatsD_Checker.ttcnpp, line 103 */ const_main__statsd__timeout_defval = 5.0; current_location.update_lineno(179); /* StatsD_Checker.ttcnpp, line 179 */ const_f__statsd__checker__snapshot_since__last__snapshot_defval = TRUE; current_location.update_lineno(244); /* StatsD_Checker.ttcnpp, line 244 */ const_f__compare__expect_use__snapshot_defval = FALSE; current_location.update_lineno(245); /* StatsD_Checker.ttcnpp, line 245 */ const_f__compare__expect_snapshot_defval = NULL_VALUE; current_location.update_lineno(269); /* StatsD_Checker.ttcnpp, line 269 */ const_f__statsd__checker__metric__expects_use__snapshot_defval = FALSE; current_location.update_lineno(270); /* StatsD_Checker.ttcnpp, line 270 */ const_f__statsd__checker__metric__expects_snapshot_defval = NULL_VALUE; current_location.update_lineno(320); /* StatsD_Checker.ttcnpp, line 320 */ const_f__statsd__checker__expect_wait__converge_defval = FALSE; current_location.update_lineno(321); /* StatsD_Checker.ttcnpp, line 321 */ const_f__statsd__checker__expect_use__snapshot_defval = FALSE; current_location.update_lineno(322); /* StatsD_Checker.ttcnpp, line 322 */ const_f__statsd__checker__expect_snapshot_defval = NULL_VALUE; current_location.update_lineno(401); /* StatsD_Checker.ttcnpp, line 401 */ const_f__init__statsd_statsd__timeout_defval = 5.0; current_location.update_lineno(432); /* StatsD_Checker.ttcnpp, line 432 */ const_f__statsd__snapshot_since__last__snapshot_defval = TRUE; current_location.update_lineno(444); /* StatsD_Checker.ttcnpp, line 444 */ const_f__statsd__expect_wait__converge_defval = FALSE; current_location.update_lineno(457); /* StatsD_Checker.ttcnpp, line 457 */ const_f__statsd__expect__from__snapshot_wait__converge_defval = FALSE; current_location.update_lineno(458); /* StatsD_Checker.ttcnpp, line 458 */ const_f__statsd__expect__from__snapshot_snapshot_defval = NULL_VALUE; } boolean set_module_param(Module_Param& param) { const char* const par_name = param.get_id()->get_current_name(); if (!strcmp(par_name, "mp_enable_stats")) { modulepar_mp__enable__stats.set_param(param); return TRUE; } else return FALSE; } void log_module_param() { TTCN_Logger::log_event_str("mp_enable_stats := "); mp__enable__stats.log(); } boolean init_comp_type(const char *component_type, boolean init_base_comps) { (void)init_base_comps; if (!strcmp(component_type, "StatsD_Checker_CT")) { StatsD__Checker__CT_component_STATSVTY.activate_port(); StatsD__Checker__CT_component_STATSD__PROC.activate_port(); StatsD__Checker__CT_component_STATS.activate_port(); StatsD__Checker__CT_component_g__timeout.clean_up(); return TRUE; } else if (!strcmp(component_type, "StatsD_ConnHdlr")) { StatsD__ConnHdlr_component_STATSD__PROC.activate_port(); return TRUE; } else return FALSE; } boolean init_system_port(const char* component_type, const char* port_name) { if (!strcmp(component_type, "StatsD_Checker_CT")) { if (!strcmp(port_name, "STATS")) { StatsD__Checker__CT_component_STATS.safe_start(); return TRUE; } if (!strcmp(port_name, "STATSD_PROC")) { StatsD__Checker__CT_component_STATSD__PROC.safe_start(); return TRUE; } if (!strcmp(port_name, "STATSVTY")) { StatsD__Checker__CT_component_STATSVTY.safe_start(); return TRUE; } } else if (!strcmp(component_type, "StatsD_ConnHdlr")) { if (!strcmp(port_name, "STATSD_PROC")) { StatsD__ConnHdlr_component_STATSD__PROC.safe_start(); return TRUE; } } return FALSE; } boolean start_ptc_function(const char *function_name, Text_Buf& function_arguments) { if (!strcmp(function_name, "main")) { CHARSTRING statsd__host; INTEGER statsd__port; FLOAT statsd__timeout; statsd__host.decode_text(function_arguments); statsd__port.decode_text(function_arguments); statsd__timeout.decode_text(function_arguments); TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function main("); statsd__host.log(); TTCN_Logger::log_event_str(", "); statsd__port.log(); TTCN_Logger::log_event_str(", "); statsd__timeout.log(); TTCN_Logger::log_event_str(")."); TTCN_Logger::end_event(); TTCN_Runtime::function_started(function_arguments); main_(statsd__host, statsd__port, statsd__timeout); TTCN_Runtime::function_finished("main"); return TRUE; } else if (!strcmp(function_name, "f_statsd_checker_snapshot")) { StatsDMetricKeys keys; BOOLEAN since__last__snapshot; keys.decode_text(function_arguments); since__last__snapshot.decode_text(function_arguments); TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_checker_snapshot("); keys.log(); TTCN_Logger::log_event_str(", "); since__last__snapshot.log(); TTCN_Logger::log_event_str(")."); TTCN_Logger::end_event(); TTCN_Runtime::function_started(function_arguments); f__statsd__checker__snapshot(keys, since__last__snapshot); TTCN_Runtime::function_finished("f_statsd_checker_snapshot"); return TRUE; } else if (!strcmp(function_name, "using_poll_mode")) { TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function using_poll_mode()."); TTCN_Runtime::function_started(function_arguments); using__poll__mode(); TTCN_Runtime::function_finished("using_poll_mode"); return TRUE; } else if (!strcmp(function_name, "poll_stats_report")) { TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function poll_stats_report()."); TTCN_Runtime::function_started(function_arguments); poll__stats__report(); TTCN_Runtime::function_finished("poll_stats_report"); return TRUE; } else if (!strcmp(function_name, "f_statsd_checker_expect")) { StatsDExpects expects; BOOLEAN wait__converge; BOOLEAN use__snapshot; StatsD__Types::StatsDMetrics snapshot; expects.decode_text(function_arguments); wait__converge.decode_text(function_arguments); use__snapshot.decode_text(function_arguments); snapshot.decode_text(function_arguments); TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_checker_expect("); expects.log(); TTCN_Logger::log_event_str(", "); wait__converge.log(); TTCN_Logger::log_event_str(", "); use__snapshot.log(); TTCN_Logger::log_event_str(", "); snapshot.log(); TTCN_Logger::log_event_str(")."); TTCN_Logger::end_event(); TTCN_Runtime::function_started(function_arguments); f__statsd__checker__expect(expects, wait__converge, use__snapshot, snapshot); TTCN_Runtime::function_finished("f_statsd_checker_expect"); return TRUE; } else if (!strcmp(function_name, "f_statsd_reset")) { TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function f_statsd_reset()."); TTCN_Runtime::function_started(function_arguments); f__statsd__reset(); TTCN_Runtime::function_finished("f_statsd_reset"); return TRUE; } else if (!strcmp(function_name, "f_statsd_snapshot")) { StatsDMetricKeys keys; BOOLEAN since__last__snapshot; keys.decode_text(function_arguments); since__last__snapshot.decode_text(function_arguments); TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_snapshot("); keys.log(); TTCN_Logger::log_event_str(", "); since__last__snapshot.log(); TTCN_Logger::log_event_str(")."); TTCN_Logger::end_event(); TTCN_Runtime::function_started(function_arguments); f__statsd__snapshot(keys, since__last__snapshot); TTCN_Runtime::function_finished("f_statsd_snapshot"); return TRUE; } else if (!strcmp(function_name, "f_statsd_expect")) { StatsDExpects expects; BOOLEAN wait__converge; expects.decode_text(function_arguments); wait__converge.decode_text(function_arguments); TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_expect("); expects.log(); TTCN_Logger::log_event_str(", "); wait__converge.log(); TTCN_Logger::log_event_str(")."); TTCN_Logger::end_event(); TTCN_Runtime::function_started(function_arguments); f__statsd__expect(expects, wait__converge); TTCN_Runtime::function_finished("f_statsd_expect"); return TRUE; } else if (!strcmp(function_name, "f_statsd_expect_from_snapshot")) { StatsDExpects expects; BOOLEAN wait__converge; StatsD__Types::StatsDMetrics snapshot; expects.decode_text(function_arguments); wait__converge.decode_text(function_arguments); snapshot.decode_text(function_arguments); TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC); TTCN_Logger::log_event_str("Starting function f_statsd_expect_from_snapshot("); expects.log(); TTCN_Logger::log_event_str(", "); wait__converge.log(); TTCN_Logger::log_event_str(", "); snapshot.log(); TTCN_Logger::log_event_str(")."); TTCN_Logger::end_event(); TTCN_Runtime::function_started(function_arguments); f__statsd__expect__from__snapshot(expects, wait__converge, snapshot); TTCN_Runtime::function_finished("f_statsd_expect_from_snapshot"); return TRUE; } else return FALSE; } } /* end of namespace */