
SOM - Perl extension for access to SOM and DSOM objects.

use SOM; blah blah blah

(exported with the tag :types):
tk_short tk_ushort tk_long tk_ulong tk_float tk_double tk_char tk_boolean tk_octet tk_enum tk_string tk_pointer # Not yet? tk_void # Output only
$class = Find_Class($classname, $major, $minor)
Returns SOM Class object. Use $major = $minor = 0 if you do not need a version check.
$obj = $class->NewObject()
Creates a new instance of an object of the given class.
$repo = RepositoryNew()
Returns an object for access to Repository.
SOMClass()
Returns the SOM (meta)class SOMClass.
SOMObject()
Returns the SOM class SOMObject.
SOMClassMgr()
Returns the SOM class SOMClassMgr.
SOMClassMgrObject()
Returns the standard SOMClassMgrObject object.
$obj->Dispatch0($method_name)
Dispatches a method with void return and no arguments (not supported, fatal error if $method_name cannot be resolved).
$obj->Dispatch_templ($method_name, $template, ...)
Dispatches a method with return type and arguments described by a $template. See t/animal.t how to build a template.
$obj->GetClass()
Return the class of the object (as a SOM object).

Some SOM methods are hardwired into the module, they operate on Perl objects with names ending on Ptr. (Other SOM methods are currently supported with Dispatch_templ() method only.)
Note that support of Repository classes is much more complete than for other classes, since support on auto-import of methods is impossible without this.
DSOM-related primitive classes are listed in "Working with DSOM".
GetClassReturns the class object.
GetClassNameReturns the class name.
Additionally, two non-SOM methods are made available: Dispatch0() and Dispatch_templ().
NewObjectReturns a new object of the given class.
All the methods take environment as an argument:
$name = $obj->name($env)
nameString name of the element (unique inside the immediate parent).
idString id of the element (unique in the repository).
defined_inString id of the immediate parent.
withinReturns a list of containers with definitions of this object.
describeReturns information defined in the IDL specification of this object. Memory management for this???. Return type is AttributeDescriptionPtr.
lookup_nameReturns a list of objects with the given name within a specified Container object, or within objects contained in the Container object.
$obj->lookup_name($env, $name, $levels, $type, $noinherited)
$levels should be -1 to search all the kids-containers as well, otherwise should be 1. $type should be one of
AttributeDef ConstantDef ExceptionDef InterfaceDef ModuleDef ParameterDef OperationDef TypeDef all
If $noinherited, any inherited objects will not be returned.
contentsReturns the list of contained elements.
$obj->contents($env, $type, $noinherited)
Parameters have the same sense as for the lookup_name method.
Should be scraped: AttributeDescriptionPtr should be substituted by proper subclass of Contained!
The methods do not take environment as an argument:
$typecode = $attr->type()
In addition to methods name(), id(), defined_in() similar to ones in Contained, has two additional methods:
TypeCodePtr object which describes the type of the attribute.
whether the attribute is readonly.
Currently there is no value() method.
All the methods take environment as an argument:
$name = $op->result($env)
resultTypeCode of the return value.
All the methods take environment as an argument:
$name = $argN->type($env)
All the methods take environment as an argument:
$kind = $tc->kind($env)
kindReturns the type of the TypeCode. Types are the same as "Supported types".
param_countReturns the number of parameters encoded in the TypeCode.
parameterReturns the nth parameter encoded in the TypeCode as any. n changes from 0 to param_count - 1.
$p = $tc->parameter($env, 2);
All the methods take environment as an argument:
$type = $any->type($env)
typeReturns the TypeCode of the value stored in the any.
valueReturns the value stored in the any. Only elementary types are supported now.

Since Container/Contained are completely supported by primitive classes, one can walk the Repository tree any way one is pleased. We use only the following subtree of the Repository: inside toplevel we find InterfaceDef elements (which carry information about SOM classes), inside an InterfaceDef we look for OperationDef elements (which correspond to methods in the class), and inside an OperationDef we look for ParameterDef elements (which correspond to arguments of a method).
We consider ContainedContainerPtr as being both a ContainerPtr and ContainedPtr. But not all of them are. This is bad, since calling C SOM bindings on an object of unappropriate type is not catchable.

After any call which includes $ev, one should $ev-Clear> to avoid memory leaks. Before this call $ev can be expected for error info. Package SOM contains following major codes of exceptions: SYSTEM_EXCEPTION, USER_EXCEPTION, NO_EXCEPTION (exportable with tag :environment).
This API is very experimental. Read DSOM reference to know what these calls are doing.
DSOM to WPS requires two servers: one is a SOMD server (a separate process), another is WPSD server (extra thread(s) in WPS shell process). To check existence: SOM::IsSOMDDReady(), SOM::IsWPDServerReady().
To create: SOM::RestartSOMDD(1), SOM::RestartWPDServer(1).
To stop: SOM::RestartSOMDD(0), SOM::RestartWPDServer(0).
Keep in mind that servers are not refcounted, so it maybe not a very good idea to shut them down even if did not run when you started (since somebody else could have started to use them in between).
Additionally, stopping servers when they did not completely started could lead to problems.
A convenience function SOM::Ensure_Servers($shutdown_dsom, $shutdown_wpsd) is provided. If the arguments are given, servers will be shutdown at end of run if they were not running when this function was called. (Exportable with :dsom)
EnvironmentPtrTo create:
$ev = SOM::CreateLocalEnvironment();
(exportable with tag :environment).
Methods:
$major = $ev->major;
$stringID = $ev->id;
$minor = $ev->id; # 0 if $ev->major != SYSTEM_EXCEPTION
$state = $ev->completed; # undef if $ev->major != SYSTEM_EXCEPTION
# or state is not YES or NO, otherwise 0 or 1
$ev->Clear; # Free() data if $ev->major == SYSTEM_EXCEPTION
A simpleminded error reporter is made available as method Check:
$err = $ev->Check and warn "Got exception $err";
$err is formatted as MAJOR=2 ID='OPSYS' MINOR=343 COMPLETED=NO.
SOM::SOMDeamonFunctions:
Init($ev); Uninit($ev); ClassMgrObject(); # Default SOMD class manager ObjectMgr(); # Default SOMD object manager WPClassManagerNew(); # One can Merge the result with ObjectMgr()
SOMClassManagerPtrMethods:
$oldmgr->MergeInto($newmgr);
ObjectMgrPtrMethods:
$mgr->ReleaseObject($ev, $servername);
SOMDObjectMgrPtrISA ObjectMgrPtr.
Methods:
$server = $mgr->FindServerByName($ev, $servername);
SOMDServerPtrMethods:
$server->GetClassObj($ev, $classname);
Initialize:
use SOM ':class', ':dsom', ':environment';
Ensure_Servers();
$ev = SOM::CreateLocalEnvironment();
sub EnvironmentPtr::CheckAndWarn {
my $err; $err = $ev->Check and warn "Got exception $err";
}
Start class dispatchers:
SOM::SOMDeamon::Init($ev);
$ev->CheckAndWarn;
$SOM_ClassMgr = SOM::SOMDeamon::ClassMgrObject or die;
$WPS_ClassMgr = SOM::SOMDeamon::WPClassManagerNew or die;
$SOM_ClassMgr->MergeInto($WPS_ClassMgr); # In fact MergeFrom
Init_WP_Classes(); # Otherwise cannot GetClassObj('WPFolder')
$server = SOM::SOMDeamon::ObjectMgr->FindServerByName($ev, "wpdServer")
or die;
$ev->CheckAndWarn;
Get a class object of requested type:
$classFolder = $server->GetClassObj($ev, "WPFolder") or die; $ev->CheckAndWarn; ## ... Do some work with $folderClass
Shut down dispatchers:
SOM::SOMDeamon::ObjectMgr->ReleaseObject($ev, $server); $ev->CheckAndWarn; SOM::SOMDeamon::Uninit($ev); $ev->CheckAndWarn;

None by default. Tags :types, :class.

A. U. Thor, a.u.thor@a.galaxy.far.far.away

Only primitive types of parameters and return value are supported.
Only in-parameters are supported.
No memory management is done at all.
Exception is not analysed.
SOM Objects have type SOMObjectPtr, SOM Classes have type SOMClassPtr etc.
Methods may be dispatched only when a signature is explicitely described.

perl(1).