Creating a service definition

TStandardServiceDefinition acts as a wrapper for the classes that derive from TServiceDefinition. The parameters you pass into the TStandardServiceDefinition constructor determines whether the framework instantiates a TLocalServiceDefinition or a TNetworkServiceDefinition object.

NOTE Service definitions cannot be copied or streamed.

To create a service definition:

  1. Define a service name by creating a TLocalObjectName object, passing into the constructor:
    This code instantiates a TLocalObjectName specifying only a TLocalObjectType.
      TLocalObjectType kServiceName = "Calculator" ;
      const TLocalObjectName nameOfService( kServiceName ) ;
  2. Define the visibility of the service using TQualityOfService, specifying the TQualityOfService identifier that matches the level of visibility you want:

kSameHost Local visibility--only clients on the same host can see this service
kNetwork Network visibility--can be accessed by service references on the same host or on any host connected to this host by a mutually interoperable networking protocol
kNone Visibility not yet defined

    This line of code specifies local visibility:
      TQualityOfService serviceVisibility ( TQualityOfService::kSameHost ) ;
  1. Instantiate TStandardServiceDefinition, passing in the TLocalObjectName and TQualityOfService objects.
    This example creates a service definition visible only to local clients (clients on the same host).
      TServiceDefinition* myServiceDefinition 
      = new TStandardServiceDefinition ( nameOfService, serviceVisibility) ; myServiceDefinition->AddReference () ;

NOTE To create an unnamed service, instantiate TStandardServiceDefinition without passing any parameters into the constructor.


[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