static void rtg_AClass1_copy( const RTObject_class * type, AClass1 *
target, const AClass1 * source )
{
(void)new( target ) AClass1( *source );
}
In the Properties view for the MotorStatus class, on the RT Properties page, in the Target RTS group, the Decode Function Body field contains the code that decodes information injected when the model is running using a probe. Code in this field triggers the generation of a static function called rtg_MotorStatus_decode. The complete signature for the function is as follows:
static int rtg_MotorStatus_decode( const RTObject_class * type, enum MotorStatus * target, RTDecoding * coding )
The parameters type and coding are defined as above. The parameter target provides access to the data field of the signal; however, its use is not limited to probes or the signals.
You must provide encode and decode functions for attributes that have double indirection (for example, int **).Histatic void rtg_AClass1_destroy( const RTObject_class * type, AClass1
* target )
{
target->~AClass1();
}
The C++ transformation does not automatically generate proper encode functions for classes that have more than one base class.
To demonstrate this concept, consider a UML enumeration called MotorStatus that has three public attributes: On, Off, and Standby. The enumeration generates the following code:
enum MotorStatus { On, Off, Standby };
In the Properties view for the MotorStatus enumeration,
on the RT Properties page, in the Target RTS group, the Encode
Function Body field contains the code that encodes the
data. If code is present in this field, it triggers the generation
of a static function called rtg_MotorStatus_encode.
The complete signature for this function is as follows: static int rtg_MotorStatus_encode( const RTObject_class * type, const enum MotorStatus * source, RTEncoding * coding )The parameter type points to a data structure that provides an internal description of the MotorStatus enumeration. The parameter source is a pointer to the data that the signal sends, and coding provides a pointer to the data structure that holds the descriptive information that a trace window will use. In the following code example, the signal data (contained in "source") is used to enter the proper string representation in "coding" using the "put_string" function:
// BEGIN CODE EXAMPLE
switch(*source)
{
case On :
coding->put_string("On");
break;
case Off:
coding->put_string("Off");
break;
case Standby:
coding->put_string("Standby");
break;
default:
coding->put_string("ERROR");
}
return 1;
// END CODE EXAMPLE
You must provide encode and decode
functions for attributes that have double indirection (for example,
int **).The type descriptor contains information that the C++ Services Library requires to initialize, copy, destroy, encode, and decode data types. If the Generate Descriptor property is set to False, the data type cannot be sent by value in messages and is not observable or injected.
static void rtg_AClass1_init( const RTObject_class * type, AClass1 *
target )
{
(void)new( target ) AClass1;
}
You should only have to modify this property if your data
type cannot be initialized with a default constructor.