#### Registering Named Objects

DCE RPC supplies every interface class with a member function, register_named_object( ), to do all that is required to register named objects. The following example shows how a server might create an object and then register it as a named object. The server first creates an object by using the new operator. Then the server calls the register_named_object function to register the object's name, universal unique identifier (UUID), and its server binding information with the name service. The function also registers the object's UUID and binding information with the host's endpoint map, and it updates the runtime's object table.

.
.
.
// Create an object on the server.
Matrix * matrix = new MatrixMgr(1, 1, 1, 1);
matrix->register_named_object((unsigned_char_t *) "/.:/MatrixObject"); . . .
.
.
.

The register_named_object( ) function greatly simplifies your work, but you need to be aware of the information it uses and generates. The following lists the approximate order of events that occur when an object invokes this function:

1. A name service entry is created if one is not already there, using the name in the first argument of the function.

2. If the named object does not already have a UUID associated with it in the name service, one is created.

3. The server's binding information is associated with the name service entry.

4. All interfaces supported by the object are also registered with the name service.

5. The object UUID is associated with the server's location on the host by registering endpoints in the host's endpoint map.

The function has an optional second argument of type boolean. The default value is TRUE, which means this is the only server on this host that services this interface. (In C++, using no argument is the same as using the default value for the argument.) If the default value is used, values in the endpoint map are updated.

If the second argument to the function is FALSE, this is not the only server this host has that services this interface. In this case, the register_named_object( ) function adds server binding information to the endpoint map (rather than updating the endpoint map) so clients can find any of the servers. See the rpc_ep_register_no_replace(3rpc) reference page for more on this topic.

6. Finally, an object table maintained by the server's RPC runtime is updated so that requests for specific objects are directed to the correct member function invocation. Even though creating the object in the first place registers it with the runtime's object table, some information (such as the object's UUID) may need to be updated.

####