The Object interface has a number of operations. We cannot define type
Object in Slice because
Object is a keyword; regardless, here is what (part of) the definition of
Object would look like if it were legal:
Note that, apart from the illegal use of the keyword Object as the interface name, the operation names all contain an underscore. This is deliberate: by putting an underscore into these operation names, it becomes impossible for these built‑in operations to ever clash with a user-defined operation. This means that all Slice interfaces can inherit from
Object without name clashes. There are three built‑in operations that are commonly used:
All interfaces support the ice_ping operation. That operation is useful for debugging because it provides a basic reachability test for an object: if the object exists and a message can successfully be dispatched to the object,
ice_ping simply returns without error. If the object cannot be reached or does not exist,
ice_ping throws a run-time exception that provides the reason for the failure.
The ice_isA operation accepts a type identifier (such as the identifier returned by
ice_id) and tests whether the target object supports the specified type, returning
true if it does. You can use this operation to check whether a target object supports a particular type. For example, referring to
Figure 4.7 once more, assume that you are holding a proxy to a target object of type
AlarmClock.
Table 4.2 illustrates the result of calling
ice_isA on that proxy with various arguments. (We assume that all type in
Figure 4.7 are defined in a module
Times):
As expected, ice_isA returns true for
::Times::Clock and
::Times::AlarmClock and also returns true for
::Ice::Object (because
all interfaces support that type). Obviously, an
AlarmClock supports neither the
Radio nor the
RadioClock interfaces, so
ice_isA returns false for these types.
The ice_ids operation returns a sequence of type IDs that contains all of the type IDs supported by an interface. For example, for the RadioClock interface in
Figure 4.7,
ice_ids returns a sequence containing the type IDs
::Ice::Object,
::Times::Clock,
::Times::AlarmClock,
::Times::Radio, and
::Times::RadioClock.