[omniORB] class constructors

Marco Verlato marco.verlato@pd.infn.it
Mon, 18 Dec 2000 18:03:46 +0100


Hello Stefan,
thanks for your e-mail,
i need a little more help due to the lack of examples in OMG CORBA/IIOP
2.3.1 specification document chapter 3. I found the keyword "factory" under
"Initializers" paragraph, but don`t understand how to use it. Perhaps you
can help me:
let`s say i take the Echo example:
interface Echo{
    string echoString(in string mesg);
};
and i put in the servant implementation class Echo_i the private member
variable "int myVar", and i want to have an additional constructor of
Echo_i(int Var) { myVar = Var}, is there a way to make this initialization
from the client when it makes Echo_var echoref = Echo::_narrow(obj), and how
should i do?
I think that i could achieve this by defining an attribute myVar
in echo interface:
interface Echo{
    attribute short myVar;
    string echoString(in string mesg);
};
since it create the accessor and mutator methods and i could then make in
the client:
Echo_var echoref = Echo::_narrow(obj);
echoref->myVar(Var);

but i would prefer to make this mandatory at the instantiation time.
Do you think it is possible?
Thanks, Marco.


>if you instantiate objects remotely, you use some form of factory. It is
the factory's
>responsability
>to pass any desired parameters to the servant's constructor. There is
nothing to publish as part
>of the IDL, as private class members (of the servant class that implements
a specific interface)
>are an implementation detail, i.e. may vary between two implementations of
the same interface.
>
>Regards, Stefan
>_______________________________________________________