Discussion:
[omniORB] Win32 CORBA
Marek Cichy
2009-03-27 01:51:23 UTC
Permalink
Hi all
I finally created a CORBA server which works properly as a Windows
console application (using VS 9.0). I have to create another one, but as
a Win32 application. So, I just copied the code from one to another, and
something works. My question are:
Where do I have tu put ORB's initialization sequence in order to not to
lose control over application window after call orb->run()?
Is it possible to initialize orb without command line parameters?
ORB_init()?
Below is a std code created by VS and ORB initialization injected inside.
Thanks in advance for any help
Marek Cichy


int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
int argc;
char* argv[1];

try {
// Initialize orb
CORBA::ORB_var orb = CORBA::ORB_init(argc,argv);
// Get reference to Root POA.
CORBA::Object_var obj = orb ->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
// Activate POA manager

PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();

// Create an object of Simple_If_Impl

Simple_If_Impl* simple_servant = new Simple_If_Impl();

PortableServer::ObjectId_var mySimpleId =
poa->activate_object(simple_servant);

ISimple_Interface_var siv = simple_servant->_this();

if( !bindSimpleToName(orb, siv) )
return 1;
// Write its stringified references to stdout
CORBA::String_var strSimple = orb->object_to_string(siv);

// Accept requests
orb->run();

}
//catch omitted

return 0;
Martin Trappel
2009-03-27 15:36:59 UTC
Permalink
Post by Marek Cichy
Hi all
I finally created a CORBA server which works properly as a Windows
console application (using VS 9.0). I have to create another one, but as
a Win32 application. So, I just copied the code from one to another, and
Where do I have tu put ORB's initialization sequence in order to not to
lose control over application window after call orb->run()?
....
It depends. You can either use orb->perform_work() interleaved with the
windows msg processing or you can run orb->run() in a separate thread
(which is what I prefer).
Note that it shouldn't matter in which thread you run your CORBA init
sequence as long as you run orb->run() in it's own thread.
Note also that you have to take a bit of care on shutdown. (Common
thread sync / wait for completion problems.)

br,
Martin
Duncan Grisby
2009-03-27 16:46:50 UTC
Permalink
Post by Marek Cichy
I finally created a CORBA server which works properly as a Windows
console application (using VS 9.0). I have to create another one, but
as a Win32 application. So, I just copied the code from one to
Where do I have tu put ORB's initialization sequence in order to not
to lose control over application window after call orb->run()?
Just don't call orb->run(). omniORB dispatches everything from its own
threads, so you don't need to call run() at all. (Unless you use the POA
main thread model.)
Post by Marek Cichy
Is it possible to initialize orb without command line parameters?
ORB_init()?
ORB_init always expects some command line parameters, but it doesn't
know or care if they really came from the command line. It's generally a
good idea to give it the real command line, though, since that allows
you to easily turn on tracing and things like that.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...