blob: 125aa5c9851e9dfcd345f3e64750f8a16c4cf021 [file] [log] [blame]
// This C++ source file was generated by the TTCN-3 compiler
// of the TTCN-3 Test Executor version CRL 113 200/6 R6A
// for Lénárd Nagy (elnrnag@elx78355y6x) on Thu Oct 24 10:29:40 2019
// Copyright (c) 2000-2019 Ericsson Telecom AB
// Do not edit this file unless you know what you are doing.
/* Including header files */
#include "SocketCANtest.hh"
namespace SocketCANtest {
/* Prototypes of static functions */
static void pre_init_module();
static void post_init_module();
static boolean init_comp_type(const char *component_type, boolean init_base_comps);
static boolean init_system_port(const char* component_type, const char* port_name);
static boolean start_ptc_function(const char *function_name, Text_Buf& function_arguments);
/* Literal string constants */
static const unsigned char module_checksum[] = { 0xb6, 0x43, 0x20, 0x73, 0x85, 0xdb, 0x97, 0xc0, 0xb3, 0x10, 0xa7, 0xb6, 0xb5, 0x9d, 0x7e, 0x65 };
/* Class definitions for internal use */
class alt__awaitPhaseStartReq_Default : public Default_Base {
e__Phase par_p__phase;
public:
alt__awaitPhaseStartReq_Default(const e__Phase& p__phase);
alt_status call_altstep();
};
/* Global variable definitions */
static FLOAT const_c__guard;
const FLOAT& c__guard = const_c__guard;
// No XER for SocketCAN__open__socket__type
const TTCN_Typedescriptor_t SocketCAN__open__socket__type_descr_ = { "@SocketCANtest.SocketCAN_open_socket_type", NULL, NULL, NULL, NULL, &ENUMERATED_json_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for e__Phase
const TTCN_Typedescriptor_t e__Phase_descr_ = { "@SocketCANtest.e_Phase", NULL, NULL, NULL, NULL, &ENUMERATED_json_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t SocketCAN__open__raw__result_socket__id_xer_ = { {"socket_id>\n", "socket_id>\n"}, {11, 11}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t SocketCAN__open__raw__result_socket__id_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t SocketCAN__open__raw__result_socket__id_descr_ = { "@SocketCANtest.SocketCAN_open_raw_result.socket_id", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &SocketCAN__open__raw__result_socket__id_xer_, &INTEGER_json_, &SocketCAN__open__raw__result_socket__id_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for SocketCAN__open__raw__result
const TTCN_Typedescriptor_t SocketCAN__open__raw__result_descr_ = { "@SocketCANtest.SocketCAN_open_raw_result", NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for BCM__cmd
const TTCN_Typedescriptor_t BCM__cmd_descr_ = { "@SocketCANtest.BCM_cmd", NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for BCM__cmds
const TTCN_Typedescriptor_t BCM__cmds_descr_ = { "@SocketCANtest.BCM_cmds", NULL, NULL, NULL, NULL, NULL, NULL, &BCM__cmd_descr_, TTCN_Typedescriptor_t::DONTCARE };
// No XER for SocketCAN__CAN__or__CAN__FD__frames
const TTCN_Typedescriptor_t SocketCAN__CAN__or__CAN__FD__frames_descr_ = { "@SocketCANtest.SocketCAN_CAN_or_CAN_FD_frames", NULL, NULL, NULL, NULL, NULL, NULL, &SocketCAN__Types::SocketCAN__CAN__or__CAN__FD__frame_descr_, TTCN_Typedescriptor_t::DONTCARE };
static e__Phase const_c__firstPhase;
const e__Phase& c__firstPhase = const_c__firstPhase;
static e__Phase const_c__testcase__complete;
const e__Phase& c__testcase__complete = const_c__testcase__complete;
const XERdescriptor_t PhaseStartReq_phase__int_xer_ = { {"phase_int>\n", "phase_int>\n"}, {11, 11}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t PhaseStartReq_phase__int_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t PhaseStartReq_phase__int_descr_ = { "@SocketCANtest.PhaseStartReq.phase_int", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &PhaseStartReq_phase__int_xer_, &INTEGER_json_, &PhaseStartReq_phase__int_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PhaseStartReq
const TTCN_Typedescriptor_t PhaseStartReq_descr_ = { "@SocketCANtest.PhaseStartReq", NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t PhaseEndInd_phase__int_xer_ = { {"phase_int>\n", "phase_int>\n"}, {11, 11}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t PhaseEndInd_phase__int_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t PhaseEndInd_phase__int_descr_ = { "@SocketCANtest.PhaseEndInd.phase_int", &INTEGER_ber_, &INTEGER_raw_, &INTEGER_text_, &PhaseEndInd_phase__int_xer_, &INTEGER_json_, &PhaseEndInd_phase__int_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PhaseEndInd
const TTCN_Typedescriptor_t PhaseEndInd_descr_ = { "@SocketCANtest.PhaseEndInd", NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
// No XER for PTCSet
const TTCN_Typedescriptor_t PTCSet_descr_ = { "@SocketCANtest.PTCSet", NULL, NULL, NULL, NULL, NULL, NULL, &COMPONENT_descr_, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& PTC_descr_ = COMPONENT_descr_;
SyncSlavePort PTC_component_pt__sync("pt_sync");
SocketCAN__PortType::SocketCAN__PT PTC_component_pt__socketCAN("pt_socketCAN");
e__Phase PTC_component_v__phase;
const TTCN_Typedescriptor_t& MTC_descr_ = COMPONENT_descr_;
TIMER MTC_component_t__guard("t_guard");
SyncMasterPort MTC_component_pt__sync("pt_sync");
PTCSet MTC_component_v__PTCSet;
TTCN_Module module_object("SocketCANtest", __DATE__, __TIME__, module_checksum, pre_init_module, NULL, 0U, 4294967295U, 4294967295U, 4294967295U, NULL, 0LU, 0, post_init_module, NULL, NULL, NULL, init_comp_type, init_system_port, start_ptc_function, NULL);
static const RuntimeVersionChecker ver_checker( current_runtime_version.requires_major_version_6,
current_runtime_version.requires_minor_version_6,
current_runtime_version.requires_patch_level_0, current_runtime_version.requires_runtime_1);
/* Member functions of C++ classes */
SocketCAN__open__socket__type::SocketCAN__open__socket__type()
{
enum_value = UNBOUND_VALUE;
}
SocketCAN__open__socket__type::SocketCAN__open__socket__type(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @SocketCANtest.SocketCAN_open_socket_type with invalid numeric value %d.", other_value);
enum_value = (enum_type)other_value;
}
SocketCAN__open__socket__type::SocketCAN__open__socket__type(enum_type other_value)
{
enum_value = other_value;
}
SocketCAN__open__socket__type::SocketCAN__open__socket__type(const SocketCAN__open__socket__type& other_value)
: Base_Type()
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
enum_value = other_value.enum_value;
}
SocketCAN__open__socket__type& SocketCAN__open__socket__type::operator=(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @SocketCANtest.SocketCAN_open_socket_type.", other_value);
enum_value = (enum_type)other_value;
return *this;
}
SocketCAN__open__socket__type& SocketCAN__open__socket__type::operator=(enum_type other_value)
{
enum_value = other_value;
return *this;
}
SocketCAN__open__socket__type& SocketCAN__open__socket__type::operator=(const SocketCAN__open__socket__type& other_value)
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
enum_value = other_value.enum_value;
return *this;
}
boolean SocketCAN__open__socket__type::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 @SocketCANtest.SocketCAN_open_socket_type.");
return enum_value == other_value;
}
boolean SocketCAN__open__socket__type::operator==(const SocketCAN__open__socket__type& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
return enum_value == other_value.enum_value;
}
boolean SocketCAN__open__socket__type::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 @SocketCANtest.SocketCAN_open_socket_type.");
return enum_value < other_value;
}
boolean SocketCAN__open__socket__type::operator<(const SocketCAN__open__socket__type& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
return enum_value < other_value.enum_value;
}
boolean SocketCAN__open__socket__type::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 @SocketCANtest.SocketCAN_open_socket_type.");
return enum_value > other_value;
}
boolean SocketCAN__open__socket__type::operator>(const SocketCAN__open__socket__type& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
return enum_value > other_value.enum_value;
}
const char *SocketCAN__open__socket__type::enum_to_str(enum_type enum_par)
{
switch (enum_par) {
case OPEN__CAN__RAW: return "OPEN_CAN_RAW";
case OPEN__CAN__BCM: return "OPEN_CAN_BCM";
case OPEN__CAN__ISOTP: return "OPEN_CAN_ISOTP";
default: return "<unknown>";
}
}
SocketCAN__open__socket__type::enum_type SocketCAN__open__socket__type::str_to_enum(const char *str_par)
{
if (!strcmp(str_par, "OPEN_CAN_RAW")) return OPEN__CAN__RAW;
else if (!strcmp(str_par, "OPEN_CAN_BCM")) return OPEN__CAN__BCM;
else if (!strcmp(str_par, "OPEN_CAN_ISOTP")) return OPEN__CAN__ISOTP;
else return UNKNOWN_VALUE;
}
boolean SocketCAN__open__socket__type::is_valid_enum(int int_par)
{
switch (int_par) {
case 0:
case 1:
case 2:
return TRUE;
default:
return FALSE;
}
}
int SocketCAN__open__socket__type::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 @SocketCANtest.SocketCAN_open_socket_type.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par;
}
int SocketCAN__open__socket__type::enum2int(const SocketCAN__open__socket__type& 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 @SocketCANtest.SocketCAN_open_socket_type.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par.enum_value;
}
void SocketCAN__open__socket__type::int2enum(int int_val)
{
if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @SocketCANtest.SocketCAN_open_socket_type.", int_val);
enum_value = (enum_type)int_val;
}
SocketCAN__open__socket__type::operator SocketCAN__open__socket__type::enum_type() const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
return enum_value;
}
void SocketCAN__open__socket__type::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 SocketCAN__open__socket__type::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", "@SocketCANtest.SocketCAN_open_socket_type");
enum_value = str_to_enum(param.get_enumerated());
if (!is_valid_enum(enum_value)) {
param.error("Invalid enumerated value for type @SocketCANtest.SocketCAN_open_socket_type.");
}
}
void SocketCAN__open__socket__type::encode_text(Text_Buf& text_buf) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
text_buf.push_int(enum_value);
}
void SocketCAN__open__socket__type::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 @SocketCANtest.SocketCAN_open_socket_type.", enum_value);
}
void SocketCAN__open__socket__type_template::copy_template(const SocketCAN__open__socket__type_template& other_value)
{
set_selection(other_value);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = other_value.single_value;
break;
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new SocketCAN__open__socket__type_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
}
}
SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template()
{
}
SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(int other_value)
: Base_Template(SPECIFIC_VALUE)
{
if (!SocketCAN__open__socket__type::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @SocketCANtest.SocketCAN_open_socket_type with unknown numeric value %d.", other_value);
single_value = (SocketCAN__open__socket__type::enum_type)other_value;
}
SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(SocketCAN__open__socket__type::enum_type other_value)
: Base_Template(SPECIFIC_VALUE)
{
single_value = other_value;
}
SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(const SocketCAN__open__socket__type& other_value)
: Base_Template(SPECIFIC_VALUE)
{
if (other_value.enum_value == SocketCAN__open__socket__type::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
single_value = other_value.enum_value;
}
SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(const OPTIONAL<SocketCAN__open__socket__type>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (SocketCAN__open__socket__type::enum_type)(const SocketCAN__open__socket__type&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of enumerated type @SocketCANtest.SocketCAN_open_socket_type from an unbound optional field.");
}
}
SocketCAN__open__socket__type_template::SocketCAN__open__socket__type_template(const SocketCAN__open__socket__type_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
SocketCAN__open__socket__type_template::~SocketCAN__open__socket__type_template()
{
clean_up();
}
boolean SocketCAN__open__socket__type_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
return TRUE;
}
boolean SocketCAN__open__socket__type_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value != SocketCAN__open__socket__type::UNBOUND_VALUE;
}
void SocketCAN__open__socket__type_template::clean_up()
{
if (template_selection == VALUE_LIST || template_selection == COMPLEMENTED_LIST) delete [] value_list.list_value;
template_selection = UNINITIALIZED_TEMPLATE;
}
SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(int other_value)
{
if (!SocketCAN__open__socket__type::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @SocketCANtest.SocketCAN_open_socket_type.", other_value);
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = (SocketCAN__open__socket__type::enum_type)other_value;
return *this;
}
SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(SocketCAN__open__socket__type::enum_type other_value)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value;
return *this;
}
SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(const SocketCAN__open__socket__type& other_value)
{
if (other_value.enum_value == SocketCAN__open__socket__type::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @SocketCANtest.SocketCAN_open_socket_type to a template.");
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value.enum_value;
return *this;
}
SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(const OPTIONAL<SocketCAN__open__socket__type>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (SocketCAN__open__socket__type::enum_type)(const SocketCAN__open__socket__type&)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 @SocketCANtest.SocketCAN_open_socket_type.");
}
return *this;
}
SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::operator=(const SocketCAN__open__socket__type_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean SocketCAN__open__socket__type_template::match(SocketCAN__open__socket__type::enum_type other_value, boolean) const
{
switch (template_selection) {
case SPECIFIC_VALUE:
return single_value == other_value;
case OMIT_VALUE:
return FALSE;
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
default:
TTCN_error("Matching an uninitialized/unsupported template of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
}
return FALSE;
}
boolean SocketCAN__open__socket__type_template::match(const SocketCAN__open__socket__type& other_value, boolean) const
{
if (other_value.enum_value == SocketCAN__open__socket__type::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @SocketCANtest.SocketCAN_open_socket_type with an unbound value.");
return match(other_value.enum_value);
}
SocketCAN__open__socket__type::enum_type SocketCAN__open__socket__type_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 @SocketCANtest.SocketCAN_open_socket_type.");
return single_value;
}
void SocketCAN__open__socket__type_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error("Setting an invalid list type for a template of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new SocketCAN__open__socket__type_template[list_length];
}
SocketCAN__open__socket__type_template& SocketCAN__open__socket__type_template::list_item(unsigned int list_index)
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Accessing a list element in a non-list template of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @SocketCANtest.SocketCAN_open_socket_type.");
return value_list.list_value[list_index];
}
void SocketCAN__open__socket__type_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_enum(SocketCAN__open__socket__type::enum_to_str(single_value), single_value);
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[elem_count].log();
}
TTCN_Logger::log_char(')');
break;
default:
log_generic();
}
log_ifpresent();
}
void SocketCAN__open__socket__type_template::log_match(const SocketCAN__open__socket__type& 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 SocketCAN__open__socket__type_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 @SocketCANtest.SocketCAN_open_socket_type.");
}
}
void SocketCAN__open__socket__type_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = (SocketCAN__open__socket__type::enum_type)text_buf.pull_int().get_val();
if (!SocketCAN__open__socket__type::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @SocketCANtest.SocketCAN_open_socket_type.", 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 SocketCAN__open__socket__type_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 @SocketCANtest.SocketCAN_open_socket_type.");
}
}
boolean SocketCAN__open__socket__type_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean SocketCAN__open__socket__type_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int i=0; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
void SocketCAN__open__socket__type_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: {
SocketCAN__open__socket__type_template new_temp;
new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, m_p->get_size());
for (size_t p_i=0; p_i<m_p->get_size(); p_i++) {
new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
}
*this = new_temp;
break; }
case Module_Param::MP_Enumerated: {
SocketCAN__open__socket__type::enum_type enum_val = SocketCAN__open__socket__type::str_to_enum(m_p->get_enumerated());
if (!SocketCAN__open__socket__type::is_valid_enum(enum_val)) {
param.error("Invalid enumerated value for type @SocketCANtest.SocketCAN_open_socket_type.");
}
*this = enum_val;
} break;
default:
param.type_error("enumerated template", "@SocketCANtest.SocketCAN_open_socket_type");
}
is_ifpresent = param.get_ifpresent();
}
void SocketCAN__open__socket__type_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 : "@SocketCANtest.SocketCAN_open_socket_type");
}
e__Phase::e__Phase()
{
enum_value = UNBOUND_VALUE;
}
e__Phase::e__Phase(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @SocketCANtest.e_Phase with invalid numeric value %d.", other_value);
enum_value = (enum_type)other_value;
}
e__Phase::e__Phase(enum_type other_value)
{
enum_value = other_value;
}
e__Phase::e__Phase(const e__Phase& other_value)
: Base_Type()
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @SocketCANtest.e_Phase.");
enum_value = other_value.enum_value;
}
e__Phase& e__Phase::operator=(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @SocketCANtest.e_Phase.", other_value);
enum_value = (enum_type)other_value;
return *this;
}
e__Phase& e__Phase::operator=(enum_type other_value)
{
enum_value = other_value;
return *this;
}
e__Phase& e__Phase::operator=(const e__Phase& other_value)
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @SocketCANtest.e_Phase.");
enum_value = other_value.enum_value;
return *this;
}
boolean e__Phase::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 @SocketCANtest.e_Phase.");
return enum_value == other_value;
}
boolean e__Phase::operator==(const e__Phase& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @SocketCANtest.e_Phase.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @SocketCANtest.e_Phase.");
return enum_value == other_value.enum_value;
}
boolean e__Phase::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 @SocketCANtest.e_Phase.");
return enum_value < other_value;
}
boolean e__Phase::operator<(const e__Phase& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @SocketCANtest.e_Phase.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @SocketCANtest.e_Phase.");
return enum_value < other_value.enum_value;
}
boolean e__Phase::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 @SocketCANtest.e_Phase.");
return enum_value > other_value;
}
boolean e__Phase::operator>(const e__Phase& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @SocketCANtest.e_Phase.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @SocketCANtest.e_Phase.");
return enum_value > other_value.enum_value;
}
const char *e__Phase::enum_to_str(enum_type enum_par)
{
switch (enum_par) {
case e__open__socket: return "e_open_socket";
case e__testbody1: return "e_testbody1";
case e__testbody2: return "e_testbody2";
case e__testbody3: return "e_testbody3";
case e__testbody4: return "e_testbody4";
case e__testbody5: return "e_testbody5";
case e__testbody6: return "e_testbody6";
case e__testbody7: return "e_testbody7";
case e__testbodyEnd: return "e_testbodyEnd";
case e__close__socket: return "e_close_socket";
case e__testcase__complete: return "e_testcase_complete";
default: return "<unknown>";
}
}
e__Phase::enum_type e__Phase::str_to_enum(const char *str_par)
{
if (!strcmp(str_par, "e_open_socket")) return e__open__socket;
else if (!strcmp(str_par, "e_testbody1")) return e__testbody1;
else if (!strcmp(str_par, "e_testbody2")) return e__testbody2;
else if (!strcmp(str_par, "e_testbody3")) return e__testbody3;
else if (!strcmp(str_par, "e_testbody4")) return e__testbody4;
else if (!strcmp(str_par, "e_testbody5")) return e__testbody5;
else if (!strcmp(str_par, "e_testbody6")) return e__testbody6;
else if (!strcmp(str_par, "e_testbody7")) return e__testbody7;
else if (!strcmp(str_par, "e_testbodyEnd")) return e__testbodyEnd;
else if (!strcmp(str_par, "e_close_socket")) return e__close__socket;
else if (!strcmp(str_par, "e_testcase_complete")) return e__testcase__complete;
else return UNKNOWN_VALUE;
}
boolean e__Phase::is_valid_enum(int int_par)
{
switch (int_par) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
return TRUE;
default:
return FALSE;
}
}
int e__Phase::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 @SocketCANtest.e_Phase.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par;
}
int e__Phase::enum2int(const e__Phase& 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 @SocketCANtest.e_Phase.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par.enum_value;
}
void e__Phase::int2enum(int int_val)
{
if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @SocketCANtest.e_Phase.", int_val);
enum_value = (enum_type)int_val;
}
e__Phase::operator e__Phase::enum_type() const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @SocketCANtest.e_Phase.");
return enum_value;
}
void e__Phase::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 e__Phase::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", "@SocketCANtest.e_Phase");
enum_value = str_to_enum(param.get_enumerated());
if (!is_valid_enum(enum_value)) {
param.error("Invalid enumerated value for type @SocketCANtest.e_Phase.");
}
}
void e__Phase::encode_text(Text_Buf& text_buf) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @SocketCANtest.e_Phase.");
text_buf.push_int(enum_value);
}
void e__Phase::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 @SocketCANtest.e_Phase.", enum_value);
}
void e__Phase_template::copy_template(const e__Phase_template& other_value)
{
set_selection(other_value);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = other_value.single_value;
break;
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new e__Phase_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of enumerated type @SocketCANtest.e_Phase.");
}
}
e__Phase_template::e__Phase_template()
{
}
e__Phase_template::e__Phase_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
e__Phase_template::e__Phase_template(int other_value)
: Base_Template(SPECIFIC_VALUE)
{
if (!e__Phase::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @SocketCANtest.e_Phase with unknown numeric value %d.", other_value);
single_value = (e__Phase::enum_type)other_value;
}
e__Phase_template::e__Phase_template(e__Phase::enum_type other_value)
: Base_Template(SPECIFIC_VALUE)
{
single_value = other_value;
}
e__Phase_template::e__Phase_template(const e__Phase& other_value)
: Base_Template(SPECIFIC_VALUE)
{
if (other_value.enum_value == e__Phase::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @SocketCANtest.e_Phase.");
single_value = other_value.enum_value;
}
e__Phase_template::e__Phase_template(const OPTIONAL<e__Phase>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (e__Phase::enum_type)(const e__Phase&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of enumerated type @SocketCANtest.e_Phase from an unbound optional field.");
}
}
e__Phase_template::e__Phase_template(const e__Phase_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
e__Phase_template::~e__Phase_template()
{
clean_up();
}
boolean e__Phase_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
return TRUE;
}
boolean e__Phase_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value != e__Phase::UNBOUND_VALUE;
}
void e__Phase_template::clean_up()
{
if (template_selection == VALUE_LIST || template_selection == COMPLEMENTED_LIST) delete [] value_list.list_value;
template_selection = UNINITIALIZED_TEMPLATE;
}
e__Phase_template& e__Phase_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
e__Phase_template& e__Phase_template::operator=(int other_value)
{
if (!e__Phase::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @SocketCANtest.e_Phase.", other_value);
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = (e__Phase::enum_type)other_value;
return *this;
}
e__Phase_template& e__Phase_template::operator=(e__Phase::enum_type other_value)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value;
return *this;
}
e__Phase_template& e__Phase_template::operator=(const e__Phase& other_value)
{
if (other_value.enum_value == e__Phase::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @SocketCANtest.e_Phase to a template.");
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value.enum_value;
return *this;
}
e__Phase_template& e__Phase_template::operator=(const OPTIONAL<e__Phase>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (e__Phase::enum_type)(const e__Phase&)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 @SocketCANtest.e_Phase.");
}
return *this;
}
e__Phase_template& e__Phase_template::operator=(const e__Phase_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean e__Phase_template::match(e__Phase::enum_type other_value, boolean) const
{
switch (template_selection) {
case SPECIFIC_VALUE:
return single_value == other_value;
case OMIT_VALUE:
return FALSE;
case ANY_VALUE:
case ANY_OR_OMIT:
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
default:
TTCN_error("Matching an uninitialized/unsupported template of enumerated type @SocketCANtest.e_Phase.");
}
return FALSE;
}
boolean e__Phase_template::match(const e__Phase& other_value, boolean) const
{
if (other_value.enum_value == e__Phase::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @SocketCANtest.e_Phase with an unbound value.");
return match(other_value.enum_value);
}
e__Phase::enum_type e__Phase_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 @SocketCANtest.e_Phase.");
return single_value;
}
void e__Phase_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error("Setting an invalid list type for a template of enumerated type @SocketCANtest.e_Phase.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new e__Phase_template[list_length];
}
e__Phase_template& e__Phase_template::list_item(unsigned int list_index)
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Accessing a list element in a non-list template of enumerated type @SocketCANtest.e_Phase.");
if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @SocketCANtest.e_Phase.");
return value_list.list_value[list_index];
}
void e__Phase_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_enum(e__Phase::enum_to_str(single_value), single_value);
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int elem_count = 0; elem_count < value_list.n_values; elem_count++) {
if (elem_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[elem_count].log();
}
TTCN_Logger::log_char(')');
break;
default:
log_generic();
}
log_ifpresent();
}
void e__Phase_template::log_match(const e__Phase& 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 e__Phase_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 @SocketCANtest.e_Phase.");
}
}
void e__Phase_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = (e__Phase::enum_type)text_buf.pull_int().get_val();
if (!e__Phase::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @SocketCANtest.e_Phase.", 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 e__Phase_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 @SocketCANtest.e_Phase.");
}
}
boolean e__Phase_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean e__Phase_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int i=0; i<value_list.n_values; i++)
if (value_list.list_value[i].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
void e__Phase_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: {
e__Phase_template new_temp;
new_temp.set_type(m_p->get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, m_p->get_size());
for (size_t p_i=0; p_i<m_p->get_size(); p_i++) {
new_temp.list_item(p_i).set_param(*m_p->get_elem(p_i));
}
*this = new_temp;
break; }
case Module_Param::MP_Enumerated: {
e__Phase::enum_type enum_val = e__Phase::str_to_enum(m_p->get_enumerated());
if (!e__Phase::is_valid_enum(enum_val)) {
param.error("Invalid enumerated value for type @SocketCANtest.e_Phase.");
}
*this = enum_val;
} break;
default:
param.type_error("enumerated template", "@SocketCANtest.e_Phase");
}
is_ifpresent = param.get_ifpresent();
}
void e__Phase_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 : "@SocketCANtest.e_Phase");
}
SocketCAN__open__raw__result::SocketCAN__open__raw__result()
{
}
SocketCAN__open__raw__result::SocketCAN__open__raw__result(const SocketCAN__Types::SocketCAN__ifr& par_ifr,
const INTEGER& par_socket__id)
: field_ifr(par_ifr),
field_socket__id(par_socket__id)
{
}
SocketCAN__open__raw__result::SocketCAN__open__raw__result(const SocketCAN__open__raw__result& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @SocketCANtest.SocketCAN_open_raw_result.");
if (other_value.ifr().is_bound()) field_ifr = other_value.ifr();
else field_ifr.clean_up();
if (other_value.socket__id().is_bound()) field_socket__id = other_value.socket__id();
else field_socket__id.clean_up();
}
void SocketCAN__open__raw__result::clean_up()
{
field_ifr.clean_up();
field_socket__id.clean_up();
}
const TTCN_Typedescriptor_t* SocketCAN__open__raw__result::get_descriptor() const { return &SocketCAN__open__raw__result_descr_; }
SocketCAN__open__raw__result& SocketCAN__open__raw__result::operator=(const SocketCAN__open__raw__result& other_value)
{
if (this != &other_value) {
if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @SocketCANtest.SocketCAN_open_raw_result.");
if (other_value.ifr().is_bound()) field_ifr = other_value.ifr();
else field_ifr.clean_up();
if (other_value.socket__id().is_bound()) field_socket__id = other_value.socket__id();
else field_socket__id.clean_up();
}
return *this;
}
boolean SocketCAN__open__raw__result::operator==(const SocketCAN__open__raw__result& other_value) const
{
return field_ifr==other_value.field_ifr
&& field_socket__id==other_value.field_socket__id;
}
boolean SocketCAN__open__raw__result::is_bound() const
{
return (field_ifr.is_bound())
|| (field_socket__id.is_bound());
}
boolean SocketCAN__open__raw__result::is_value() const
{
return field_ifr.is_value()
&& field_socket__id.is_value();
}
void SocketCAN__open__raw__result::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ ifr := ");
field_ifr.log();
TTCN_Logger::log_event_str(", socket_id := ");
field_socket__id.log();
TTCN_Logger::log_event_str(" }");
}
void SocketCAN__open__raw__result::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 @SocketCANtest.SocketCAN_open_raw_result 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) ifr().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) socket__id().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(), "ifr")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
ifr().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(), "socket_id")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
socket__id().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 @SocketCANtest.SocketCAN_open_raw_result: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record value", "@SocketCANtest.SocketCAN_open_raw_result");
}
}
void SocketCAN__open__raw__result::set_implicit_omit()
{
if (ifr().is_bound()) ifr().set_implicit_omit();
if (socket__id().is_bound()) socket__id().set_implicit_omit();
}
void SocketCAN__open__raw__result::encode_text(Text_Buf& text_buf) const
{
field_ifr.encode_text(text_buf);
field_socket__id.encode_text(text_buf);
}
void SocketCAN__open__raw__result::decode_text(Text_Buf& text_buf)
{
field_ifr.decode_text(text_buf);
field_socket__id.decode_text(text_buf);
}
struct SocketCAN__open__raw__result_template::single_value_struct {
SocketCAN__Types::SocketCAN__ifr_template field_ifr;
INTEGER_template field_socket__id;
};
void SocketCAN__open__raw__result_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_ifr = ANY_VALUE;
single_value->field_socket__id = ANY_VALUE;
}
}
}
void SocketCAN__open__raw__result_template::copy_value(const SocketCAN__open__raw__result& other_value)
{
single_value = new single_value_struct;
if (other_value.ifr().is_bound()) {
single_value->field_ifr = other_value.ifr();
} else {
single_value->field_ifr.clean_up();
}
if (other_value.socket__id().is_bound()) {
single_value->field_socket__id = other_value.socket__id();
} else {
single_value->field_socket__id.clean_up();
}
set_selection(SPECIFIC_VALUE);
}
void SocketCAN__open__raw__result_template::copy_template(const SocketCAN__open__raw__result_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.ifr().get_selection()) {
single_value->field_ifr = other_value.ifr();
} else {
single_value->field_ifr.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.socket__id().get_selection()) {
single_value->field_socket__id = other_value.socket__id();
} else {
single_value->field_socket__id.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new SocketCAN__open__raw__result_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @SocketCANtest.SocketCAN_open_raw_result.");
break;
}
set_selection(other_value);
}
SocketCAN__open__raw__result_template::SocketCAN__open__raw__result_template()
{
}
SocketCAN__open__raw__result_template::SocketCAN__open__raw__result_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
SocketCAN__open__raw__result_template::SocketCAN__open__raw__result_template(const SocketCAN__open__raw__result& other_value)
{
copy_value(other_value);
}
SocketCAN__open__raw__result_template::SocketCAN__open__raw__result_template(const OPTIONAL<SocketCAN__open__raw__result>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const SocketCAN__open__raw__result&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @SocketCANtest.SocketCAN_open_raw_result from an unbound optional field.");
}
}
SocketCAN__open__raw__result_template::SocketCAN__open__raw__result_template(const SocketCAN__open__raw__result_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
SocketCAN__open__raw__result_template::~SocketCAN__open__raw__result_template()
{
clean_up();
}
SocketCAN__open__raw__result_template& SocketCAN__open__raw__result_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
SocketCAN__open__raw__result_template& SocketCAN__open__raw__result_template::operator=(const SocketCAN__open__raw__result& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
SocketCAN__open__raw__result_template& SocketCAN__open__raw__result_template::operator=(const OPTIONAL<SocketCAN__open__raw__result>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const SocketCAN__open__raw__result&)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 @SocketCANtest.SocketCAN_open_raw_result.");
}
return *this;
}
SocketCAN__open__raw__result_template& SocketCAN__open__raw__result_template::operator=(const SocketCAN__open__raw__result_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean SocketCAN__open__raw__result_template::match(const SocketCAN__open__raw__result& 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.ifr().is_bound()) return FALSE;
if(!single_value->field_ifr.match(other_value.ifr(), legacy))return FALSE;
if(!other_value.socket__id().is_bound()) return FALSE;
if(!single_value->field_socket__id.match(other_value.socket__id(), legacy))return FALSE;
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
default:
TTCN_error("Matching an uninitialized/unsupported template of type @SocketCANtest.SocketCAN_open_raw_result.");
}
return FALSE;
}
boolean SocketCAN__open__raw__result_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_ifr.is_bound()
||single_value->field_socket__id.is_bound()
;
}
boolean SocketCAN__open__raw__result_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_ifr.is_value()
&&single_value->field_socket__id.is_value();
}
void SocketCAN__open__raw__result_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
SocketCAN__open__raw__result SocketCAN__open__raw__result_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 @SocketCANtest.SocketCAN_open_raw_result.");
SocketCAN__open__raw__result ret_val;
if (single_value->field_ifr.is_bound()) {
ret_val.ifr() = single_value->field_ifr.valueof();
}
if (single_value->field_socket__id.is_bound()) {
ret_val.socket__id() = single_value->field_socket__id.valueof();
}
return ret_val;
}
void SocketCAN__open__raw__result_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST)
TTCN_error("Setting an invalid list for a template of type @SocketCANtest.SocketCAN_open_raw_result.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new SocketCAN__open__raw__result_template[list_length];
}
SocketCAN__open__raw__result_template& SocketCAN__open__raw__result_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST)
TTCN_error("Accessing a list element of a non-list template of type @SocketCANtest.SocketCAN_open_raw_result.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @SocketCANtest.SocketCAN_open_raw_result.");
return value_list.list_value[list_index];
}
SocketCAN__Types::SocketCAN__ifr_template& SocketCAN__open__raw__result_template::ifr()
{
set_specific();
return single_value->field_ifr;
}
const SocketCAN__Types::SocketCAN__ifr_template& SocketCAN__open__raw__result_template::ifr() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field ifr of a non-specific template of type @SocketCANtest.SocketCAN_open_raw_result.");
return single_value->field_ifr;
}
INTEGER_template& SocketCAN__open__raw__result_template::socket__id()
{
set_specific();
return single_value->field_socket__id;
}
const INTEGER_template& SocketCAN__open__raw__result_template::socket__id() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field socket_id of a non-specific template of type @SocketCANtest.SocketCAN_open_raw_result.");
return single_value->field_socket__id;
}
int SocketCAN__open__raw__result_template::size_of() const
{
if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @SocketCANtest.SocketCAN_open_raw_result 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 @SocketCANtest.SocketCAN_open_raw_result 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 @SocketCANtest.SocketCAN_open_raw_result containing a value list with different sizes.");
}
return item_size;
}
case OMIT_VALUE:
TTCN_error("Performing sizeof() operation on a template of type @SocketCANtest.SocketCAN_open_raw_result containing omit value.");
case ANY_VALUE:
case ANY_OR_OMIT:
TTCN_error("Performing sizeof() operation on a template of type @SocketCANtest.SocketCAN_open_raw_result containing */? value.");
case COMPLEMENTED_LIST:
TTCN_error("Performing sizeof() operation on a template of type @SocketCANtest.SocketCAN_open_raw_result containing complemented list.");
default:
TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @SocketCANtest.SocketCAN_open_raw_result.");
}
return 0;
}
void SocketCAN__open__raw__result_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ ifr := ");
single_value->field_ifr.log();
TTCN_Logger::log_event_str(", socket_id := ");
single_value->field_socket__id.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) {
if (list_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[list_count].log();
}
TTCN_Logger::log_char(')');
break;
default:
log_generic();
}
log_ifpresent();
}
void SocketCAN__open__raw__result_template::log_match(const SocketCAN__open__raw__result& 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_ifr.match(match_value.ifr(), legacy)){
TTCN_Logger::log_logmatch_info(".ifr");
single_value->field_ifr.log_match(match_value.ifr(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_socket__id.match(match_value.socket__id(), legacy)){
TTCN_Logger::log_logmatch_info(".socket_id");
single_value->field_socket__id.log_match(match_value.socket__id(), 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("{ ifr := ");
single_value->field_ifr.log_match(match_value.ifr(), legacy);
TTCN_Logger::log_event_str(", socket_id := ");
single_value->field_socket__id.log_match(match_value.socket__id(), 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 SocketCAN__open__raw__result_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_ifr.encode_text(text_buf);
single_value->field_socket__id.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 @SocketCANtest.SocketCAN_open_raw_result.");
}
}
void SocketCAN__open__raw__result_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_ifr.decode_text(text_buf);
single_value->field_socket__id.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 SocketCAN__open__raw__result_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 @SocketCANtest.SocketCAN_open_raw_result.");
}
}
void SocketCAN__open__raw__result_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: {
SocketCAN__open__raw__result_template new_temp;
new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, param.get_size());
for (size_t p_i=0; p_i<param.get_size(); p_i++) {
new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
}
*this = new_temp;
break; }
case Module_Param::MP_Value_List:
if (2<param.get_size()) {
param.error("record template of type @SocketCANtest.SocketCAN_open_raw_result 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) ifr().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) socket__id().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(), "ifr")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
ifr().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(), "socket_id")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
socket__id().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 @SocketCANtest.SocketCAN_open_raw_result: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record template", "@SocketCANtest.SocketCAN_open_raw_result");
}
is_ifpresent = param.get_ifpresent();
}
void SocketCAN__open__raw__result_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_ifr.check_restriction(t_res, t_name ? t_name : "@SocketCANtest.SocketCAN_open_raw_result");
single_value->field_socket__id.check_restriction(t_res, t_name ? t_name : "@SocketCANtest.SocketCAN_open_raw_result");
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 : "@SocketCANtest.SocketCAN_open_raw_result");
}
boolean SocketCAN__open__raw__result_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean SocketCAN__open__raw__result_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
BCM__cmd::BCM__cmd()
{
}
BCM__cmd::BCM__cmd(const e__Phase& par_phase,
const Bcm::SocketCAN__bcm__frame& par_bcm__frame)
: field_phase(par_phase),
field_bcm__frame(par_bcm__frame)
{
}
BCM__cmd::BCM__cmd(const BCM__cmd& other_value)
{
if(!other_value.is_bound()) TTCN_error("Copying an unbound value of type @SocketCANtest.BCM_cmd.");
if (other_value.phase().is_bound()) field_phase = other_value.phase();
else field_phase.clean_up();
if (other_value.bcm__frame().is_bound()) field_bcm__frame = other_value.bcm__frame();
else field_bcm__frame.clean_up();
}
void BCM__cmd::clean_up()
{
field_phase.clean_up();
field_bcm__frame.clean_up();
}
const TTCN_Typedescriptor_t* BCM__cmd::get_descriptor() const { return &BCM__cmd_descr_; }
BCM__cmd& BCM__cmd::operator=(const BCM__cmd& other_value)
{
if (this != &other_value) {
if(!other_value.is_bound()) TTCN_error("Assignment of an unbound value of type @SocketCANtest.BCM_cmd.");
if (other_value.phase().is_bound()) field_phase = other_value.phase();
else field_phase.clean_up();
if (other_value.bcm__frame().is_bound()) field_bcm__frame = other_value.bcm__frame();
else field_bcm__frame.clean_up();
}
return *this;
}
boolean BCM__cmd::operator==(const BCM__cmd& other_value) const
{
return field_phase==other_value.field_phase
&& field_bcm__frame==other_value.field_bcm__frame;
}
boolean BCM__cmd::is_bound() const
{
return (field_phase.is_bound())
|| (field_bcm__frame.is_bound());
}
boolean BCM__cmd::is_value() const
{
return field_phase.is_value()
&& field_bcm__frame.is_value();
}
void BCM__cmd::log() const
{
if (!is_bound()) {
TTCN_Logger::log_event_unbound();
return;
}
TTCN_Logger::log_event_str("{ phase := ");
field_phase.log();
TTCN_Logger::log_event_str(", bcm_frame := ");
field_bcm__frame.log();
TTCN_Logger::log_event_str(" }");
}
void BCM__cmd::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 @SocketCANtest.BCM_cmd 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) phase().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) bcm__frame().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(), "phase")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
phase().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(), "bcm_frame")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
bcm__frame().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 @SocketCANtest.BCM_cmd: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record value", "@SocketCANtest.BCM_cmd");
}
}
void BCM__cmd::set_implicit_omit()
{
if (phase().is_bound()) phase().set_implicit_omit();
if (bcm__frame().is_bound()) bcm__frame().set_implicit_omit();
}
void BCM__cmd::encode_text(Text_Buf& text_buf) const
{
field_phase.encode_text(text_buf);
field_bcm__frame.encode_text(text_buf);
}
void BCM__cmd::decode_text(Text_Buf& text_buf)
{
field_phase.decode_text(text_buf);
field_bcm__frame.decode_text(text_buf);
}
struct BCM__cmd_template::single_value_struct {
e__Phase_template field_phase;
Bcm::SocketCAN__bcm__frame_template field_bcm__frame;
};
void BCM__cmd_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_phase = ANY_VALUE;
single_value->field_bcm__frame = ANY_VALUE;
}
}
}
void BCM__cmd_template::copy_value(const BCM__cmd& other_value)
{
single_value = new single_value_struct;
if (other_value.phase().is_bound()) {
single_value->field_phase = other_value.phase();
} else {
single_value->field_phase.clean_up();
}
if (other_value.bcm__frame().is_bound()) {
single_value->field_bcm__frame = other_value.bcm__frame();
} else {
single_value->field_bcm__frame.clean_up();
}
set_selection(SPECIFIC_VALUE);
}
void BCM__cmd_template::copy_template(const BCM__cmd_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value = new single_value_struct;
if (UNINITIALIZED_TEMPLATE != other_value.phase().get_selection()) {
single_value->field_phase = other_value.phase();
} else {
single_value->field_phase.clean_up();
}
if (UNINITIALIZED_TEMPLATE != other_value.bcm__frame().get_selection()) {
single_value->field_bcm__frame = other_value.bcm__frame();
} else {
single_value->field_bcm__frame.clean_up();
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new BCM__cmd_template[value_list.n_values];
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
value_list.list_value[list_count].copy_template(other_value.value_list.list_value[list_count]);
break;
default:
TTCN_error("Copying an uninitialized/unsupported template of type @SocketCANtest.BCM_cmd.");
break;
}
set_selection(other_value);
}
BCM__cmd_template::BCM__cmd_template()
{
}
BCM__cmd_template::BCM__cmd_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
BCM__cmd_template::BCM__cmd_template(const BCM__cmd& other_value)
{
copy_value(other_value);
}
BCM__cmd_template::BCM__cmd_template(const OPTIONAL<BCM__cmd>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const BCM__cmd&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of type @SocketCANtest.BCM_cmd from an unbound optional field.");
}
}
BCM__cmd_template::BCM__cmd_template(const BCM__cmd_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
BCM__cmd_template::~BCM__cmd_template()
{
clean_up();
}
BCM__cmd_template& BCM__cmd_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
BCM__cmd_template& BCM__cmd_template::operator=(const BCM__cmd& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
BCM__cmd_template& BCM__cmd_template::operator=(const OPTIONAL<BCM__cmd>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const BCM__cmd&)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 @SocketCANtest.BCM_cmd.");
}
return *this;
}
BCM__cmd_template& BCM__cmd_template::operator=(const BCM__cmd_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean BCM__cmd_template::match(const BCM__cmd& 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.phase().is_bound()) return FALSE;
if(!single_value->field_phase.match(other_value.phase(), legacy))return FALSE;
if(!other_value.bcm__frame().is_bound()) return FALSE;
if(!single_value->field_bcm__frame.match(other_value.bcm__frame(), legacy))return FALSE;
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++)
if (value_list.list_value[list_count].match(other_value, legacy)) return template_selection == VALUE_LIST;
return template_selection == COMPLEMENTED_LIST;
default:
TTCN_error("Matching an uninitialized/unsupported template of type @SocketCANtest.BCM_cmd.");
}
return FALSE;
}
boolean BCM__cmd_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
if (template_selection != SPECIFIC_VALUE) return TRUE;
return single_value->field_phase.is_bound()
||single_value->field_bcm__frame.is_bound()
;
}
boolean BCM__cmd_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value->field_phase.is_value()
&&single_value->field_bcm__frame.is_value();
}
void BCM__cmd_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
delete single_value;
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
BCM__cmd BCM__cmd_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 @SocketCANtest.BCM_cmd.");
BCM__cmd ret_val;
if (single_value->field_phase.is_bound()) {
ret_val.phase() = single_value->field_phase.valueof();
}
if (single_value->field_bcm__frame.is_bound()) {
ret_val.bcm__frame() = single_value->field_bcm__frame.valueof();
}
return ret_val;
}
void BCM__cmd_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST)
TTCN_error("Setting an invalid list for a template of type @SocketCANtest.BCM_cmd.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new BCM__cmd_template[list_length];
}
BCM__cmd_template& BCM__cmd_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST)
TTCN_error("Accessing a list element of a non-list template of type @SocketCANtest.BCM_cmd.");
if (list_index >= value_list.n_values)
TTCN_error("Index overflow in a value list template of type @SocketCANtest.BCM_cmd.");
return value_list.list_value[list_index];
}
e__Phase_template& BCM__cmd_template::phase()
{
set_specific();
return single_value->field_phase;
}
const e__Phase_template& BCM__cmd_template::phase() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field phase of a non-specific template of type @SocketCANtest.BCM_cmd.");
return single_value->field_phase;
}
Bcm::SocketCAN__bcm__frame_template& BCM__cmd_template::bcm__frame()
{
set_specific();
return single_value->field_bcm__frame;
}
const Bcm::SocketCAN__bcm__frame_template& BCM__cmd_template::bcm__frame() const
{
if (template_selection != SPECIFIC_VALUE)
TTCN_error("Accessing field bcm_frame of a non-specific template of type @SocketCANtest.BCM_cmd.");
return single_value->field_bcm__frame;
}
int BCM__cmd_template::size_of() const
{
if (is_ifpresent) TTCN_error("Performing sizeof() operation on a template of type @SocketCANtest.BCM_cmd 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 @SocketCANtest.BCM_cmd 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 @SocketCANtest.BCM_cmd containing a value list with different sizes.");
}
return item_size;
}
case OMIT_VALUE:
TTCN_error("Performing sizeof() operation on a template of type @SocketCANtest.BCM_cmd containing omit value.");
case ANY_VALUE:
case ANY_OR_OMIT:
TTCN_error("Performing sizeof() operation on a template of type @SocketCANtest.BCM_cmd containing */? value.");
case COMPLEMENTED_LIST:
TTCN_error("Performing sizeof() operation on a template of type @SocketCANtest.BCM_cmd containing complemented list.");
default:
TTCN_error("Performing sizeof() operation on an uninitialized/unsupported template of type @SocketCANtest.BCM_cmd.");
}
return 0;
}
void BCM__cmd_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_str("{ phase := ");
single_value->field_phase.log();
TTCN_Logger::log_event_str(", bcm_frame := ");
single_value->field_bcm__frame.log();
TTCN_Logger::log_event_str(" }");
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) {
if (list_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[list_count].log();
}
TTCN_Logger::log_char(')');
break;
default:
log_generic();
}
log_ifpresent();
}
void BCM__cmd_template::log_match(const BCM__cmd& 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_phase.match(match_value.phase(), legacy)){
TTCN_Logger::log_logmatch_info(".phase");
single_value->field_phase.log_match(match_value.phase(), legacy);
TTCN_Logger::set_logmatch_buffer_len(previous_size);
}
if(!single_value->field_bcm__frame.match(match_value.bcm__frame(), legacy)){
TTCN_Logger::log_logmatch_info(".bcm_frame");
single_value->field_bcm__frame.log_match(match_value.bcm__frame(), 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("{ phase := ");
single_value->field_phase.log_match(match_value.phase(), legacy);
TTCN_Logger::log_event_str(", bcm_frame := ");
single_value->field_bcm__frame.log_match(match_value.bcm__frame(), 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 BCM__cmd_template::encode_text(Text_Buf& text_buf) const
{
encode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value->field_phase.encode_text(text_buf);
single_value->field_bcm__frame.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 @SocketCANtest.BCM_cmd.");
}
}
void BCM__cmd_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_phase.decode_text(text_buf);
single_value->field_bcm__frame.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 BCM__cmd_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 @SocketCANtest.BCM_cmd.");
}
}
void BCM__cmd_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: {
BCM__cmd_template new_temp;
new_temp.set_type(param.get_type()==Module_Param::MP_List_Template ? VALUE_LIST : COMPLEMENTED_LIST, param.get_size());
for (size_t p_i=0; p_i<param.get_size(); p_i++) {
new_temp.list_item(p_i).set_param(*param.get_elem(p_i));
}
*this = new_temp;
break; }
case Module_Param::MP_Value_List:
if (2<param.get_size()) {
param.error("record template of type @SocketCANtest.BCM_cmd 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) phase().set_param(*param.get_elem(0));
if (param.get_size()>1 && param.get_elem(1)->get_type()!=Module_Param::MP_NotUsed) bcm__frame().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(), "phase")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
phase().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(), "bcm_frame")) {
if (curr_param->get_type()!=Module_Param::MP_NotUsed) {
bcm__frame().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 @SocketCANtest.BCM_cmd: %s", curr_param->get_id()->get_name());
break;
}
} break;
default:
param.type_error("record template", "@SocketCANtest.BCM_cmd");
}
is_ifpresent = param.get_ifpresent();
}
void BCM__cmd_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_phase.check_restriction(t_res, t_name ? t_name : "@SocketCANtest.BCM_cmd");
single_value->field_bcm__frame.check_restriction(t_res, t_name ? t_name : "@SocketCANtest.BCM_cmd");
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 : "@SocketCANtest.BCM_cmd");
}
boolean BCM__cmd_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean BCM__cmd_template::match_omit(boolean legacy) const
{
if (is_ifpresent) return TRUE;
switch (template_selection) {
case OMIT_VALUE:
case ANY_OR_OMIT:
return TRUE;
case VALUE_LIST:
case COMPLEMENTED_LIST:
if (legacy) {
for (unsigned int l_idx=0; l_idx<value_list.n_values; l_idx++)
if (value_list.list_value[l_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
const BCM__cmd BCM__cmds::UNBOUND_ELEM;
BCM__cmds::BCM__cmds()
{
val_ptr = NULL;
}
BCM__cmds::BCM__cmds(null_type)
{
val_ptr = new recordof_setof_struct;
val_ptr->ref_count = 1;
val_ptr->n_elements = 0;
val_ptr->value_elements = NULL;
}
BCM__cmds::BCM__cmds(const BCM__cmds& other_value)
{
if (!other_value.is_bound()) TTCN_error("Copying an unbound value of type @SocketCANtest.BCM_cmds.");
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
BCM__cmds::~BCM__cmds()
{
clean_up();
if (val_ptr != NULL) val_ptr = NULL;
}
void BCM__cmds::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.");
}
}
BCM__cmds& BCM__cmds::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;
}
BCM__cmds& BCM__cmds::operator=(const BCM__cmds& other_value)
{
if (other_value.val_ptr == NULL) TTCN_error("Assigning an unbound value of type @SocketCANtest.BCM_cmds.");
if (this != &other_value) {
clean_up();
val_ptr = other_value.val_ptr;
val_ptr->ref_count++;
}
return *this;
}
boolean BCM__cmds::operator==(null_type) const
{
if (val_ptr == NULL)
TTCN_error("The left operand of comparison is an unbound value of type @SocketCANtest.BCM_cmds.");
return val_ptr->n_elements == 0 ;
}
boolean BCM__cmds::operator==(const BCM__cmds& other_value) const
{
if (val_ptr == NULL) TTCN_error("The left operand of comparison is an unbound value of type @SocketCANtest.BCM_cmds.");
if (other_value.val_ptr == NULL) TTCN_error("The right operand of comparison is an unbound value of type @SocketCANtest.BCM_cmds.");
if (val_ptr == other_value.val_ptr) return TRUE;
if (val_ptr->n_elements != (other_value.val_ptr)->n_elements)
return FALSE;
for (int elem_count = 0; elem_count < val_ptr->n_elements; elem_count++){
if (val_ptr->value_elements[elem_count] != NULL){
if ((other_value.val_ptr)->value_elements[elem_count] != NULL){
if (*val_ptr->value_elements[elem_count] != *(other_value.val_ptr)->value_elements[elem_count]) return FALSE;
} else return FALSE;
} else {
if ((other_value.val_ptr)->value_elements[elem_count] != NULL) return FALSE;
}
}
return TRUE;
}
BCM__cmd& BCM__cmds::operator[](int index_value)
{
if (index_value < 0) TTCN_error("Accessing an element of type @SocketCANtest.BCM_cmds 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 = (BCM__cmd**)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 BCM__cmd(*(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 BCM__cmd;
}
return *val_ptr->value_elements[index_value];
}