An application may wish to define its own constructor methods for a particular class, via a user-supplied metaclass. In this case, the somdNewObject method should not be used, since it simply calls the default constructor method, somNew, defined by SOMClass.
Instead, the application can obtain a proxy to the actual class object in the server process. It can do so via the somdGetClassObj method, invoked on the SOMDServer proxy returned by one of the somdFindServerXxx methods. The application-defined constructor method can then be invoked on the proxy for the remote class object.
Note: The same issues apply to destructor methods. If the application defines its own destructor methods, they can be called via the class object returned by somdGetClassObj, as opposed to calling somdDestroyObject.
The following example creates a new object in a remote server using an application-defined constructor method, "makeCar", which is assumed to have been defined in the metaclass of "Car", named "MetaCar".
#include <somd.h> #include <Car.h> main( ) { Environment ev; SOMDServer server; Car car; MetaCar carClass; SOM_InitEnvironment(&ev); SOMD_Init(&ev); /* find a Car server */ server = _somdFindAnyServerByClass(SOMD_ObjectMgr, &ev, "Car"); /* get the class object for Car */ carClass = (MetaCar) _somdGetClassObj(server, &ev, "Car"); /* create the car object */ car = _makeCar(carClass, &ev, "Red", "Toyota", "2-door"); ... }