Public operations

Public operations are part of the interface for the object. Declarations of public operations are generated in the specification file for the object, after the object's struct declaration. Definitions of public operations are generated in the implementation file for the object.

For example, the following declaration is generated in the specification file for the Valve object for the public operation open():

/*## operation open() */
void Valve_open(Valve* const me);

The following definition is generated in the implementation file for the Valve object for the public operation open():

void Valve_open(Valve* const me) {
   NOTIFY_OPERATION(me, &me, NULL, Valve, Valve_open, Valve_open(),
      0, Default_Valve_open_SERIALIZE);
   /*#[ operation open() */
   /*#]*/
}

The NOTIFY_OPERATION macro is used for animation. It notifies the animator that a new operation has been called. The NOTIFY_OPERATION macro is only inserted into the code when animation is enabled.

To control the way names are generated for public operations, use the C_CG::Operation::PublicName property. The default value of this property, $objectName_$opName, prefixes the name of the operation with the name of the object. For example, the public operation to open the valve in the heating system is named Valve_open().

Use the :I switch after $objectName (for example, $objectName:I or $objectName:i) to expand $objectName to be only uppercase letters (and digits) of the object name.


Feedback