Class hierarchy for caller-dispatcher pairs

Caller-dispatcher pairs use a specific inheritance scheme to simplify remote communication.

To create a simple caller-dispatcher pair, you only need to define four classes:


The abstract base class defines the interface of the dispatcher implementation that you want to call remotely. The member functions in this class are usually all pure virtual functions.

The caller class derives from MRemoteCaller and the abstract base class. MRemoteCaller provides the basic functionality for marshalling arguments into and out of the transport. The caller implements the virtual member functions of the base class as stub code. This stub code makes the calls to the dispatcher class, using the transport.

The dispatcher class derives only from MRemoteDispatcher. MRemoteDispatcher provides member functions for receiving requests from a caller and returning replies. For each member function to be called remotely, the dispatcher defines stub code that unmarshalls arguments from the caller and passes these to the dispatcher implementation. The dispatcher does not inherit from the abstract base class because, unlike the caller, the dispatcher stub code does not accept the same parameters as the dispatcher implementation.

The dispatcher implementation class derives only from the abstract base class. This is the class that does the actual "work" of the remote call--it overrides each member function of the base class, defining the behavior that you want to execute remotely.

NOTE You do not need to write any special code to support remote calls to the member functions of the dispatcher implementation class, but you do need to carefully consider the data types that these functions accept as parameters. For example, raw pointers passed into another task are no longer meaningful. For a detailed discussion of parameters in remote calls, see "Passing parameters to remote member functions" on page 74.

Looking at a simple caller-dispatcher pair, the abstract base class and stub code might seem to contain a lot of boilerplate code. However, the ratio of boilerplate code to "real" code decreases as you create more complex caller-dispatcher configurations.

Using this structured approach to remote procedure calls:

To learn how objects of these classes interact at runtime, read "How classes interact in the RPC model" on page 72. For instructions on how to define a caller-dispatcher pair using this model, read "Implementing a caller-dispatcher pair" on page 78.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker