Discussion:
[omniORB] Help for a beginner
debutant
2008-07-31 22:46:50 UTC
Permalink
Hello,

I would really appreciate any help to understand how omniORB works.

Imagine I have a c++ solver that consists in two classes:

class A { ...}
class B { B(A a);
void DoSomething();
}

What could be an idl module for it? And what would be the implantation ?
Many thanks in advance
Sincerely,
Michel
--
View this message in context: http://www.nabble.com/Help-for-a-beginner-tp18755089p18755089.html
Sent from the OmniORB - User mailing list archive at Nabble.com.
Michael
2008-08-01 09:05:57 UTC
Permalink
Hello Michel,

I would suggest reading a book about CORBA (this is not omniORB specific).

In general, there are no constructors in CORBA (remember, the I in IDL
means Interface) - instead you'll have to use the factory pattern.

A possible similar effect of an interface that represents your example is:

module Test
{
interface A
{
void foo();
};

interface B: A
{
void doSomething();
};

interface BFactory
{
B createB(in Test::A a);
};
};

The implementation would include the followin:
- Implementation of BFactory (normally a singleton)
- Implementation of B
- Implementation of A
- A main that initializes the ORB, creates POAs, registers BFactory
in a well-known place (e.g. using the naming service), so clients
can factor objects of type B and starts up the orb. Since you're
only passing around object references the question here would be
where to get object references of A (besides nil references).

In the end, try to get a copy of "Advanced CORBA Programming with C++"
to understand what CORBA is about.

cheers
michael
Post by debutant
Hello,
I would really appreciate any help to understand how omniORB works.
class A { ...}
class B { B(A a);
void DoSomething();
}
What could be an idl module for it? And what would be the implantation ?
Many thanks in advance
Sincerely,
Michel
debutant
2008-08-01 22:55:10 UTC
Permalink
Hello Michael,

Thanks a lot for your reply.

I practised few exercices but none of them involved inheritance.
I could not write an implementation for the example you gave me.

I ordered the book you suggested. Waiting for it I would like to
ask you a last question:

Is it possible, on the server side, to convert a pointer to an
object reference A_ptr into a pointer to the instante of A_i it is related
to ?

Thanks.
Sincerely,
Michel
--
View this message in context: http://www.nabble.com/Help-for-a-beginner-tp18755089p18778718.html
Sent from the OmniORB - User mailing list archive at Nabble.com.
Michael
2008-08-01 23:09:47 UTC
Permalink
Hi Michel,

Test::B_ptr BFactory_i::createB(Test::A_ptr a)
{
try
{
PortableServer::Servant servant = poa_->reference_to_servant(a)
if (A_i* aimpl = dynamic_cast<A_i*>(servant))
{
return aimpl->createBFromThis(); // example
}
}
catch(...)
{
// there are different (meaningful) exceptions emitted, check the
// standard
std::cerr << "exception" << std::endl;
}
throw CORBA::BAD_PARAM();
}

(this assumes, you stored the poa used in poa_ - if it's the default poa
you could also get it through resolve_initial_reference)

This is also nice, because you can verify that the servant is really out
of this poa (and not a remote object).

The following calling conventions exist for reference_to_servant:

"This operation returns the servant associated with the object reference
if the RETAIN policy is set and the object is present in the active
object map. If the POA has the USE_DEFAULT_SERVANT policy and a default
servant has been registered with the POA, the default servant is
returned. If the object reference was not created by this POA, the
WrongAdapter exception is raised."

Exceptions:
WrongPolicy An error occurs if neither the RETAIN nor the
USE_DEFAULT_SERVANT policy was specified.
ObjectNotActive An error occurs if the RETAIN policy was specified and
the object is not in the active object map.
WrongAdapter An error occurs if the the reference does not belong to
this POA.

cheers
michael
Post by debutant
Hello Michael,
Thanks a lot for your reply.
I practised few exercices but none of them involved inheritance.
I could not write an implementation for the example you gave me.
I ordered the book you suggested. Waiting for it I would like to
Is it possible, on the server side, to convert a pointer to an
object reference A_ptr into a pointer to the instante of A_i it is related
to ?
Thanks.
Sincerely,
Michel
debutant
2008-08-02 00:57:25 UTC
Permalink
Fantastic ! I made it work !

Many thanks for your help and your time. I really appreciate.

I understand that I still have a lot to learn but it is a
pretty nice subject ....

Sincerely,
Michel
--
View this message in context: http://www.nabble.com/Help-for-a-beginner-tp18755089p18780712.html
Sent from the OmniORB - User mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...