Passing Objects from a client

If there is no BOS running locally, (that is, your process is strictly a client) you cannot expose your local objects to remote machines by reference. However, that doesn't mean you can't pass objects around. The client can still pass references to remote objects on other remote servers, and can still pass both local and remote objects by copy. For this section, we will take our examples from this SIDL:


package foo version 0.1 {
  
  class Bar {
    void setBaz(in foo.Baz bz);
    void setBazCopy(in copy foo.Baz bz);
    //returns the registered Baz, or a new one if none exists
    foo.Baz returnBaz();
  }

  class Baz {}
}

From the above SIDL, you can see that the following C code is perfectly legal for a client:


foo_Bar fb = foo_Bar__createRemote("simhandle://pc1:9999", &_ex);
foo_Baz fz = foo_Bar_returnBaz(fb, &_ex);
foo_Baz_runSimulation(fz, &_ex);

It's legal because the remote call returns a reference to another remote object, the client never actually exports any of it's local objects.

The following chunk is also legal, because it passes a remote object to a different remote server. (Passing it to the same remote server would be OK too.)


foo_Bar fb = foo_Bar__createRemote("simhandle://pc1:9999", &_ex);
foo_Baz fz = foo_Baz__createRemote("simhandle://pc2:9999", &_ex);
foo_Bar_setBaz(fb, fz, &_ex);

And the following is ALSO legal, because clients can pass local objects remotely by copy, they just can't pass local objects by reference. (This allows users to drive a remote simulation on a cluster from a regular workstation with nothing but a simple client.)


foo_Bar fb = foo_Bar__createRemote("simhandle://pc1:9999", &_ex);
foo_Baz fz = foo_Baz__create(&_ex);  //Local object
foo_Bar_setBazCopy(fb, fz, &_ex);    //Pass by copy

However this final bit of code will throw an exception if run by a client that has no BOS:


/* X ILLEGAL X WILL THROW EXCEPTION X     */ 

foo_Bar fb = foo_Bar__createRemote("simhandle://pc1:9999", &_ex);
foo_Baz fz = foo_Baz__create(&_ex); //Local object
foo_Bar_setBaz(fb, fz, &_ex);       //Pass by reference X BAD! X

/* X ILLEGAL X WILL THROW EXCEPTION X     */ 



babel-1.4.0
users_guide Last Modified 2008-10-16

http://www.llnl.gov/CASC/components
components@llnl.gov