blob: f5f04d4771d0c0b07fefd760f05b399d6a2d8d9e [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 "Isobustest.hh"
namespace Isobustest {
/* 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);
static void module_control_part();
/* Literal string constants */
static const unsigned char bs_1_bits[] = { 0 },
bs_11_bits[] = { 0 },
bs_5_bits[] = { 64 },
bs_6_bits[] = { 192 },
bs_12_bits[] = { 32 },
bs_4_bits[] = { 8 },
bs_0_bits[] = { 24 },
bs_7_bits[] = { 20 },
bs_3_bits[] = { 6 },
bs_2_bits[] = { 1 },
bs_9_bits[] = { 1, 0 },
bs_10_bits[] = { 133, 80, 0 },
bs_8_bits[] = { 3 };
static const BITSTRING bs_1(1, bs_1_bits),
bs_11(6, bs_11_bits),
bs_5(7, bs_5_bits),
bs_6(8, bs_6_bits),
bs_12(6, bs_12_bits),
bs_4(4, bs_4_bits),
bs_0(6, bs_0_bits),
bs_7(5, bs_7_bits),
bs_3(3, bs_3_bits),
bs_2(1, bs_2_bits),
bs_9(11, bs_9_bits),
bs_10(21, bs_10_bits),
bs_8(3, bs_8_bits);
static const unsigned char os_7_octets[] = { 0 },
os_2_octets[] = { 0, 255, 0 },
os_17_octets[] = { 1 },
os_18_octets[] = { 2 },
os_19_octets[] = { 3 },
os_3_octets[] = { 3, 255, 255 },
os_20_octets[] = { 4 },
os_21_octets[] = { 5 },
os_22_octets[] = { 6 },
os_23_octets[] = { 7 },
os_14_octets[] = { 10 },
os_15_octets[] = { 11 },
os_16_octets[] = { 12 },
os_1_octets[] = { 17 },
os_28_octets[] = { 24, 236, 248, 248, 16, 22, 0, 4, 255, 235, 254, 0 },
os_10_octets[] = { 34, 51 },
os_11_octets[] = { 68, 85 },
os_12_octets[] = { 102 },
os_26_octets[] = { 108, 101, 32, 115, 101, 114, 118 },
os_27_octets[] = { 152, 234, 255, 254, 0, 238, 0 },
os_9_octets[] = { 170 },
os_8_octets[] = { 192 },
os_6_octets[] = { 230 },
os_4_octets[] = { 233 },
os_25_octets[] = { 248 },
os_5_octets[] = { 253 },
os_24_octets[] = { 254 },
os_13_octets[] = { 255 };
static const OCTETSTRING os_0(0, NULL),
os_7(1, os_7_octets),
os_2(3, os_2_octets),
os_17(1, os_17_octets),
os_18(1, os_18_octets),
os_19(1, os_19_octets),
os_3(3, os_3_octets),
os_20(1, os_20_octets),
os_21(1, os_21_octets),
os_22(1, os_22_octets),
os_23(1, os_23_octets),
os_14(1, os_14_octets),
os_15(1, os_15_octets),
os_16(1, os_16_octets),
os_1(1, os_1_octets),
os_28(12, os_28_octets),
os_10(2, os_10_octets),
os_11(2, os_11_octets),
os_12(1, os_12_octets),
os_26(7, os_26_octets),
os_27(7, os_27_octets),
os_9(1, os_9_octets),
os_8(1, os_8_octets),
os_6(1, os_6_octets),
os_4(1, os_4_octets),
os_25(1, os_25_octets),
os_5(1, os_5_octets),
os_24(1, os_24_octets),
os_13(1, os_13_octets);
static const unsigned char module_checksum[] = { 0x05, 0x4a, 0xb3, 0x61, 0xd4, 0x66, 0xd1, 0x06, 0xe1, 0x15, 0x44, 0x5f, 0x26, 0xc8, 0x14, 0x9d };
/* Global variable definitions */
// No XER for CAN__ID
const TTCN_Typedescriptor_t CAN__ID_descr_ = { "@Isobustest.CAN_ID", NULL, NULL, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t CAN__ID_can__eff_xer_ = { {"can_eff>\n", "can_eff>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int CAN__ID_can__eff_oer_ext_arr_[0] = {};
const int CAN__ID_can__eff_oer_p_[0] = {};
const TTCN_OERdescriptor_t CAN__ID_can__eff_oer_ = { -1, TRUE, 4, FALSE, 0, 0, CAN__ID_can__eff_oer_ext_arr_, 0, CAN__ID_can__eff_oer_p_};
const TTCN_Typedescriptor_t CAN__ID_can__eff_descr_ = { "@Isobustest.CAN_ID.can_eff", &OCTETSTRING_ber_, &General__Types::OCT4_raw_, &OCTETSTRING_text_, &CAN__ID_can__eff_xer_, &OCTETSTRING_json_, &CAN__ID_can__eff_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t CAN__ID_can__sff_xer_ = { {"can_sff>\n", "can_sff>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int CAN__ID_can__sff_oer_ext_arr_[0] = {};
const int CAN__ID_can__sff_oer_p_[0] = {};
const TTCN_OERdescriptor_t CAN__ID_can__sff_oer_ = { -1, TRUE, 2, FALSE, 0, 0, CAN__ID_can__sff_oer_ext_arr_, 0, CAN__ID_can__sff_oer_p_};
const TTCN_Typedescriptor_t CAN__ID_can__sff_descr_ = { "@Isobustest.CAN_ID.can_sff", &OCTETSTRING_ber_, &General__Types::OCT2_raw_, &OCTETSTRING_text_, &CAN__ID_can__sff_xer_, &OCTETSTRING_json_, &CAN__ID_can__sff_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t RTR_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for RTR
const TTCN_Typedescriptor_t RTR_descr_ = { "@Isobustest.RTR", NULL, &RTR_raw_, NULL, NULL, &ENUMERATED_json_, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t BIT29_raw_ = {29,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
const XERdescriptor_t BIT29_xer_ = { {"BIT29>\n", "BIT29>\n"}, {7, 7}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t BIT29_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t BIT29_descr_ = { "@Isobustest.BIT29", &BITSTRING_ber_, &BIT29_raw_, NULL, &BIT29_xer_, &BITSTRING_json_, &BIT29_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t CAN__ID_can__err_xer_ = { {"can_err>\n", "can_err>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t CAN__ID_can__err_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t CAN__ID_can__err_descr_ = { "@Isobustest.CAN_ID.can_err", &BITSTRING_ber_, &BIT29_raw_, NULL, &CAN__ID_can__err_xer_, &BITSTRING_json_, &CAN__ID_can__err_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t Can__IDs_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for Can__IDs
const TTCN_Typedescriptor_t Can__IDs_descr_ = { "@Isobustest.Can_IDs", NULL, &Can__IDs_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t Can__IDs_can__eff_xer_ = { {"can_eff>\n", "can_eff>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Can__IDs_can__eff_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Can__IDs_can__eff_descr_ = { "@Isobustest.Can_IDs.can_eff", &BITSTRING_ber_, &BIT29_raw_, NULL, &Can__IDs_can__eff_xer_, &BITSTRING_json_, &Can__IDs_can__eff_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t Can__IDs_can__sff_xer_ = { {"can_sff>\n", "can_sff>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Can__IDs_can__sff_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Can__IDs_can__sff_descr_ = { "@Isobustest.Can_IDs.can_sff", &BITSTRING_ber_, &General__Types::BIT11_raw_, NULL, &Can__IDs_can__sff_xer_, &BITSTRING_json_, &Can__IDs_can__sff_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t Can__IDs_can__err_xer_ = { {"can_err>\n", "can_err>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Can__IDs_can__err_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Can__IDs_can__err_descr_ = { "@Isobustest.Can_IDs.can_err", &BITSTRING_ber_, &BIT29_raw_, NULL, &Can__IDs_can__err_xer_, &BITSTRING_json_, &Can__IDs_can__err_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t Can__IDwithType_cantype_xer_ = { {"cantype>\n", "cantype>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const TTCN_OERdescriptor_t Can__IDwithType_cantype_oer_ = { -1, FALSE, -1, FALSE, 0, 0, NULL, 0, NULL };
const TTCN_Typedescriptor_t Can__IDwithType_cantype_descr_ = { "@Isobustest.Can_IDwithType.cantype", &INTEGER_ber_, &General__Types::INT1_raw_, &INTEGER_text_, &Can__IDwithType_cantype_xer_, &INTEGER_json_, &Can__IDwithType_cantype_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t Can__IDwithType_can__ids_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for Can__IDwithType_can__ids
const TTCN_Typedescriptor_t Can__IDwithType_can__ids_descr_ = { "@Isobustest.Can_IDwithType.can_ids", NULL, &Can__IDwithType_can__ids_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_RAWdescriptor_t Can__IDwithType_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
// No XER for Can__IDwithType
const TTCN_Typedescriptor_t Can__IDwithType_descr_ = { "@Isobustest.Can_IDwithType", NULL, &Can__IDwithType_raw_, NULL, NULL, NULL, NULL, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& MTC__CT_descr_ = COMPONENT_descr_;
const TTCN_Typedescriptor_t& PTC__isobus__CT_descr_ = COMPONENT_descr_;
SocketCAN__PortType::SocketCAN__PT PTC__isobus__CT_component_pt__socketCAN("pt_socketCAN");
Isobus__PT PTC__isobus__CT_component_pt__isobus("pt_isobus");
TIMER PTC__isobus__CT_component_T0("T0", 2.0e-1);
static INTEGER const_MAX__CONNECTIONS;
const INTEGER& MAX__CONNECTIONS = const_MAX__CONNECTIONS;
// No XER for OpenConnections
const TTCN_Typedescriptor_t OpenConnections_descr_ = { "@Isobustest.OpenConnections", NULL, NULL, NULL, NULL, NULL, NULL, &COMPONENT_descr_, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& PTC2__CT_descr_ = COMPONENT_descr_;
// No XER for OpenConnectionsFlags
const TTCN_Typedescriptor_t OpenConnectionsFlags_descr_ = { "@Isobustest.OpenConnectionsFlags", NULL, NULL, NULL, NULL, NULL, NULL, &BOOLEAN_descr_, TTCN_Typedescriptor_t::DONTCARE };
const XERdescriptor_t OpenConnectionsFlags_0_xer_ = { {"BOOLEAN>\n", "BOOLEAN>\n"}, {9, 9}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int OpenConnectionsFlags_0_oer_ext_arr_[0] = {};
const int OpenConnectionsFlags_0_oer_p_[0] = {};
const TTCN_OERdescriptor_t OpenConnectionsFlags_0_oer_ = { -1, TRUE, -1, FALSE, 0, 0, OpenConnectionsFlags_0_oer_ext_arr_, 0, OpenConnectionsFlags_0_oer_p_};
const TTCN_Typedescriptor_t OpenConnectionsFlags_0_descr_ = { "@Isobustest.OpenConnectionsFlags.BOOLEAN", &BOOLEAN_ber_, &BOOLEAN_raw_, &BOOLEAN_text_, &OpenConnectionsFlags_0_xer_, &BOOLEAN_json_, &OpenConnectionsFlags_0_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
const TTCN_Typedescriptor_t& PTC1__CT_descr_ = COMPONENT_descr_;
Isobus__PT PTC1__CT_component_pt__isobus("pt_isobus");
OpenConnections PTC1__CT_component_openConnections;
OpenConnectionsFlags PTC1__CT_component_openConnectionsFlags;
TIMER PTC1__CT_component_T1("T1", 2.0e-1);
Isobus__PT PTC2__CT_component_pt__isobus("pt_isobus");
OCTETSTRING PTC2__CT_component_receivedUnacknowledgedData;
INTEGER PTC2__CT_component_msgSizeInBytes;
INTEGER PTC2__CT_component_receivedUnacknowledgedMsgSizeInBytes;
INTEGER PTC2__CT_component_nextExpectedPacketNumber;
INTEGER PTC2__CT_component_pgnOfMultiPacketMessage;
const XERdescriptor_t _T_PTC2__CT_component_ps_xer_ = { {"OCT1>\n", "OCT1>\n"}, {6, 6}, 0 |FORM_UNQUALIFIED, WHITESPACE_PRESERVE, NULL, &module_object, -1, 0, NULL, NULL, -1, XSD_NONE };
const int _T_PTC2__CT_component_ps_oer_ext_arr_[0] = {};
const int _T_PTC2__CT_component_ps_oer_p_[0] = {};
const TTCN_OERdescriptor_t _T_PTC2__CT_component_ps_oer_ = { -1, TRUE, 1, FALSE, 0, 0, _T_PTC2__CT_component_ps_oer_ext_arr_, 0, _T_PTC2__CT_component_ps_oer_p_};
const TTCN_Typedescriptor_t _T_PTC2__CT_component_ps_descr_ = { "@Isobustest.PTC2_CT.ps.<type>", &OCTETSTRING_ber_, &General__Types::OCT1_raw_, &OCTETSTRING_text_, &_T_PTC2__CT_component_ps_xer_, &OCTETSTRING_json_, &_T_PTC2__CT_component_ps_oer_, NULL, TTCN_Typedescriptor_t::DONTCARE };
OCTETSTRING PTC2__CT_component_ps;
OCTETSTRING PTC2__CT_component_sa;
OCTETSTRING PTC2__CT_component_tp__dt__can__id;
TIMER PTC2__CT_component_T2("T2", 2.0e-1);
// No XER for PTCSet
const TTCN_Typedescriptor_t PTCSet_descr_ = { "@Isobustest.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");
SocketCANtest::e__Phase PTC_component_v__phase;
TTCN_Module module_object("Isobustest", __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, module_control_part);
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 */
void CAN__ID::copy_value(const CAN__ID& other_value)
{
switch (other_value.union_selection) {
case ALT_can__eff:
field_can__eff = new OCTETSTRING(*other_value.field_can__eff);
break;
case ALT_can__sff:
field_can__sff = new OCTETSTRING(*other_value.field_can__sff);
break;
case ALT_can__rtr:
field_can__rtr = new RTR(*other_value.field_can__rtr);
break;
case ALT_can__err:
field_can__err = new BITSTRING(*other_value.field_can__err);
break;
default:
TTCN_error("Assignment of an unbound union value of type @Isobustest.CAN_ID.");
}
union_selection = other_value.union_selection;
}
CAN__ID::CAN__ID()
{
union_selection = UNBOUND_VALUE;
}
CAN__ID::CAN__ID(const CAN__ID& other_value)
: Base_Type(){
copy_value(other_value);
}
CAN__ID::~CAN__ID()
{
clean_up();
}
CAN__ID& CAN__ID::operator=(const CAN__ID& other_value)
{
if (this != &other_value) {
clean_up();
copy_value(other_value);
}
return *this;
}
boolean CAN__ID::operator==(const CAN__ID& other_value) const
{
if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type @Isobustest.CAN_ID.");
if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type @Isobustest.CAN_ID.");
if (union_selection != other_value.union_selection) return FALSE;
switch (union_selection) {
case ALT_can__eff:
return *field_can__eff == *other_value.field_can__eff;
case ALT_can__sff:
return *field_can__sff == *other_value.field_can__sff;
case ALT_can__rtr:
return *field_can__rtr == *other_value.field_can__rtr;
case ALT_can__err:
return *field_can__err == *other_value.field_can__err;
default:
return FALSE;
}
}
OCTETSTRING& CAN__ID::can__eff()
{
if (union_selection != ALT_can__eff) {
clean_up();
field_can__eff = new OCTETSTRING;
union_selection = ALT_can__eff;
}
return *field_can__eff;
}
const OCTETSTRING& CAN__ID::can__eff() const
{
if (union_selection != ALT_can__eff) TTCN_error("Using non-selected field can_eff in a value of union type @Isobustest.CAN_ID.");
return *field_can__eff;
}
OCTETSTRING& CAN__ID::can__sff()
{
if (union_selection != ALT_can__sff) {
clean_up();
field_can__sff = new OCTETSTRING;
union_selection = ALT_can__sff;
}
return *field_can__sff;
}
const OCTETSTRING& CAN__ID::can__sff() const
{
if (union_selection != ALT_can__sff) TTCN_error("Using non-selected field can_sff in a value of union type @Isobustest.CAN_ID.");
return *field_can__sff;
}
RTR& CAN__ID::can__rtr()
{
if (union_selection != ALT_can__rtr) {
clean_up();
field_can__rtr = new RTR;
union_selection = ALT_can__rtr;
}
return *field_can__rtr;
}
const RTR& CAN__ID::can__rtr() const
{
if (union_selection != ALT_can__rtr) TTCN_error("Using non-selected field can_rtr in a value of union type @Isobustest.CAN_ID.");
return *field_can__rtr;
}
BITSTRING& CAN__ID::can__err()
{
if (union_selection != ALT_can__err) {
clean_up();
field_can__err = new BITSTRING;
union_selection = ALT_can__err;
}
return *field_can__err;
}
const BITSTRING& CAN__ID::can__err() const
{
if (union_selection != ALT_can__err) TTCN_error("Using non-selected field can_err in a value of union type @Isobustest.CAN_ID.");
return *field_can__err;
}
boolean CAN__ID::ischosen(union_selection_type checked_selection) const
{
if (checked_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @Isobustest.CAN_ID.");
return union_selection == checked_selection;
}
boolean CAN__ID::is_bound() const
{
return union_selection != UNBOUND_VALUE;
}
boolean CAN__ID::is_value() const
{
switch (union_selection) {
case UNBOUND_VALUE: return FALSE;
case ALT_can__eff: return field_can__eff->is_value();
case ALT_can__sff: return field_can__sff->is_value();
case ALT_can__rtr: return field_can__rtr->is_value();
case ALT_can__err: return field_can__err->is_value();
default: TTCN_error("Invalid selection in union is_bound");}
}
void CAN__ID::clean_up()
{
switch (union_selection) {
case ALT_can__eff:
delete field_can__eff;
break;
case ALT_can__sff:
delete field_can__sff;
break;
case ALT_can__rtr:
delete field_can__rtr;
break;
case ALT_can__err:
delete field_can__err;
break;
default:
break;
}
union_selection = UNBOUND_VALUE;
}
void CAN__ID::log() const
{
switch (union_selection) {
case ALT_can__eff:
TTCN_Logger::log_event_str("{ can_eff := ");
field_can__eff->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__sff:
TTCN_Logger::log_event_str("{ can_sff := ");
field_can__sff->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__rtr:
TTCN_Logger::log_event_str("{ can_rtr := ");
field_can__rtr->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__err:
TTCN_Logger::log_event_str("{ can_err := ");
field_can__err->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_unbound();
}
}
void CAN__ID::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE, "union value");
Module_Param_Ptr m_p = &param;
if (m_p->get_type()==Module_Param::MP_Value_List && m_p->get_size()==0) return;
if (m_p->get_type()!=Module_Param::MP_Assignment_List) {
param.error("union value with field name was expected");
}
Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
char* last_name = mp_last->get_id()->get_name();
if (!strcmp(last_name, "can_eff")) {
can__eff().set_param(*mp_last);
if (!can__eff().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_sff")) {
can__sff().set_param(*mp_last);
if (!can__sff().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_rtr")) {
can__rtr().set_param(*mp_last);
if (!can__rtr().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_err")) {
can__err().set_param(*mp_last);
if (!can__err().is_bound()) clean_up();
return;
}
mp_last->error("Field %s does not exist in type @Isobustest.CAN_ID.", last_name);
}
void CAN__ID::set_implicit_omit()
{
switch (union_selection) {
case ALT_can__eff:
field_can__eff->set_implicit_omit(); break;
case ALT_can__sff:
field_can__sff->set_implicit_omit(); break;
case ALT_can__rtr:
field_can__rtr->set_implicit_omit(); break;
case ALT_can__err:
field_can__err->set_implicit_omit(); break;
default: break;
}
}
void CAN__ID::encode_text(Text_Buf& text_buf) const
{
text_buf.push_int(union_selection);
switch (union_selection) {
case ALT_can__eff:
field_can__eff->encode_text(text_buf);
break;
case ALT_can__sff:
field_can__sff->encode_text(text_buf);
break;
case ALT_can__rtr:
field_can__rtr->encode_text(text_buf);
break;
case ALT_can__err:
field_can__err->encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an unbound value of union type @Isobustest.CAN_ID.");
}
}
void CAN__ID::decode_text(Text_Buf& text_buf)
{
switch ((union_selection_type)text_buf.pull_int().get_val()) {
case ALT_can__eff:
can__eff().decode_text(text_buf);
break;
case ALT_can__sff:
can__sff().decode_text(text_buf);
break;
case ALT_can__rtr:
can__rtr().decode_text(text_buf);
break;
case ALT_can__err:
can__err().decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for type @Isobustest.CAN_ID.");
}
}
void CAN__ID_template::copy_value(const CAN__ID& other_value)
{
single_value.union_selection = other_value.get_selection();
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff = new OCTETSTRING_template(other_value.can__eff());
break;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff = new OCTETSTRING_template(other_value.can__sff());
break;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template(other_value.can__rtr());
break;
case CAN__ID::ALT_can__err:
single_value.field_can__err = new BITSTRING_template(other_value.can__err());
break;
default:
TTCN_error("Initializing a template with an unbound value of type @Isobustest.CAN_ID.");
}
set_selection(SPECIFIC_VALUE);
}
void CAN__ID_template::copy_template(const CAN__ID_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value.union_selection = other_value.single_value.union_selection;
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff = new OCTETSTRING_template(*other_value.single_value.field_can__eff);
break;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff = new OCTETSTRING_template(*other_value.single_value.field_can__sff);
break;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template(*other_value.single_value.field_can__rtr);
break;
case CAN__ID::ALT_can__err:
single_value.field_can__err = new BITSTRING_template(*other_value.single_value.field_can__err);
break;
default:
TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type @Isobustest.CAN_ID.");
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new CAN__ID_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 template of union type @Isobustest.CAN_ID.");
}
set_selection(other_value);
}
CAN__ID_template::CAN__ID_template()
{
}
CAN__ID_template::CAN__ID_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
CAN__ID_template::CAN__ID_template(const CAN__ID& other_value)
{
copy_value(other_value);
}
CAN__ID_template::CAN__ID_template(const OPTIONAL<CAN__ID>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CAN__ID&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of union type @Isobustest.CAN_ID from an unbound optional field.");
}
}
CAN__ID_template::CAN__ID_template(const CAN__ID_template& other_value)
: Base_Template(){
copy_template(other_value);
}
CAN__ID_template::~CAN__ID_template()
{
clean_up();
}
void CAN__ID_template::clean_up()
{
switch (template_selection) {
case SPECIFIC_VALUE:
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
delete single_value.field_can__eff;
break;
case CAN__ID::ALT_can__sff:
delete single_value.field_can__sff;
break;
case CAN__ID::ALT_can__rtr:
delete single_value.field_can__rtr;
break;
case CAN__ID::ALT_can__err:
delete single_value.field_can__err;
default:
break;
}
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
delete [] value_list.list_value;
default:
break;
}
template_selection = UNINITIALIZED_TEMPLATE;
}
CAN__ID_template& CAN__ID_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
CAN__ID_template& CAN__ID_template::operator=(const CAN__ID& other_value)
{
clean_up();
copy_value(other_value);
return *this;
}
CAN__ID_template& CAN__ID_template::operator=(const OPTIONAL<CAN__ID>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
copy_value((const CAN__ID&)other_value);
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Assignment of an unbound optional field to a template of union type @Isobustest.CAN_ID.");
}
return *this;
}
CAN__ID_template& CAN__ID_template::operator=(const CAN__ID_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean CAN__ID_template::match(const CAN__ID& 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:
{
CAN__ID::union_selection_type value_selection = other_value.get_selection();
if (value_selection == CAN__ID::UNBOUND_VALUE) return FALSE;
if (value_selection != single_value.union_selection) return FALSE;
switch (value_selection) {
case CAN__ID::ALT_can__eff:
return single_value.field_can__eff->match(other_value.can__eff(), legacy);
case CAN__ID::ALT_can__sff:
return single_value.field_can__sff->match(other_value.can__sff(), legacy);
case CAN__ID::ALT_can__rtr:
return single_value.field_can__rtr->match(other_value.can__rtr(), legacy);
case CAN__ID::ALT_can__err:
return single_value.field_can__err->match(other_value.can__err(), legacy);
default:
TTCN_error("Internal error: Invalid selector in a specific value when matching a template of union type @Isobustest.CAN_ID.");
}
}
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 template of union type @Isobustest.CAN_ID.");
}
return FALSE;
}
boolean CAN__ID_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
return single_value.field_can__eff->is_value();
case CAN__ID::ALT_can__sff:
return single_value.field_can__sff->is_value();
case CAN__ID::ALT_can__rtr:
return single_value.field_can__rtr->is_value();
case CAN__ID::ALT_can__err:
return single_value.field_can__err->is_value();
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing is_value operation on a template of union type @Isobustest.CAN_ID.");
}
}
CAN__ID CAN__ID_template::valueof() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent)
TTCN_error("Performing a valueof or send operation on a non-specific template of union type @Isobustest.CAN_ID.");
CAN__ID ret_val;
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
ret_val.can__eff() = single_value.field_can__eff->valueof();
break;
case CAN__ID::ALT_can__sff:
ret_val.can__sff() = single_value.field_can__sff->valueof();
break;
case CAN__ID::ALT_can__rtr:
ret_val.can__rtr() = single_value.field_can__rtr->valueof();
break;
case CAN__ID::ALT_can__err:
ret_val.can__err() = single_value.field_can__err->valueof();
break;
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing valueof operation on a template of union type @Isobustest.CAN_ID.");
}
return ret_val;
}
CAN__ID_template& CAN__ID_template::list_item(unsigned int list_index) const
{
if (template_selection != VALUE_LIST && template_selection != COMPLEMENTED_LIST) TTCN_error("Internal error: Accessing a list element of a non-list template of union type @Isobustest.CAN_ID.");
if (list_index >= value_list.n_values) TTCN_error("Internal error: Index overflow in a value list template of union type @Isobustest.CAN_ID.");
return value_list.list_value[list_index];
}
void CAN__ID_template::set_type(template_sel template_type, unsigned int list_length)
{
if (template_type != VALUE_LIST && template_type != COMPLEMENTED_LIST) TTCN_error ("Internal error: Setting an invalid list for a template of union type @Isobustest.CAN_ID.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new CAN__ID_template[list_length];
}
OCTETSTRING_template& CAN__ID_template::can__eff()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CAN__ID::ALT_can__eff) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__eff = new OCTETSTRING_template(ANY_VALUE);
else single_value.field_can__eff = new OCTETSTRING_template;
single_value.union_selection = CAN__ID::ALT_can__eff;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__eff;
}
const OCTETSTRING_template& CAN__ID_template::can__eff() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_eff in a non-specific template of union type @Isobustest.CAN_ID.");
if (single_value.union_selection != CAN__ID::ALT_can__eff) TTCN_error("Accessing non-selected field can_eff in a template of union type @Isobustest.CAN_ID.");
return *single_value.field_can__eff;
}
OCTETSTRING_template& CAN__ID_template::can__sff()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CAN__ID::ALT_can__sff) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__sff = new OCTETSTRING_template(ANY_VALUE);
else single_value.field_can__sff = new OCTETSTRING_template;
single_value.union_selection = CAN__ID::ALT_can__sff;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__sff;
}
const OCTETSTRING_template& CAN__ID_template::can__sff() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_sff in a non-specific template of union type @Isobustest.CAN_ID.");
if (single_value.union_selection != CAN__ID::ALT_can__sff) TTCN_error("Accessing non-selected field can_sff in a template of union type @Isobustest.CAN_ID.");
return *single_value.field_can__sff;
}
RTR_template& CAN__ID_template::can__rtr()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CAN__ID::ALT_can__rtr) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__rtr = new RTR_template(ANY_VALUE);
else single_value.field_can__rtr = new RTR_template;
single_value.union_selection = CAN__ID::ALT_can__rtr;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__rtr;
}
const RTR_template& CAN__ID_template::can__rtr() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_rtr in a non-specific template of union type @Isobustest.CAN_ID.");
if (single_value.union_selection != CAN__ID::ALT_can__rtr) TTCN_error("Accessing non-selected field can_rtr in a template of union type @Isobustest.CAN_ID.");
return *single_value.field_can__rtr;
}
BITSTRING_template& CAN__ID_template::can__err()
{
if (template_selection != SPECIFIC_VALUE || single_value.union_selection != CAN__ID::ALT_can__err) {
template_sel old_selection = template_selection;
clean_up();
if (old_selection == ANY_VALUE || old_selection == ANY_OR_OMIT) single_value.field_can__err = new BITSTRING_template(ANY_VALUE);
else single_value.field_can__err = new BITSTRING_template;
single_value.union_selection = CAN__ID::ALT_can__err;
set_selection(SPECIFIC_VALUE);
}
return *single_value.field_can__err;
}
const BITSTRING_template& CAN__ID_template::can__err() const
{
if (template_selection != SPECIFIC_VALUE) TTCN_error("Accessing field can_err in a non-specific template of union type @Isobustest.CAN_ID.");
if (single_value.union_selection != CAN__ID::ALT_can__err) TTCN_error("Accessing non-selected field can_err in a template of union type @Isobustest.CAN_ID.");
return *single_value.field_can__err;
}
boolean CAN__ID_template::ischosen(CAN__ID::union_selection_type checked_selection) const
{
if (checked_selection == CAN__ID::UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @Isobustest.CAN_ID.");
switch (template_selection) {
case SPECIFIC_VALUE:
if (single_value.union_selection == CAN__ID::UNBOUND_VALUE) TTCN_error("Internal error: Invalid selector in a specific value when performing ischosen() operation on a template of union type @Isobustest.CAN_ID.");
return single_value.union_selection == checked_selection;
case VALUE_LIST:
{
if (value_list.n_values < 1)
TTCN_error("Internal error: Performing ischosen() operation on a template of union type @Isobustest.CAN_ID containing an empty list.");
boolean ret_val = value_list.list_value[0].ischosen(checked_selection);
for (unsigned int list_count = 1; ret_val == TRUE && list_count < value_list.n_values; list_count++) {
ret_val = value_list.list_value[list_count].ischosen(checked_selection);
}
return ret_val;
}
default:
return FALSE;
}
return FALSE;
}
void CAN__ID_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
TTCN_Logger::log_event_str("{ can_eff := ");
single_value.field_can__eff->log();
TTCN_Logger::log_event_str(" }");
break;
case CAN__ID::ALT_can__sff:
TTCN_Logger::log_event_str("{ can_sff := ");
single_value.field_can__sff->log();
TTCN_Logger::log_event_str(" }");
break;
case CAN__ID::ALT_can__rtr:
TTCN_Logger::log_event_str("{ can_rtr := ");
single_value.field_can__rtr->log();
TTCN_Logger::log_event_str(" }");
break;
case CAN__ID::ALT_can__err:
TTCN_Logger::log_event_str("{ can_err := ");
single_value.field_can__err->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_str("<invalid selector>");
}
break;
case COMPLEMENTED_LIST:
TTCN_Logger::log_event_str("complement");
case VALUE_LIST:
TTCN_Logger::log_char('(');
for (unsigned int list_count = 0; list_count < value_list.n_values; list_count++) {
if (list_count > 0) TTCN_Logger::log_event_str(", ");
value_list.list_value[list_count].log();
}
TTCN_Logger::log_char(')');
break;
default:
log_generic();
}
log_ifpresent();
}
void CAN__ID_template::log_match(const CAN__ID& match_value, boolean legacy) const
{
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity() && match(match_value, legacy)){
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str(" matched");
return;
}
if (template_selection == SPECIFIC_VALUE && single_value.union_selection == match_value.get_selection()) {
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_eff");
single_value.field_can__eff->log_match(match_value.can__eff(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_eff := ");
single_value.field_can__eff->log_match(match_value.can__eff(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CAN__ID::ALT_can__sff:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_sff");
single_value.field_can__sff->log_match(match_value.can__sff(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_sff := ");
single_value.field_can__sff->log_match(match_value.can__sff(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CAN__ID::ALT_can__rtr:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_rtr");
single_value.field_can__rtr->log_match(match_value.can__rtr(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_rtr := ");
single_value.field_can__rtr->log_match(match_value.can__rtr(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
case CAN__ID::ALT_can__err:
if(TTCN_Logger::VERBOSITY_COMPACT == TTCN_Logger::get_matching_verbosity()){
TTCN_Logger::log_logmatch_info(".can_err");
single_value.field_can__err->log_match(match_value.can__err(), legacy);
} else {
TTCN_Logger::log_event_str("{ can_err := ");
single_value.field_can__err->log_match(match_value.can__err(), legacy);
TTCN_Logger::log_event_str(" }");
}
break;
default:
TTCN_Logger::print_logmatch_buffer();
TTCN_Logger::log_event_str("<invalid selector>");
}
} else {
TTCN_Logger::print_logmatch_buffer();
match_value.log();
TTCN_Logger::log_event_str(" with ");
log();
if (match(match_value, legacy)) TTCN_Logger::log_event_str(" matched");
else TTCN_Logger::log_event_str(" unmatched");
}
}
void CAN__ID_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.union_selection);
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff->encode_text(text_buf);
break;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff->encode_text(text_buf);
break;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr->encode_text(text_buf);
break;
case CAN__ID::ALT_can__err:
single_value.field_can__err->encode_text(text_buf);
break;
default:
TTCN_error("Internal error: Invalid selector in a specific value when encoding a template of union type @Isobustest.CAN_ID.");
}
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 template of type @Isobustest.CAN_ID.");
}
}
void CAN__ID_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
{
single_value.union_selection = CAN__ID::UNBOUND_VALUE;
CAN__ID::union_selection_type new_selection = (CAN__ID::union_selection_type)text_buf.pull_int().get_val();
switch (new_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff = new OCTETSTRING_template;
single_value.field_can__eff->decode_text(text_buf);
break;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff = new OCTETSTRING_template;
single_value.field_can__sff->decode_text(text_buf);
break;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template;
single_value.field_can__rtr->decode_text(text_buf);
break;
case CAN__ID::ALT_can__err:
single_value.field_can__err = new BITSTRING_template;
single_value.field_can__err->decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for a template of type @Isobustest.CAN_ID.");
}
single_value.union_selection = new_selection;
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = text_buf.pull_int().get_val();
value_list.list_value = new CAN__ID_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: Unrecognized selector was received in a template of type @Isobustest.CAN_ID.");
}
}
boolean CAN__ID_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean CAN__ID_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 v_idx=0; v_idx<value_list.n_values; v_idx++)
if (value_list.list_value[v_idx].match_omit())
return template_selection==VALUE_LIST;
return template_selection==COMPLEMENTED_LIST;
} // else fall through
default:
return FALSE;
}
return FALSE;
}
void CAN__ID_template::set_param(Module_Param& param)
{
if (dynamic_cast<Module_Param_Name*>(param.get_id()) != NULL &&
param.get_id()->next_name()) {
char* param_field = param.get_id()->get_current_name();
if (param_field[0] >= '0' && param_field[0] <= '9') {
param.error("Unexpected array index in module parameter, expected a valid field"
" name for union template type `@Isobustest.CAN_ID'");
}
if (strcmp("can_eff", param_field) == 0) {
can__eff().set_param(param);
return;
} else if (strcmp("can_sff", param_field) == 0) {
can__sff().set_param(param);
return;
} else if (strcmp("can_rtr", param_field) == 0) {
can__rtr().set_param(param);
return;
} else if (strcmp("can_err", param_field) == 0) {
can__err().set_param(param);
return;
} else param.error("Field `%s' not found in union template type `@Isobustest.CAN_ID'", param_field);
}
param.basic_check(Module_Param::BC_TEMPLATE, "union 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: {
CAN__ID_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_Value_List:
if (m_p->get_size()==0) break;
param.type_error("union template", "@Isobustest.CAN_ID");
break;
case Module_Param::MP_Assignment_List: {
Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
char* last_name = mp_last->get_id()->get_name();
if (!strcmp(last_name, "can_eff")) {
can__eff().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_sff")) {
can__sff().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_rtr")) {
can__rtr().set_param(*mp_last);
break;
}
if (!strcmp(last_name, "can_err")) {
can__err().set_param(*mp_last);
break;
}
mp_last->error("Field %s does not exist in type @Isobustest.CAN_ID.", last_name);
} break;
default:
param.type_error("union template", "@Isobustest.CAN_ID");
}
is_ifpresent = param.get_ifpresent();
}
void CAN__ID_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;
switch (single_value.union_selection) {
case CAN__ID::ALT_can__eff:
single_value.field_can__eff->check_restriction(t_res, t_name ? t_name : "@Isobustest.CAN_ID");
return;
case CAN__ID::ALT_can__sff:
single_value.field_can__sff->check_restriction(t_res, t_name ? t_name : "@Isobustest.CAN_ID");
return;
case CAN__ID::ALT_can__rtr:
single_value.field_can__rtr->check_restriction(t_res, t_name ? t_name : "@Isobustest.CAN_ID");
return;
case CAN__ID::ALT_can__err:
single_value.field_can__err->check_restriction(t_res, t_name ? t_name : "@Isobustest.CAN_ID");
return;
default:
TTCN_error("Internal error: Invalid selector in a specific value when performing check_restriction operation on a template of union type @Isobustest.CAN_ID.");
}
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 : "@Isobustest.CAN_ID");
}
RTR::RTR()
{
enum_value = UNBOUND_VALUE;
}
RTR::RTR(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Initializing a variable of enumerated type @Isobustest.RTR with invalid numeric value %d.", other_value);
enum_value = (enum_type)other_value;
}
RTR::RTR(enum_type other_value)
{
enum_value = other_value;
}
RTR::RTR(const RTR& other_value)
: Base_Type()
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Copying an unbound value of enumerated type @Isobustest.RTR.");
enum_value = other_value.enum_value;
}
RTR& RTR::operator=(int other_value)
{
if (!is_valid_enum(other_value)) TTCN_error("Assigning unknown numeric value %d to a variable of enumerated type @Isobustest.RTR.", other_value);
enum_value = (enum_type)other_value;
return *this;
}
RTR& RTR::operator=(enum_type other_value)
{
enum_value = other_value;
return *this;
}
RTR& RTR::operator=(const RTR& other_value)
{
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Isobustest.RTR.");
enum_value = other_value.enum_value;
return *this;
}
boolean RTR::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 @Isobustest.RTR.");
return enum_value == other_value;
}
boolean RTR::operator==(const RTR& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value == other_value.enum_value;
}
boolean RTR::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 @Isobustest.RTR.");
return enum_value < other_value;
}
boolean RTR::operator<(const RTR& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value < other_value.enum_value;
}
boolean RTR::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 @Isobustest.RTR.");
return enum_value > other_value;
}
boolean RTR::operator>(const RTR& other_value) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
if (other_value.enum_value == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of enumerated type @Isobustest.RTR.");
return enum_value > other_value.enum_value;
}
const char *RTR::enum_to_str(enum_type enum_par)
{
switch (enum_par) {
case RTRNULL: return "RTRNULL";
default: return "<unknown>";
}
}
RTR::enum_type RTR::str_to_enum(const char *str_par)
{
if (!strcmp(str_par, "RTRNULL")) return RTRNULL;
else return UNKNOWN_VALUE;
}
boolean RTR::is_valid_enum(int int_par)
{
switch (int_par) {
case 0:
return TRUE;
default:
return FALSE;
}
}
int RTR::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 @Isobustest.RTR.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par;
}
int RTR::enum2int(const RTR& 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 @Isobustest.RTR.", enum_par==UNBOUND_VALUE?"unbound":"invalid");
return enum_par.enum_value;
}
void RTR::int2enum(int int_val)
{
if (!is_valid_enum(int_val)) TTCN_error("Assigning invalid numeric value %d to a variable of enumerated type @Isobustest.RTR.", int_val);
enum_value = (enum_type)int_val;
}
RTR::operator RTR::enum_type() const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Using the value of an unbound variable of enumerated type @Isobustest.RTR.");
return enum_value;
}
void RTR::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 RTR::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", "@Isobustest.RTR");
enum_value = str_to_enum(param.get_enumerated());
if (!is_valid_enum(enum_value)) {
param.error("Invalid enumerated value for type @Isobustest.RTR.");
}
}
void RTR::encode_text(Text_Buf& text_buf) const
{
if (enum_value == UNBOUND_VALUE) TTCN_error("Text encoder: Encoding an unbound value of enumerated type @Isobustest.RTR.");
text_buf.push_int(enum_value);
}
void RTR::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 @Isobustest.RTR.", enum_value);
}
void RTR::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
{
va_list pvar;
va_start(pvar, p_coding);
switch(p_coding) {
case TTCN_EncDec::CT_BER: {
TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
unsigned BER_coding=va_arg(pvar, unsigned);
BER_encode_chk_coding(BER_coding);
ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
tlv->put_in_buffer(p_buf);
ASN_BER_TLV_t::destruct(tlv);
break;}
case TTCN_EncDec::CT_RAW: {
TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
if(!p_td.raw)
TTCN_EncDec_ErrorContext::error_internal
("No RAW descriptor available for type '%s'.", p_td.name);
RAW_enc_tr_pos rp;
rp.level=0;
rp.pos=NULL;
RAW_enc_tree root(TRUE, NULL, &rp, 1, p_td.raw);
RAW_encode(p_td, root);
root.put_to_buf(p_buf);
break;}
case TTCN_EncDec::CT_TEXT: {
TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
if(!p_td.text)
TTCN_EncDec_ErrorContext::error_internal
("No TEXT descriptor available for type '%s'.", p_td.name);
TEXT_encode(p_td,p_buf);
break;}
case TTCN_EncDec::CT_XER: {
TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
unsigned XER_coding=va_arg(pvar, unsigned);
XER_encode_chk_coding(XER_coding, p_td);
XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
p_buf.put_c('\n');
break;}
case TTCN_EncDec::CT_JSON: {
TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
if(!p_td.json)
TTCN_EncDec_ErrorContext::error_internal
("No JSON descriptor available for type '%s'.", p_td.name);
JSON_Tokenizer tok(va_arg(pvar, int) != 0);
JSON_encode(p_td, tok);
p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
break;}
case TTCN_EncDec::CT_OER: {
TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
if(!p_td.oer)
TTCN_EncDec_ErrorContext::error_internal
("No OER descriptor available for type '%s'.", p_td.name);
OER_encode(p_td, p_buf);
break;}
default:
TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
}
va_end(pvar);
}
void RTR::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
{
va_list pvar;
va_start(pvar, p_coding);
switch(p_coding) {
case TTCN_EncDec::CT_BER: {
TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
unsigned L_form=va_arg(pvar, unsigned);
ASN_BER_TLV_t tlv;
BER_decode_str2TLV(p_buf, tlv, L_form);
BER_decode_TLV(p_td, tlv, L_form);
if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
break;}
case TTCN_EncDec::CT_RAW: {
TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
if(!p_td.raw)
TTCN_EncDec_ErrorContext::error_internal
("No RAW descriptor available for type '%s'.", p_td.name);
raw_order_t r_order;
switch(p_td.raw->top_bit_order) {
case TOP_BIT_LEFT:
r_order=ORDER_LSB;
break;
case TOP_BIT_RIGHT:
default:
r_order=ORDER_MSB;
}
int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
if(rawr<0) switch (-rawr) {
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
break;
case 1:
default:
ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
break;
}
break;}
case TTCN_EncDec::CT_TEXT: {
Limit_Token_List limit;
TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
if(!p_td.text)
TTCN_EncDec_ErrorContext::error_internal
("No TEXT descriptor available for type '%s'.", p_td.name);
const unsigned char *b_data=p_buf.get_data();
if(b_data[p_buf.get_len()-1]!='\0'){
p_buf.set_pos(p_buf.get_len());
p_buf.put_zero(8,ORDER_LSB);
p_buf.rewind();
}
if(TEXT_decode(p_td,p_buf,limit)<0)
ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
break;}
case TTCN_EncDec::CT_XER: {
TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
unsigned XER_coding=va_arg(pvar, unsigned);
XER_encode_chk_coding(XER_coding, p_td);
XmlReaderWrap reader(p_buf);
for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
}
XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
size_t bytes = reader.ByteConsumed();
p_buf.set_pos(bytes);
break;}
case TTCN_EncDec::CT_JSON: {
TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
if(!p_td.json)
TTCN_EncDec_ErrorContext::error_internal
("No JSON descriptor available for type '%s'.", p_td.name);
JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
if(JSON_decode(p_td, tok, FALSE)<0)
ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
p_buf.set_pos(tok.get_buf_pos());
break;}
case TTCN_EncDec::CT_OER: {
TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
if(!p_td.oer)
TTCN_EncDec_ErrorContext::error_internal
("No OER descriptor available for type '%s'.", p_td.name);
OER_struct p_oer;
OER_decode(p_td, p_buf, p_oer);
break;}
default:
TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
}
va_end(pvar);
}
int RTR::RAW_decode(const TTCN_Typedescriptor_t& p_td,TTCN_Buffer& p_buf,int limit, raw_order_t top_bit_ord, boolean no_err, int, boolean, const RAW_Force_Omit*)
{
int decoded_value = 0;
int decoded_length = RAW_decode_enum_type(p_td, p_buf, limit, top_bit_ord, decoded_value, 1, no_err);
if (decoded_length < 0) return decoded_length;
if (is_valid_enum(decoded_value)) enum_value = (enum_type)decoded_value;
else {
if(no_err){
return -1;
} else {
TTCN_EncDec_ErrorContext::error
(TTCN_EncDec::ET_ENC_ENUM, "Invalid enum value '%d' for '%s': ",decoded_value, p_td.name);
enum_value = UNKNOWN_VALUE;
}
}
return decoded_length;
}
int RTR::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) const
{
return RAW_encode_enum_type(p_td, myleaf, (int)enum_value, 1);
}
void RTR_template::copy_template(const RTR_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 RTR_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 @Isobustest.RTR.");
}
}
RTR_template::RTR_template()
{
}
RTR_template::RTR_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}
RTR_template::RTR_template(int other_value)
: Base_Template(SPECIFIC_VALUE)
{
if (!RTR::is_valid_enum(other_value)) TTCN_error("Initializing a template of enumerated type @Isobustest.RTR with unknown numeric value %d.", other_value);
single_value = (RTR::enum_type)other_value;
}
RTR_template::RTR_template(RTR::enum_type other_value)
: Base_Template(SPECIFIC_VALUE)
{
single_value = other_value;
}
RTR_template::RTR_template(const RTR& other_value)
: Base_Template(SPECIFIC_VALUE)
{
if (other_value.enum_value == RTR::UNBOUND_VALUE) TTCN_error("Creating a template from an unbound value of enumerated type @Isobustest.RTR.");
single_value = other_value.enum_value;
}
RTR_template::RTR_template(const OPTIONAL<RTR>& other_value)
{
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (RTR::enum_type)(const RTR&)other_value;
break;
case OPTIONAL_OMIT:
set_selection(OMIT_VALUE);
break;
default:
TTCN_error("Creating a template of enumerated type @Isobustest.RTR from an unbound optional field.");
}
}
RTR_template::RTR_template(const RTR_template& other_value)
: Base_Template()
{
copy_template(other_value);
}
RTR_template::~RTR_template()
{
clean_up();
}
boolean RTR_template::is_bound() const
{
if (template_selection == UNINITIALIZED_TEMPLATE && !is_ifpresent) return FALSE;
return TRUE;
}
boolean RTR_template::is_value() const
{
if (template_selection != SPECIFIC_VALUE || is_ifpresent) return FALSE;
return single_value != RTR::UNBOUND_VALUE;
}
void RTR_template::clean_up()
{
if (template_selection == VALUE_LIST || template_selection == COMPLEMENTED_LIST) delete [] value_list.list_value;
template_selection = UNINITIALIZED_TEMPLATE;
}
RTR_template& RTR_template::operator=(template_sel other_value)
{
check_single_selection(other_value);
clean_up();
set_selection(other_value);
return *this;
}
RTR_template& RTR_template::operator=(int other_value)
{
if (!RTR::is_valid_enum(other_value)) TTCN_warning("Assigning unknown numeric value %d to a template of enumerated type @Isobustest.RTR.", other_value);
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = (RTR::enum_type)other_value;
return *this;
}
RTR_template& RTR_template::operator=(RTR::enum_type other_value)
{
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value;
return *this;
}
RTR_template& RTR_template::operator=(const RTR& other_value)
{
if (other_value.enum_value == RTR::UNBOUND_VALUE) TTCN_error("Assignment of an unbound value of enumerated type @Isobustest.RTR to a template.");
clean_up();
set_selection(SPECIFIC_VALUE);
single_value = other_value.enum_value;
return *this;
}
RTR_template& RTR_template::operator=(const OPTIONAL<RTR>& other_value)
{
clean_up();
switch (other_value.get_selection()) {
case OPTIONAL_PRESENT:
set_selection(SPECIFIC_VALUE);
single_value = (RTR::enum_type)(const RTR&)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 @Isobustest.RTR.");
}
return *this;
}
RTR_template& RTR_template::operator=(const RTR_template& other_value)
{
if (&other_value != this) {
clean_up();
copy_template(other_value);
}
return *this;
}
boolean RTR_template::match(RTR::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 @Isobustest.RTR.");
}
return FALSE;
}
boolean RTR_template::match(const RTR& other_value, boolean) const
{
if (other_value.enum_value == RTR::UNBOUND_VALUE) TTCN_error("Matching a template of enumerated type @Isobustest.RTR with an unbound value.");
return match(other_value.enum_value);
}
RTR::enum_type RTR_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 @Isobustest.RTR.");
return single_value;
}
void RTR_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 @Isobustest.RTR.");
clean_up();
set_selection(template_type);
value_list.n_values = list_length;
value_list.list_value = new RTR_template[list_length];
}
RTR_template& RTR_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 @Isobustest.RTR.");
if (list_index >= value_list.n_values) TTCN_error("Index overflow in a value list template of enumerated type @Isobustest.RTR.");
return value_list.list_value[list_index];
}
void RTR_template::log() const
{
switch (template_selection) {
case SPECIFIC_VALUE:
TTCN_Logger::log_event_enum(RTR::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 RTR_template::log_match(const RTR& 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 RTR_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 @Isobustest.RTR.");
}
}
void RTR_template::decode_text(Text_Buf& text_buf)
{
clean_up();
decode_text_base(text_buf);
switch (template_selection) {
case SPECIFIC_VALUE:
single_value = (RTR::enum_type)text_buf.pull_int().get_val();
if (!RTR::is_valid_enum(single_value)) TTCN_error("Text decoder: Unknown numeric value %d was received for a template of enumerated type @Isobustest.RTR.", 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 RTR_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 @Isobustest.RTR.");
}
}
boolean RTR_template::is_present(boolean legacy) const
{
if (template_selection==UNINITIALIZED_TEMPLATE) return FALSE;
return !match_omit(legacy);
}
boolean RTR_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 RTR_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: {
RTR_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: {
RTR::enum_type enum_val = RTR::str_to_enum(m_p->get_enumerated());
if (!RTR::is_valid_enum(enum_val)) {
param.error("Invalid enumerated value for type @Isobustest.RTR.");
}
*this = enum_val;
} break;
default:
param.type_error("enumerated template", "@Isobustest.RTR");
}
is_ifpresent = param.get_ifpresent();
}
void RTR_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 : "@Isobustest.RTR");
}
void Can__IDs::copy_value(const Can__IDs& other_value)
{
switch (other_value.union_selection) {
case ALT_can__eff:
field_can__eff = new BITSTRING(*other_value.field_can__eff);
break;
case ALT_can__sff:
field_can__sff = new BITSTRING(*other_value.field_can__sff);
break;
case ALT_can__rtr:
field_can__rtr = new RTR(*other_value.field_can__rtr);
break;
case ALT_can__err:
field_can__err = new BITSTRING(*other_value.field_can__err);
break;
default:
TTCN_error("Assignment of an unbound union value of type @Isobustest.Can_IDs.");
}
union_selection = other_value.union_selection;
}
Can__IDs::Can__IDs()
{
union_selection = UNBOUND_VALUE;
}
Can__IDs::Can__IDs(const Can__IDs& other_value)
: Base_Type(){
copy_value(other_value);
}
Can__IDs::~Can__IDs()
{
clean_up();
}
Can__IDs& Can__IDs::operator=(const Can__IDs& other_value)
{
if (this != &other_value) {
clean_up();
copy_value(other_value);
}
return *this;
}
boolean Can__IDs::operator==(const Can__IDs& other_value) const
{
if (union_selection == UNBOUND_VALUE) TTCN_error("The left operand of comparison is an unbound value of union type @Isobustest.Can_IDs.");
if (other_value.union_selection == UNBOUND_VALUE) TTCN_error("The right operand of comparison is an unbound value of union type @Isobustest.Can_IDs.");
if (union_selection != other_value.union_selection) return FALSE;
switch (union_selection) {
case ALT_can__eff:
return *field_can__eff == *other_value.field_can__eff;
case ALT_can__sff:
return *field_can__sff == *other_value.field_can__sff;
case ALT_can__rtr:
return *field_can__rtr == *other_value.field_can__rtr;
case ALT_can__err:
return *field_can__err == *other_value.field_can__err;
default:
return FALSE;
}
}
BITSTRING& Can__IDs::can__eff()
{
if (union_selection != ALT_can__eff) {
clean_up();
field_can__eff = new BITSTRING;
union_selection = ALT_can__eff;
}
return *field_can__eff;
}
const BITSTRING& Can__IDs::can__eff() const
{
if (union_selection != ALT_can__eff) TTCN_error("Using non-selected field can_eff in a value of union type @Isobustest.Can_IDs.");
return *field_can__eff;
}
BITSTRING& Can__IDs::can__sff()
{
if (union_selection != ALT_can__sff) {
clean_up();
field_can__sff = new BITSTRING;
union_selection = ALT_can__sff;
}
return *field_can__sff;
}
const BITSTRING& Can__IDs::can__sff() const
{
if (union_selection != ALT_can__sff) TTCN_error("Using non-selected field can_sff in a value of union type @Isobustest.Can_IDs.");
return *field_can__sff;
}
RTR& Can__IDs::can__rtr()
{
if (union_selection != ALT_can__rtr) {
clean_up();
field_can__rtr = new RTR;
union_selection = ALT_can__rtr;
}
return *field_can__rtr;
}
const RTR& Can__IDs::can__rtr() const
{
if (union_selection != ALT_can__rtr) TTCN_error("Using non-selected field can_rtr in a value of union type @Isobustest.Can_IDs.");
return *field_can__rtr;
}
BITSTRING& Can__IDs::can__err()
{
if (union_selection != ALT_can__err) {
clean_up();
field_can__err = new BITSTRING;
union_selection = ALT_can__err;
}
return *field_can__err;
}
const BITSTRING& Can__IDs::can__err() const
{
if (union_selection != ALT_can__err) TTCN_error("Using non-selected field can_err in a value of union type @Isobustest.Can_IDs.");
return *field_can__err;
}
boolean Can__IDs::ischosen(union_selection_type checked_selection) const
{
if (checked_selection == UNBOUND_VALUE) TTCN_error("Internal error: Performing ischosen() operation on an invalid field of union type @Isobustest.Can_IDs.");
return union_selection == checked_selection;
}
boolean Can__IDs::is_bound() const
{
return union_selection != UNBOUND_VALUE;
}
boolean Can__IDs::is_value() const
{
switch (union_selection) {
case UNBOUND_VALUE: return FALSE;
case ALT_can__eff: return field_can__eff->is_value();
case ALT_can__sff: return field_can__sff->is_value();
case ALT_can__rtr: return field_can__rtr->is_value();
case ALT_can__err: return field_can__err->is_value();
default: TTCN_error("Invalid selection in union is_bound");}
}
void Can__IDs::clean_up()
{
switch (union_selection) {
case ALT_can__eff:
delete field_can__eff;
break;
case ALT_can__sff:
delete field_can__sff;
break;
case ALT_can__rtr:
delete field_can__rtr;
break;
case ALT_can__err:
delete field_can__err;
break;
default:
break;
}
union_selection = UNBOUND_VALUE;
}
void Can__IDs::log() const
{
switch (union_selection) {
case ALT_can__eff:
TTCN_Logger::log_event_str("{ can_eff := ");
field_can__eff->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__sff:
TTCN_Logger::log_event_str("{ can_sff := ");
field_can__sff->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__rtr:
TTCN_Logger::log_event_str("{ can_rtr := ");
field_can__rtr->log();
TTCN_Logger::log_event_str(" }");
break;
case ALT_can__err:
TTCN_Logger::log_event_str("{ can_err := ");
field_can__err->log();
TTCN_Logger::log_event_str(" }");
break;
default:
TTCN_Logger::log_event_unbound();
}
}
void Can__IDs::set_param(Module_Param& param)
{
param.basic_check(Module_Param::BC_VALUE, "union value");
Module_Param_Ptr m_p = &param;
if (m_p->get_type()==Module_Param::MP_Value_List && m_p->get_size()==0) return;
if (m_p->get_type()!=Module_Param::MP_Assignment_List) {
param.error("union value with field name was expected");
}
Module_Param* mp_last = m_p->get_elem(m_p->get_size()-1);
char* last_name = mp_last->get_id()->get_name();
if (!strcmp(last_name, "can_eff")) {
can__eff().set_param(*mp_last);
if (!can__eff().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_sff")) {
can__sff().set_param(*mp_last);
if (!can__sff().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_rtr")) {
can__rtr().set_param(*mp_last);
if (!can__rtr().is_bound()) clean_up();
return;
}
if (!strcmp(last_name, "can_err")) {
can__err().set_param(*mp_last);
if (!can__err().is_bound()) clean_up();
return;
}
mp_last->error("Field %s does not exist in type @Isobustest.Can_IDs.", last_name);
}
void Can__IDs::set_implicit_omit()
{
switch (union_selection) {
case ALT_can__eff:
field_can__eff->set_implicit_omit(); break;
case ALT_can__sff:
field_can__sff->set_implicit_omit(); break;
case ALT_can__rtr:
field_can__rtr->set_implicit_omit(); break;
case ALT_can__err:
field_can__err->set_implicit_omit(); break;
default: break;
}
}
void Can__IDs::encode_text(Text_Buf& text_buf) const
{
text_buf.push_int(union_selection);
switch (union_selection) {
case ALT_can__eff:
field_can__eff->encode_text(text_buf);
break;
case ALT_can__sff:
field_can__sff->encode_text(text_buf);
break;
case ALT_can__rtr:
field_can__rtr->encode_text(text_buf);
break;
case ALT_can__err:
field_can__err->encode_text(text_buf);
break;
default:
TTCN_error("Text encoder: Encoding an unbound value of union type @Isobustest.Can_IDs.");
}
}
void Can__IDs::decode_text(Text_Buf& text_buf)
{
switch ((union_selection_type)text_buf.pull_int().get_val()) {
case ALT_can__eff:
can__eff().decode_text(text_buf);
break;
case ALT_can__sff:
can__sff().decode_text(text_buf);
break;
case ALT_can__rtr:
can__rtr().decode_text(text_buf);
break;
case ALT_can__err:
can__err().decode_text(text_buf);
break;
default:
TTCN_error("Text decoder: Unrecognized union selector was received for type @Isobustest.Can_IDs.");
}
}
void Can__IDs::encode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...) const
{
va_list pvar;
va_start(pvar, p_coding);
switch(p_coding) {
case TTCN_EncDec::CT_BER: {
TTCN_EncDec_ErrorContext ec("While BER-encoding type '%s': ", p_td.name);
unsigned BER_coding=va_arg(pvar, unsigned);
BER_encode_chk_coding(BER_coding);
ASN_BER_TLV_t *tlv=BER_encode_TLV(p_td, BER_coding);
tlv->put_in_buffer(p_buf);
ASN_BER_TLV_t::destruct(tlv);
break;}
case TTCN_EncDec::CT_RAW: {
TTCN_EncDec_ErrorContext ec("While RAW-encoding type '%s': ", p_td.name);
if(!p_td.raw)
TTCN_EncDec_ErrorContext::error_internal
("No RAW descriptor available for type '%s'.", p_td.name);
RAW_enc_tr_pos rp;
rp.level=0;
rp.pos=NULL;
RAW_enc_tree root(TRUE, NULL, &rp, 1, p_td.raw);
RAW_encode(p_td, root);
root.put_to_buf(p_buf);
break;}
case TTCN_EncDec::CT_TEXT: {
TTCN_EncDec_ErrorContext ec("While TEXT-encoding type '%s': ", p_td.name);
if(!p_td.text)
TTCN_EncDec_ErrorContext::error_internal
("No TEXT descriptor available for type '%s'.", p_td.name);
TEXT_encode(p_td,p_buf);
break;}
case TTCN_EncDec::CT_XER: {
TTCN_EncDec_ErrorContext ec("While XER-encoding type '%s': ", p_td.name);
unsigned XER_coding=va_arg(pvar, unsigned);
XER_encode_chk_coding(XER_coding, p_td);
XER_encode(*(p_td.xer),p_buf, XER_coding, 0, 0, 0);
p_buf.put_c('\n');
break;}
case TTCN_EncDec::CT_JSON: {
TTCN_EncDec_ErrorContext ec("While JSON-encoding type '%s': ", p_td.name);
if(!p_td.json)
TTCN_EncDec_ErrorContext::error_internal
("No JSON descriptor available for type '%s'.", p_td.name);
JSON_Tokenizer tok(va_arg(pvar, int) != 0);
JSON_encode(p_td, tok);
p_buf.put_s(tok.get_buffer_length(), (const unsigned char*)tok.get_buffer());
break;}
case TTCN_EncDec::CT_OER: {
TTCN_EncDec_ErrorContext ec("While OER-encoding type '%s': ", p_td.name);
if(!p_td.oer)
TTCN_EncDec_ErrorContext::error_internal
("No OER descriptor available for type '%s'.", p_td.name);
OER_encode(p_td, p_buf);
break;}
default:
TTCN_error("Unknown coding method requested to encode type '%s'", p_td.name);
}
va_end(pvar);
}
void Can__IDs::decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, TTCN_EncDec::coding_t p_coding, ...)
{
va_list pvar;
va_start(pvar, p_coding);
switch(p_coding) {
case TTCN_EncDec::CT_BER: {
TTCN_EncDec_ErrorContext ec("While BER-decoding type '%s': ", p_td.name);
unsigned L_form=va_arg(pvar, unsigned);
ASN_BER_TLV_t tlv;
BER_decode_str2TLV(p_buf, tlv, L_form);
BER_decode_TLV(p_td, tlv, L_form);
if(tlv.isComplete) p_buf.increase_pos(tlv.get_len());
break;}
case TTCN_EncDec::CT_RAW: {
TTCN_EncDec_ErrorContext ec("While RAW-decoding type '%s': ", p_td.name);
if(!p_td.raw)
TTCN_EncDec_ErrorContext::error_internal
("No RAW descriptor available for type '%s'.", p_td.name);
raw_order_t r_order;
switch(p_td.raw->top_bit_order) {
case TOP_BIT_LEFT:
r_order=ORDER_LSB;
break;
case TOP_BIT_RIGHT:
default:
r_order=ORDER_MSB;
}
int rawr = RAW_decode(p_td, p_buf, p_buf.get_len()*8, r_order);
if(rawr<0) switch (-rawr) {
case TTCN_EncDec::ET_INCOMPL_MSG:
case TTCN_EncDec::ET_LEN_ERR:
ec.error((TTCN_EncDec::error_type_t)-rawr, "Can not decode type '%s', because incomplete message was received", p_td.name);
break;
case 1:
default:
ec.error(TTCN_EncDec::ET_INVAL_MSG, "Can not decode type '%s', because invalid message was received", p_td.name);
break;
}
break;}
case TTCN_EncDec::CT_TEXT: {
Limit_Token_List limit;
TTCN_EncDec_ErrorContext ec("While TEXT-decoding type '%s': ", p_td.name);
if(!p_td.text)
TTCN_EncDec_ErrorContext::error_internal
("No TEXT descriptor available for type '%s'.", p_td.name);
const unsigned char *b_data=p_buf.get_data();
if(b_data[p_buf.get_len()-1]!='\0'){
p_buf.set_pos(p_buf.get_len());
p_buf.put_zero(8,ORDER_LSB);
p_buf.rewind();
}
if(TEXT_decode(p_td,p_buf,limit)<0)
ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
break;}
case TTCN_EncDec::CT_XER: {
TTCN_EncDec_ErrorContext ec("While XER-decoding type '%s': ", p_td.name);
unsigned XER_coding=va_arg(pvar, unsigned);
XER_encode_chk_coding(XER_coding, p_td);
XmlReaderWrap reader(p_buf);
for (int rd_ok=reader.Read(); rd_ok==1; rd_ok=reader.Read()) {
if (reader.NodeType() == XML_READER_TYPE_ELEMENT) break;
}
XER_decode(*(p_td.xer), reader, XER_coding | XER_TOPLEVEL, XER_NONE, 0);
size_t bytes = reader.ByteConsumed();
p_buf.set_pos(bytes);
break;}
case TTCN_EncDec::CT_JSON: {
TTCN_EncDec_ErrorContext ec("While JSON-decoding type '%s': ", p_td.name);
if(!p_td.json)
TTCN_EncDec_ErrorContext::error_internal
("No JSON descriptor available for type '%s'.", p_td.name);
JSON_Tokenizer tok((const char*)p_buf.get_data(), p_buf.get_len());
if(JSON_decode(p_td, tok, FALSE)<0)
ec.error(TTCN_EncDec::ET_INCOMPL_MSG,"Can not decode type '%s', because invalid or incomplete message was received", p_td.name);
p_buf.set_pos(tok.get_buf_pos());
break;}
case TTCN_EncDec::CT_OER: {
TTCN_EncDec_ErrorContext ec("While OER-decoding type '%s': ", p_td.name);
if(!p_td.oer)
TTCN_EncDec_ErrorContext::error_internal
("No OER descriptor available for type '%s'.", p_td.name);
OER_struct p_oer;
OER_decode(p_td, p_buf, p_oer);
break;}
default:
TTCN_error("Unknown coding method requested to decode type '%s'", p_td.name);
}
va_end(pvar);
}
int Can__IDs::RAW_decode(
const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_buf, int limit,
raw_order_t top_bit_ord, boolean no_err, int sel_field, boolean, const RAW_Force_Omit* force_omit)
{
int prepaddlength=p_buf.increase_pos_padd(p_td.raw->prepadding);
limit-=prepaddlength;
int decoded_length=0;
int starting_pos=p_buf.get_pos_bit();
if(sel_field!=-1){
switch(sel_field){
case 0: {
RAW_Force_Omit field_force_omit(0, force_omit, BIT29_descr_.raw->forceomit);
decoded_length = can__eff().RAW_decode(BIT29_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit);
break; }
case 1: {
RAW_Force_Omit field_force_omit(1, force_omit, General__Types::BIT11_descr_.raw->forceomit);
decoded_length = can__sff().RAW_decode(General__Types::BIT11_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit);
break; }
case 2: {
RAW_Force_Omit field_force_omit(2, force_omit, RTR_descr_.raw->forceomit);
decoded_length = can__rtr().RAW_decode(RTR_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit);
break; }
case 3: {
RAW_Force_Omit field_force_omit(3, force_omit, BIT29_descr_.raw->forceomit);
decoded_length = can__err().RAW_decode(BIT29_descr_, p_buf, limit, top_bit_ord, no_err, -1, TRUE, &field_force_omit);
break; }
default: break;
}
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
} else {
p_buf.set_pos_bit(starting_pos);
RAW_Force_Omit field_0_force_omit(0, force_omit, BIT29_descr_.raw->forceomit);
decoded_length = can__eff().RAW_decode(BIT29_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_0_force_omit);
if (decoded_length >= 0) {
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
}
p_buf.set_pos_bit(starting_pos);
RAW_Force_Omit field_1_force_omit(1, force_omit, General__Types::BIT11_descr_.raw->forceomit);
decoded_length = can__sff().RAW_decode(General__Types::BIT11_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_1_force_omit);
if (decoded_length >= 0) {
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
}
p_buf.set_pos_bit(starting_pos);
RAW_Force_Omit field_2_force_omit(2, force_omit, RTR_descr_.raw->forceomit);
decoded_length = can__rtr().RAW_decode(RTR_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_2_force_omit);
if (decoded_length >= 0) {
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
}
p_buf.set_pos_bit(starting_pos);
RAW_Force_Omit field_3_force_omit(3, force_omit, BIT29_descr_.raw->forceomit);
decoded_length = can__err().RAW_decode(BIT29_descr_, p_buf, limit, top_bit_ord, TRUE, -1, TRUE, &field_3_force_omit);
if (decoded_length >= 0) {
return decoded_length + p_buf.increase_pos_padd(p_td.raw->padding) + prepaddlength;
}
}
clean_up();
return -1;
}
int Can__IDs::RAW_encode(const TTCN_Typedescriptor_t&, RAW_enc_tree& myleaf) const
{
int encoded_length = 0;
myleaf.isleaf = FALSE;
myleaf.body.node.num_of_nodes = 4; myleaf.body.node.nodes = init_nodes_of_enc_tree(4);
memset(myleaf.body.node.nodes, 0, 4 * sizeof(RAW_enc_tree *));
switch (union_selection) {
case ALT_can__eff:
myleaf.body.node.nodes[0] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 0, BIT29_descr_.raw);
encoded_length = field_can__eff->RAW_encode(BIT29_descr_, *myleaf.body.node.nodes[0]);
myleaf.body.node.nodes[0]->coding_descr = &BIT29_descr_;
break;
case ALT_can__sff:
myleaf.body.node.nodes[1] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 1, General__Types::BIT11_descr_.raw);
encoded_length = field_can__sff->RAW_encode(General__Types::BIT11_descr_, *myleaf.body.node.nodes[1]);
myleaf.body.node.nodes[1]->coding_descr = &General__Types::BIT11_descr_;
break;
case ALT_can__rtr:
myleaf.body.node.nodes[2] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 2, RTR_descr_.raw);
encoded_length = field_can__rtr->RAW_encode(RTR_descr_, *myleaf.body.node.nodes[2]);
myleaf.body.node.nodes[2]->coding_descr = &RTR_descr_;
break;
case ALT_can__err:
myleaf.body.node.nodes[3] = new RAW_enc_tree(TRUE, &myleaf, &myleaf.curr_pos, 3, BIT29_descr_.raw);
encoded_length = field_can__err->RAW_encode(BIT29_descr_, *myleaf.body.node.nodes[3]);
myleaf.body.node.nodes[3]->coding_descr = &BIT29_descr_;
break;
default:
TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_UNBOUND, "Encoding an unbound value.");
}
return encoded_length;
}
void Can__IDs_template::copy_value(const Can__IDs& other_value)
{
single_value.union_selection = other_value.get_selection();
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
single_value.field_can__eff = new BITSTRING_template(other_value.can__eff());
break;
case Can__IDs::ALT_can__sff:
single_value.field_can__sff = new BITSTRING_template(other_value.can__sff());
break;
case Can__IDs::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template(other_value.can__rtr());
break;
case Can__IDs::ALT_can__err:
single_value.field_can__err = new BITSTRING_template(other_value.can__err());
break;
default:
TTCN_error("Initializing a template with an unbound value of type @Isobustest.Can_IDs.");
}
set_selection(SPECIFIC_VALUE);
}
void Can__IDs_template::copy_template(const Can__IDs_template& other_value)
{
switch (other_value.template_selection) {
case SPECIFIC_VALUE:
single_value.union_selection = other_value.single_value.union_selection;
switch (single_value.union_selection) {
case Can__IDs::ALT_can__eff:
single_value.field_can__eff = new BITSTRING_template(*other_value.single_value.field_can__eff);
break;
case Can__IDs::ALT_can__sff:
single_value.field_can__sff = new BITSTRING_template(*other_value.single_value.field_can__sff);
break;
case Can__IDs::ALT_can__rtr:
single_value.field_can__rtr = new RTR_template(*other_value.single_value.field_can__rtr);
break;
case Can__IDs::ALT_can__err:
single_value.field_can__err = new BITSTRING_template(*other_value.single_value.field_can__err);
break;
default:
TTCN_error("Internal error: Invalid union selector in a specific value when copying a template of type @Isobustest.Can_IDs.");
}
case OMIT_VALUE:
case ANY_VALUE:
case ANY_OR_OMIT:
break;
case VALUE_LIST:
case COMPLEMENTED_LIST:
value_list.n_values = other_value.value_list.n_values;
value_list.list_value = new Can__IDs_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 template of union type @Isobustest.Can_IDs.");
}
set_selection(other_value);
}
Can__IDs_template::Can__IDs_template()
{
}
Can__IDs_template::Can__IDs_template(template_sel other_value)
: Base_Template(other_value)
{
check_single_selection(other_value);
}