// 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 "Prometheus_Checker.hh"

namespace Prometheus__Checker {

/* Literal string constants */

extern const CHARSTRING cs_3('\n'),
cs_6(' '),
cs_4(7, "# HELP "),
cs_5(7, "# TYPE "),
cs_7(8, "/metrics"),
cs_8(3, "GET"),
cs_2(23, "Prometheus_Checker.ttcn"),
cs_0(7, "counter"),
cs_1(5, "gauge");
const unsigned char module_checksum[] = { 0xea, 0x73, 0x63, 0x46, 0x4d, 0x32, 0xa4, 0xda, 0xe2, 0x58, 0x96, 0xfb, 0x78, 0x48, 0x47, 0x43 };

/* Global variable definitions */

INTEGER const_c__prometheus__default__http__port;
const INTEGER& c__prometheus__default__http__port = const_c__prometheus__default__http__port;
// No XER for PrometheusMetricType
const TTCN_Typedescriptor_t PrometheusMetricType_descr_ = { "@Prometheus_Checker.PrometheusMetricType", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t       PrometheusMetricKey_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 PrometheusMetricKey_name_descr_ = { "@Prometheus_Checker.PrometheusMetricKey.name", NULL, &CHARSTRING_raw_, &CHARSTRING_text_, &PrometheusMetricKey_name_xer_, &CHARSTRING_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PrometheusMetricKey
const TTCN_Typedescriptor_t PrometheusMetricKey_descr_ = { "@Prometheus_Checker.PrometheusMetricKey", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PrometheusMetricKeys
const TTCN_Typedescriptor_t PrometheusMetricKeys_descr_ = { "@Prometheus_Checker.PrometheusMetricKeys", NULL, NULL, NULL, NULL, NULL, NULL, NULL, &PrometheusMetricKey_descr_, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t       PrometheusMetric_val_xer_ = { {"val>\n", "val>\n"}, {5, 5}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_Typedescriptor_t PrometheusMetric_val_descr_ = { "@Prometheus_Checker.PrometheusMetric.val", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &PrometheusMetric_val_xer_, &INTEGER_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PrometheusMetric
const TTCN_Typedescriptor_t PrometheusMetric_descr_ = { "@Prometheus_Checker.PrometheusMetric", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PrometheusMetrics
const TTCN_Typedescriptor_t PrometheusMetrics_descr_ = { "@Prometheus_Checker.PrometheusMetrics", NULL, NULL, NULL, NULL, NULL, NULL, NULL, &PrometheusMetric_descr_, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t       PrometheusExpect_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_Typedescriptor_t PrometheusExpect_min_descr_ = { "@Prometheus_Checker.PrometheusExpect.min", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &PrometheusExpect_min_xer_, &INTEGER_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t       PrometheusExpect_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_Typedescriptor_t PrometheusExpect_max_descr_ = { "@Prometheus_Checker.PrometheusExpect.max", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &PrometheusExpect_max_xer_, &INTEGER_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PrometheusExpect
const TTCN_Typedescriptor_t PrometheusExpect_descr_ = { "@Prometheus_Checker.PrometheusExpect", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PrometheusExpects
const TTCN_Typedescriptor_t PrometheusExpects_descr_ = { "@Prometheus_Checker.PrometheusExpects", NULL, NULL, NULL, NULL, NULL, NULL, NULL, &PrometheusExpect_descr_, TTCN_Typedescriptor_t::DONTCARE };
BOOLEAN modulepar_mp__enable__stats;
const BOOLEAN& mp__enable__stats = modulepar_mp__enable__stats;
// No XER for PrometheusResultType
const TTCN_Typedescriptor_t PrometheusResultType_descr_ = { "@Prometheus_Checker.PrometheusResultType", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t       PrometheusExpectResult_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 PrometheusExpectResult_idx_descr_ = { "@Prometheus_Checker.PrometheusExpectResult.idx", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &PrometheusExpectResult_idx_xer_, &INTEGER_json_, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PrometheusExpectResult
const TTCN_Typedescriptor_t PrometheusExpectResult_descr_ = { "@Prometheus_Checker.PrometheusExpectResult", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& Prometheus__Checker__CT_descr_ = COMPONENT_descr_;
FLOAT Prometheus__Checker__CT_component_g__tout__http;
INTEGER_template template_ts__PrometheusMetric_val_defval;
const INTEGER_template& ts__PrometheusMetric_val_defval = template_ts__PrometheusMetric_val_defval;
INTEGER const_f__prometheus__init_http__port_defval;
const INTEGER& f__prometheus__init_http__port_defval = const_f__prometheus__init_http__port_defval;
FLOAT const_f__prometheus__snapshot_time__out_defval;
const FLOAT& f__prometheus__snapshot_time__out_defval = const_f__prometheus__snapshot_time__out_defval;
BOOLEAN const_f__compare__expect_use__snapshot_defval;
const BOOLEAN& f__compare__expect_use__snapshot_defval = const_f__compare__expect_use__snapshot_defval;
PrometheusMetrics const_f__compare__expect_snapshot_defval;
const PrometheusMetrics& f__compare__expect_snapshot_defval = const_f__compare__expect_snapshot_defval;
BOOLEAN const_f__prometheus__metric__expects_use__snapshot_defval;
const BOOLEAN& f__prometheus__metric__expects_use__snapshot_defval = const_f__prometheus__metric__expects_use__snapshot_defval;
PrometheusMetrics const_f__prometheus__metric__expects_snapshot_defval;
const PrometheusMetrics& f__prometheus__metric__expects_snapshot_defval = const_f__prometheus__metric__expects_snapshot_defval;
BOOLEAN const_f__prometheus__expect__ext_wait__converge_defval;
const BOOLEAN& f__prometheus__expect__ext_wait__converge_defval = const_f__prometheus__expect__ext_wait__converge_defval;
BOOLEAN const_f__prometheus__expect__ext_use__snapshot_defval;
const BOOLEAN& f__prometheus__expect__ext_use__snapshot_defval = const_f__prometheus__expect__ext_use__snapshot_defval;
PrometheusMetrics const_f__prometheus__expect__ext_snapshot_defval;
const PrometheusMetrics& f__prometheus__expect__ext_snapshot_defval = const_f__prometheus__expect__ext_snapshot_defval;
FLOAT const_f__prometheus__expect__ext_time__out_defval;
const FLOAT& f__prometheus__expect__ext_time__out_defval = const_f__prometheus__expect__ext_time__out_defval;
BOOLEAN const_f__prometheus__expect_wait__converge_defval;
const BOOLEAN& f__prometheus__expect_wait__converge_defval = const_f__prometheus__expect_wait__converge_defval;
FLOAT const_f__prometheus__expect_time__out_defval;
const FLOAT& f__prometheus__expect_time__out_defval = const_f__prometheus__expect_time__out_defval;
BOOLEAN const_f__prometheus__expect__from__snapshot_wait__converge_defval;
const BOOLEAN& f__prometheus__expect__from__snapshot_wait__converge_defval = const_f__prometheus__expect__from__snapshot_wait__converge_defval;
PrometheusMetrics const_f__prometheus__expect__from__snapshot_snapshot_defval;
const PrometheusMetrics& f__prometheus__expect__from__snapshot_snapshot_defval = const_f__prometheus__expect__from__snapshot_snapshot_defval;
FLOAT const_f__prometheus__expect__from__snapshot_time__out_defval;
const FLOAT& f__prometheus__expect__from__snapshot_time__out_defval = const_f__prometheus__expect__from__snapshot_time__out_defval;
TTCN_Module module_object("Prometheus_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 */

PrometheusMetricType::PrometheusMetricType()
{
enum_value = UNBOUND_VALUE;
}

PrometheusMetricType::PrometheusMetricType(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @Prometheus_Checker.PrometheusMetricType with invalid numeric value %d.", other_value);
enum_value = (enum_type)other_value;
}

PrometheusMetricType::PrometheusMetricType(enum_type other_value)
{
enum_value = other_value;
}

PrometheusMetricType::PrometheusMetricType(const PrometheusMetricType& other_value)
: Base_Type()
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
enum_value = other_value.enum_value;
}

PrometheusMetricType& PrometheusMetricType::operator=(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @Prometheus_Checker.PrometheusMetricType.", other_value);
enum_value = (enum_type)other_value;
return *this;
}

PrometheusMetricType& PrometheusMetricType::operator=(enum_type other_value)
{
enum_value = other_value;
return *this;
}

PrometheusMetricType& PrometheusMetricType::operator=(const PrometheusMetricType& other_value)
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
enum_value = other_value.enum_value;
return *this;
}

boolean PrometheusMetricType::operator==(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @Prometheus_Checker.PrometheusMetricType comparison is an unknown numeric value %d", other_value);
return enum_value == other_value;
}

boolean PrometheusMetricType::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 @Prometheus_Checker.PrometheusMetricType.");
return enum_value == other_value;
}

boolean PrometheusMetricType::operator==(const PrometheusMetricType& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
return enum_value == other_value.enum_value;
}

boolean PrometheusMetricType::operator<(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @Prometheus_Checker.PrometheusMetricType comparison is an unknown numeric value %d", other_value);
return enum_value < other_value;
}

boolean PrometheusMetricType::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 @Prometheus_Checker.PrometheusMetricType.");
return enum_value < other_value;
}

boolean PrometheusMetricType::operator<(const PrometheusMetricType& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
return enum_value < other_value.enum_value;
}

boolean PrometheusMetricType::operator>(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @Prometheus_Checker.PrometheusMetricType comparison is an unknown numeric value %d", other_value);
return enum_value > other_value;
}

boolean PrometheusMetricType::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 @Prometheus_Checker.PrometheusMetricType.");
return enum_value > other_value;
}

boolean PrometheusMetricType::operator>(const PrometheusMetricType& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
return enum_value > other_value.enum_value;
}

const char *PrometheusMetricType::enum_to_str(enum_type enum_par)
{
switch (enum_par) {
case COUNTER: return "COUNTER";
case GAUGE: return "GAUGE";
default:
return "<unknown>";
}
}

PrometheusMetricType::enum_type PrometheusMetricType::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, "COUNTER")) return COUNTER;
if (!strcmp(str_par, "GAUGE")) return GAUGE;
}
return UNKNOWN_VALUE;
}

boolean PrometheusMetricType::is_valid_enum(int int_par)
{
switch (int_par) {
case 0:
case 1:
return TRUE;
default:
return FALSE;
}
}

int PrometheusMetricType::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 @Prometheus_Checker.PrometheusMetricType.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par;
}

int PrometheusMetricType::enum2int(const PrometheusMetricType& 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 @Prometheus_Checker.PrometheusMetricType.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par.enum_value;
}

void PrometheusMetricType::int2enum(int int_val)
{
if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @Prometheus_Checker.PrometheusMetricType.", int_val);
enum_value = (enum_type)int_val;
}

PrometheusMetricType::operator PrometheusMetricType::enum_type() const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @Prometheus_Checker.PrometheusMetricType.");
return enum_value;
}

void PrometheusMetricType::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 PrometheusMetricType::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", "@Prometheus_Checker.PrometheusMetricType");
  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 @Prometheus_Checker.PrometheusMetricType.");
  }
}

void PrometheusMetricType::encode_text(Text_Buf& text_buf) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
text_buf.push_int(enum_value);
}

void PrometheusMetricType::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 @Prometheus_Checker.PrometheusMetricType.", enum_value);
}

void PrometheusMetricType_template::copy_template(const PrometheusMetricType_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 PrometheusMetricType_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 PrometheusMetricType_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusMetricType_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 @Prometheus_Checker.PrometheusMetricType.");
}
}

PrometheusMetricType_template::PrometheusMetricType_template()
{
}

PrometheusMetricType_template::PrometheusMetricType_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusMetricType_template::PrometheusMetricType_template(int other_value)
 : Base_Template(SPECIFIC_VALUE)
{
if (!PrometheusMetricType::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @Prometheus_Checker.PrometheusMetricType with unknown numeric value %d.", other_value);
single_value = (PrometheusMetricType::enum_type)other_value;
}

PrometheusMetricType_template::PrometheusMetricType_template(PrometheusMetricType::enum_type other_value)
 : Base_Template(SPECIFIC_VALUE)
{
single_value = other_value;
}

PrometheusMetricType_template::PrometheusMetricType_template(const PrometheusMetricType& other_value)
 : Base_Template(SPECIFIC_VALUE)
{
if (other_value.enum_value == PrometheusMetricType::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType.");
single_value = other_value.enum_value;
}

PrometheusMetricType_template::PrometheusMetricType_template(const OPTIONAL<PrometheusMetricType>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (PrometheusMetricType::enum_type)(const PrometheusMetricType&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of enumerated type @Prometheus_Checker.PrometheusMetricType from an unbound optional field.");
}
}

PrometheusMetricType_template::PrometheusMetricType_template(PrometheusMetricType_template* p_precondition, PrometheusMetricType_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusMetricType_template::PrometheusMetricType_template(Dynamic_Match_Interface<PrometheusMetricType>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusMetricType>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusMetricType_template::PrometheusMetricType_template(const PrometheusMetricType_template& other_value)
 : Base_Template()
{
copy_template(other_value);
}

PrometheusMetricType_template::~PrometheusMetricType_template()
{
clean_up();
}

boolean PrometheusMetricType_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
return TRUE;
}

boolean PrometheusMetricType_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value != PrometheusMetricType::UNBOUND_VALUE;
}

void PrometheusMetricType_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;
}

PrometheusMetricType_template& PrometheusMetricType_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusMetricType_template& PrometheusMetricType_template::operator=(int other_value)
{
if (!PrometheusMetricType::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @Prometheus_Checker.PrometheusMetricType.", other_value);
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = (PrometheusMetricType::enum_type)other_value;
return *this;
}

PrometheusMetricType_template& PrometheusMetricType_template::operator=(PrometheusMetricType::enum_type other_value)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value;
return *this;
}

PrometheusMetricType_template& PrometheusMetricType_template::operator=(const PrometheusMetricType& other_value)
{
if (other_value.enum_value == PrometheusMetricType::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Prometheus_Checker.PrometheusMetricType to a template.");
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value.enum_value;
return *this;
}

PrometheusMetricType_template& PrometheusMetricType_template::operator=(const OPTIONAL<PrometheusMetricType>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (PrometheusMetricType::enum_type)(const PrometheusMetricType&)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 @Prometheus_Checker.PrometheusMetricType.");
}
return *this;
}

PrometheusMetricType_template& PrometheusMetricType_template::operator=(const PrometheusMetricType_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean PrometheusMetricType_template::match(PrometheusMetricType::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 @Prometheus_Checker.PrometheusMetricType.");
}
return FALSE;
}

boolean PrometheusMetricType_template::match(const PrometheusMetricType& other_value, boolean) const
{
if (other_value.enum_value == PrometheusMetricType::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @Prometheus_Checker.PrometheusMetricType with an unbound value.");
return match(other_value.enum_value);
}

PrometheusMetricType::enum_type PrometheusMetricType_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 @Prometheus_Checker.PrometheusMetricType.");
return single_value;
}

void PrometheusMetricType_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 PrometheusMetricType_template[list_length];
break;
default:
TTCN_error("Setting an invalid type for a template of enumerated type @Prometheus_Checker.PrometheusMetricType.");
}
}

PrometheusMetricType_template& PrometheusMetricType_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 @Prometheus_Checker.PrometheusMetricType.");
if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @Prometheus_Checker.PrometheusMetricType.");
return value_list.list_value[list_index];
}

void PrometheusMetricType_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_enum(PrometheusMetricType::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 PrometheusMetricType_template::log_match(const PrometheusMetricType& 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 PrometheusMetricType_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 @Prometheus_Checker.PrometheusMetricType.");
}
}

void PrometheusMetricType_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = (PrometheusMetricType::enum_type)text_buf.pull_int().get_val();
if (!PrometheusMetricType::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @Prometheus_Checker.PrometheusMetricType.", 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 PrometheusMetricType_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 @Prometheus_Checker.PrometheusMetricType.");
}
}

boolean PrometheusMetricType_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusMetricType_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; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

void PrometheusMetricType_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "enumerated template");
  Module_Param_Ptr m_p = &param;
  switch (m_p->get_type()) {
  case Module_Param::MP_Omit:
    *this = OMIT_VALUE;
    break;
  case Module_Param::MP_Any:
    *this = ANY_VALUE;
    break;
  case Module_Param::MP_AnyOrNone:
    *this = ANY_OR_OMIT;
    break;
  case Module_Param::MP_List_Template:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    PrometheusMetricType_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_i<m_p->get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Enumerated: {
    PrometheusMetricType::enum_type enum_val = PrometheusMetricType::str_to_enum(m_p->get_enumerated(), m_p->get_enumerated_value());
    if (!PrometheusMetricType::is_valid_enum(enum_val)) {
      param.error("Invalid enumerated value for type @Prometheus_Checker.PrometheusMetricType.");
    }
    *this = enum_val;
  } break;
  case Module_Param::MP_Implication_Template: {
    PrometheusMetricType_template* precondition = new PrometheusMetricType_template;
    precondition->set_param(*m_p->get_elem(0));
    PrometheusMetricType_template* implied_template = new PrometheusMetricType_template;
    implied_template->set_param(*m_p->get_elem(1));
    *this = PrometheusMetricType_template(precondition, implied_template);
  } break;
  default:
    param.type_error("enumerated template", "@Prometheus_Checker.PrometheusMetricType");
  }
  is_ifpresent = param.get_ifpresent();
}

void PrometheusMetricType_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 : "@Prometheus_Checker.PrometheusMetricType");
}

PrometheusMetricKey::PrometheusMetricKey()
{
}

PrometheusMetricKey::PrometheusMetricKey(const CHARSTRING& par_name,
    const PrometheusMetricType& par_mtype)
  :   field_name(par_name),
  field_mtype(par_mtype)
{
}

PrometheusMetricKey::PrometheusMetricKey(const PrometheusMetricKey& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Prometheus_Checker.PrometheusMetricKey.");
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 PrometheusMetricKey::clean_up()
{
field_name.clean_up();
field_mtype.clean_up();
}

const TTCN_Typedescriptor_t* PrometheusMetricKey::get_descriptor() const { return &PrometheusMetricKey_descr_; }
PrometheusMetricKey& PrometheusMetricKey::operator=(const PrometheusMetricKey& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Prometheus_Checker.PrometheusMetricKey.");
  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 PrometheusMetricKey::operator==(const PrometheusMetricKey& other_value) const
{
return field_name==other_value.field_name
  && field_mtype==other_value.field_mtype;
}

boolean PrometheusMetricKey::is_bound() const
{
return (field_name.is_bound())
  || (field_mtype.is_bound());
}
boolean PrometheusMetricKey::is_value() const
{
return field_name.is_value()
  && field_mtype.is_value();
}
void PrometheusMetricKey::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 PrometheusMetricKey::set_implicit_omit()
{
if (name().is_bound()) name().set_implicit_omit();
if (mtype().is_bound()) mtype().set_implicit_omit();
}

void PrometheusMetricKey::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record value of type @Prometheus_Checker.PrometheusMetricKey has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) 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<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "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_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_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_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Prometheus_Checker.PrometheusMetricKey: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@Prometheus_Checker.PrometheusMetricKey");
  }
}

void PrometheusMetricKey::encode_text(Text_Buf& text_buf) const
{
field_name.encode_text(text_buf);
field_mtype.encode_text(text_buf);
}

void PrometheusMetricKey::decode_text(Text_Buf& text_buf)
{
field_name.decode_text(text_buf);
field_mtype.decode_text(text_buf);
}

struct PrometheusMetricKey_template::single_value_struct {
CHARSTRING_template field_name;
PrometheusMetricType_template field_mtype;
};

void PrometheusMetricKey_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 PrometheusMetricKey_template::copy_value(const PrometheusMetricKey& 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 PrometheusMetricKey_template::copy_template(const PrometheusMetricKey_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 PrometheusMetricKey_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 PrometheusMetricKey_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusMetricKey_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 @Prometheus_Checker.PrometheusMetricKey.");
break;
}
set_selection(other_value);
}

PrometheusMetricKey_template::PrometheusMetricKey_template()
{
}

PrometheusMetricKey_template::PrometheusMetricKey_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusMetricKey_template::PrometheusMetricKey_template(const PrometheusMetricKey& other_value)
{
copy_value(other_value);
}

PrometheusMetricKey_template::PrometheusMetricKey_template(const OPTIONAL<PrometheusMetricKey>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusMetricKey&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Prometheus_Checker.PrometheusMetricKey from an unbound optional field.");
}
}

PrometheusMetricKey_template::PrometheusMetricKey_template(PrometheusMetricKey_template* p_precondition, PrometheusMetricKey_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusMetricKey_template::PrometheusMetricKey_template(Dynamic_Match_Interface<PrometheusMetricKey>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusMetricKey>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusMetricKey_template::PrometheusMetricKey_template(const PrometheusMetricKey_template& other_value)
: Base_Template()
{
copy_template(other_value);
}

PrometheusMetricKey_template::~PrometheusMetricKey_template()
{
clean_up();
}

PrometheusMetricKey_template& PrometheusMetricKey_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusMetricKey_template& PrometheusMetricKey_template::operator=(const PrometheusMetricKey& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

PrometheusMetricKey_template& PrometheusMetricKey_template::operator=(const OPTIONAL<PrometheusMetricKey>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusMetricKey&)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 @Prometheus_Checker.PrometheusMetricKey.");
}
return *this;
}

PrometheusMetricKey_template& PrometheusMetricKey_template::operator=(const PrometheusMetricKey_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean PrometheusMetricKey_template::match(const PrometheusMetricKey& 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 @Prometheus_Checker.PrometheusMetricKey.");
}
return FALSE;
}

boolean PrometheusMetricKey_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 PrometheusMetricKey_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 PrometheusMetricKey_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;
}

PrometheusMetricKey PrometheusMetricKey_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 @Prometheus_Checker.PrometheusMetricKey.");
PrometheusMetricKey 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 PrometheusMetricKey_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 @Prometheus_Checker.PrometheusMetricKey.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new PrometheusMetricKey_template[list_length];
}

PrometheusMetricKey_template& PrometheusMetricKey_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 @Prometheus_Checker.PrometheusMetricKey.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Prometheus_Checker.PrometheusMetricKey.");
return value_list.list_value[list_index];
}

CHARSTRING_template& PrometheusMetricKey_template::name()
{
set_specific();
return single_value->field_name;
}

const CHARSTRING_template& PrometheusMetricKey_template::name() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field name of a non-specific template of type @Prometheus_Checker.PrometheusMetricKey.");
return single_value->field_name;
}

PrometheusMetricType_template& PrometheusMetricKey_template::mtype()
{
set_specific();
return single_value->field_mtype;
}

const PrometheusMetricType_template& PrometheusMetricKey_template::mtype() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field mtype of a non-specific template of type @Prometheus_Checker.PrometheusMetricKey.");
return single_value->field_mtype;
}

int PrometheusMetricKey_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetricKey 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 @Prometheus_Checker.PrometheusMetricKey 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 @Prometheus_Checker.PrometheusMetricKey containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetricKey containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetricKey containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetricKey containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetricKey containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetricKey containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetricKey containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Prometheus_Checker.PrometheusMetricKey.");
  }
  return 0;
}

void PrometheusMetricKey_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 PrometheusMetricKey_template::log_match(const PrometheusMetricKey& 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 PrometheusMetricKey_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 PrometheusMetricKey_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 @Prometheus_Checker.PrometheusMetricKey.");
}
}

void PrometheusMetricKey_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 PrometheusMetricKey_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 @Prometheus_Checker.PrometheusMetricKey.");
}
}

void PrometheusMetricKey_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: {
    PrometheusMetricKey_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_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record template of type @Prometheus_Checker.PrometheusMetricKey has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) 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<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "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_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_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_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Prometheus_Checker.PrometheusMetricKey: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    PrometheusMetricKey_template* precondition = new PrometheusMetricKey_template;
    precondition->set_param(*param.get_elem(0));
    PrometheusMetricKey_template* implied_template = new PrometheusMetricKey_template;
    implied_template->set_param(*param.get_elem(1));
    *this = PrometheusMetricKey_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@Prometheus_Checker.PrometheusMetricKey");
  }
  is_ifpresent = param.get_ifpresent();
}

void PrometheusMetricKey_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 : "@Prometheus_Checker.PrometheusMetricKey");
single_value->field_mtype.check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusMetricKey");
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 : "@Prometheus_Checker.PrometheusMetricKey");
}

boolean PrometheusMetricKey_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusMetricKey_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_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}


const PrometheusMetricKey PrometheusMetricKeys::UNBOUND_ELEM;
boolean PrometheusMetricKeys::compare_function(const Base_Type *left_ptr, int left_index, const Base_Type *right_ptr, int right_index)
{
if (((const PrometheusMetricKeys*)left_ptr)->val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
if (((const PrometheusMetricKeys*)right_ptr)->val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
if (((const PrometheusMetricKeys*)left_ptr)->val_ptr->value_elements[left_index] != NULL){
if (((const PrometheusMetricKeys*)right_ptr)->val_ptr->value_elements[right_index] != NULL){
return *((const PrometheusMetricKeys*)left_ptr)->val_ptr->value_elements[left_index] == *((const PrometheusMetricKeys*)right_ptr)->val_ptr->value_elements[right_index];
} else return FALSE;
} else {
return ((const PrometheusMetricKeys*)right_ptr)->val_ptr->value_elements[right_index] == NULL;
}
}

PrometheusMetricKeys::PrometheusMetricKeys()
{
val_ptr = NULL;
}

PrometheusMetricKeys::PrometheusMetricKeys(null_type)
{
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
}

PrometheusMetricKeys::PrometheusMetricKeys(const PrometheusMetricKeys& other_value)
{
if (!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}

PrometheusMetricKeys::~PrometheusMetricKeys()
{
clean_up();
if (val_ptr != NULL) val_ptr = NULL;
}

void PrometheusMetricKeys::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.");
}
}

PrometheusMetricKeys& PrometheusMetricKeys::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;
}

PrometheusMetricKeys& PrometheusMetricKeys::operator=(const PrometheusMetricKeys& other_value)
{
if (other_value.val_ptr == NULL) TTCN_error("Assigning an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
if (this != &other_value) {
clean_up();
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
return *this;
}

boolean PrometheusMetricKeys::operator==(null_type) const
{
if (val_ptr == NULL)
TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
return val_ptr->n_elements == 0 ;
}

boolean PrometheusMetricKeys::operator==(const PrometheusMetricKeys& other_value) const
{
if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
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);
}

PrometheusMetricKey& PrometheusMetricKeys::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of type @Prometheus_Checker.PrometheusMetricKeys 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 = (PrometheusMetricKey**)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 PrometheusMetricKey(*(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 PrometheusMetricKey;
}
return *val_ptr->value_elements[index_value];
}

PrometheusMetricKey& PrometheusMetricKeys::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Prometheus_Checker.PrometheusMetricKeys.");
return (*this)[(int)index_value];
}

const PrometheusMetricKey& PrometheusMetricKeys::operator[](int index_value) const
{
if (val_ptr == NULL)
TTCN_error("Accessing an element in an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
if (index_value < 0) TTCN_error("Accessing an element of type @Prometheus_Checker.PrometheusMetricKeys using a negative index: %d.", index_value);
if (index_value >= val_ptr->n_elements) TTCN_error("Index overflow in a value of type @Prometheus_Checker.PrometheusMetricKeys: 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 PrometheusMetricKey& PrometheusMetricKeys::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Prometheus_Checker.PrometheusMetricKeys.");
return (*this)[(int)index_value];
}

PrometheusMetricKeys PrometheusMetricKeys::operator<<=(int rotate_count) const
{
return *this >>= (-rotate_count);
}

PrometheusMetricKeys PrometheusMetricKeys::operator<<=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate left operator.");
return *this >>= (int)(-rotate_count);
}

PrometheusMetricKeys PrometheusMetricKeys::operator>>=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate right operator.");
return *this >>= (int)rotate_count;
}

PrometheusMetricKeys PrometheusMetricKeys::operator>>=(int rotate_count) const
{
if (val_ptr == NULL) TTCN_error("Performing rotation operation on an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
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;
PrometheusMetricKeys ret_val;
ret_val.set_size(val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[(i+rc)%val_ptr->n_elements] =new PrometheusMetricKey(*val_ptr->value_elements[i]);
}
}
return ret_val;
}

PrometheusMetricKeys PrometheusMetricKeys::operator+(const PrometheusMetricKeys& other_value) const
{
if (val_ptr == NULL || other_value.val_ptr == NULL) TTCN_error("Unbound operand of @Prometheus_Checker.PrometheusMetricKeys concatenation.");
if (val_ptr->n_elements == 0) return other_value;
if (other_value.val_ptr->n_elements == 0) return *this;
PrometheusMetricKeys ret_val;
ret_val.set_size(val_ptr->n_elements+other_value.val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i] = new PrometheusMetricKey(*val_ptr->value_elements[i]);
}
}
for (int i=0; i<other_value.val_ptr->n_elements; i++) {
if (other_value.val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i+val_ptr->n_elements] = new PrometheusMetricKey(*other_value.val_ptr->value_elements[i]);
}
}
return ret_val;
}

PrometheusMetricKeys PrometheusMetricKeys::substr(int index, int returncount) const
{
if (val_ptr == NULL) TTCN_error("The first argument of substr() is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
check_substr_arguments(val_ptr->n_elements, index, returncount, "@Prometheus_Checker.PrometheusMetricKeys","element");
PrometheusMetricKeys ret_val;
ret_val.set_size(returncount);
for (int i=0; i<returncount; i++) {
if (val_ptr->value_elements[i+index] != NULL) {
ret_val.val_ptr->value_elements[i] = new PrometheusMetricKey(*val_ptr->value_elements[i+index]);
}
}
return ret_val;
}

PrometheusMetricKeys PrometheusMetricKeys::replace(int index, int len, const PrometheusMetricKeys& repl) const
{
if (val_ptr == NULL) TTCN_error("The first argument of replace() is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
if (repl.val_ptr == NULL) TTCN_error("The fourth argument of replace() is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
check_replace_arguments(val_ptr->n_elements, index, len, "@Prometheus_Checker.PrometheusMetricKeys","element");
PrometheusMetricKeys 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 PrometheusMetricKey(*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 PrometheusMetricKey(*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 PrometheusMetricKey(*val_ptr->value_elements[index+i+len]);
}
}
return ret_val;
}

PrometheusMetricKeys PrometheusMetricKeys::replace(int index, int len, const PrometheusMetricKeys_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 PrometheusMetricKeys::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a value of type @Prometheus_Checker.PrometheusMetricKeys.");
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 = (PrometheusMetricKey**)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 PrometheusMetricKey(*(val_ptr->value_elements[elem_count]));
}
}
clean_up();
val_ptr = new_val_ptr;
}
if (new_size > val_ptr->n_elements) {
val_ptr->value_elements = (PrometheusMetricKey**)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 @Prometheus_Checker.PrometheusMetricKeys: %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 = (PrometheusMetricKey**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size);
val_ptr->n_elements = new_size;
}
}

boolean PrometheusMetricKeys::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 PrometheusMetricKeys::size_of() const
{
if (val_ptr == NULL) TTCN_error("Performing sizeof operation on an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
return val_ptr->n_elements;
}

int PrometheusMetricKeys::lengthof() const
{
if (val_ptr == NULL) TTCN_error("Performing lengthof operation on an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
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 PrometheusMetricKeys::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 PrometheusMetricKeys::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 PrometheusMetricKeys::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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        if (curr->get_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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        (*this)[curr->get_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", "@Prometheus_Checker.PrometheusMetricKeys");
    }
    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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        if ((curr->get_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", "@Prometheus_Checker.PrometheusMetricKeys");
    }
    break;
  default:
    TTCN_error("Internal error: Unknown operation type.");
  }
}

void PrometheusMetricKeys::encode_text(Text_Buf& text_buf) const
{
if (val_ptr == NULL) TTCN_error("Text encoder: Encoding an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
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 PrometheusMetricKeys::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 @Prometheus_Checker.PrometheusMetricKeys.");
val_ptr->value_elements = (PrometheusMetricKey**)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 PrometheusMetricKey;
val_ptr->value_elements[elem_count]->decode_text(text_buf);
}
}

void PrometheusMetricKeys_template::copy_value(const PrometheusMetricKeys& other_value)
{
if (!other_value.is_bound()) TTCN_error("Initialization of a template of type @Prometheus_Checker.PrometheusMetricKeys with an unbound value.");
single_value.n_elements = other_value.size_of();
single_value.value_elements = (PrometheusMetricKey_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 PrometheusMetricKey_template(other_value[elem_count]);
} else {
single_value.value_elements[elem_count] = new PrometheusMetricKey_template;
}
}
set_selection(SPECIFIC_VALUE);
}

void PrometheusMetricKeys_template::copy_template(const PrometheusMetricKeys_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 = (PrometheusMetricKey_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 PrometheusMetricKey_template(*other_value.single_value.value_elements[elem_count]);
} else {
single_value.value_elements[elem_count] = new PrometheusMetricKey_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 PrometheusMetricKeys_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 PrometheusMetricKey_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 PrometheusMetricKeys_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusMetricKeys_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 @Prometheus_Checker.PrometheusMetricKeys.");
break;
}
set_selection(other_value);
}

boolean PrometheusMetricKeys_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 PrometheusMetricKeys_template*)template_ptr)->single_value.value_elements[template_index]->match((*(const PrometheusMetricKeys*)value_ptr)[value_index], legacy);
else return ((const PrometheusMetricKeys_template*)template_ptr)->single_value.value_elements[template_index]->is_any_or_omit();
}

boolean PrometheusMetricKeys_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 PrometheusMetricKeys_template*)template_ptr)->value_set.set_items[template_index].match((*(const PrometheusMetricKeys*)value_ptr)[value_index], legacy);
else return ((const PrometheusMetricKeys_template*)template_ptr)->value_set.set_items[template_index].is_any_or_omit();
}

void PrometheusMetricKeys_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 PrometheusMetricKeys_template*)template_ptr)->single_value.value_elements[index_template]->log();
}
} else if (template_ptr == NULL) {
(*(const PrometheusMetricKeys*)value_ptr)[index_value].log();
} else {
((const PrometheusMetricKeys_template*)template_ptr)->single_value.value_elements[index_template]->log_match((*(const PrometheusMetricKeys*)value_ptr)[index_value], legacy);
}
}

PrometheusMetricKeys_template::PrometheusMetricKeys_template()
{
}

PrometheusMetricKeys_template::PrometheusMetricKeys_template(template_sel other_value)
 : Restricted_Length_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusMetricKeys_template::PrometheusMetricKeys_template(null_type)
 : Restricted_Length_Template(SPECIFIC_VALUE)
{
single_value.n_elements = 0;
single_value.value_elements = NULL;
}

PrometheusMetricKeys_template::PrometheusMetricKeys_template(const PrometheusMetricKeys& other_value)
{
copy_value(other_value);
}

PrometheusMetricKeys_template::PrometheusMetricKeys_template(const OPTIONAL<PrometheusMetricKeys>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusMetricKeys&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Prometheus_Checker.PrometheusMetricKeys from an unbound optional field.");
}
}

PrometheusMetricKeys_template::PrometheusMetricKeys_template(PrometheusMetricKeys_template* p_precondition, PrometheusMetricKeys_template* p_implied_template)
 : Restricted_Length_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusMetricKeys_template::PrometheusMetricKeys_template(Dynamic_Match_Interface<PrometheusMetricKeys>* p_dyn_match)
 : Restricted_Length_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusMetricKeys>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusMetricKeys_template::PrometheusMetricKeys_template(const PrometheusMetricKeys_template& other_value)
 : Restricted_Length_Template()
{
copy_template(other_value);
}

PrometheusMetricKeys_template::~PrometheusMetricKeys_template()
{
clean_up();
}

void PrometheusMetricKeys_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;
}

PrometheusMetricKeys_template& PrometheusMetricKeys_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusMetricKeys_template& PrometheusMetricKeys_template::operator=(null_type)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value.n_elements = 0;
single_value.value_elements = NULL;
return *this;
}

PrometheusMetricKeys_template& PrometheusMetricKeys_template::operator=(const PrometheusMetricKeys& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

PrometheusMetricKeys_template& PrometheusMetricKeys_template::operator=(const OPTIONAL<PrometheusMetricKeys>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusMetricKeys&)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 @Prometheus_Checker.PrometheusMetricKeys.");
}
return *this;
}

PrometheusMetricKeys_template& PrometheusMetricKeys_template::operator=(const PrometheusMetricKeys_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

PrometheusMetricKey_template& PrometheusMetricKeys_template::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Prometheus_Checker.PrometheusMetricKeys 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 @Prometheus_Checker.PrometheusMetricKeys.");
    break;
}
return *single_value.value_elements[index_value];
}

PrometheusMetricKey_template& PrometheusMetricKeys_template::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Prometheus_Checker.PrometheusMetricKeys.");
return (*this)[(int)index_value];
}

const PrometheusMetricKey_template& PrometheusMetricKeys_template::operator[](int index_value) const
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Prometheus_Checker.PrometheusMetricKeys using a negative index: %d.", index_value);
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing an element of a non-specific template for type @Prometheus_Checker.PrometheusMetricKeys.");
if (index_value >= single_value.n_elements) TTCN_error("Index overflow in a template of type @Prometheus_Checker.PrometheusMetricKeys: 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 PrometheusMetricKey_template& PrometheusMetricKeys_template::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Prometheus_Checker.PrometheusMetricKeys.");
return (*this)[(int)index_value];
}

void PrometheusMetricKeys_template::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a template of type @Prometheus_Checker.PrometheusMetricKeys.");
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 = (PrometheusMetricKey_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 PrometheusMetricKey_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 PrometheusMetricKey_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 = (PrometheusMetricKey_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size);
single_value.n_elements = new_size;
}
}

int PrometheusMetricKeys_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 PrometheusMetricKeys_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 @Prometheus_Checker.PrometheusMetricKeys 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; i<elem_count; i++) {
    switch (single_value.value_elements[i]->get_selection()) {
    case OMIT_VALUE:
      TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusMetricKeys 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; i<elem_count; i++) {
    switch (value_set.set_items[i].get_selection())
    {
    case OMIT_VALUE:
      TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusMetricKeys containing omit element.", op_name);
    case ANY_OR_OMIT:
      has_any_or_none = TRUE;
      break;
    default:
      min_size++;
      break;
    }
  }
  if (template_selection==SUPERSET_MATCH) {
    has_any_or_none = TRUE;
   } else {
    int max_size = min_size;
    min_size = 0;
    if (!has_any_or_none) { // [0,max_size]
      switch (length_restriction_type) {
      case NO_LENGTH_RESTRICTION:
        if (max_size==0) return 0;
        TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusMetricKeys with no exact size.", op_name);
      case SINGLE_LENGTH_RESTRICTION:
        if (length_restriction.single_length<=max_size)
          return length_restriction.single_length;
        TTCN_error("Performing %sof() operation on an invalid template of type @Prometheus_Checker.PrometheusMetricKeys. The maximum size (%d) contradicts the length restriction (%d).", op_name, max_size, length_restriction.single_length);
      case RANGE_LENGTH_RESTRICTION:
        if (max_size==length_restriction.range_length.min_length) {
          return max_size;
        } else if (max_size>length_restriction.range_length.min_length){
          TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusMetricKeys with no exact size.", op_name);
        } else
          TTCN_error("Performing %sof() operation on an invalid template of type @Prometheus_Checker.PrometheusMetricKeys. 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 @Prometheus_Checker.PrometheusMetricKeys 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 @Prometheus_Checker.PrometheusMetricKeys 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 @Prometheus_Checker.PrometheusMetricKeys 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 @Prometheus_Checker.PrometheusMetricKeys containing complemented list.", op_name);
default:
  TTCN_error("Performing %sof() operation on an uninitialized/unsupported template of type @Prometheus_Checker.PrometheusMetricKeys.", op_name);
}
return check_section_is_single(min_size, has_any_or_none, op_name, "a", "template of type @Prometheus_Checker.PrometheusMetricKeys");
}

boolean PrometheusMetricKeys_template::match(const PrometheusMetricKeys& 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 @Prometheus_Checker.PrometheusMetricKeys.");
}
return FALSE;
}

boolean PrometheusMetricKeys_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;
}

PrometheusMetricKeys PrometheusMetricKeys_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 @Prometheus_Checker.PrometheusMetricKeys.");
PrometheusMetricKeys 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;
}

PrometheusMetricKeys PrometheusMetricKeys_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);
}

PrometheusMetricKeys PrometheusMetricKeys_template::replace(int index, int len, const PrometheusMetricKeys_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());
}

PrometheusMetricKeys PrometheusMetricKeys_template::replace(int index, int len, const PrometheusMetricKeys& 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 PrometheusMetricKeys_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 PrometheusMetricKeys_template[list_length];
break;
case SUPERSET_MATCH:
case SUBSET_MATCH:
value_set.n_items = list_length;
value_set.set_items = new PrometheusMetricKey_template[list_length];
break;
default:
TTCN_error("Internal error: Setting an invalid type for a template of type @Prometheus_Checker.PrometheusMetricKeys.");
}
set_selection(template_type);
}

PrometheusMetricKeys_template& PrometheusMetricKeys_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 @Prometheus_Checker.PrometheusMetricKeys.");
if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of type @Prometheus_Checker.PrometheusMetricKeys.");
return value_list.list_value[list_index];
}

PrometheusMetricKey_template& PrometheusMetricKeys_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 @Prometheus_Checker.PrometheusMetricKeys.");
if (set_index >= value_set.n_items) TTCN_error("Internal error: Index overflow in a set template of type @Prometheus_Checker.PrometheusMetricKeys.");
return value_set.set_items[set_index];
}

void PrometheusMetricKeys_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 PrometheusMetricKeys_template::log_match(const PrometheusMetricKeys& 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 PrometheusMetricKeys_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 @Prometheus_Checker.PrometheusMetricKeys.");
}
}

void PrometheusMetricKeys_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 @Prometheus_Checker.PrometheusMetricKeys.");
single_value.value_elements = (PrometheusMetricKey_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 PrometheusMetricKey_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 PrometheusMetricKeys_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 PrometheusMetricKey_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 @Prometheus_Checker.PrometheusMetricKeys.");
}
}

boolean PrometheusMetricKeys_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusMetricKeys_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; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

void PrometheusMetricKeys_template::set_implicit_omit()
{
if (template_selection != SPECIFIC_VALUE) return;
for (int i = 0; i < single_value.n_elements; i++) {
if (single_value.value_elements[i] != NULL) single_value.value_elements[i]->set_implicit_omit();
}
}

void PrometheusMetricKeys_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: {
    PrometheusMetricKeys_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_i<param.get_size(); p_i++) {
      temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = temp;
    break; }
  case Module_Param::MP_Indexed_List:
    if (template_selection!=SPECIFIC_VALUE) set_size(0);
    for (size_t p_i=0; p_i<param.get_size(); ++p_i) {
      (*this)[(int)(param.get_elem(p_i)->get_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_i<param.get_size(); ++p_i) {
      if (param.get_elem(p_i)->get_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_i<param.get_size(); p_i++) {
      set_item(p_i).set_param(*param.get_elem(p_i));
    }
    break;
  case Module_Param::MP_Implication_Template: {
    PrometheusMetricKeys_template* precondition = new PrometheusMetricKeys_template;
    precondition->set_param(*param.get_elem(0));
    PrometheusMetricKeys_template* implied_template = new PrometheusMetricKeys_template;
    implied_template->set_param(*param.get_elem(1));
    *this = PrometheusMetricKeys_template(precondition, implied_template);
  } break;
  default:
    param.type_error("set of template", "@Prometheus_Checker.PrometheusMetricKeys");
  }
  is_ifpresent = param.get_ifpresent();
  set_length_range(param);
}

void PrometheusMetricKeys_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; i<single_value.n_elements; i++) single_value.value_elements[i]->check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusMetricKeys");
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 : "@Prometheus_Checker.PrometheusMetricKeys");
}

boolean PrometheusMetricKeys_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);
}
}
PrometheusMetric::PrometheusMetric()
{
}

PrometheusMetric::PrometheusMetric(const PrometheusMetricKey& par_key,
    const INTEGER& par_val)
  :   field_key(par_key),
  field_val(par_val)
{
}

PrometheusMetric::PrometheusMetric(const PrometheusMetric& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Prometheus_Checker.PrometheusMetric.");
if (other_value.key().is_bound()) field_key = other_value.key();
else field_key.clean_up();
if (other_value.val().is_bound()) field_val = other_value.val();
else field_val.clean_up();
}

void PrometheusMetric::clean_up()
{
field_key.clean_up();
field_val.clean_up();
}

const TTCN_Typedescriptor_t* PrometheusMetric::get_descriptor() const { return &PrometheusMetric_descr_; }
PrometheusMetric& PrometheusMetric::operator=(const PrometheusMetric& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Prometheus_Checker.PrometheusMetric.");
  if (other_value.key().is_bound()) field_key = other_value.key();
  else field_key.clean_up();
  if (other_value.val().is_bound()) field_val = other_value.val();
  else field_val.clean_up();
}
return *this;
}

boolean PrometheusMetric::operator==(const PrometheusMetric& other_value) const
{
return field_key==other_value.field_key
  && field_val==other_value.field_val;
}

boolean PrometheusMetric::is_bound() const
{
return (field_key.is_bound())
  || (field_val.is_bound());
}
boolean PrometheusMetric::is_value() const
{
return field_key.is_value()
  && field_val.is_value();
}
void PrometheusMetric::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ key := ");
field_key.log();
TTCN_Logger::log_event_str(", val := ");
field_val.log();
TTCN_Logger::log_event_str(" }");
}

void PrometheusMetric::set_implicit_omit()
{
if (key().is_bound()) key().set_implicit_omit();
if (val().is_bound()) val().set_implicit_omit();
}

void PrometheusMetric::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record value of type @Prometheus_Checker.PrometheusMetric has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) key().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) val().set_param(*param.get_elem(1));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "key")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          key().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "val")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          val().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Prometheus_Checker.PrometheusMetric: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@Prometheus_Checker.PrometheusMetric");
  }
}

void PrometheusMetric::encode_text(Text_Buf& text_buf) const
{
field_key.encode_text(text_buf);
field_val.encode_text(text_buf);
}

void PrometheusMetric::decode_text(Text_Buf& text_buf)
{
field_key.decode_text(text_buf);
field_val.decode_text(text_buf);
}

struct PrometheusMetric_template::single_value_struct {
PrometheusMetricKey_template field_key;
INTEGER_template field_val;
};

void PrometheusMetric_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_key = ANY_VALUE;
single_value->field_val = ANY_VALUE;
}
}
}

void PrometheusMetric_template::copy_value(const PrometheusMetric& other_value)
{
single_value = new single_value_struct;
if (other_value.key().is_bound()) {
  single_value->field_key = other_value.key();
} else {
  single_value->field_key.clean_up();
}
if (other_value.val().is_bound()) {
  single_value->field_val = other_value.val();
} else {
  single_value->field_val.clean_up();
}
set_selection(SPECIFIC_VALUE);
}

void PrometheusMetric_template::copy_template(const PrometheusMetric_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.key().get_selection()) {
single_value->field_key = other_value.key();
} else {
single_value->field_key.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.val().get_selection()) {
single_value->field_val = other_value.val();
} else {
single_value->field_val.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 PrometheusMetric_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 PrometheusMetric_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusMetric_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 @Prometheus_Checker.PrometheusMetric.");
break;
}
set_selection(other_value);
}

PrometheusMetric_template::PrometheusMetric_template()
{
}

PrometheusMetric_template::PrometheusMetric_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusMetric_template::PrometheusMetric_template(const PrometheusMetric& other_value)
{
copy_value(other_value);
}

PrometheusMetric_template::PrometheusMetric_template(const OPTIONAL<PrometheusMetric>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusMetric&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Prometheus_Checker.PrometheusMetric from an unbound optional field.");
}
}

PrometheusMetric_template::PrometheusMetric_template(PrometheusMetric_template* p_precondition, PrometheusMetric_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusMetric_template::PrometheusMetric_template(Dynamic_Match_Interface<PrometheusMetric>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusMetric>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusMetric_template::PrometheusMetric_template(const PrometheusMetric_template& other_value)
: Base_Template()
{
copy_template(other_value);
}

PrometheusMetric_template::~PrometheusMetric_template()
{
clean_up();
}

PrometheusMetric_template& PrometheusMetric_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusMetric_template& PrometheusMetric_template::operator=(const PrometheusMetric& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

PrometheusMetric_template& PrometheusMetric_template::operator=(const OPTIONAL<PrometheusMetric>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusMetric&)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 @Prometheus_Checker.PrometheusMetric.");
}
return *this;
}

PrometheusMetric_template& PrometheusMetric_template::operator=(const PrometheusMetric_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean PrometheusMetric_template::match(const PrometheusMetric& 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.key().is_bound()) return FALSE;
if(!single_value->field_key.match(other_value.key(), legacy))return FALSE;
if(!other_value.val().is_bound()) return FALSE;
if(!single_value->field_val.match(other_value.val(), 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 @Prometheus_Checker.PrometheusMetric.");
}
return FALSE;
}

boolean PrometheusMetric_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_key.is_bound()
 || single_value->field_val.is_bound();
}

boolean PrometheusMetric_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_key.is_value()
 && single_value->field_val.is_value();
}

void PrometheusMetric_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;
}

PrometheusMetric PrometheusMetric_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 @Prometheus_Checker.PrometheusMetric.");
PrometheusMetric ret_val;
if (single_value->field_key.is_bound()) {
ret_val.key() = single_value->field_key.valueof();
}
if (single_value->field_val.is_bound()) {
ret_val.val() = single_value->field_val.valueof();
}
return ret_val;
}

void PrometheusMetric_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 @Prometheus_Checker.PrometheusMetric.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new PrometheusMetric_template[list_length];
}

PrometheusMetric_template& PrometheusMetric_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 @Prometheus_Checker.PrometheusMetric.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Prometheus_Checker.PrometheusMetric.");
return value_list.list_value[list_index];
}

PrometheusMetricKey_template& PrometheusMetric_template::key()
{
set_specific();
return single_value->field_key;
}

const PrometheusMetricKey_template& PrometheusMetric_template::key() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field key of a non-specific template of type @Prometheus_Checker.PrometheusMetric.");
return single_value->field_key;
}

INTEGER_template& PrometheusMetric_template::val()
{
set_specific();
return single_value->field_val;
}

const INTEGER_template& PrometheusMetric_template::val() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field val of a non-specific template of type @Prometheus_Checker.PrometheusMetric.");
return single_value->field_val;
}

int PrometheusMetric_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetric 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 @Prometheus_Checker.PrometheusMetric 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 @Prometheus_Checker.PrometheusMetric containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetric containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetric containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetric containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetric containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetric containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusMetric containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Prometheus_Checker.PrometheusMetric.");
  }
  return 0;
}

void PrometheusMetric_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ key := ");
single_value->field_key.log();
TTCN_Logger::log_event_str(", val := ");
single_value->field_val.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 PrometheusMetric_template::log_match(const PrometheusMetric& 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_key.match(match_value.key(), legacy)){
TTCN_Logger::log_logmatch_info(".key");
single_value->field_key.log_match(match_value.key(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_val.match(match_value.val(), legacy)){
TTCN_Logger::log_logmatch_info(".val");
single_value->field_val.log_match(match_value.val(), 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("{ key := ");
single_value->field_key.log_match(match_value.key(), legacy);
TTCN_Logger::log_event_str(", val := ");
single_value->field_val.log_match(match_value.val(), 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 PrometheusMetric_template::set_implicit_omit()
{
if (template_selection != SPECIFIC_VALUE) return;
if (key().is_bound()) key().set_implicit_omit();
if (val().is_bound()) val().set_implicit_omit();
}

void PrometheusMetric_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_key.encode_text(text_buf);
single_value->field_val.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 @Prometheus_Checker.PrometheusMetric.");
}
}

void PrometheusMetric_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_key.decode_text(text_buf);
single_value->field_val.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 PrometheusMetric_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 @Prometheus_Checker.PrometheusMetric.");
}
}

void PrometheusMetric_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: {
    PrometheusMetric_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_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record template of type @Prometheus_Checker.PrometheusMetric has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) key().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) val().set_param(*param.get_elem(1));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "key")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          key().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "val")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          val().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Prometheus_Checker.PrometheusMetric: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    PrometheusMetric_template* precondition = new PrometheusMetric_template;
    precondition->set_param(*param.get_elem(0));
    PrometheusMetric_template* implied_template = new PrometheusMetric_template;
    implied_template->set_param(*param.get_elem(1));
    *this = PrometheusMetric_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@Prometheus_Checker.PrometheusMetric");
  }
  is_ifpresent = param.get_ifpresent();
}

void PrometheusMetric_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_key.check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusMetric");
single_value->field_val.check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusMetric");
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 : "@Prometheus_Checker.PrometheusMetric");
}

boolean PrometheusMetric_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusMetric_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_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}


const PrometheusMetric PrometheusMetrics::UNBOUND_ELEM;
boolean PrometheusMetrics::compare_function(const Base_Type *left_ptr, int left_index, const Base_Type *right_ptr, int right_index)
{
if (((const PrometheusMetrics*)left_ptr)->val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
if (((const PrometheusMetrics*)right_ptr)->val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
if (((const PrometheusMetrics*)left_ptr)->val_ptr->value_elements[left_index] != NULL){
if (((const PrometheusMetrics*)right_ptr)->val_ptr->value_elements[right_index] != NULL){
return *((const PrometheusMetrics*)left_ptr)->val_ptr->value_elements[left_index] == *((const PrometheusMetrics*)right_ptr)->val_ptr->value_elements[right_index];
} else return FALSE;
} else {
return ((const PrometheusMetrics*)right_ptr)->val_ptr->value_elements[right_index] == NULL;
}
}

PrometheusMetrics::PrometheusMetrics()
{
val_ptr = NULL;
}

PrometheusMetrics::PrometheusMetrics(null_type)
{
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
}

PrometheusMetrics::PrometheusMetrics(const PrometheusMetrics& other_value)
{
if (!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}

PrometheusMetrics::~PrometheusMetrics()
{
clean_up();
if (val_ptr != NULL) val_ptr = NULL;
}

void PrometheusMetrics::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.");
}
}

PrometheusMetrics& PrometheusMetrics::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;
}

PrometheusMetrics& PrometheusMetrics::operator=(const PrometheusMetrics& other_value)
{
if (other_value.val_ptr == NULL) TTCN_error("Assigning an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
if (this != &other_value) {
clean_up();
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
return *this;
}

boolean PrometheusMetrics::operator==(null_type) const
{
if (val_ptr == NULL)
TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
return val_ptr->n_elements == 0 ;
}

boolean PrometheusMetrics::operator==(const PrometheusMetrics& other_value) const
{
if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
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);
}

PrometheusMetric& PrometheusMetrics::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of type @Prometheus_Checker.PrometheusMetrics 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 = (PrometheusMetric**)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 PrometheusMetric(*(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 PrometheusMetric;
}
return *val_ptr->value_elements[index_value];
}

PrometheusMetric& PrometheusMetrics::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Prometheus_Checker.PrometheusMetrics.");
return (*this)[(int)index_value];
}

const PrometheusMetric& PrometheusMetrics::operator[](int index_value) const
{
if (val_ptr == NULL)
TTCN_error("Accessing an element in an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
if (index_value < 0) TTCN_error("Accessing an element of type @Prometheus_Checker.PrometheusMetrics using a negative index: %d.", index_value);
if (index_value >= val_ptr->n_elements) TTCN_error("Index overflow in a value of type @Prometheus_Checker.PrometheusMetrics: 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 PrometheusMetric& PrometheusMetrics::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Prometheus_Checker.PrometheusMetrics.");
return (*this)[(int)index_value];
}

PrometheusMetrics PrometheusMetrics::operator<<=(int rotate_count) const
{
return *this >>= (-rotate_count);
}

PrometheusMetrics PrometheusMetrics::operator<<=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate left operator.");
return *this >>= (int)(-rotate_count);
}

PrometheusMetrics PrometheusMetrics::operator>>=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate right operator.");
return *this >>= (int)rotate_count;
}

PrometheusMetrics PrometheusMetrics::operator>>=(int rotate_count) const
{
if (val_ptr == NULL) TTCN_error("Performing rotation operation on an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
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;
PrometheusMetrics ret_val;
ret_val.set_size(val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[(i+rc)%val_ptr->n_elements] =new PrometheusMetric(*val_ptr->value_elements[i]);
}
}
return ret_val;
}

PrometheusMetrics PrometheusMetrics::operator+(const PrometheusMetrics& other_value) const
{
if (val_ptr == NULL || other_value.val_ptr == NULL) TTCN_error("Unbound operand of @Prometheus_Checker.PrometheusMetrics concatenation.");
if (val_ptr->n_elements == 0) return other_value;
if (other_value.val_ptr->n_elements == 0) return *this;
PrometheusMetrics ret_val;
ret_val.set_size(val_ptr->n_elements+other_value.val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i] = new PrometheusMetric(*val_ptr->value_elements[i]);
}
}
for (int i=0; i<other_value.val_ptr->n_elements; i++) {
if (other_value.val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i+val_ptr->n_elements] = new PrometheusMetric(*other_value.val_ptr->value_elements[i]);
}
}
return ret_val;
}

PrometheusMetrics PrometheusMetrics::substr(int index, int returncount) const
{
if (val_ptr == NULL) TTCN_error("The first argument of substr() is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
check_substr_arguments(val_ptr->n_elements, index, returncount, "@Prometheus_Checker.PrometheusMetrics","element");
PrometheusMetrics ret_val;
ret_val.set_size(returncount);
for (int i=0; i<returncount; i++) {
if (val_ptr->value_elements[i+index] != NULL) {
ret_val.val_ptr->value_elements[i] = new PrometheusMetric(*val_ptr->value_elements[i+index]);
}
}
return ret_val;
}

PrometheusMetrics PrometheusMetrics::replace(int index, int len, const PrometheusMetrics& repl) const
{
if (val_ptr == NULL) TTCN_error("The first argument of replace() is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
if (repl.val_ptr == NULL) TTCN_error("The fourth argument of replace() is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
check_replace_arguments(val_ptr->n_elements, index, len, "@Prometheus_Checker.PrometheusMetrics","element");
PrometheusMetrics 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 PrometheusMetric(*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 PrometheusMetric(*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 PrometheusMetric(*val_ptr->value_elements[index+i+len]);
}
}
return ret_val;
}

PrometheusMetrics PrometheusMetrics::replace(int index, int len, const PrometheusMetrics_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 PrometheusMetrics::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a value of type @Prometheus_Checker.PrometheusMetrics.");
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 = (PrometheusMetric**)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 PrometheusMetric(*(val_ptr->value_elements[elem_count]));
}
}
clean_up();
val_ptr = new_val_ptr;
}
if (new_size > val_ptr->n_elements) {
val_ptr->value_elements = (PrometheusMetric**)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 @Prometheus_Checker.PrometheusMetrics: %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 = (PrometheusMetric**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size);
val_ptr->n_elements = new_size;
}
}

boolean PrometheusMetrics::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 PrometheusMetrics::size_of() const
{
if (val_ptr == NULL) TTCN_error("Performing sizeof operation on an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
return val_ptr->n_elements;
}

int PrometheusMetrics::lengthof() const
{
if (val_ptr == NULL) TTCN_error("Performing lengthof operation on an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
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 PrometheusMetrics::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 PrometheusMetrics::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 PrometheusMetrics::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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        if (curr->get_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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        (*this)[curr->get_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", "@Prometheus_Checker.PrometheusMetrics");
    }
    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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        if ((curr->get_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", "@Prometheus_Checker.PrometheusMetrics");
    }
    break;
  default:
    TTCN_error("Internal error: Unknown operation type.");
  }
}

void PrometheusMetrics::encode_text(Text_Buf& text_buf) const
{
if (val_ptr == NULL) TTCN_error("Text encoder: Encoding an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
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 PrometheusMetrics::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 @Prometheus_Checker.PrometheusMetrics.");
val_ptr->value_elements = (PrometheusMetric**)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 PrometheusMetric;
val_ptr->value_elements[elem_count]->decode_text(text_buf);
}
}

void PrometheusMetrics_template::copy_value(const PrometheusMetrics& other_value)
{
if (!other_value.is_bound()) TTCN_error("Initialization of a template of type @Prometheus_Checker.PrometheusMetrics with an unbound value.");
single_value.n_elements = other_value.size_of();
single_value.value_elements = (PrometheusMetric_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 PrometheusMetric_template(other_value[elem_count]);
} else {
single_value.value_elements[elem_count] = new PrometheusMetric_template;
}
}
set_selection(SPECIFIC_VALUE);
}

void PrometheusMetrics_template::copy_template(const PrometheusMetrics_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 = (PrometheusMetric_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 PrometheusMetric_template(*other_value.single_value.value_elements[elem_count]);
} else {
single_value.value_elements[elem_count] = new PrometheusMetric_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 PrometheusMetrics_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 PrometheusMetric_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 PrometheusMetrics_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusMetrics_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 @Prometheus_Checker.PrometheusMetrics.");
break;
}
set_selection(other_value);
}

boolean PrometheusMetrics_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 PrometheusMetrics_template*)template_ptr)->single_value.value_elements[template_index]->match((*(const PrometheusMetrics*)value_ptr)[value_index], legacy);
else return ((const PrometheusMetrics_template*)template_ptr)->single_value.value_elements[template_index]->is_any_or_omit();
}

boolean PrometheusMetrics_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 PrometheusMetrics_template*)template_ptr)->value_set.set_items[template_index].match((*(const PrometheusMetrics*)value_ptr)[value_index], legacy);
else return ((const PrometheusMetrics_template*)template_ptr)->value_set.set_items[template_index].is_any_or_omit();
}

void PrometheusMetrics_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 PrometheusMetrics_template*)template_ptr)->single_value.value_elements[index_template]->log();
}
} else if (template_ptr == NULL) {
(*(const PrometheusMetrics*)value_ptr)[index_value].log();
} else {
((const PrometheusMetrics_template*)template_ptr)->single_value.value_elements[index_template]->log_match((*(const PrometheusMetrics*)value_ptr)[index_value], legacy);
}
}

PrometheusMetrics_template::PrometheusMetrics_template()
{
}

PrometheusMetrics_template::PrometheusMetrics_template(template_sel other_value)
 : Restricted_Length_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusMetrics_template::PrometheusMetrics_template(null_type)
 : Restricted_Length_Template(SPECIFIC_VALUE)
{
single_value.n_elements = 0;
single_value.value_elements = NULL;
}

PrometheusMetrics_template::PrometheusMetrics_template(const PrometheusMetrics& other_value)
{
copy_value(other_value);
}

PrometheusMetrics_template::PrometheusMetrics_template(const OPTIONAL<PrometheusMetrics>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusMetrics&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Prometheus_Checker.PrometheusMetrics from an unbound optional field.");
}
}

PrometheusMetrics_template::PrometheusMetrics_template(PrometheusMetrics_template* p_precondition, PrometheusMetrics_template* p_implied_template)
 : Restricted_Length_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusMetrics_template::PrometheusMetrics_template(Dynamic_Match_Interface<PrometheusMetrics>* p_dyn_match)
 : Restricted_Length_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusMetrics>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusMetrics_template::PrometheusMetrics_template(const PrometheusMetrics_template& other_value)
 : Restricted_Length_Template()
{
copy_template(other_value);
}

PrometheusMetrics_template::~PrometheusMetrics_template()
{
clean_up();
}

void PrometheusMetrics_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;
}

PrometheusMetrics_template& PrometheusMetrics_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusMetrics_template& PrometheusMetrics_template::operator=(null_type)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value.n_elements = 0;
single_value.value_elements = NULL;
return *this;
}

PrometheusMetrics_template& PrometheusMetrics_template::operator=(const PrometheusMetrics& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

PrometheusMetrics_template& PrometheusMetrics_template::operator=(const OPTIONAL<PrometheusMetrics>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusMetrics&)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 @Prometheus_Checker.PrometheusMetrics.");
}
return *this;
}

PrometheusMetrics_template& PrometheusMetrics_template::operator=(const PrometheusMetrics_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

PrometheusMetric_template& PrometheusMetrics_template::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Prometheus_Checker.PrometheusMetrics 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 @Prometheus_Checker.PrometheusMetrics.");
    break;
}
return *single_value.value_elements[index_value];
}

PrometheusMetric_template& PrometheusMetrics_template::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Prometheus_Checker.PrometheusMetrics.");
return (*this)[(int)index_value];
}

const PrometheusMetric_template& PrometheusMetrics_template::operator[](int index_value) const
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Prometheus_Checker.PrometheusMetrics using a negative index: %d.", index_value);
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing an element of a non-specific template for type @Prometheus_Checker.PrometheusMetrics.");
if (index_value >= single_value.n_elements) TTCN_error("Index overflow in a template of type @Prometheus_Checker.PrometheusMetrics: 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 PrometheusMetric_template& PrometheusMetrics_template::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Prometheus_Checker.PrometheusMetrics.");
return (*this)[(int)index_value];
}

void PrometheusMetrics_template::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a template of type @Prometheus_Checker.PrometheusMetrics.");
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 = (PrometheusMetric_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 PrometheusMetric_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 PrometheusMetric_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 = (PrometheusMetric_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size);
single_value.n_elements = new_size;
}
}

int PrometheusMetrics_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 PrometheusMetrics_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 @Prometheus_Checker.PrometheusMetrics 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; i<elem_count; i++) {
    switch (single_value.value_elements[i]->get_selection()) {
    case OMIT_VALUE:
      TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusMetrics 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; i<elem_count; i++) {
    switch (value_set.set_items[i].get_selection())
    {
    case OMIT_VALUE:
      TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusMetrics containing omit element.", op_name);
    case ANY_OR_OMIT:
      has_any_or_none = TRUE;
      break;
    default:
      min_size++;
      break;
    }
  }
  if (template_selection==SUPERSET_MATCH) {
    has_any_or_none = TRUE;
   } else {
    int max_size = min_size;
    min_size = 0;
    if (!has_any_or_none) { // [0,max_size]
      switch (length_restriction_type) {
      case NO_LENGTH_RESTRICTION:
        if (max_size==0) return 0;
        TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusMetrics with no exact size.", op_name);
      case SINGLE_LENGTH_RESTRICTION:
        if (length_restriction.single_length<=max_size)
          return length_restriction.single_length;
        TTCN_error("Performing %sof() operation on an invalid template of type @Prometheus_Checker.PrometheusMetrics. The maximum size (%d) contradicts the length restriction (%d).", op_name, max_size, length_restriction.single_length);
      case RANGE_LENGTH_RESTRICTION:
        if (max_size==length_restriction.range_length.min_length) {
          return max_size;
        } else if (max_size>length_restriction.range_length.min_length){
          TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusMetrics with no exact size.", op_name);
        } else
          TTCN_error("Performing %sof() operation on an invalid template of type @Prometheus_Checker.PrometheusMetrics. 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 @Prometheus_Checker.PrometheusMetrics 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 @Prometheus_Checker.PrometheusMetrics 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 @Prometheus_Checker.PrometheusMetrics 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 @Prometheus_Checker.PrometheusMetrics containing complemented list.", op_name);
default:
  TTCN_error("Performing %sof() operation on an uninitialized/unsupported template of type @Prometheus_Checker.PrometheusMetrics.", op_name);
}
return check_section_is_single(min_size, has_any_or_none, op_name, "a", "template of type @Prometheus_Checker.PrometheusMetrics");
}

boolean PrometheusMetrics_template::match(const PrometheusMetrics& 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 @Prometheus_Checker.PrometheusMetrics.");
}
return FALSE;
}

boolean PrometheusMetrics_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;
}

PrometheusMetrics PrometheusMetrics_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 @Prometheus_Checker.PrometheusMetrics.");
PrometheusMetrics 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;
}

PrometheusMetrics PrometheusMetrics_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);
}

PrometheusMetrics PrometheusMetrics_template::replace(int index, int len, const PrometheusMetrics_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());
}

PrometheusMetrics PrometheusMetrics_template::replace(int index, int len, const PrometheusMetrics& 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 PrometheusMetrics_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 PrometheusMetrics_template[list_length];
break;
case SUPERSET_MATCH:
case SUBSET_MATCH:
value_set.n_items = list_length;
value_set.set_items = new PrometheusMetric_template[list_length];
break;
default:
TTCN_error("Internal error: Setting an invalid type for a template of type @Prometheus_Checker.PrometheusMetrics.");
}
set_selection(template_type);
}

PrometheusMetrics_template& PrometheusMetrics_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 @Prometheus_Checker.PrometheusMetrics.");
if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of type @Prometheus_Checker.PrometheusMetrics.");
return value_list.list_value[list_index];
}

PrometheusMetric_template& PrometheusMetrics_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 @Prometheus_Checker.PrometheusMetrics.");
if (set_index >= value_set.n_items) TTCN_error("Internal error: Index overflow in a set template of type @Prometheus_Checker.PrometheusMetrics.");
return value_set.set_items[set_index];
}

void PrometheusMetrics_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 PrometheusMetrics_template::log_match(const PrometheusMetrics& 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 PrometheusMetrics_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 @Prometheus_Checker.PrometheusMetrics.");
}
}

void PrometheusMetrics_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 @Prometheus_Checker.PrometheusMetrics.");
single_value.value_elements = (PrometheusMetric_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 PrometheusMetric_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 PrometheusMetrics_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 PrometheusMetric_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 @Prometheus_Checker.PrometheusMetrics.");
}
}

boolean PrometheusMetrics_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusMetrics_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; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

void PrometheusMetrics_template::set_implicit_omit()
{
if (template_selection != SPECIFIC_VALUE) return;
for (int i = 0; i < single_value.n_elements; i++) {
if (single_value.value_elements[i] != NULL) single_value.value_elements[i]->set_implicit_omit();
}
}

void PrometheusMetrics_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: {
    PrometheusMetrics_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_i<param.get_size(); p_i++) {
      temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = temp;
    break; }
  case Module_Param::MP_Indexed_List:
    if (template_selection!=SPECIFIC_VALUE) set_size(0);
    for (size_t p_i=0; p_i<param.get_size(); ++p_i) {
      (*this)[(int)(param.get_elem(p_i)->get_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_i<param.get_size(); ++p_i) {
      if (param.get_elem(p_i)->get_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_i<param.get_size(); p_i++) {
      set_item(p_i).set_param(*param.get_elem(p_i));
    }
    break;
  case Module_Param::MP_Implication_Template: {
    PrometheusMetrics_template* precondition = new PrometheusMetrics_template;
    precondition->set_param(*param.get_elem(0));
    PrometheusMetrics_template* implied_template = new PrometheusMetrics_template;
    implied_template->set_param(*param.get_elem(1));
    *this = PrometheusMetrics_template(precondition, implied_template);
  } break;
  default:
    param.type_error("set of template", "@Prometheus_Checker.PrometheusMetrics");
  }
  is_ifpresent = param.get_ifpresent();
  set_length_range(param);
}

void PrometheusMetrics_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; i<single_value.n_elements; i++) single_value.value_elements[i]->check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusMetrics");
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 : "@Prometheus_Checker.PrometheusMetrics");
}

boolean PrometheusMetrics_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);
}
}
PrometheusExpect::PrometheusExpect()
{
}

PrometheusExpect::PrometheusExpect(const PrometheusMetricKey& par_key,
    const INTEGER& par_min,
    const INTEGER& par_max)
  :   field_key(par_key),
  field_min(par_min),
  field_max(par_max)
{
}

PrometheusExpect::PrometheusExpect(const PrometheusExpect& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Prometheus_Checker.PrometheusExpect.");
if (other_value.key().is_bound()) field_key = other_value.key();
else field_key.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 PrometheusExpect::clean_up()
{
field_key.clean_up();
field_min.clean_up();
field_max.clean_up();
}

const TTCN_Typedescriptor_t* PrometheusExpect::get_descriptor() const { return &PrometheusExpect_descr_; }
PrometheusExpect& PrometheusExpect::operator=(const PrometheusExpect& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Prometheus_Checker.PrometheusExpect.");
  if (other_value.key().is_bound()) field_key = other_value.key();
  else field_key.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 PrometheusExpect::operator==(const PrometheusExpect& other_value) const
{
return field_key==other_value.field_key
  && field_min==other_value.field_min
  && field_max==other_value.field_max;
}

boolean PrometheusExpect::is_bound() const
{
return (field_key.is_bound())
  || (field_min.is_bound())
  || (field_max.is_bound());
}
boolean PrometheusExpect::is_value() const
{
return field_key.is_value()
  && field_min.is_value()
  && field_max.is_value();
}
void PrometheusExpect::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ key := ");
field_key.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 PrometheusExpect::set_implicit_omit()
{
if (key().is_bound()) key().set_implicit_omit();
if (min().is_bound()) min().set_implicit_omit();
if (max().is_bound()) max().set_implicit_omit();
}

void PrometheusExpect::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 (3<param.get_size()) {
      param.error("record value of type @Prometheus_Checker.PrometheusExpect has 3 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) key().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) min().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) max().set_param(*param.get_elem(2));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "key")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          key().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "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_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_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_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Prometheus_Checker.PrometheusExpect: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@Prometheus_Checker.PrometheusExpect");
  }
}

void PrometheusExpect::encode_text(Text_Buf& text_buf) const
{
field_key.encode_text(text_buf);
field_min.encode_text(text_buf);
field_max.encode_text(text_buf);
}

void PrometheusExpect::decode_text(Text_Buf& text_buf)
{
field_key.decode_text(text_buf);
field_min.decode_text(text_buf);
field_max.decode_text(text_buf);
}

struct PrometheusExpect_template::single_value_struct {
PrometheusMetricKey_template field_key;
INTEGER_template field_min;
INTEGER_template field_max;
};

void PrometheusExpect_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_key = ANY_VALUE;
single_value->field_min = ANY_VALUE;
single_value->field_max = ANY_VALUE;
}
}
}

void PrometheusExpect_template::copy_value(const PrometheusExpect& other_value)
{
single_value = new single_value_struct;
if (other_value.key().is_bound()) {
  single_value->field_key = other_value.key();
} else {
  single_value->field_key.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 PrometheusExpect_template::copy_template(const PrometheusExpect_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.key().get_selection()) {
single_value->field_key = other_value.key();
} else {
single_value->field_key.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 PrometheusExpect_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 PrometheusExpect_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusExpect_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 @Prometheus_Checker.PrometheusExpect.");
break;
}
set_selection(other_value);
}

PrometheusExpect_template::PrometheusExpect_template()
{
}

PrometheusExpect_template::PrometheusExpect_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusExpect_template::PrometheusExpect_template(const PrometheusExpect& other_value)
{
copy_value(other_value);
}

PrometheusExpect_template::PrometheusExpect_template(const OPTIONAL<PrometheusExpect>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusExpect&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Prometheus_Checker.PrometheusExpect from an unbound optional field.");
}
}

PrometheusExpect_template::PrometheusExpect_template(PrometheusExpect_template* p_precondition, PrometheusExpect_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusExpect_template::PrometheusExpect_template(Dynamic_Match_Interface<PrometheusExpect>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusExpect>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusExpect_template::PrometheusExpect_template(const PrometheusExpect_template& other_value)
: Base_Template()
{
copy_template(other_value);
}

PrometheusExpect_template::~PrometheusExpect_template()
{
clean_up();
}

PrometheusExpect_template& PrometheusExpect_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusExpect_template& PrometheusExpect_template::operator=(const PrometheusExpect& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

PrometheusExpect_template& PrometheusExpect_template::operator=(const OPTIONAL<PrometheusExpect>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusExpect&)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 @Prometheus_Checker.PrometheusExpect.");
}
return *this;
}

PrometheusExpect_template& PrometheusExpect_template::operator=(const PrometheusExpect_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean PrometheusExpect_template::match(const PrometheusExpect& 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.key().is_bound()) return FALSE;
if(!single_value->field_key.match(other_value.key(), 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 @Prometheus_Checker.PrometheusExpect.");
}
return FALSE;
}

boolean PrometheusExpect_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_key.is_bound()
 || single_value->field_min.is_bound()
 || single_value->field_max.is_bound();
}

boolean PrometheusExpect_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_key.is_value()
 && single_value->field_min.is_value()
 && single_value->field_max.is_value();
}

void PrometheusExpect_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;
}

PrometheusExpect PrometheusExpect_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 @Prometheus_Checker.PrometheusExpect.");
PrometheusExpect ret_val;
if (single_value->field_key.is_bound()) {
ret_val.key() = single_value->field_key.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 PrometheusExpect_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 @Prometheus_Checker.PrometheusExpect.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new PrometheusExpect_template[list_length];
}

PrometheusExpect_template& PrometheusExpect_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 @Prometheus_Checker.PrometheusExpect.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Prometheus_Checker.PrometheusExpect.");
return value_list.list_value[list_index];
}

PrometheusMetricKey_template& PrometheusExpect_template::key()
{
set_specific();
return single_value->field_key;
}

const PrometheusMetricKey_template& PrometheusExpect_template::key() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field key of a non-specific template of type @Prometheus_Checker.PrometheusExpect.");
return single_value->field_key;
}

INTEGER_template& PrometheusExpect_template::min()
{
set_specific();
return single_value->field_min;
}

const INTEGER_template& PrometheusExpect_template::min() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field min of a non-specific template of type @Prometheus_Checker.PrometheusExpect.");
return single_value->field_min;
}

INTEGER_template& PrometheusExpect_template::max()
{
set_specific();
return single_value->field_max;
}

const INTEGER_template& PrometheusExpect_template::max() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field max of a non-specific template of type @Prometheus_Checker.PrometheusExpect.");
return single_value->field_max;
}

int PrometheusExpect_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpect which has an ifpresent attribute.");
  switch (template_selection)
  {
  case SPECIFIC_VALUE:
    return 3;
  case VALUE_LIST:
   {
     if (value_list.n_values<1)
       TTCN_error("Internal error: Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpect 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 @Prometheus_Checker.PrometheusExpect containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpect containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpect containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpect containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpect containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpect containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpect containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Prometheus_Checker.PrometheusExpect.");
  }
  return 0;
}

void PrometheusExpect_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ key := ");
single_value->field_key.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 PrometheusExpect_template::log_match(const PrometheusExpect& 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_key.match(match_value.key(), legacy)){
TTCN_Logger::log_logmatch_info(".key");
single_value->field_key.log_match(match_value.key(), 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("{ key := ");
single_value->field_key.log_match(match_value.key(), 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 PrometheusExpect_template::set_implicit_omit()
{
if (template_selection != SPECIFIC_VALUE) return;
if (key().is_bound()) key().set_implicit_omit();
if (min().is_bound()) min().set_implicit_omit();
if (max().is_bound()) max().set_implicit_omit();
}

void PrometheusExpect_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_key.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 @Prometheus_Checker.PrometheusExpect.");
}
}

void PrometheusExpect_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_key.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 PrometheusExpect_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 @Prometheus_Checker.PrometheusExpect.");
}
}

void PrometheusExpect_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: {
    PrometheusExpect_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_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (3<param.get_size()) {
      param.error("record template of type @Prometheus_Checker.PrometheusExpect has 3 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) key().set_param(*param.get_elem(0));
    if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) min().set_param(*param.get_elem(1));
    if (param.get_size()>2 && param.get_elem(2)->get_type()!=Module_Param::MP_NotUsed) max().set_param(*param.get_elem(2));
    break;
  case Module_Param::MP_Assignment_List: {
    Vector<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "key")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          key().set_param(*curr_param);
        }
        value_used[val_idx]=TRUE;
      }
    }
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "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_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_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_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Prometheus_Checker.PrometheusExpect: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    PrometheusExpect_template* precondition = new PrometheusExpect_template;
    precondition->set_param(*param.get_elem(0));
    PrometheusExpect_template* implied_template = new PrometheusExpect_template;
    implied_template->set_param(*param.get_elem(1));
    *this = PrometheusExpect_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@Prometheus_Checker.PrometheusExpect");
  }
  is_ifpresent = param.get_ifpresent();
}

void PrometheusExpect_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_key.check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusExpect");
single_value->field_min.check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusExpect");
single_value->field_max.check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusExpect");
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 : "@Prometheus_Checker.PrometheusExpect");
}

boolean PrometheusExpect_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusExpect_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_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}


const PrometheusExpect PrometheusExpects::UNBOUND_ELEM;
boolean PrometheusExpects::compare_function(const Base_Type *left_ptr, int left_index, const Base_Type *right_ptr, int right_index)
{
if (((const PrometheusExpects*)left_ptr)->val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
if (((const PrometheusExpects*)right_ptr)->val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
if (((const PrometheusExpects*)left_ptr)->val_ptr->value_elements[left_index] != NULL){
if (((const PrometheusExpects*)right_ptr)->val_ptr->value_elements[right_index] != NULL){
return *((const PrometheusExpects*)left_ptr)->val_ptr->value_elements[left_index] == *((const PrometheusExpects*)right_ptr)->val_ptr->value_elements[right_index];
} else return FALSE;
} else {
return ((const PrometheusExpects*)right_ptr)->val_ptr->value_elements[right_index] == NULL;
}
}

PrometheusExpects::PrometheusExpects()
{
val_ptr = NULL;
}

PrometheusExpects::PrometheusExpects(null_type)
{
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
}

PrometheusExpects::PrometheusExpects(const PrometheusExpects& other_value)
{
if (!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Prometheus_Checker.PrometheusExpects.");
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}

PrometheusExpects::~PrometheusExpects()
{
clean_up();
if (val_ptr != NULL) val_ptr = NULL;
}

void PrometheusExpects::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.");
}
}

PrometheusExpects& PrometheusExpects::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;
}

PrometheusExpects& PrometheusExpects::operator=(const PrometheusExpects& other_value)
{
if (other_value.val_ptr == NULL) TTCN_error("Assigning an unbound value of type @Prometheus_Checker.PrometheusExpects.");
if (this != &other_value) {
clean_up();
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
return *this;
}

boolean PrometheusExpects::operator==(null_type) const
{
if (val_ptr == NULL)
TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
return val_ptr->n_elements == 0 ;
}

boolean PrometheusExpects::operator==(const PrometheusExpects& other_value) const
{
if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
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);
}

PrometheusExpect& PrometheusExpects::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of type @Prometheus_Checker.PrometheusExpects 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 = (PrometheusExpect**)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 PrometheusExpect(*(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 PrometheusExpect;
}
return *val_ptr->value_elements[index_value];
}

PrometheusExpect& PrometheusExpects::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Prometheus_Checker.PrometheusExpects.");
return (*this)[(int)index_value];
}

const PrometheusExpect& PrometheusExpects::operator[](int index_value) const
{
if (val_ptr == NULL)
TTCN_error("Accessing an element in an unbound value of type @Prometheus_Checker.PrometheusExpects.");
if (index_value < 0) TTCN_error("Accessing an element of type @Prometheus_Checker.PrometheusExpects using a negative index: %d.", index_value);
if (index_value >= val_ptr->n_elements) TTCN_error("Index overflow in a value of type @Prometheus_Checker.PrometheusExpects: 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 PrometheusExpect& PrometheusExpects::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a value of type @Prometheus_Checker.PrometheusExpects.");
return (*this)[(int)index_value];
}

PrometheusExpects PrometheusExpects::operator<<=(int rotate_count) const
{
return *this >>= (-rotate_count);
}

PrometheusExpects PrometheusExpects::operator<<=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate left operator.");
return *this >>= (int)(-rotate_count);
}

PrometheusExpects PrometheusExpects::operator>>=(const INTEGER& rotate_count) const
{
rotate_count.must_bound("Unbound integer operand of rotate right operator.");
return *this >>= (int)rotate_count;
}

PrometheusExpects PrometheusExpects::operator>>=(int rotate_count) const
{
if (val_ptr == NULL) TTCN_error("Performing rotation operation on an unbound value of type @Prometheus_Checker.PrometheusExpects.");
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;
PrometheusExpects ret_val;
ret_val.set_size(val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[(i+rc)%val_ptr->n_elements] =new PrometheusExpect(*val_ptr->value_elements[i]);
}
}
return ret_val;
}

PrometheusExpects PrometheusExpects::operator+(const PrometheusExpects& other_value) const
{
if (val_ptr == NULL || other_value.val_ptr == NULL) TTCN_error("Unbound operand of @Prometheus_Checker.PrometheusExpects concatenation.");
if (val_ptr->n_elements == 0) return other_value;
if (other_value.val_ptr->n_elements == 0) return *this;
PrometheusExpects ret_val;
ret_val.set_size(val_ptr->n_elements+other_value.val_ptr->n_elements);
for (int i=0; i<val_ptr->n_elements; i++) {
if (val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i] = new PrometheusExpect(*val_ptr->value_elements[i]);
}
}
for (int i=0; i<other_value.val_ptr->n_elements; i++) {
if (other_value.val_ptr->value_elements[i] != NULL) {
ret_val.val_ptr->value_elements[i+val_ptr->n_elements] = new PrometheusExpect(*other_value.val_ptr->value_elements[i]);
}
}
return ret_val;
}

PrometheusExpects PrometheusExpects::substr(int index, int returncount) const
{
if (val_ptr == NULL) TTCN_error("The first argument of substr() is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
check_substr_arguments(val_ptr->n_elements, index, returncount, "@Prometheus_Checker.PrometheusExpects","element");
PrometheusExpects ret_val;
ret_val.set_size(returncount);
for (int i=0; i<returncount; i++) {
if (val_ptr->value_elements[i+index] != NULL) {
ret_val.val_ptr->value_elements[i] = new PrometheusExpect(*val_ptr->value_elements[i+index]);
}
}
return ret_val;
}

PrometheusExpects PrometheusExpects::replace(int index, int len, const PrometheusExpects& repl) const
{
if (val_ptr == NULL) TTCN_error("The first argument of replace() is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
if (repl.val_ptr == NULL) TTCN_error("The fourth argument of replace() is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
check_replace_arguments(val_ptr->n_elements, index, len, "@Prometheus_Checker.PrometheusExpects","element");
PrometheusExpects 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 PrometheusExpect(*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 PrometheusExpect(*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 PrometheusExpect(*val_ptr->value_elements[index+i+len]);
}
}
return ret_val;
}

PrometheusExpects PrometheusExpects::replace(int index, int len, const PrometheusExpects_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 PrometheusExpects::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a value of type @Prometheus_Checker.PrometheusExpects.");
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 = (PrometheusExpect**)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 PrometheusExpect(*(val_ptr->value_elements[elem_count]));
}
}
clean_up();
val_ptr = new_val_ptr;
}
if (new_size > val_ptr->n_elements) {
val_ptr->value_elements = (PrometheusExpect**)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 @Prometheus_Checker.PrometheusExpects: %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 = (PrometheusExpect**)reallocate_pointers((void**)val_ptr->value_elements, val_ptr->n_elements, new_size);
val_ptr->n_elements = new_size;
}
}

boolean PrometheusExpects::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 PrometheusExpects::size_of() const
{
if (val_ptr == NULL) TTCN_error("Performing sizeof operation on an unbound value of type @Prometheus_Checker.PrometheusExpects.");
return val_ptr->n_elements;
}

int PrometheusExpects::lengthof() const
{
if (val_ptr == NULL) TTCN_error("Performing lengthof operation on an unbound value of type @Prometheus_Checker.PrometheusExpects.");
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 PrometheusExpects::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 PrometheusExpects::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 PrometheusExpects::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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        if (curr->get_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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        (*this)[curr->get_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", "@Prometheus_Checker.PrometheusExpects");
    }
    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; i<param.get_size(); ++i) {
        Module_Param* const curr = param.get_elem(i);
        if ((curr->get_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", "@Prometheus_Checker.PrometheusExpects");
    }
    break;
  default:
    TTCN_error("Internal error: Unknown operation type.");
  }
}

void PrometheusExpects::encode_text(Text_Buf& text_buf) const
{
if (val_ptr == NULL) TTCN_error("Text encoder: Encoding an unbound value of type @Prometheus_Checker.PrometheusExpects.");
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 PrometheusExpects::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 @Prometheus_Checker.PrometheusExpects.");
val_ptr->value_elements = (PrometheusExpect**)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 PrometheusExpect;
val_ptr->value_elements[elem_count]->decode_text(text_buf);
}
}

void PrometheusExpects_template::copy_value(const PrometheusExpects& other_value)
{
if (!other_value.is_bound()) TTCN_error("Initialization of a template of type @Prometheus_Checker.PrometheusExpects with an unbound value.");
single_value.n_elements = other_value.size_of();
single_value.value_elements = (PrometheusExpect_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 PrometheusExpect_template(other_value[elem_count]);
} else {
single_value.value_elements[elem_count] = new PrometheusExpect_template;
}
}
set_selection(SPECIFIC_VALUE);
}

void PrometheusExpects_template::copy_template(const PrometheusExpects_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 = (PrometheusExpect_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 PrometheusExpect_template(*other_value.single_value.value_elements[elem_count]);
} else {
single_value.value_elements[elem_count] = new PrometheusExpect_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 PrometheusExpects_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 PrometheusExpect_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 PrometheusExpects_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusExpects_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 @Prometheus_Checker.PrometheusExpects.");
break;
}
set_selection(other_value);
}

boolean PrometheusExpects_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 PrometheusExpects_template*)template_ptr)->single_value.value_elements[template_index]->match((*(const PrometheusExpects*)value_ptr)[value_index], legacy);
else return ((const PrometheusExpects_template*)template_ptr)->single_value.value_elements[template_index]->is_any_or_omit();
}

boolean PrometheusExpects_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 PrometheusExpects_template*)template_ptr)->value_set.set_items[template_index].match((*(const PrometheusExpects*)value_ptr)[value_index], legacy);
else return ((const PrometheusExpects_template*)template_ptr)->value_set.set_items[template_index].is_any_or_omit();
}

void PrometheusExpects_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 PrometheusExpects_template*)template_ptr)->single_value.value_elements[index_template]->log();
}
} else if (template_ptr == NULL) {
(*(const PrometheusExpects*)value_ptr)[index_value].log();
} else {
((const PrometheusExpects_template*)template_ptr)->single_value.value_elements[index_template]->log_match((*(const PrometheusExpects*)value_ptr)[index_value], legacy);
}
}

PrometheusExpects_template::PrometheusExpects_template()
{
}

PrometheusExpects_template::PrometheusExpects_template(template_sel other_value)
 : Restricted_Length_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusExpects_template::PrometheusExpects_template(null_type)
 : Restricted_Length_Template(SPECIFIC_VALUE)
{
single_value.n_elements = 0;
single_value.value_elements = NULL;
}

PrometheusExpects_template::PrometheusExpects_template(const PrometheusExpects& other_value)
{
copy_value(other_value);
}

PrometheusExpects_template::PrometheusExpects_template(const OPTIONAL<PrometheusExpects>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusExpects&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Prometheus_Checker.PrometheusExpects from an unbound optional field.");
}
}

PrometheusExpects_template::PrometheusExpects_template(PrometheusExpects_template* p_precondition, PrometheusExpects_template* p_implied_template)
 : Restricted_Length_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusExpects_template::PrometheusExpects_template(Dynamic_Match_Interface<PrometheusExpects>* p_dyn_match)
 : Restricted_Length_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusExpects>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusExpects_template::PrometheusExpects_template(const PrometheusExpects_template& other_value)
 : Restricted_Length_Template()
{
copy_template(other_value);
}

PrometheusExpects_template::~PrometheusExpects_template()
{
clean_up();
}

void PrometheusExpects_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;
}

PrometheusExpects_template& PrometheusExpects_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusExpects_template& PrometheusExpects_template::operator=(null_type)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value.n_elements = 0;
single_value.value_elements = NULL;
return *this;
}

PrometheusExpects_template& PrometheusExpects_template::operator=(const PrometheusExpects& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

PrometheusExpects_template& PrometheusExpects_template::operator=(const OPTIONAL<PrometheusExpects>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusExpects&)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 @Prometheus_Checker.PrometheusExpects.");
}
return *this;
}

PrometheusExpects_template& PrometheusExpects_template::operator=(const PrometheusExpects_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

PrometheusExpect_template& PrometheusExpects_template::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Prometheus_Checker.PrometheusExpects 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 @Prometheus_Checker.PrometheusExpects.");
    break;
}
return *single_value.value_elements[index_value];
}

PrometheusExpect_template& PrometheusExpects_template::operator[](const INTEGER& index_value)
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Prometheus_Checker.PrometheusExpects.");
return (*this)[(int)index_value];
}

const PrometheusExpect_template& PrometheusExpects_template::operator[](int index_value) const
{
if (index_value < 0) TTCN_error("Accessing an element of a template for type @Prometheus_Checker.PrometheusExpects using a negative index: %d.", index_value);
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing an element of a non-specific template for type @Prometheus_Checker.PrometheusExpects.");
if (index_value >= single_value.n_elements) TTCN_error("Index overflow in a template of type @Prometheus_Checker.PrometheusExpects: 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 PrometheusExpect_template& PrometheusExpects_template::operator[](const INTEGER& index_value) const
{
index_value.must_bound("Using an unbound integer value for indexing a template of type @Prometheus_Checker.PrometheusExpects.");
return (*this)[(int)index_value];
}

void PrometheusExpects_template::set_size(int new_size)
{
if (new_size < 0) TTCN_error("Internal error: Setting a negative size for a template of type @Prometheus_Checker.PrometheusExpects.");
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 = (PrometheusExpect_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 PrometheusExpect_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 PrometheusExpect_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 = (PrometheusExpect_template**)reallocate_pointers((void**)single_value.value_elements, single_value.n_elements, new_size);
single_value.n_elements = new_size;
}
}

int PrometheusExpects_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 PrometheusExpects_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 @Prometheus_Checker.PrometheusExpects 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; i<elem_count; i++) {
    switch (single_value.value_elements[i]->get_selection()) {
    case OMIT_VALUE:
      TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusExpects 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; i<elem_count; i++) {
    switch (value_set.set_items[i].get_selection())
    {
    case OMIT_VALUE:
      TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusExpects containing omit element.", op_name);
    case ANY_OR_OMIT:
      has_any_or_none = TRUE;
      break;
    default:
      min_size++;
      break;
    }
  }
  if (template_selection==SUPERSET_MATCH) {
    has_any_or_none = TRUE;
   } else {
    int max_size = min_size;
    min_size = 0;
    if (!has_any_or_none) { // [0,max_size]
      switch (length_restriction_type) {
      case NO_LENGTH_RESTRICTION:
        if (max_size==0) return 0;
        TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusExpects with no exact size.", op_name);
      case SINGLE_LENGTH_RESTRICTION:
        if (length_restriction.single_length<=max_size)
          return length_restriction.single_length;
        TTCN_error("Performing %sof() operation on an invalid template of type @Prometheus_Checker.PrometheusExpects. The maximum size (%d) contradicts the length restriction (%d).", op_name, max_size, length_restriction.single_length);
      case RANGE_LENGTH_RESTRICTION:
        if (max_size==length_restriction.range_length.min_length) {
          return max_size;
        } else if (max_size>length_restriction.range_length.min_length){
          TTCN_error("Performing %sof() operation on a template of type @Prometheus_Checker.PrometheusExpects with no exact size.", op_name);
        } else
          TTCN_error("Performing %sof() operation on an invalid template of type @Prometheus_Checker.PrometheusExpects. 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 @Prometheus_Checker.PrometheusExpects 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 @Prometheus_Checker.PrometheusExpects 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 @Prometheus_Checker.PrometheusExpects 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 @Prometheus_Checker.PrometheusExpects containing complemented list.", op_name);
default:
  TTCN_error("Performing %sof() operation on an uninitialized/unsupported template of type @Prometheus_Checker.PrometheusExpects.", op_name);
}
return check_section_is_single(min_size, has_any_or_none, op_name, "a", "template of type @Prometheus_Checker.PrometheusExpects");
}

boolean PrometheusExpects_template::match(const PrometheusExpects& 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 @Prometheus_Checker.PrometheusExpects.");
}
return FALSE;
}

boolean PrometheusExpects_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;
}

PrometheusExpects PrometheusExpects_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 @Prometheus_Checker.PrometheusExpects.");
PrometheusExpects 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;
}

PrometheusExpects PrometheusExpects_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);
}

PrometheusExpects PrometheusExpects_template::replace(int index, int len, const PrometheusExpects_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());
}

PrometheusExpects PrometheusExpects_template::replace(int index, int len, const PrometheusExpects& 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 PrometheusExpects_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 PrometheusExpects_template[list_length];
break;
case SUPERSET_MATCH:
case SUBSET_MATCH:
value_set.n_items = list_length;
value_set.set_items = new PrometheusExpect_template[list_length];
break;
default:
TTCN_error("Internal error: Setting an invalid type for a template of type @Prometheus_Checker.PrometheusExpects.");
}
set_selection(template_type);
}

PrometheusExpects_template& PrometheusExpects_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 @Prometheus_Checker.PrometheusExpects.");
if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of type @Prometheus_Checker.PrometheusExpects.");
return value_list.list_value[list_index];
}

PrometheusExpect_template& PrometheusExpects_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 @Prometheus_Checker.PrometheusExpects.");
if (set_index >= value_set.n_items) TTCN_error("Internal error: Index overflow in a set template of type @Prometheus_Checker.PrometheusExpects.");
return value_set.set_items[set_index];
}

void PrometheusExpects_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 PrometheusExpects_template::log_match(const PrometheusExpects& 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 PrometheusExpects_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 @Prometheus_Checker.PrometheusExpects.");
}
}

void PrometheusExpects_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 @Prometheus_Checker.PrometheusExpects.");
single_value.value_elements = (PrometheusExpect_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 PrometheusExpect_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 PrometheusExpects_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 PrometheusExpect_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 @Prometheus_Checker.PrometheusExpects.");
}
}

boolean PrometheusExpects_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusExpects_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; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

void PrometheusExpects_template::set_implicit_omit()
{
if (template_selection != SPECIFIC_VALUE) return;
for (int i = 0; i < single_value.n_elements; i++) {
if (single_value.value_elements[i] != NULL) single_value.value_elements[i]->set_implicit_omit();
}
}

void PrometheusExpects_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: {
    PrometheusExpects_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_i<param.get_size(); p_i++) {
      temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = temp;
    break; }
  case Module_Param::MP_Indexed_List:
    if (template_selection!=SPECIFIC_VALUE) set_size(0);
    for (size_t p_i=0; p_i<param.get_size(); ++p_i) {
      (*this)[(int)(param.get_elem(p_i)->get_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_i<param.get_size(); ++p_i) {
      if (param.get_elem(p_i)->get_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_i<param.get_size(); p_i++) {
      set_item(p_i).set_param(*param.get_elem(p_i));
    }
    break;
  case Module_Param::MP_Implication_Template: {
    PrometheusExpects_template* precondition = new PrometheusExpects_template;
    precondition->set_param(*param.get_elem(0));
    PrometheusExpects_template* implied_template = new PrometheusExpects_template;
    implied_template->set_param(*param.get_elem(1));
    *this = PrometheusExpects_template(precondition, implied_template);
  } break;
  default:
    param.type_error("set of template", "@Prometheus_Checker.PrometheusExpects");
  }
  is_ifpresent = param.get_ifpresent();
  set_length_range(param);
}

void PrometheusExpects_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; i<single_value.n_elements; i++) single_value.value_elements[i]->check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusExpects");
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 : "@Prometheus_Checker.PrometheusExpects");
}

boolean PrometheusExpects_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);
}
}
PrometheusResultType::PrometheusResultType()
{
enum_value = UNBOUND_VALUE;
}

PrometheusResultType::PrometheusResultType(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @Prometheus_Checker.PrometheusResultType with invalid numeric value %d.", other_value);
enum_value = (enum_type)other_value;
}

PrometheusResultType::PrometheusResultType(enum_type other_value)
{
enum_value = other_value;
}

PrometheusResultType::PrometheusResultType(const PrometheusResultType& other_value)
: Base_Type()
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
enum_value = other_value.enum_value;
}

PrometheusResultType& PrometheusResultType::operator=(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @Prometheus_Checker.PrometheusResultType.", other_value);
enum_value = (enum_type)other_value;
return *this;
}

PrometheusResultType& PrometheusResultType::operator=(enum_type other_value)
{
enum_value = other_value;
return *this;
}

PrometheusResultType& PrometheusResultType::operator=(const PrometheusResultType& other_value)
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
enum_value = other_value.enum_value;
return *this;
}

boolean PrometheusResultType::operator==(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @Prometheus_Checker.PrometheusResultType comparison is an unknown numeric value %d", other_value);
return enum_value == other_value;
}

boolean PrometheusResultType::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 @Prometheus_Checker.PrometheusResultType.");
return enum_value == other_value;
}

boolean PrometheusResultType::operator==(const PrometheusResultType& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
return enum_value == other_value.enum_value;
}

boolean PrometheusResultType::operator<(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @Prometheus_Checker.PrometheusResultType comparison is an unknown numeric value %d", other_value);
return enum_value < other_value;
}

boolean PrometheusResultType::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 @Prometheus_Checker.PrometheusResultType.");
return enum_value < other_value;
}

boolean PrometheusResultType::operator<(const PrometheusResultType& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
return enum_value < other_value.enum_value;
}

boolean PrometheusResultType::operator>(int other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
if (!is_valid_enum(other_value)) TTCN_error("The right operand of enumerated type @Prometheus_Checker.PrometheusResultType comparison is an unknown numeric value %d", other_value);
return enum_value > other_value;
}

boolean PrometheusResultType::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 @Prometheus_Checker.PrometheusResultType.");
return enum_value > other_value;
}

boolean PrometheusResultType::operator>(const PrometheusResultType& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
return enum_value > other_value.enum_value;
}

const char *PrometheusResultType::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 "<unknown>";
}
}

PrometheusResultType::enum_type PrometheusResultType::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 PrometheusResultType::is_valid_enum(int int_par)
{
switch (int_par) {
case 0:
case 1:
case 2:
return TRUE;
default:
return FALSE;
}
}

int PrometheusResultType::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 @Prometheus_Checker.PrometheusResultType.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par;
}

int PrometheusResultType::enum2int(const PrometheusResultType& 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 @Prometheus_Checker.PrometheusResultType.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par.enum_value;
}

void PrometheusResultType::int2enum(int int_val)
{
if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @Prometheus_Checker.PrometheusResultType.", int_val);
enum_value = (enum_type)int_val;
}

PrometheusResultType::operator PrometheusResultType::enum_type() const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @Prometheus_Checker.PrometheusResultType.");
return enum_value;
}

void PrometheusResultType::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 PrometheusResultType::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", "@Prometheus_Checker.PrometheusResultType");
  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 @Prometheus_Checker.PrometheusResultType.");
  }
}

void PrometheusResultType::encode_text(Text_Buf& text_buf) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
text_buf.push_int(enum_value);
}

void PrometheusResultType::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 @Prometheus_Checker.PrometheusResultType.", enum_value);
}

void PrometheusResultType_template::copy_template(const PrometheusResultType_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 PrometheusResultType_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 PrometheusResultType_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusResultType_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 @Prometheus_Checker.PrometheusResultType.");
}
}

PrometheusResultType_template::PrometheusResultType_template()
{
}

PrometheusResultType_template::PrometheusResultType_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusResultType_template::PrometheusResultType_template(int other_value)
 : Base_Template(SPECIFIC_VALUE)
{
if (!PrometheusResultType::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @Prometheus_Checker.PrometheusResultType with unknown numeric value %d.", other_value);
single_value = (PrometheusResultType::enum_type)other_value;
}

PrometheusResultType_template::PrometheusResultType_template(PrometheusResultType::enum_type other_value)
 : Base_Template(SPECIFIC_VALUE)
{
single_value = other_value;
}

PrometheusResultType_template::PrometheusResultType_template(const PrometheusResultType& other_value)
 : Base_Template(SPECIFIC_VALUE)
{
if (other_value.enum_value == PrometheusResultType::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType.");
single_value = other_value.enum_value;
}

PrometheusResultType_template::PrometheusResultType_template(const OPTIONAL<PrometheusResultType>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (PrometheusResultType::enum_type)(const PrometheusResultType&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of enumerated type @Prometheus_Checker.PrometheusResultType from an unbound optional field.");
}
}

PrometheusResultType_template::PrometheusResultType_template(PrometheusResultType_template* p_precondition, PrometheusResultType_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusResultType_template::PrometheusResultType_template(Dynamic_Match_Interface<PrometheusResultType>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusResultType>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusResultType_template::PrometheusResultType_template(const PrometheusResultType_template& other_value)
 : Base_Template()
{
copy_template(other_value);
}

PrometheusResultType_template::~PrometheusResultType_template()
{
clean_up();
}

boolean PrometheusResultType_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
return TRUE;
}

boolean PrometheusResultType_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value != PrometheusResultType::UNBOUND_VALUE;
}

void PrometheusResultType_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;
}

PrometheusResultType_template& PrometheusResultType_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusResultType_template& PrometheusResultType_template::operator=(int other_value)
{
if (!PrometheusResultType::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @Prometheus_Checker.PrometheusResultType.", other_value);
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = (PrometheusResultType::enum_type)other_value;
return *this;
}

PrometheusResultType_template& PrometheusResultType_template::operator=(PrometheusResultType::enum_type other_value)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value;
return *this;
}

PrometheusResultType_template& PrometheusResultType_template::operator=(const PrometheusResultType& other_value)
{
if (other_value.enum_value == PrometheusResultType::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Prometheus_Checker.PrometheusResultType to a template.");
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value.enum_value;
return *this;
}

PrometheusResultType_template& PrometheusResultType_template::operator=(const OPTIONAL<PrometheusResultType>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (PrometheusResultType::enum_type)(const PrometheusResultType&)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 @Prometheus_Checker.PrometheusResultType.");
}
return *this;
}

PrometheusResultType_template& PrometheusResultType_template::operator=(const PrometheusResultType_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean PrometheusResultType_template::match(PrometheusResultType::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 @Prometheus_Checker.PrometheusResultType.");
}
return FALSE;
}

boolean PrometheusResultType_template::match(const PrometheusResultType& other_value, boolean) const
{
if (other_value.enum_value == PrometheusResultType::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @Prometheus_Checker.PrometheusResultType with an unbound value.");
return match(other_value.enum_value);
}

PrometheusResultType::enum_type PrometheusResultType_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 @Prometheus_Checker.PrometheusResultType.");
return single_value;
}

void PrometheusResultType_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 PrometheusResultType_template[list_length];
break;
default:
TTCN_error("Setting an invalid type for a template of enumerated type @Prometheus_Checker.PrometheusResultType.");
}
}

PrometheusResultType_template& PrometheusResultType_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 @Prometheus_Checker.PrometheusResultType.");
if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @Prometheus_Checker.PrometheusResultType.");
return value_list.list_value[list_index];
}

void PrometheusResultType_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_enum(PrometheusResultType::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 PrometheusResultType_template::log_match(const PrometheusResultType& 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 PrometheusResultType_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 @Prometheus_Checker.PrometheusResultType.");
}
}

void PrometheusResultType_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = (PrometheusResultType::enum_type)text_buf.pull_int().get_val();
if (!PrometheusResultType::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @Prometheus_Checker.PrometheusResultType.", 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 PrometheusResultType_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 @Prometheus_Checker.PrometheusResultType.");
}
}

boolean PrometheusResultType_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusResultType_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; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}

void PrometheusResultType_template::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_TEMPLATE, "enumerated template");
  Module_Param_Ptr m_p = &param;
  switch (m_p->get_type()) {
  case Module_Param::MP_Omit:
    *this = OMIT_VALUE;
    break;
  case Module_Param::MP_Any:
    *this = ANY_VALUE;
    break;
  case Module_Param::MP_AnyOrNone:
    *this = ANY_OR_OMIT;
    break;
  case Module_Param::MP_List_Template:
  case Module_Param::MP_ComplementList_Template:
  case Module_Param::MP_ConjunctList_Template: {
    PrometheusResultType_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_i<m_p->get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Enumerated: {
    PrometheusResultType::enum_type enum_val = PrometheusResultType::str_to_enum(m_p->get_enumerated(), m_p->get_enumerated_value());
    if (!PrometheusResultType::is_valid_enum(enum_val)) {
      param.error("Invalid enumerated value for type @Prometheus_Checker.PrometheusResultType.");
    }
    *this = enum_val;
  } break;
  case Module_Param::MP_Implication_Template: {
    PrometheusResultType_template* precondition = new PrometheusResultType_template;
    precondition->set_param(*m_p->get_elem(0));
    PrometheusResultType_template* implied_template = new PrometheusResultType_template;
    implied_template->set_param(*m_p->get_elem(1));
    *this = PrometheusResultType_template(precondition, implied_template);
  } break;
  default:
    param.type_error("enumerated template", "@Prometheus_Checker.PrometheusResultType");
  }
  is_ifpresent = param.get_ifpresent();
}

void PrometheusResultType_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 : "@Prometheus_Checker.PrometheusResultType");
}

PrometheusExpectResult::PrometheusExpectResult()
{
}

PrometheusExpectResult::PrometheusExpectResult(const PrometheusResultType& par_kind,
    const INTEGER& par_idx)
  :   field_kind(par_kind),
  field_idx(par_idx)
{
}

PrometheusExpectResult::PrometheusExpectResult(const PrometheusExpectResult& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @Prometheus_Checker.PrometheusExpectResult.");
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 PrometheusExpectResult::clean_up()
{
field_kind.clean_up();
field_idx.clean_up();
}

const TTCN_Typedescriptor_t* PrometheusExpectResult::get_descriptor() const { return &PrometheusExpectResult_descr_; }
PrometheusExpectResult& PrometheusExpectResult::operator=(const PrometheusExpectResult& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @Prometheus_Checker.PrometheusExpectResult.");
  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 PrometheusExpectResult::operator==(const PrometheusExpectResult& other_value) const
{
return field_kind==other_value.field_kind
  && field_idx==other_value.field_idx;
}

boolean PrometheusExpectResult::is_bound() const
{
return (field_kind.is_bound())
  || (field_idx.is_bound());
}
boolean PrometheusExpectResult::is_value() const
{
return field_kind.is_value()
  && field_idx.is_value();
}
void PrometheusExpectResult::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 PrometheusExpectResult::set_implicit_omit()
{
if (kind().is_bound()) kind().set_implicit_omit();
if (idx().is_bound()) idx().set_implicit_omit();
}

void PrometheusExpectResult::set_param(Module_Param& param)
{
  param.basic_check(Module_Param::BC_VALUE, "record value");
  switch (param.get_type()) {
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record value of type @Prometheus_Checker.PrometheusExpectResult has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) 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<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "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_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_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_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Prometheus_Checker.PrometheusExpectResult: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@Prometheus_Checker.PrometheusExpectResult");
  }
}

void PrometheusExpectResult::encode_text(Text_Buf& text_buf) const
{
field_kind.encode_text(text_buf);
field_idx.encode_text(text_buf);
}

void PrometheusExpectResult::decode_text(Text_Buf& text_buf)
{
field_kind.decode_text(text_buf);
field_idx.decode_text(text_buf);
}

struct PrometheusExpectResult_template::single_value_struct {
PrometheusResultType_template field_kind;
INTEGER_template field_idx;
};

void PrometheusExpectResult_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 PrometheusExpectResult_template::copy_value(const PrometheusExpectResult& 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 PrometheusExpectResult_template::copy_template(const PrometheusExpectResult_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 PrometheusExpectResult_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 PrometheusExpectResult_template(*other_value.implication_.precondition);
implication_.implied_template = new PrometheusExpectResult_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 @Prometheus_Checker.PrometheusExpectResult.");
break;
}
set_selection(other_value);
}

PrometheusExpectResult_template::PrometheusExpectResult_template()
{
}

PrometheusExpectResult_template::PrometheusExpectResult_template(template_sel other_value)
 : Base_Template(other_value)
{
check_single_selection(other_value);
}

PrometheusExpectResult_template::PrometheusExpectResult_template(const PrometheusExpectResult& other_value)
{
copy_value(other_value);
}

PrometheusExpectResult_template::PrometheusExpectResult_template(const OPTIONAL<PrometheusExpectResult>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusExpectResult&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @Prometheus_Checker.PrometheusExpectResult from an unbound optional field.");
}
}

PrometheusExpectResult_template::PrometheusExpectResult_template(PrometheusExpectResult_template* p_precondition, PrometheusExpectResult_template* p_implied_template)
 : Base_Template(IMPLICATION_MATCH)
{
implication_.precondition = p_precondition;
implication_.implied_template = p_implied_template;
}

PrometheusExpectResult_template::PrometheusExpectResult_template(Dynamic_Match_Interface<PrometheusExpectResult>* p_dyn_match)
 : Base_Template(DYNAMIC_MATCH)
{
dyn_match = new dynmatch_struct<PrometheusExpectResult>;
dyn_match->ptr = p_dyn_match;
dyn_match->ref_count = 1;
}

PrometheusExpectResult_template::PrometheusExpectResult_template(const PrometheusExpectResult_template& other_value)
: Base_Template()
{
copy_template(other_value);
}

PrometheusExpectResult_template::~PrometheusExpectResult_template()
{
clean_up();
}

PrometheusExpectResult_template& PrometheusExpectResult_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}

PrometheusExpectResult_template& PrometheusExpectResult_template::operator=(const PrometheusExpectResult& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}

PrometheusExpectResult_template& PrometheusExpectResult_template::operator=(const OPTIONAL<PrometheusExpectResult>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const PrometheusExpectResult&)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 @Prometheus_Checker.PrometheusExpectResult.");
}
return *this;
}

PrometheusExpectResult_template& PrometheusExpectResult_template::operator=(const PrometheusExpectResult_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}

boolean PrometheusExpectResult_template::match(const PrometheusExpectResult& 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 @Prometheus_Checker.PrometheusExpectResult.");
}
return FALSE;
}

boolean PrometheusExpectResult_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 PrometheusExpectResult_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 PrometheusExpectResult_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;
}

PrometheusExpectResult PrometheusExpectResult_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 @Prometheus_Checker.PrometheusExpectResult.");
PrometheusExpectResult 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 PrometheusExpectResult_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 @Prometheus_Checker.PrometheusExpectResult.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new PrometheusExpectResult_template[list_length];
}

PrometheusExpectResult_template& PrometheusExpectResult_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 @Prometheus_Checker.PrometheusExpectResult.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @Prometheus_Checker.PrometheusExpectResult.");
return value_list.list_value[list_index];
}

PrometheusResultType_template& PrometheusExpectResult_template::kind()
{
set_specific();
return single_value->field_kind;
}

const PrometheusResultType_template& PrometheusExpectResult_template::kind() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field kind of a non-specific template of type @Prometheus_Checker.PrometheusExpectResult.");
return single_value->field_kind;
}

INTEGER_template& PrometheusExpectResult_template::idx()
{
set_specific();
return single_value->field_idx;
}

const INTEGER_template& PrometheusExpectResult_template::idx() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field idx of a non-specific template of type @Prometheus_Checker.PrometheusExpectResult.");
return single_value->field_idx;
}

int PrometheusExpectResult_template::size_of() const
{
  if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpectResult 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 @Prometheus_Checker.PrometheusExpectResult 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 @Prometheus_Checker.PrometheusExpectResult containing a value list with different sizes.");
      }
      return item_size;
    }
  case OMIT_VALUE:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpectResult containing omit value.");
  case ANY_VALUE:
  case ANY_OR_OMIT:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpectResult containing */? value.");
  case COMPLEMENTED_LIST:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpectResult containing complemented list.");
  case CONJUNCTION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpectResult containing a conjunction list match.");
  case IMPLICATION_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpectResult containing an implication match.");
  case DYNAMIC_MATCH:
    TTCN_error("Performing sizeof() operation on a template of type @Prometheus_Checker.PrometheusExpectResult containing a dynamic match.");
  default:
    TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @Prometheus_Checker.PrometheusExpectResult.");
  }
  return 0;
}

void PrometheusExpectResult_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 PrometheusExpectResult_template::log_match(const PrometheusExpectResult& 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 PrometheusExpectResult_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 PrometheusExpectResult_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 @Prometheus_Checker.PrometheusExpectResult.");
}
}

void PrometheusExpectResult_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 PrometheusExpectResult_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 @Prometheus_Checker.PrometheusExpectResult.");
}
}

void PrometheusExpectResult_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: {
    PrometheusExpectResult_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_i<param.get_size(); p_i++) {
      new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
    }
    *this = new_temp;
    break; }
  case Module_Param::MP_Value_List:
    if (2<param.get_size()) {
      param.error("record template of type @Prometheus_Checker.PrometheusExpectResult has 2 fields but list value has %d fields", (int)param.get_size());
    }
    if (param.get_size()>0 && param.get_elem(0)->get_type()!=Module_Param::MP_NotUsed) 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<bool> value_used(param.get_size());
    value_used.resize(param.get_size(), FALSE);
    for (size_t val_idx=0; val_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_id()->get_name(), "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_idx<param.get_size(); val_idx++) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      if (!strcmp(curr_param->get_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_idx<param.get_size(); val_idx++) if (!value_used[val_idx]) {
      Module_Param* const curr_param = param.get_elem(val_idx);
      curr_param->error("Non existent field name in type @Prometheus_Checker.PrometheusExpectResult: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    PrometheusExpectResult_template* precondition = new PrometheusExpectResult_template;
    precondition->set_param(*param.get_elem(0));
    PrometheusExpectResult_template* implied_template = new PrometheusExpectResult_template;
    implied_template->set_param(*param.get_elem(1));
    *this = PrometheusExpectResult_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@Prometheus_Checker.PrometheusExpectResult");
  }
  is_ifpresent = param.get_ifpresent();
}

void PrometheusExpectResult_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 : "@Prometheus_Checker.PrometheusExpectResult");
single_value->field_idx.check_restriction(t_res, t_name ? t_name : "@Prometheus_Checker.PrometheusExpectResult");
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 : "@Prometheus_Checker.PrometheusExpectResult");
}

boolean PrometheusExpectResult_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}

boolean PrometheusExpectResult_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_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}


/* Bodies of functions, altsteps and testcases */

boolean operator==(null_type, const PrometheusMetricKeys& other_value)
{
if (other_value.val_ptr == NULL)
TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetricKeys.");
return other_value.val_ptr->n_elements == 0;
}

boolean operator==(null_type, const PrometheusMetrics& other_value)
{
if (other_value.val_ptr == NULL)
TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusMetrics.");
return other_value.val_ptr->n_elements == 0;
}

boolean operator==(null_type, const PrometheusExpects& other_value)
{
if (other_value.val_ptr == NULL)
TTCN_error("The right operand of comparison is an unbound value of type @Prometheus_Checker.PrometheusExpects.");
return other_value.val_ptr->n_elements == 0;
}

PrometheusMetricKey_template ts__PrometheusMetricKey(const CHARSTRING_template& name, const PrometheusMetricType_template& mtype)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 67, TTCN_Location::LOCATION_TEMPLATE, "ts_PrometheusMetricKey");
PrometheusMetricKey_template ret_val;
ret_val.name() = name;
ret_val.mtype() = mtype;
return ret_val;
}

PrometheusMetric_template ts__PrometheusMetric(const CHARSTRING_template& name, const PrometheusMetricType_template& mtype, const INTEGER_template& val)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 74, TTCN_Location::LOCATION_TEMPLATE, "ts_PrometheusMetric");
PrometheusMetric_template ret_val;
ret_val.key() = ts__PrometheusMetricKey(name, mtype);
ret_val.val() = val;
return ret_val;
}

PrometheusExpect_template ts__PrometheusExpect(const CHARSTRING_template& name, const PrometheusMetricType_template& mtype, const INTEGER_template& min, const INTEGER_template& max)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 82, TTCN_Location::LOCATION_TEMPLATE, "ts_PrometheusExpect");
PrometheusExpect_template ret_val;
ret_val.key() = ts__PrometheusMetricKey(name, mtype);
ret_val.min() = min;
ret_val.max() = max;
return ret_val;
}

void f__prometheus__init(const CHARSTRING& http__host, const INTEGER& http__port)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 92, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_init");
current_location.update_lineno(93);
/* Prometheus_Checker.ttcn, line 93 */
HTTP__Adapter::HTTP__Adapter__Params http__adapter__pars;
http__adapter__pars.http__host() = http__host;
http__adapter__pars.http__port() = http__port;
http__adapter__pars.use__ssl() = FALSE;
current_location.update_lineno(98);
/* Prometheus_Checker.ttcn, line 98 */
HTTP__Adapter::f__http__init(HTTP__Adapter::HTTP__Adapter__Params_template(http__adapter__pars));
}

void start_f__prometheus__init(const COMPONENT& component_reference, const CHARSTRING& http__host, const INTEGER& http__port)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_init(");
http__host.log();
TTCN_Logger::log_event_str(", ");
http__port.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, "Prometheus_Checker", "f_prometheus_init", text_buf);
http__host.encode_text(text_buf);
http__port.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}

PrometheusMetricType f__prometheus__metric__mtype__from__string(const CHARSTRING& str)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 101, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_metric_mtype_from_string");
current_location.update_lineno(103);
/* Prometheus_Checker.ttcn, line 103 */
PrometheusMetricType mtype;
current_location.update_lineno(104);
/* Prometheus_Checker.ttcn, line 104 */
if ((str == cs_0)) {
current_location.update_lineno(105);
/* Prometheus_Checker.ttcn, line 105 */
mtype = PrometheusMetricType::COUNTER;
}
else {
current_location.update_lineno(106);
/* Prometheus_Checker.ttcn, line 106 */
if ((str == cs_1)) {
current_location.update_lineno(107);
/* Prometheus_Checker.ttcn, line 107 */
mtype = PrometheusMetricType::GAUGE;
}
else {
current_location.update_lineno(109);
/* Prometheus_Checker.ttcn, line 109 */
Misc__Helpers::f__shutdown(cs_2, 109, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Unknown Prometheus metric type: "),str.log(),TTCN_Logger::end_event_log2str()));
}
}
current_location.update_lineno(112);
/* Prometheus_Checker.ttcn, line 112 */
return mtype;
}

PrometheusMetrics f__prometheus__parse__http__response(const CHARSTRING& body)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 115, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_parse_http_response");
current_location.update_lineno(117);
/* Prometheus_Checker.ttcn, line 117 */
PrometheusMetrics metrics(NULL_VALUE);
current_location.update_lineno(118);
/* Prometheus_Checker.ttcn, line 118 */
Misc__Helpers::ro__charstring lines(Misc__Helpers::f__str__split(body, cs_3));
{
current_location.update_lineno(119);
/* Prometheus_Checker.ttcn, line 119 */
INTEGER i(0);
current_location.update_lineno(119);
/* Prometheus_Checker.ttcn, line 119 */
for ( ; ; ) {
current_location.update_lineno(119);
/* Prometheus_Checker.ttcn, line 119 */
if (!((i + 2) < lines.lengthof())) break;
current_location.update_lineno(120);
/* Prometheus_Checker.ttcn, line 120 */
PrometheusMetric it;
current_location.update_lineno(122);
/* Prometheus_Checker.ttcn, line 122 */
if ((!(Misc__Helpers::f__str__startswith(const_cast< const Misc__Helpers::ro__charstring&>(lines)[i], cs_4)))) {
current_location.update_lineno(123);
/* Prometheus_Checker.ttcn, line 123 */
Misc__Helpers::f__shutdown(cs_2, 123, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Failed parsing Prometheus HTTP response line: "),const_cast< const Misc__Helpers::ro__charstring&>(lines)[i].log(),TTCN_Logger::end_event_log2str()));
}
current_location.update_lineno(128);
/* Prometheus_Checker.ttcn, line 128 */
if ((!(Misc__Helpers::f__str__startswith(const_cast< const Misc__Helpers::ro__charstring&>(lines)[(i + 1)], cs_5)))) {
current_location.update_lineno(129);
/* Prometheus_Checker.ttcn, line 129 */
Misc__Helpers::f__shutdown(cs_2, 129, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Failed parsing Prometheus HTTP response line: "),const_cast< const Misc__Helpers::ro__charstring&>(lines)[(i + 1)].log(),TTCN_Logger::end_event_log2str()));
}
current_location.update_lineno(132);
/* Prometheus_Checker.ttcn, line 132 */
Misc__Helpers::ro__charstring type__tokens(Misc__Helpers::f__str__split(const_cast< const Misc__Helpers::ro__charstring&>(lines)[(i + 1)], cs_6));
current_location.update_lineno(133);
/* Prometheus_Checker.ttcn, line 133 */
if ((type__tokens.lengthof() < 4)) {
current_location.update_lineno(134);
/* Prometheus_Checker.ttcn, line 134 */
Misc__Helpers::f__shutdown(cs_2, 134, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Failed parsing Prometheus HTTP response line: "),type__tokens.log(),TTCN_Logger::end_event_log2str()));
}
current_location.update_lineno(137);
/* Prometheus_Checker.ttcn, line 137 */
it.key().name() = const_cast< const Misc__Helpers::ro__charstring&>(type__tokens)[2];
current_location.update_lineno(138);
/* Prometheus_Checker.ttcn, line 138 */
it.key().mtype() = f__prometheus__metric__mtype__from__string(const_cast< const Misc__Helpers::ro__charstring&>(type__tokens)[3]);
current_location.update_lineno(141);
/* Prometheus_Checker.ttcn, line 141 */
if ((!(Misc__Helpers::f__str__startswith(const_cast< const Misc__Helpers::ro__charstring&>(lines)[(i + 2)], const_cast< const PrometheusMetric&>(it).key().name())))) {
current_location.update_lineno(142);
/* Prometheus_Checker.ttcn, line 142 */
Misc__Helpers::f__shutdown(cs_2, 142, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Failed parsing Prometheus HTTP response line: "),const_cast< const Misc__Helpers::ro__charstring&>(lines)[(i + 2)].log(),TTCN_Logger::end_event_log2str()));
}
current_location.update_lineno(145);
/* Prometheus_Checker.ttcn, line 145 */
Misc__Helpers::ro__charstring value__tokens(Misc__Helpers::f__str__split(const_cast< const Misc__Helpers::ro__charstring&>(lines)[(i + 2)], cs_6));
current_location.update_lineno(146);
/* Prometheus_Checker.ttcn, line 146 */
it.val() = str2int(const_cast< const Misc__Helpers::ro__charstring&>(value__tokens)[1]);
current_location.update_lineno(148);
/* Prometheus_Checker.ttcn, line 148 */
{
PrometheusMetrics tmp_5;
{
PrometheusMetrics tmp_6;
tmp_6.set_size(1);
tmp_6[0] = it;
tmp_5 = (metrics + tmp_6);
}
metrics = tmp_5;
}
current_location.update_lineno(119);
/* Prometheus_Checker.ttcn, line 119 */
{
INTEGER tmp_7;
tmp_7 = (i + 3);
i = tmp_7;
}
}
}
current_location.update_lineno(150);
/* Prometheus_Checker.ttcn, line 150 */
return metrics;
}

CHARSTRING f__prometheus__get__http__metrics()
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 153, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_get_http_metrics");
current_location.update_lineno(155);
/* Prometheus_Checker.ttcn, line 155 */
HTTPmsg__Types::HTTPMessage http__resp;
current_location.update_lineno(156);
/* Prometheus_Checker.ttcn, line 156 */
HTTP__Adapter::f__http__tx__request(cs_7, cs_8, HTTP__Adapter::f__http__tx__request_body_defval, HTTP__Adapter::f__http__tx__request_binary__body_defval, HTTP__Adapter::f__http__tx__request_content__type_defval, HTTP__Adapter::f__http__tx__request_custom__hdr_defval, FLOAT(Prometheus__Checker__CT_component_g__tout__http), HTTP__Adapter::f__http__tx__request_client__id_defval, HTTP__Adapter::f__http__tx__request_http__pars_defval);
current_location.update_lineno(157);
/* Prometheus_Checker.ttcn, line 157 */
http__resp = HTTP__Adapter::f__http__rx__response(HTTP__Adapter::tr__HTTP__Resp(INTEGER_template(200)), FLOAT(Prometheus__Checker__CT_component_g__tout__http), HTTP__Adapter::f__http__rx__response_client__id_defval, HTTP__Adapter::f__http__rx__response_keep__connection_defval);
current_location.update_lineno(158);
/* Prometheus_Checker.ttcn, line 158 */
return const_cast< const HTTPmsg__Types::HTTPMessage&>(http__resp).response().body();
}

void start_f__prometheus__get__http__metrics(const COMPONENT& component_reference)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_get_http_metrics(");
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, "Prometheus_Checker", "f_prometheus_get_http_metrics", text_buf);
TTCN_Runtime::send_start_component(text_buf);
}

PrometheusMetrics f__prometheus__get__metrics()
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 161, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_get_metrics");
current_location.update_lineno(163);
/* Prometheus_Checker.ttcn, line 163 */
PrometheusMetrics metrics;
current_location.update_lineno(164);
/* Prometheus_Checker.ttcn, line 164 */
CHARSTRING str;
current_location.update_lineno(165);
/* Prometheus_Checker.ttcn, line 165 */
str = f__prometheus__get__http__metrics();
current_location.update_lineno(166);
/* Prometheus_Checker.ttcn, line 166 */
metrics = f__prometheus__parse__http__response(str);
current_location.update_lineno(167);
/* Prometheus_Checker.ttcn, line 167 */
return metrics;
}

void start_f__prometheus__get__metrics(const COMPONENT& component_reference)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_get_metrics(");
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, "Prometheus_Checker", "f_prometheus_get_metrics", text_buf);
TTCN_Runtime::send_start_component(text_buf);
}

BOOLEAN f__prometheus__metrics__update__value(PrometheusMetrics& metrics, General__Types::Booleans& seen, const PrometheusMetric& it)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 171, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_metrics_update_value");
{
current_location.update_lineno(173);
/* Prometheus_Checker.ttcn, line 173 */
INTEGER i(0);
current_location.update_lineno(173);
/* Prometheus_Checker.ttcn, line 173 */
for ( ; ; ) {
current_location.update_lineno(173);
/* Prometheus_Checker.ttcn, line 173 */
if (!(i < metrics.lengthof())) break;
{
current_location.update_lineno(174);
/* Prometheus_Checker.ttcn, line 174 */
{
boolean tmp_12;
tmp_12 = (const_cast< const PrometheusMetric&>(it).key().name() != const_cast< const PrometheusMetrics&>(metrics)[i].key().name());
if (!tmp_12) tmp_12 = (const_cast< const PrometheusMetric&>(it).key().mtype() != const_cast< const PrometheusMetrics&>(metrics)[i].key().mtype());
if (tmp_12) {
current_location.update_lineno(175);
/* Prometheus_Checker.ttcn, line 175 */
goto tmp_11;
}
}
current_location.update_lineno(177);
/* Prometheus_Checker.ttcn, line 177 */
metrics[i] = it;
current_location.update_lineno(178);
/* Prometheus_Checker.ttcn, line 178 */
if (const_cast< const General__Types::Booleans&>(seen)[i]) {
current_location.update_lineno(179);
/* Prometheus_Checker.ttcn, line 179 */
return FALSE;
}
else {
current_location.update_lineno(181);
/* Prometheus_Checker.ttcn, line 181 */
seen[i] = TRUE;
current_location.update_lineno(182);
/* Prometheus_Checker.ttcn, line 182 */
return TRUE;
}
}
tmp_11:
current_location.update_lineno(173);
/* Prometheus_Checker.ttcn, line 173 */
{
INTEGER tmp_15;
++i;
}
}
}
current_location.update_lineno(185);
/* Prometheus_Checker.ttcn, line 185 */
return FALSE;
}

PrometheusMetricKeys f__prometheus__keys__from__expect(const PrometheusExpects& expects)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 189, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_keys_from_expect");
current_location.update_lineno(191);
/* Prometheus_Checker.ttcn, line 191 */
PrometheusMetricKeys keys(NULL_VALUE);
{
current_location.update_lineno(192);
/* Prometheus_Checker.ttcn, line 192 */
INTEGER i(0);
current_location.update_lineno(192);
/* Prometheus_Checker.ttcn, line 192 */
for ( ; ; ) {
current_location.update_lineno(192);
/* Prometheus_Checker.ttcn, line 192 */
if (!(i < expects.lengthof())) break;
current_location.update_lineno(193);
/* Prometheus_Checker.ttcn, line 193 */
{
PrometheusMetricKeys tmp_16;
{
PrometheusMetricKeys tmp_17;
tmp_17.set_size(1);
tmp_17[0] = const_cast< const PrometheusExpects&>(expects)[i].key();
tmp_16 = (keys + tmp_17);
}
keys = tmp_16;
}
current_location.update_lineno(192);
/* Prometheus_Checker.ttcn, line 192 */
{
INTEGER tmp_18;
++i;
}
}
}
current_location.update_lineno(195);
/* Prometheus_Checker.ttcn, line 195 */
return keys;
}

PrometheusMetrics f__prometheus__snapshot(const PrometheusMetricKeys& keys, const FLOAT& time__out)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 198, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_snapshot");
current_location.update_lineno(199);
/* Prometheus_Checker.ttcn, line 199 */
PrometheusMetrics rx__metrics;
current_location.update_lineno(200);
/* Prometheus_Checker.ttcn, line 200 */
PrometheusMetrics metrics(NULL_VALUE);
current_location.update_lineno(201);
/* Prometheus_Checker.ttcn, line 201 */
General__Types::Booleans seen(NULL_VALUE);
current_location.update_lineno(202);
/* Prometheus_Checker.ttcn, line 202 */
INTEGER seen__remain(0);
current_location.update_lineno(203);
/* Prometheus_Checker.ttcn, line 203 */
TIMER T__snapshot("T_snapshot", time__out);
current_location.update_lineno(205);
/* Prometheus_Checker.ttcn, line 205 */
if ((!(mp__enable__stats))) {
current_location.update_lineno(206);
/* Prometheus_Checker.ttcn, line 206 */
return metrics;
}
{
current_location.update_lineno(209);
/* Prometheus_Checker.ttcn, line 209 */
INTEGER i(0);
current_location.update_lineno(209);
/* Prometheus_Checker.ttcn, line 209 */
for ( ; ; ) {
current_location.update_lineno(209);
/* Prometheus_Checker.ttcn, line 209 */
if (!(i < keys.lengthof())) break;
current_location.update_lineno(210);
/* Prometheus_Checker.ttcn, line 210 */
{
PrometheusMetrics tmp_19;
{
PrometheusMetrics tmp_20;
tmp_20.set_size(1);
tmp_20[0] = ts__PrometheusMetric(CHARSTRING_template(const_cast< const PrometheusMetricKeys&>(keys)[i].name()), PrometheusMetricType_template(const_cast< const PrometheusMetricKeys&>(keys)[i].mtype()), INTEGER_template(0)).valueof();
tmp_19 = (metrics + tmp_20);
}
metrics = tmp_19;
}
current_location.update_lineno(211);
/* Prometheus_Checker.ttcn, line 211 */
{
General__Types::Booleans tmp_21;
{
General__Types::Booleans tmp_22;
tmp_22.set_size(1);
tmp_22[0] = FALSE;
tmp_21 = (seen + tmp_22);
}
seen = tmp_21;
}
current_location.update_lineno(212);
/* Prometheus_Checker.ttcn, line 212 */
{
INTEGER tmp_23;
++seen__remain;
}
current_location.update_lineno(209);
/* Prometheus_Checker.ttcn, line 209 */
{
INTEGER tmp_24;
++i;
}
}
}
current_location.update_lineno(215);
/* Prometheus_Checker.ttcn, line 215 */
T__snapshot.start();
for ( ; ; ) {
current_location.update_lineno(216);
/* Prometheus_Checker.ttcn, line 216 */
if (!(seen__remain > 0)) break;
current_location.update_lineno(217);
/* Prometheus_Checker.ttcn, line 217 */
if ((!(T__snapshot.running(NULL)))) {
{
current_location.update_lineno(218);
/* Prometheus_Checker.ttcn, line 218 */
INTEGER i(0);
current_location.update_lineno(218);
/* Prometheus_Checker.ttcn, line 218 */
for ( ; ; ) {
current_location.update_lineno(218);
/* Prometheus_Checker.ttcn, line 218 */
if (!(i < metrics.lengthof())) break;
current_location.update_lineno(220);
/* Prometheus_Checker.ttcn, line 220 */
if ((!(const_cast< const General__Types::Booleans&>(seen)[i]))) {
current_location.update_lineno(221);
/* Prometheus_Checker.ttcn, line 221 */
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Timeout waiting for ");
const_cast< const PrometheusMetrics&>(metrics)[i].key().name().log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
}
current_location.update_lineno(218);
/* Prometheus_Checker.ttcn, line 218 */
{
INTEGER tmp_25;
++i;
}
}
}
current_location.update_lineno(224);
/* Prometheus_Checker.ttcn, line 224 */
Misc__Helpers::f__shutdown(cs_2, 224, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Timeout waiting for metrics: "),keys.log(),seen.log(),TTCN_Logger::end_event_log2str()));
}
current_location.update_lineno(228);
/* Prometheus_Checker.ttcn, line 228 */
rx__metrics = f__prometheus__get__metrics();
{
current_location.update_lineno(230);
/* Prometheus_Checker.ttcn, line 230 */
INTEGER i(0);
current_location.update_lineno(230);
/* Prometheus_Checker.ttcn, line 230 */
for ( ; ; ) {
current_location.update_lineno(230);
/* Prometheus_Checker.ttcn, line 230 */
if (!(i < rx__metrics.lengthof())) break;
current_location.update_lineno(231);
/* Prometheus_Checker.ttcn, line 231 */
PrometheusMetric metric(const_cast< const PrometheusMetrics&>(rx__metrics)[i]);
current_location.update_lineno(232);
/* Prometheus_Checker.ttcn, line 232 */
if (f__prometheus__metrics__update__value(metrics, seen, metric)) {
current_location.update_lineno(233);
/* Prometheus_Checker.ttcn, line 233 */
{
INTEGER tmp_27;
--seen__remain;
}
}
current_location.update_lineno(230);
/* Prometheus_Checker.ttcn, line 230 */
{
INTEGER tmp_28;
++i;
}
}
}
current_location.update_lineno(237);
/* Prometheus_Checker.ttcn, line 237 */
if ((seen__remain > 0)) {
current_location.update_lineno(239);
/* Prometheus_Checker.ttcn, line 239 */
Osmocom__Types::f__sleep(1.0);
}
}
current_location.update_lineno(242);
/* Prometheus_Checker.ttcn, line 242 */
T__snapshot.stop();
current_location.update_lineno(244);
/* Prometheus_Checker.ttcn, line 244 */
return metrics;
}

void start_f__prometheus__snapshot(const COMPONENT& component_reference, const PrometheusMetricKeys& keys, const FLOAT& time__out)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_snapshot(");
keys.log();
TTCN_Logger::log_event_str(", ");
time__out.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, "Prometheus_Checker", "f_prometheus_snapshot", text_buf);
keys.encode_text(text_buf);
time__out.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}

BOOLEAN f__compare__PrometheusMetricKey(const PrometheusMetricKey& a, const PrometheusMetricKey& b)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 247, TTCN_Location::LOCATION_FUNCTION, "f_compare_PrometheusMetricKey");
current_location.update_lineno(248);
/* Prometheus_Checker.ttcn, line 248 */
boolean tmp_29;
tmp_29 = (const_cast< const PrometheusMetricKey&>(a).name() == const_cast< const PrometheusMetricKey&>(b).name());
if (tmp_29) tmp_29 = (const_cast< const PrometheusMetricKey&>(a).mtype() == const_cast< const PrometheusMetricKey&>(b).mtype());
return tmp_29;
}

BOOLEAN get__val__from__snapshot(INTEGER& val, const PrometheusMetric& metric, const PrometheusMetrics& snapshot)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 251, TTCN_Location::LOCATION_FUNCTION, "get_val_from_snapshot");
{
current_location.update_lineno(253);
/* Prometheus_Checker.ttcn, line 253 */
INTEGER i(0);
current_location.update_lineno(253);
/* Prometheus_Checker.ttcn, line 253 */
for ( ; ; ) {
current_location.update_lineno(253);
/* Prometheus_Checker.ttcn, line 253 */
if (!(i < snapshot.lengthof())) break;
{
current_location.update_lineno(254);
/* Prometheus_Checker.ttcn, line 254 */
if ((!(f__compare__PrometheusMetricKey(const_cast< const PrometheusMetric&>(metric).key(), const_cast< const PrometheusMetrics&>(snapshot)[i].key())))) {
current_location.update_lineno(255);
/* Prometheus_Checker.ttcn, line 255 */
goto tmp_30;
}
current_location.update_lineno(257);
/* Prometheus_Checker.ttcn, line 257 */
val = const_cast< const PrometheusMetrics&>(snapshot)[i].val();
current_location.update_lineno(258);
/* Prometheus_Checker.ttcn, line 258 */
return TRUE;
}
tmp_30:
current_location.update_lineno(253);
/* Prometheus_Checker.ttcn, line 253 */
{
INTEGER tmp_32;
++i;
}
}
}
current_location.update_lineno(260);
/* Prometheus_Checker.ttcn, line 260 */
return FALSE;
}

BOOLEAN f__compare__expect(const PrometheusMetric& metric, const PrometheusExpect& expect, const BOOLEAN& use__snapshot, const PrometheusMetrics& snapshot)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 265, TTCN_Location::LOCATION_FUNCTION, "f_compare_expect");
current_location.update_lineno(269);
/* Prometheus_Checker.ttcn, line 269 */
INTEGER val(0);
current_location.update_lineno(270);
/* Prometheus_Checker.ttcn, line 270 */
if ((!(f__compare__PrometheusMetricKey(const_cast< const PrometheusMetric&>(metric).key(), const_cast< const PrometheusExpect&>(expect).key())))) {
current_location.update_lineno(271);
/* Prometheus_Checker.ttcn, line 271 */
return FALSE;
}
current_location.update_lineno(273);
/* Prometheus_Checker.ttcn, line 273 */
if (use__snapshot) {
current_location.update_lineno(274);
/* Prometheus_Checker.ttcn, line 274 */
INTEGER prev__val(0);
current_location.update_lineno(275);
/* Prometheus_Checker.ttcn, line 275 */
if ((!(get__val__from__snapshot(prev__val, metric, snapshot)))) {
current_location.update_lineno(276);
/* Prometheus_Checker.ttcn, line 276 */
Misc__Helpers::f__shutdown(cs_2, 276, FAIL, (TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Metric "),const_cast< const PrometheusMetric&>(metric).key().log(),TTCN_Logger::log_event_str(" not found in snapshot "),snapshot.log(),TTCN_Logger::end_event_log2str()));
}
current_location.update_lineno(279);
/* Prometheus_Checker.ttcn, line 279 */
val = (const_cast< const PrometheusMetric&>(metric).val() - prev__val);
}
else {
current_location.update_lineno(281);
/* Prometheus_Checker.ttcn, line 281 */
val = const_cast< const PrometheusMetric&>(metric).val();
}
current_location.update_lineno(284);
/* Prometheus_Checker.ttcn, line 284 */
{
boolean tmp_35;
tmp_35 = (val < const_cast< const PrometheusExpect&>(expect).min());
if (!tmp_35) tmp_35 = (val > const_cast< const PrometheusExpect&>(expect).max());
if (tmp_35) {
current_location.update_lineno(285);
/* Prometheus_Checker.ttcn, line 285 */
return FALSE;
}
}
current_location.update_lineno(287);
/* Prometheus_Checker.ttcn, line 287 */
return TRUE;
}

PrometheusExpectResult f__prometheus__metric__expects(const PrometheusExpects& expects, const PrometheusMetric& metric, const BOOLEAN& use__snapshot, const PrometheusMetrics& snapshot)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 291, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_metric_expects");
current_location.update_lineno(296);
/* Prometheus_Checker.ttcn, line 296 */
PrometheusExpectResult result;
result.kind() = PrometheusResultType::e__NotFound;
result.idx() = -1;
{
current_location.update_lineno(301);
/* Prometheus_Checker.ttcn, line 301 */
INTEGER i(0);
current_location.update_lineno(301);
/* Prometheus_Checker.ttcn, line 301 */
for ( ; ; ) {
current_location.update_lineno(301);
/* Prometheus_Checker.ttcn, line 301 */
if (!(i < expects.lengthof())) break;
{
current_location.update_lineno(302);
/* Prometheus_Checker.ttcn, line 302 */
PrometheusExpect exp(const_cast< const PrometheusExpects&>(expects)[i]);
current_location.update_lineno(303);
/* Prometheus_Checker.ttcn, line 303 */
if ((const_cast< const PrometheusExpect&>(exp).key().name() != const_cast< const PrometheusMetric&>(metric).key().name())) {
current_location.update_lineno(304);
/* Prometheus_Checker.ttcn, line 304 */
goto tmp_36;
}
current_location.update_lineno(306);
/* Prometheus_Checker.ttcn, line 306 */
if ((!(f__compare__expect(metric, exp, use__snapshot, snapshot)))) {
current_location.update_lineno(307);
/* Prometheus_Checker.ttcn, line 307 */
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(308);
/* Prometheus_Checker.ttcn, line 308 */
result.kind() = PrometheusResultType::e__Mismatched;
result.idx() = i;
current_location.update_lineno(312);
/* Prometheus_Checker.ttcn, line 312 */
break;
}
else {
current_location.update_lineno(314);
/* Prometheus_Checker.ttcn, line 314 */
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(315);
/* Prometheus_Checker.ttcn, line 315 */
result.kind() = PrometheusResultType::e__Matched;
result.idx() = i;
current_location.update_lineno(319);
/* Prometheus_Checker.ttcn, line 319 */
break;
}
}
tmp_36:
current_location.update_lineno(301);
/* Prometheus_Checker.ttcn, line 301 */
{
INTEGER tmp_39;
++i;
}
}
}
current_location.update_lineno(322);
/* Prometheus_Checker.ttcn, line 322 */
return result;
}

BOOLEAN f__prometheus__expect__ext(const PrometheusExpects& expects, const BOOLEAN& wait__converge, const BOOLEAN& use__snapshot, const PrometheusMetrics& snapshot, const FLOAT& time__out)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 325, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_expect_ext");
current_location.update_lineno(331);
/* Prometheus_Checker.ttcn, line 331 */
PrometheusMetrics rx__metrics;
current_location.update_lineno(332);
/* Prometheus_Checker.ttcn, line 332 */
PrometheusExpectResult res;
current_location.update_lineno(333);
/* Prometheus_Checker.ttcn, line 333 */
General__Types::Booleans matched(NULL_VALUE);
current_location.update_lineno(334);
/* Prometheus_Checker.ttcn, line 334 */
INTEGER matched__remain(0);
current_location.update_lineno(335);
/* Prometheus_Checker.ttcn, line 335 */
TIMER T__expect("T_expect", time__out);
{
current_location.update_lineno(337);
/* Prometheus_Checker.ttcn, line 337 */
INTEGER i(0);
current_location.update_lineno(337);
/* Prometheus_Checker.ttcn, line 337 */
for ( ; ; ) {
current_location.update_lineno(337);
/* Prometheus_Checker.ttcn, line 337 */
if (!(i < expects.lengthof())) break;
current_location.update_lineno(338);
/* Prometheus_Checker.ttcn, line 338 */
{
General__Types::Booleans tmp_40;
{
General__Types::Booleans tmp_41;
tmp_41.set_size(1);
tmp_41[0] = FALSE;
tmp_40 = (matched + tmp_41);
}
matched = tmp_40;
}
current_location.update_lineno(339);
/* Prometheus_Checker.ttcn, line 339 */
{
INTEGER tmp_42;
++matched__remain;
}
current_location.update_lineno(337);
/* Prometheus_Checker.ttcn, line 337 */
{
INTEGER tmp_43;
++i;
}
}
}
current_location.update_lineno(342);
/* Prometheus_Checker.ttcn, line 342 */
T__expect.start();
for ( ; ; ) {
current_location.update_lineno(343);
/* Prometheus_Checker.ttcn, line 343 */
if (!(matched__remain > 0)) break;
current_location.update_lineno(344);
/* Prometheus_Checker.ttcn, line 344 */
if ((!(T__expect.running(NULL)))) {
{
current_location.update_lineno(345);
/* Prometheus_Checker.ttcn, line 345 */
INTEGER i(0);
current_location.update_lineno(345);
/* Prometheus_Checker.ttcn, line 345 */
for ( ; ; ) {
current_location.update_lineno(345);
/* Prometheus_Checker.ttcn, line 345 */
if (!(i < expects.lengthof())) break;
current_location.update_lineno(347);
/* Prometheus_Checker.ttcn, line 347 */
if ((!(const_cast< const General__Types::Booleans&>(matched)[i]))) {
current_location.update_lineno(348);
/* Prometheus_Checker.ttcn, line 348 */
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Timeout waiting for ");
const_cast< const PrometheusExpects&>(expects)[i].key().log();
TTCN_Logger::log_event_str(" (min: ");
const_cast< const PrometheusExpects&>(expects)[i].min().log();
TTCN_Logger::log_event_str(", max: ");
const_cast< const PrometheusExpects&>(expects)[i].max().log();
TTCN_Logger::log_char(')');
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
}
current_location.update_lineno(345);
/* Prometheus_Checker.ttcn, line 345 */
{
INTEGER tmp_44;
++i;
}
}
}
current_location.update_lineno(352);
/* Prometheus_Checker.ttcn, line 352 */
TTCN_Runtime::setverdict(FAIL,(TTCN_Logger::begin_event_log2str(),TTCN_Logger::log_event_str("Timeout waiting for metrics "),expects.log(),matched.log(),TTCN_Logger::end_event_log2str()));
current_location.update_lineno(353);
/* Prometheus_Checker.ttcn, line 353 */
return FALSE;
}
current_location.update_lineno(356);
/* Prometheus_Checker.ttcn, line 356 */
rx__metrics = f__prometheus__get__metrics();
{
current_location.update_lineno(358);
/* Prometheus_Checker.ttcn, line 358 */
INTEGER i(0);
current_location.update_lineno(358);
/* Prometheus_Checker.ttcn, line 358 */
for ( ; ; ) {
current_location.update_lineno(358);
/* Prometheus_Checker.ttcn, line 358 */
if (!(i < rx__metrics.lengthof())) break;
{
current_location.update_lineno(359);
/* Prometheus_Checker.ttcn, line 359 */
PrometheusMetric metric(const_cast< const PrometheusMetrics&>(rx__metrics)[i]);
current_location.update_lineno(360);
/* Prometheus_Checker.ttcn, line 360 */
res = f__prometheus__metric__expects(expects, metric, use__snapshot, snapshot);
current_location.update_lineno(361);
/* Prometheus_Checker.ttcn, line 361 */
if ((const_cast< const PrometheusExpectResult&>(res).kind() == PrometheusResultType::e__NotFound)) {
current_location.update_lineno(362);
/* Prometheus_Checker.ttcn, line 362 */
goto tmp_46;
}
current_location.update_lineno(364);
/* Prometheus_Checker.ttcn, line 364 */
if ((const_cast< const PrometheusExpectResult&>(res).kind() == PrometheusResultType::e__Mismatched)) {
current_location.update_lineno(365);
/* Prometheus_Checker.ttcn, line 365 */
{
boolean tmp_48;
tmp_48 = wait__converge;
if (tmp_48) tmp_48 = (!(const_cast< const General__Types::Booleans&>(matched)[const_cast< const PrometheusExpectResult&>(res).idx()]));
if (tmp_48) {
current_location.update_lineno(366);
/* Prometheus_Checker.ttcn, line 366 */
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 PrometheusExpects&>(expects)[const_cast< const PrometheusExpectResult&>(res).idx()].log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(367);
/* Prometheus_Checker.ttcn, line 367 */
goto tmp_46;
}
}
current_location.update_lineno(369);
/* Prometheus_Checker.ttcn, line 369 */
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(370);
/* Prometheus_Checker.ttcn, line 370 */
try {
TTCN_Logger::begin_event(TTCN_USER);
TTCN_Logger::log_event_str("Expect: ");
const_cast< const PrometheusExpects&>(expects)[const_cast< const PrometheusExpectResult&>(res).idx()].log();
TTCN_Logger::end_event();
} catch (...) {
TTCN_Logger::finish_event();
throw;
}
current_location.update_lineno(371);
/* Prometheus_Checker.ttcn, line 371 */
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 PrometheusExpects&>(expects)[const_cast< const PrometheusExpectResult&>(res).idx()].log(),TTCN_Logger::end_event_log2str()));
current_location.update_lineno(372);
/* Prometheus_Checker.ttcn, line 372 */
return FALSE;
}
current_location.update_lineno(374);
/* Prometheus_Checker.ttcn, line 374 */
if ((const_cast< const PrometheusExpectResult&>(res).kind() == PrometheusResultType::e__Matched)) {
current_location.update_lineno(375);
/* Prometheus_Checker.ttcn, line 375 */
if ((!(const_cast< const General__Types::Booleans&>(matched)[const_cast< const PrometheusExpectResult&>(res).idx()]))) {
current_location.update_lineno(376);
/* Prometheus_Checker.ttcn, line 376 */
matched[const_cast< const PrometheusExpectResult&>(res).idx()] = TRUE;
current_location.update_lineno(377);
/* Prometheus_Checker.ttcn, line 377 */
{
INTEGER tmp_50;
--matched__remain;
}
}
current_location.update_lineno(379);
/* Prometheus_Checker.ttcn, line 379 */
goto tmp_46;
}
}
tmp_46:
current_location.update_lineno(358);
/* Prometheus_Checker.ttcn, line 358 */
{
INTEGER tmp_51;
++i;
}
}
}
current_location.update_lineno(383);
/* Prometheus_Checker.ttcn, line 383 */
if ((matched__remain > 0)) {
current_location.update_lineno(385);
/* Prometheus_Checker.ttcn, line 385 */
Osmocom__Types::f__sleep(1.0);
}
}
current_location.update_lineno(389);
/* Prometheus_Checker.ttcn, line 389 */
T__expect.stop();
current_location.update_lineno(390);
/* Prometheus_Checker.ttcn, line 390 */
return TRUE;
}

void start_f__prometheus__expect__ext(const COMPONENT& component_reference, const PrometheusExpects& expects, const BOOLEAN& wait__converge, const BOOLEAN& use__snapshot, const PrometheusMetrics& snapshot, const FLOAT& time__out)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_expect_ext(");
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(", ");
time__out.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, "Prometheus_Checker", "f_prometheus_expect_ext", text_buf);
expects.encode_text(text_buf);
wait__converge.encode_text(text_buf);
use__snapshot.encode_text(text_buf);
snapshot.encode_text(text_buf);
time__out.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}

BOOLEAN f__prometheus__expect(const PrometheusExpects& expects, const BOOLEAN& wait__converge, const FLOAT& time__out)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 393, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_expect");
current_location.update_lineno(397);
/* Prometheus_Checker.ttcn, line 397 */
return f__prometheus__expect__ext(expects, wait__converge, FALSE, NULL_VALUE, time__out);
}

void start_f__prometheus__expect(const COMPONENT& component_reference, const PrometheusExpects& expects, const BOOLEAN& wait__converge, const FLOAT& time__out)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_expect(");
expects.log();
TTCN_Logger::log_event_str(", ");
wait__converge.log();
TTCN_Logger::log_event_str(", ");
time__out.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, "Prometheus_Checker", "f_prometheus_expect", text_buf);
expects.encode_text(text_buf);
wait__converge.encode_text(text_buf);
time__out.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}

BOOLEAN f__prometheus__expect__from__snapshot(const PrometheusExpects& expects, const BOOLEAN& wait__converge, const PrometheusMetrics& snapshot, const FLOAT& time__out)
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 400, TTCN_Location::LOCATION_FUNCTION, "f_prometheus_expect_from_snapshot");
current_location.update_lineno(405);
/* Prometheus_Checker.ttcn, line 405 */
return f__prometheus__expect__ext(expects, wait__converge, TRUE, snapshot, time__out);
}

void start_f__prometheus__expect__from__snapshot(const COMPONENT& component_reference, const PrometheusExpects& expects, const BOOLEAN& wait__converge, const PrometheusMetrics& snapshot, const FLOAT& time__out)
{
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_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(", ");
time__out.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, "Prometheus_Checker", "f_prometheus_expect_from_snapshot", text_buf);
expects.encode_text(text_buf);
wait__converge.encode_text(text_buf);
snapshot.encode_text(text_buf);
time__out.encode_text(text_buf);
TTCN_Runtime::send_start_component(text_buf);
}


/* Bodies of static functions */

void pre_init_module()
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Prometheus_Checker");
Misc__Helpers::module_object.pre_init_module();
Socket__API__Definitions::module_object.pre_init_module();
Osmocom__Types::module_object.pre_init_module();
HTTP__Adapter::module_object.pre_init_module();
current_location.update_lineno(22);
/* Prometheus_Checker.ttcn, line 22 */
const_c__prometheus__default__http__port = 9090;
current_location.update_lineno(49);
/* Prometheus_Checker.ttcn, line 49 */
modulepar_mp__enable__stats = TRUE;
module_object.add_modulepar("mp_enable_stats");
module_object.add_function("f_prometheus_init", (genericfunc_t)&f__prometheus__init, (genericfunc_t)&start_f__prometheus__init);
module_object.add_function("f_prometheus_metric_mtype_from_string", (genericfunc_t)&f__prometheus__metric__mtype__from__string, NULL);
module_object.add_function("f_prometheus_parse_http_response", (genericfunc_t)&f__prometheus__parse__http__response, NULL);
module_object.add_function("f_prometheus_get_http_metrics", (genericfunc_t)&f__prometheus__get__http__metrics, (genericfunc_t)&start_f__prometheus__get__http__metrics);
module_object.add_function("f_prometheus_get_metrics", (genericfunc_t)&f__prometheus__get__metrics, (genericfunc_t)&start_f__prometheus__get__metrics);
module_object.add_function("f_prometheus_metrics_update_value", (genericfunc_t)&f__prometheus__metrics__update__value, NULL);
module_object.add_function("f_prometheus_keys_from_expect", (genericfunc_t)&f__prometheus__keys__from__expect, NULL);
module_object.add_function("f_prometheus_snapshot", (genericfunc_t)&f__prometheus__snapshot, (genericfunc_t)&start_f__prometheus__snapshot);
module_object.add_function("f_compare_PrometheusMetricKey", (genericfunc_t)&f__compare__PrometheusMetricKey, NULL);
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_prometheus_metric_expects", (genericfunc_t)&f__prometheus__metric__expects, NULL);
module_object.add_function("f_prometheus_expect_ext", (genericfunc_t)&f__prometheus__expect__ext, (genericfunc_t)&start_f__prometheus__expect__ext);
module_object.add_function("f_prometheus_expect", (genericfunc_t)&f__prometheus__expect, (genericfunc_t)&start_f__prometheus__expect);
module_object.add_function("f_prometheus_expect_from_snapshot", (genericfunc_t)&f__prometheus__expect__from__snapshot, (genericfunc_t)&start_f__prometheus__expect__from__snapshot);
}

void post_init_module()
{
TTCN_Location current_location("Prometheus_Checker.ttcn", 0, TTCN_Location::LOCATION_UNKNOWN, "Prometheus_Checker");
Misc__Helpers::module_object.post_init_module();
Socket__API__Definitions::module_object.post_init_module();
Osmocom__Types::module_object.post_init_module();
HTTP__Adapter::module_object.post_init_module();
current_location.update_lineno(77);
/* Prometheus_Checker.ttcn, line 77 */
template_ts__PrometheusMetric_val_defval = 0;
current_location.update_lineno(92);
/* Prometheus_Checker.ttcn, line 92 */
const_f__prometheus__init_http__port_defval = 9090;
current_location.update_lineno(198);
/* Prometheus_Checker.ttcn, line 198 */
const_f__prometheus__snapshot_time__out_defval = 1.0e1;
current_location.update_lineno(267);
/* Prometheus_Checker.ttcn, line 267 */
const_f__compare__expect_use__snapshot_defval = FALSE;
current_location.update_lineno(268);
/* Prometheus_Checker.ttcn, line 268 */
const_f__compare__expect_snapshot_defval = NULL_VALUE;
current_location.update_lineno(293);
/* Prometheus_Checker.ttcn, line 293 */
const_f__prometheus__metric__expects_use__snapshot_defval = FALSE;
current_location.update_lineno(294);
/* Prometheus_Checker.ttcn, line 294 */
const_f__prometheus__metric__expects_snapshot_defval = NULL_VALUE;
current_location.update_lineno(326);
/* Prometheus_Checker.ttcn, line 326 */
const_f__prometheus__expect__ext_wait__converge_defval = FALSE;
current_location.update_lineno(327);
/* Prometheus_Checker.ttcn, line 327 */
const_f__prometheus__expect__ext_use__snapshot_defval = FALSE;
current_location.update_lineno(328);
/* Prometheus_Checker.ttcn, line 328 */
const_f__prometheus__expect__ext_snapshot_defval = NULL_VALUE;
current_location.update_lineno(329);
/* Prometheus_Checker.ttcn, line 329 */
const_f__prometheus__expect__ext_time__out_defval = 1.0e1;
current_location.update_lineno(394);
/* Prometheus_Checker.ttcn, line 394 */
const_f__prometheus__expect_wait__converge_defval = FALSE;
current_location.update_lineno(395);
/* Prometheus_Checker.ttcn, line 395 */
const_f__prometheus__expect_time__out_defval = 1.0e1;
current_location.update_lineno(401);
/* Prometheus_Checker.ttcn, line 401 */
const_f__prometheus__expect__from__snapshot_wait__converge_defval = FALSE;
current_location.update_lineno(402);
/* Prometheus_Checker.ttcn, line 402 */
const_f__prometheus__expect__from__snapshot_snapshot_defval = NULL_VALUE;
current_location.update_lineno(403);
/* Prometheus_Checker.ttcn, line 403 */
const_f__prometheus__expect__from__snapshot_time__out_defval = 1.0e1;
}

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, "Prometheus_Checker_CT")) {
if (init_base_comps) {
Module_List::initialize_component("HTTP_Adapter", "http_CT", FALSE);
}
Prometheus__Checker__CT_component_g__tout__http = 5.0;
return TRUE;
} else return FALSE;
}

boolean init_system_port(const char* component_type, const char* port_name)
{
if (!strcmp(component_type, "Prometheus_Checker_CT")) {
if (!strcmp(port_name, "HTTP")) {
HTTP__Adapter::http__CT_component_HTTP.safe_start();
return TRUE;
}
}
return FALSE;
}

boolean start_ptc_function(const char *function_name, Text_Buf& function_arguments)
{
if (!strcmp(function_name, "f_prometheus_init")) {
CHARSTRING http__host;
INTEGER http__port;
http__host.decode_text(function_arguments);
http__port.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_init(");
http__host.log();
TTCN_Logger::log_event_str(", ");
http__port.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__prometheus__init(http__host, http__port);
TTCN_Runtime::function_finished("f_prometheus_init");
return TRUE;
} else if (!strcmp(function_name, "f_prometheus_get_http_metrics")) {
TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function f_prometheus_get_http_metrics().");
TTCN_Runtime::function_started(function_arguments);
f__prometheus__get__http__metrics();
TTCN_Runtime::function_finished("f_prometheus_get_http_metrics");
return TRUE;
} else if (!strcmp(function_name, "f_prometheus_get_metrics")) {
TTCN_Logger::log_str(TTCN_Logger::PARALLEL_PTC, "Starting function f_prometheus_get_metrics().");
TTCN_Runtime::function_started(function_arguments);
f__prometheus__get__metrics();
TTCN_Runtime::function_finished("f_prometheus_get_metrics");
return TRUE;
} else if (!strcmp(function_name, "f_prometheus_snapshot")) {
PrometheusMetricKeys keys;
FLOAT time__out;
keys.decode_text(function_arguments);
time__out.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_snapshot(");
keys.log();
TTCN_Logger::log_event_str(", ");
time__out.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__prometheus__snapshot(keys, time__out);
TTCN_Runtime::function_finished("f_prometheus_snapshot");
return TRUE;
} else if (!strcmp(function_name, "f_prometheus_expect_ext")) {
PrometheusExpects expects;
BOOLEAN wait__converge;
BOOLEAN use__snapshot;
PrometheusMetrics snapshot;
FLOAT time__out;
expects.decode_text(function_arguments);
wait__converge.decode_text(function_arguments);
use__snapshot.decode_text(function_arguments);
snapshot.decode_text(function_arguments);
time__out.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_expect_ext(");
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(", ");
time__out.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__prometheus__expect__ext(expects, wait__converge, use__snapshot, snapshot, time__out);
TTCN_Runtime::function_finished("f_prometheus_expect_ext");
return TRUE;
} else if (!strcmp(function_name, "f_prometheus_expect")) {
PrometheusExpects expects;
BOOLEAN wait__converge;
FLOAT time__out;
expects.decode_text(function_arguments);
wait__converge.decode_text(function_arguments);
time__out.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_expect(");
expects.log();
TTCN_Logger::log_event_str(", ");
wait__converge.log();
TTCN_Logger::log_event_str(", ");
time__out.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__prometheus__expect(expects, wait__converge, time__out);
TTCN_Runtime::function_finished("f_prometheus_expect");
return TRUE;
} else if (!strcmp(function_name, "f_prometheus_expect_from_snapshot")) {
PrometheusExpects expects;
BOOLEAN wait__converge;
PrometheusMetrics snapshot;
FLOAT time__out;
expects.decode_text(function_arguments);
wait__converge.decode_text(function_arguments);
snapshot.decode_text(function_arguments);
time__out.decode_text(function_arguments);
TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);
TTCN_Logger::log_event_str("Starting function f_prometheus_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(", ");
time__out.log();
TTCN_Logger::log_event_str(").");
TTCN_Logger::end_event();
TTCN_Runtime::function_started(function_arguments);
f__prometheus__expect__from__snapshot(expects, wait__converge, snapshot, time__out);
TTCN_Runtime::function_finished("f_prometheus_expect_from_snapshot");
return TRUE;
} else return FALSE;
}


} /* end of namespace */
