Dispatcher API
Ice::Object Base Class
For historical reasons, the Dispatcher abstraction does not correspond to a Dispatcher
abstract base class in C++. We use instead the base class Ice::Object
as the dispatcher base class.
Object
is a concrete class that implements the pseudo Slice interface Object:
namespace Ice
{
class Object
{
public:
virtual void dispatch(
IncomingRequest& request,
std::function<void(OutgoingResponse)> sendResponse);
...
};
}
The implementation of dispatch
on Ice::Object
dispatches an incoming request to the 4 operations defined on Object
: ice_id
, ice_ids
, ice_isA
, and ice_ping
. It throws OperationNotExistException
for any other operation.
This implementation is immaterial: in practice, a dispatcher is any C++ class derived from Ice::Object
that reimplements dispatch
. This dispatcher may (but does not need to) implement the 4 operations defined on Object
.
Servants
In C++, a servant is a concrete class that implements the Dispatcher abstraction by itself, without delegating to some other object. In other words, a servant is a “terminal dispatcher”. The base class for all C++ servants is Ice::Object
. A servant should generally handle the 4 operations defined on the pseudo-Slice interface Object
.
The most common type of C++ servants are classes that implement skeleton classes generated by the Slice compiler. These generated skeleton classes reimplement dispatch
by:
unmarshaling input parameters
calling the pure virtual member function whose name matches the operation name carried by the request (you implement this pure virtual function in the servant class)
creating a response from the return value and out parameters returned by this function
They also implement or reimplement the 4 operations defined on Object
.