CORBA-MICO

 view release on metacpan or  search on metacpan

MICO/mapping.pod  view on Meta::CPAN

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.

An object reference for the object will be created when required.
That is, when the object is marshalled as the argument or return
value from a call, or when an API operation that requires 

=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 do this transparently when
a servant is used in place of an object reference.

=head2 Implementing interfaces

Interface are implemented 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 in addition from the
implementation of a base interface, then the module
for the interface being implemented must appear in the @ISA 
array before the base interface implementation. 

For instance, when implementing the following IDL:

  module Foo {
     interface A { long foo(); };
     interface B : A { long bar(); }
  }

with the following Perl code;

  package MyA;

  @MyA::ISA = qw(Foo::A);
 
  sub foo {
      return 1;
  }  

  package MyB;

  @MyA::ISA = qw(Foo::B MyA);
 
  sub bar {
     return 2;
  } 

  sub new {
     my $self = bless {};
  }

C<Foo:B> must come first in C<MyB>'s C<@ISA>.

=head2 Implementing operations and attributes

Operations and attributes are implemented exactly as expected 
from the client-side mapping. That is, the operation is called
with the same parameters as a client would use to 
invoke the operation.



( run in 1.524 second using v1.01-cache-2.11-cpan-39bf76dae61 )