Creating an object in an arbitrary server

Following is an example of how to create a new remote object in the case where the client does not care in which server the object is created. In this situation, the client defers these decisions to the DSOM Object Manager (SOMD_ObjectMgr) by using the somdNewObject method call, which has this IDL definition:

  // (from file om.idl)


  SOMObject somdNewObject(in Identifier objclass, in string hints);

  // Returns a new object of the named class.  This is a "basic"
  // creation method, where the decisions about where and how to
  // create the object are mostly left up to the Object Manager.
  // However, the Object Manager may optionally define creation
  // "hints" which the client may specify in this call.

Here is the example of how a remote "Car" would be created using somdNewObject:

#include <somd.h>
#include <Car.h>

main()
{
    Environment ev;
    Car car;

    SOM_InitEnvironment(&ev);
    SOMD_Init(&ev);

    /* create the class object */
    CarNewClass(Car_MajorVersion, Car_MinorVersion);

    /* create a Car object on some server, let the
       Object Manager choose which one */
    car = _somdNewObject(SOMD_ObjectMgr, &ev, "Car", "");
    ...
}

The main argument to the somdNewObject method call is a string specifying the name of the class of the desired object. The last argument is a string that may contain "hints" for the Object Manager when choosing a server. In this example, the client is providing no hints. (Currently, the DSOM Object Manager simply passes the hints to the server object in a somdCreateObj call.)


[Back: Creating remote objects]
[Next: Proxy objects]