PreviousNext

Operation Declarations

Operation declarations specify the signature of each operation in the interface, including the operation name, the type of data returned, and the types of all parameters passed (if any) in a call.

The general form of an operation declaration is

[operation_attribute, ...] type_specifier operation_identifier ([parameter_declaration, ...]);

where the bracketed list of operation attributes is optional. Among the possible attributes of an operation are idempotent, broadcast, and maybe, which specify semantics to be applied by the RPC runtime mechanism when the operation is called. If an operation when called once can safely be executed more than once, the IDL declaration of the operation may specify the idempotent attribute; idempotent semantics allow remote procedure calls to execute more efficiently by letting the underlying RPC mechanism retry the procedure if it deems it necessary.

The type_specifier specifies the type of data returned by the operation.

The operation_identifier names the operation. Although operation names are arbitrary, a common convention is to use the name of an interface as a prefix for the names of its operations. For example, a bank interface may have operations named bank_open, bank_close, bank_deposit, bank_withdraw, and bank_balance.

Each parameter_declaration in an operation declaration declares a parameter of the operation. A parameter_declaration takes the following form:

[parameter_attribute, ...] type_specifier parameter_declarator

Every parameter attribute must have at least one of the parameter attributes in or out to specify whether the parameter is passed as an input, as an output, or in both directions. The type_specifier and parameter_declarator specify the type and name of the parameter.

Output parameters must be passed by reference and therefore must be declared as pointers via the pointer operator * (an asterisk) or an array.

If you want an interface to always use explicit binding handles, the first parameter of each operation declaration must be a binding handle, as in the following example:

void greet(

[in] handle_t h,

[in, string] char client_greeting[],

[out, string] char server_reply[REPLY_SIZE]

);

However, if you want applications to use the ACF feature of an implicit binding handle (or even an automatic binding handle) for some or all procedures, operation declarations must not have binding handle parameters in the interface definition:

void greet_no_handle(

[in, string] char client_greeting[],

[out, string] char server_reply[REPLY_SIZE]

);

This form of operation declaration is the most flexible because applications can always specify explicit, implicit, or automatic binding handles through an ACF.