PreviousNext

Using cxx_static to Specify Static Interface Member Functions

Member functions can be specified as static by applying the cxx_static attribute to the function name. The cxx_static attribute is an operation attribute with a format as follows:

[cxx_static [(local_function)] ] member_function( );

The member_function name must match a function named in the associated IDL file.

Both remote and local versions of objects are implemented in an application by linking in both client and server stubs. A client links in the server stub to implement client-local versions of interface objects. A server links in the client stub to allow access to remote (in this case, client-local) objects that are passed in as parameters to member functions. The local_function argument to the cxx_static attribute specifies the function name that the application uses to locally implement the static member function and avoid name conflicts with the remote version of the function (always defined in the client stub).

The server implements a static function named member_function in its manager code if no local_function is specified. However, if a local_function is specified, the server implements a static function named local_function in its manager code. In this case, the manager_function is automatically implemented in the client stub that is linked into the application (along with the server stub) to handle marshalling of parameters that are client-local objects (remote to the server). When there is a local_function, it must be declared for the server stub in a header file and included by using the sstub attribute with the include statement in the ACF.

When a client calls the static member_function, the client stub executes a proxy function that uses RPCs to execute the associated remote function on a server. A client uses the local_function argument to specify a function name to use when implementing its own local version of the member_function. In this case, in addition to linking in the client stub, the client application also links in the idl-generated server stub with a local implementation of the function. When you develop a client, it might be easier if you think of the server stub as a local-implementation stub, because, when the client calls the static local_function, the call is strictly local and no RPCs are involved. If you compile an interface such that a server stub is not generated, the local_function argument to cxx_static is ignored.

An interface can instead specify member functions by using the static keyword in the interface definition, in front of a member function.