CORBA-ORBit
view release on metacpan or search on metacpan
ORBit/mapping.pod view on Meta::CPAN
=back
=head1 Constants
Constants defined in IDL map to a Perl subroutine which returns
the value of the constant.
=head1 Objects
CORBA object references are opaque perl objects.
=head2 Attributes
Attributes are mapped to a pair of methods with names which are the
attribute name prepended with C<_set_> and C<_get_>. The C<_set_>
method (not present for C<readonly> attributes) takes a single
parameter of the type of the attribute. The C<_get_> method returns
a value of the type of the attribute.
=head2 Operations
Operations are mapped to method calls. C<in> parameters are
mapped to parameters normally, C<inout> parameters get an
extra reference, and C<out> parameters are returned as part
of a list.
For instance, the operation:
char foo(in long l, inout string b, out float f);
would be called as:
($c,$f) = $obj->foo($l, \$s);
=head1 Exceptions
Exceptions are implemented using the Error module by Graham Barr.
To throw an exception, use the C<throw> method in the Exception
package:
throw MyInterface::MyException field1 => 'red', field2 => 32;
To catch an exception, use a C<try...catch> statement.
try {
$foo->runit();
} catch MyInterface::MyException with {
$e = shift;
print "Caught a $e->{field1} exception";
}
=head1 Object Implementations
=over 4
The POA supports modes of operation where a single servant
may incarnate multiple object references. For this reason,
it is not, in general, permissible to supply a servant
where an object reference is required. However, in
situations where it is valid to call the _this() method of
the servant, an ORB may transparently do this when
a servant is used in place of an object reference.
=head2 Implementing interfaces
The implementation of an interfaces is defined by deriving from the
package corresponding to the interface prepended with "POA_".
package MyAccount;
@MyAccount::ISA = qw(POA_Bank::Account);
sub new {
my $self = bless {
current_balance => 0
};
}
If the implementation of a interface inherits in addition from the
implementation of a base interface, then the module for the interface
being implemented directly must appear in the @ISA array before the
base interface implementation.
For instance, when implementing the following IDL:
module Foo {
interface A { long method1(); };
interface B : A { long method2(); }
}
with the following Perl code;
package MyA;
@MyA::ISA = qw(POA_Foo::A);
sub method1 {
return 1;
}
package MyB;
@MyA::ISA = qw(POA_Foo::B MyA);
sub method2 {
return 2;
}
sub new {
my $self = bless {};
}
C<POA_Foo:B> must come first in C<MyB>'s C<@ISA>.
(The rational for this is that the ORB will use a hidden
method in order to identifiy the class that a servant
implements.)
A servant is simply an Perl object blessed in a package
implemented as above.
=head2 Implementing operations and attributes
( run in 1.194 second using v1.01-cache-2.11-cpan-39bf76dae61 )