VIRTUAL CALLBACK

System Testing Test Script Language.

C++ only.

The VIRTUAL keyword modifies the CALLBACK statement, allowing it to handle messages using C++ inheritance.

Syntax

VIRTUAL CALLBACK <message_type>: <msg> ON <commtype>: <id> [<n>]

END CALLBACK

Description

The CALLBACK instruction dynamically recalls message reception and adds a connection identifier value to a communication channel identifier.

<message_type> is a message type, previously declared with a C++ typedef statement. Syntax using <message_type>* is not allowed.

<msg> is the output parameter of <message_type> that must be a polymorphic C++ class, which means that it must contain at least one virtual method.

<commtype> is the type of communication used for reading messages.

<id> is the input connection parameter on which a message must be read.

Because a single VIRTUAL CALLBACK can read several message types, the implicit choice of a CALLBACK may be ambiguous. The following rules apply:

  1. If a CALLBACK exists for a given <message type>, System Testing chooses it.

    If not, and if the message type is actually a virtual class, then System Testing chooses the VIRTUAL CALLBACK with the closest type in terms of path in the inheritance diagram of <message_type>.

    If more than one VIRTUAL CALLBACK can be chosen by following the above rules, the CALLBACK is ambiguous and System Testing produces an error.

Example

class high_level_message

{

 public:

  char from[12];

  char applname[12];

  virtual int get_type(){return 0;}

};

  

class ack : public high_level_message

{

 public:

  int get_type(){return ACK;}

};

class negack : public high_level_message

{

 public:

  int get_type(){return NEG_ACK;}

};

class data : public high_level_message

{

 public:

  char userdata[MAX_USERDATA_LENGTH];

  int length;

  int get_type(){return DATA;}

};

#typedef  high_level_message * pt_ high_level_message;

VIRTUAL CALLBACK pt_ high_level_message: msg ON appl_comm: id

 CALL get_message ( &id, &msg, 0 ) @@ errcode

   MESSAGE_DATE

   IF ( errcode == err_empty ) THEN

      NO_MESSAGE

   END IF

   IF ( errcode != err_ok ) THEN

      ERROR

   END IF

END CALLBACK

 

This VIRTUAL CALLBACK allows you to read high_level_message, ack, negack and data message types, as shown on the following lines:

MESSAGE data : a_data

MESSAGE ack : my_ack

MESSAGE negack : my_neg_ack

MESSAGE high_level_message : hm

DEF_MESSAGE my_ack, EV={}

WAITTIL (MATCHING(my_ack), WTIME==300)

 DEF_MESSAGE a_data, EV={}

WAITTIL (MATCHING(a_data), WTIME==300)

Related Topics

CALLBACK ... END CALLBACKPROCSEND ... END PROCSENDVIRTUAL PROCSENDMESSAGE