A client application must declare and initialize the DSOM run time before attempting to create or access a remote object. The SOMD_Init procedure initializes all of the DSOM run time, including the SOMDObjectMgr object. The global variable, SOMD_ObjectMgr is initialized to point to the local DSOM Object Manager.
A client application must also initialize all application classes used by the program. For each class, the corresponding <className>NewClass call should be made.
Note: In non-distributed SOM programs, the <className>New macro (and the new operator provided for each class by the SOM C++ bindings) implicitly calls the procedure <className>NewClass when creating a new object. This is not currently possible in DSOM because, when creating remote objects, DSOM uses a generic method that is not class-specific.
This was shown in the "Stack" example in section 6.2. In a similar example of an application that uses "Car" and "Driver" objects, the initialization code might look like this:
#include <somd.h> /* needed by all clients */ #include <Car.h> /* needed to access remote Car */ #include <Driver.h> /* needed to access remote Driver */ main() { Environment ev; /* ev used for error passing */ SOM_InitEnvironment(&ev); /* Do DSOM initialization */ SOMD_Init(&ev); /* Initialize application classes */ CarNewClass(Car_MajorVersion, Car_MinorVersion); DriverNewClass(Driver_MajorVersion, Driver_MinorVersion); ... }
As shown, client programs should include the "somd.h" file (or, for C++ programs, the "somd.xh" file) in order to define the DSOM run#time interfaces.
Note also that, since Environments are used for passing error results between a method and its caller, an Environment variable (ev) must be declared and initialized for this purpose.
The calls to "CarNewClass" and "DriverNewClass" are required if the client will be creating or accessing Cars and Drivers. The procedures "CarNewClass" and "DriverNewClass" create class objects for the classes "Car" and "Driver". When a DSOM Object Manager method like somdNewObject is invoked to create a "Car", it expects the "Car" class object to exist. If the class does not yet exist, the "ClassNotFound" exception will be returned.