Locating Clusters

Top  Previous  Next

The clusters required by the Diamond run-time library are built into the server. These clusters are installed when the server starts by being inserted into a table that is efficiently searched each time a service is required. If a cluster cannot be located in this table, the server attempts to find it externally.

 

You can use the server object’s member function SetCallback to install a single call-back handler for the server to invoke when a call is made to any unknown cluster. The base class for a call-back is as follows:

 

class Callback {

   public:

      virtual bool Handler(unsigned int ClusterNo,

                           unsigned int ServiceNo,

                           bool         ReplyWanted,

                           Present     *P)=0;

};

 

Once you have installed a call-back, its handler member will be called when an unknown cluster is referenced. It can either handle the service request or install an appropriate cluster handler. If the handler returns true, the server flushes any pending output requests to the root by calling P->push() and then continues to process the next command; subsequent references to the cluster result in direct calls to the handler. If the handler returns false, the server assumes that a new service cluster has been installed and will attempt to locate it; once located, the cluster is entered directly on subsequent references without invoking the call-back.

 

If the request has still not been satisfied, the server attempts to install a dynamic-link library for the cluster. This library is found by searching for the file Clu3L_xx.dll, where xx is the hexadecimal representation of the required cluster number. This is a minimum of two characters long. For example, given a command word of 1234567816 , the cluster number is 345616 and the server tries to load Clu3L_3456.dll.

 

The server returns a value of 0000008016 if both of these methods fail. In addition, if you have selected General Monitoring, the server displays a warning message.  When using your own cluster, the DSP should start by checking that the services can be located by attempting to call service 0 in the cluster. This returns 0 if the cluster has been located:

 

int CheckCluster(unsigned int clu) {

   int r;

   _ps1_put_bits(clu<<8);     // service 0 exists in all clusters

   r = _ps1_get_integer();

   if (r != 0) printf("Missing cluster %d\n", clu);

   return r;

}

 

Each cluster is given pointers to two classes:

 


P

a pointer to the Presentation class, used for all communication between the server and the root CPU.


C

a pointer to the Core class which provides commonly-used functions.