Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Corba-Orb Initialisation in Class Constructor

Status
Not open for further replies.

JebeDIAHSpringFieLd

Programmer
Jul 3, 2002
5
0
0
DE

I have got quite a big problem and I wonder if you could help me out!! ! The problem is as follows:

I declared a Class in C++ called Messenger, offering some methods (Which are passed from my GUI). Its purpose
is to handle this methods through to a CORBA Server, which passes it to someone else (should be some kind
of video-conference....).
So the constructor of the class Messenger should include the initialisation of a CORBA-Orb Client. But I absolutely
don't have any idea how this works. I have looked at several examples, but they are all main programs
and no seperated classes like I have.

The code as it is suggested in the main programms is:
main(int argc, char * argv[])
{
try
{
// Initialize the ORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
// Convert the contents of the file to an object reference.
CORBA::Object_var obj = orb->string_to_object("file://Messenger.ior");
if (CORBA::is_nil(obj.in()))
{
cerr << &quot;Nil Messenger reference&quot; << endl;
throw 0;
}
// Narrow the object reference to a Messenger object reference.
Messenger_var messenger = Messenger::_narrow(obj.in());
if (CORBA::is_nil(messenger.in ()))
{
cerr << &quot;Not a Messenger object reference&quot; << endl;
throw 0;
}
// Create a message and send it to the Messenger.
CORBA::String_var message = CORBA::string_dup(&quot;Howdy!&quot;);
messenger->send_message (&quot;rick&quot;, &quot;Test&quot;, message.inout());
// Release resources.
orb->destroy();
}
catch (const CORBA::Exception & ex)
{
cerr << &quot;Caught a CORBA exception: &quot; << ex << endl;
return 1;
}
catch (...)
{
return 1;
}
cout << &quot;Message was sent&quot; << endl;
return 0;
}


exception handling included. I don't see the point of the following code line:
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

What are the parameters for, given the init-method??

I hope you understand what I am asking. Sorry for my bad English . I'm going to learn it better (At least I
hope so...)

Thank you very much for your help!
Charly
 
You need not give any arguments to the main program unless it's needed.
in most of the corba implementations like visibroker, if you specify any arguments at the command line for main, they will be used only if they make sense to the orb. Otherwise they will be ignored.
Please refer to the documentation to find out what valid arguments you can pass as command line parameters to control the corba server.
Gopi
 
hi charly,
why don't you use argc and argv from the main() as your class' constructor input params (or as input to an init() func which sound better)?
oren.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top