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

namespace AF__PACKET__PortTypes {

/* Literal string constants */

const unsigned char module_checksum[] = { 0xc2, 0x84, 0xde, 0xcb, 0xc0, 0x05, 0x9c, 0x57, 0x25, 0x23, 0x6b, 0xf0, 0x61, 0x60, 0x78, 0x1c };

/* Global variable definitions */

const XERdescriptor_t       AF__PACKET__Unitdata_data_xer_ = { {"data>\n", "data>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE,  NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int AF__PACKET__Unitdata_data_oer_ext_arr_[0] = {};
const int AF__PACKET__Unitdata_data_oer_p_[0] = {};
const TTCN_OERdescriptor_t AF__PACKET__Unitdata_data_oer_ = { -1, TRUE, -1, FALSE, 0, 0, AF__PACKET__Unitdata_data_oer_ext_arr_, 0, AF__PACKET__Unitdata_data_oer_p_};
const TTCN_Typedescriptor_t AF__PACKET__Unitdata_data_descr_ = { "@AF_PACKET_PortTypes.AF_PACKET_Unitdata.data", &OCTETSTRING_ber_, &OCTETSTRING_raw_, &OCTETSTRING_text_, &AF__PACKET__Unitdata_data_xer_, &OCTETSTRING_json_, &AF__PACKET__Unitdata_data_oer_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for AF__PACKET__Unitdata
const TTCN_Typedescriptor_t AF__PACKET__Unitdata_descr_ = { "@AF_PACKET_PortTypes.AF_PACKET_Unitdata", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
TTCN_Module module_object("AF_PACKET_PortTypes", __DATE__, __TIME__, module_checksum, NULL, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 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 */

AF__PACKET__Unitdata::AF__PACKET__Unitdata()
{
}

AF__PACKET__Unitdata::AF__PACKET__Unitdata(const OCTETSTRING& par_data)
  :   field_data(par_data)
{
}

AF__PACKET__Unitdata::AF__PACKET__Unitdata(const AF__PACKET__Unitdata& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
if (other_value.data().is_bound()) field_data = other_value.data();
else field_data.clean_up();
}

void AF__PACKET__Unitdata::clean_up()
{
field_data.clean_up();
}

const TTCN_Typedescriptor_t* AF__PACKET__Unitdata::get_descriptor() const { return &AF__PACKET__Unitdata_descr_; }
AF__PACKET__Unitdata& AF__PACKET__Unitdata::operator=(const AF__PACKET__Unitdata& other_value)
{
if (this != &other_value) {
  if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
  if (other_value.data().is_bound()) field_data = other_value.data();
  else field_data.clean_up();
}
return *this;
}

boolean AF__PACKET__Unitdata::operator==(const AF__PACKET__Unitdata& other_value) const
{
return field_data==other_value.field_data;
}

boolean AF__PACKET__Unitdata::is_bound() const
{
return (field_data.is_bound());
}
boolean AF__PACKET__Unitdata::is_value() const
{
return field_data.is_value();
}
void AF__PACKET__Unitdata::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ data := ");
field_data.log();
TTCN_Logger::log_event_str(" }");
}

void AF__PACKET__Unitdata::set_implicit_omit()
{
if (data().is_bound()) data().set_implicit_omit();
}

void AF__PACKET__Unitdata::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 (1<param.get_size()) {
      param.error("record value of type @AF_PACKET_PortTypes.AF_PACKET_Unitdata has 1 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) data().set_param(*param.get_elem(0));
    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(), "data")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          data().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 @AF_PACKET_PortTypes.AF_PACKET_Unitdata: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  default:
    param.type_error("record value", "@AF_PACKET_PortTypes.AF_PACKET_Unitdata");
  }
}

void AF__PACKET__Unitdata::encode_text(Text_Buf& text_buf) const
{
field_data.encode_text(text_buf);
}

void AF__PACKET__Unitdata::decode_text(Text_Buf& text_buf)
{
field_data.decode_text(text_buf);
}

struct AF__PACKET__Unitdata_template::single_value_struct {
OCTETSTRING_template field_data;
};

void AF__PACKET__Unitdata_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_data = ANY_VALUE;
}
}
}

void AF__PACKET__Unitdata_template::copy_value(const AF__PACKET__Unitdata& other_value)
{
single_value = new single_value_struct;
if (other_value.data().is_bound()) {
  single_value->field_data = other_value.data();
} else {
  single_value->field_data.clean_up();
}
set_selection(SPECIFIC_VALUE);
}

void AF__PACKET__Unitdata_template::copy_template(const AF__PACKET__Unitdata_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.data().get_selection()) {
single_value->field_data = other_value.data();
} else {
single_value->field_data.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 AF__PACKET__Unitdata_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 AF__PACKET__Unitdata_template(*other_value.implication_.precondition);
implication_.implied_template = new AF__PACKET__Unitdata_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 @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
break;
}
set_selection(other_value);
}

AF__PACKET__Unitdata_template::AF__PACKET__Unitdata_template()
{
}

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

AF__PACKET__Unitdata_template::AF__PACKET__Unitdata_template(const AF__PACKET__Unitdata& other_value)
{
copy_value(other_value);
}

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

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

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

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

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

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

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

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

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

boolean AF__PACKET__Unitdata_template::match(const AF__PACKET__Unitdata& 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.data().is_bound()) return FALSE;
if(!single_value->field_data.match(other_value.data(), 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 @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
}
return FALSE;
}

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

boolean AF__PACKET__Unitdata_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_data.is_value();
}

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

AF__PACKET__Unitdata AF__PACKET__Unitdata_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 @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
AF__PACKET__Unitdata ret_val;
if (single_value->field_data.is_bound()) {
ret_val.data() = single_value->field_data.valueof();
}
return ret_val;
}

void AF__PACKET__Unitdata_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 @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new AF__PACKET__Unitdata_template[list_length];
}

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

OCTETSTRING_template& AF__PACKET__Unitdata_template::data()
{
set_specific();
return single_value->field_data;
}

const OCTETSTRING_template& AF__PACKET__Unitdata_template::data() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field data of a non-specific template of type @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
return single_value->field_data;
}

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

void AF__PACKET__Unitdata_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ data := ");
single_value->field_data.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 AF__PACKET__Unitdata_template::log_match(const AF__PACKET__Unitdata& 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_data.match(match_value.data(), legacy)){
TTCN_Logger::log_logmatch_info(".data");
single_value->field_data.log_match(match_value.data(), 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("{ data := ");
single_value->field_data.log_match(match_value.data(), 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 AF__PACKET__Unitdata_template::set_implicit_omit()
{
if (template_selection != SPECIFIC_VALUE) return;
if (data().is_bound()) data().set_implicit_omit();
}

void AF__PACKET__Unitdata_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_data.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 @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
}
}

void AF__PACKET__Unitdata_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_data.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 AF__PACKET__Unitdata_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 @AF_PACKET_PortTypes.AF_PACKET_Unitdata.");
}
}

void AF__PACKET__Unitdata_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: {
    AF__PACKET__Unitdata_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 (1<param.get_size()) {
      param.error("record template of type @AF_PACKET_PortTypes.AF_PACKET_Unitdata has 1 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) data().set_param(*param.get_elem(0));
    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(), "data")) {
        if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
          data().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 @AF_PACKET_PortTypes.AF_PACKET_Unitdata: %s", curr_param->get_id()->get_name());
      break;
    }
  } break;
  case Module_Param::MP_Implication_Template: {
    AF__PACKET__Unitdata_template* precondition = new AF__PACKET__Unitdata_template;
    precondition->set_param(*param.get_elem(0));
    AF__PACKET__Unitdata_template* implied_template = new AF__PACKET__Unitdata_template;
    implied_template->set_param(*param.get_elem(1));
    *this = AF__PACKET__Unitdata_template(precondition, implied_template);
  } break;
  default:
    param.type_error("record template", "@AF_PACKET_PortTypes.AF_PACKET_Unitdata");
  }
  is_ifpresent = param.get_ifpresent();
}

void AF__PACKET__Unitdata_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_data.check_restriction(t_res, t_name ? t_name : "@AF_PACKET_PortTypes.AF_PACKET_Unitdata");
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 : "@AF_PACKET_PortTypes.AF_PACKET_Unitdata");
}

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

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


} /* end of namespace */
