<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
</head>
<body>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
Ist there a technique to dynamically generate CORBA objects during runtime. I want to
generate multiple event channels, but if I do that in the implementation of the CORBA object,
I get a "AlreadyExist"-Message. Can you please help me.</span></font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
The code is attached. I only want to create multiple objects of the event channel during
runtime, but it doesn't succeed. Please help me.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
// A little bit changed from the examples to omniEvents</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//                      Package   : omniEvents</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//   channel.cc               Created   : 2005/04/23</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//                            Author    : Alex Tingle</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    Copyright (C) 2005 Alex Tingle</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    This file is part of the omniEvents application and has been
modified</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//     during the study thesis of Sebastian BIckel.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    omniEvents is free software; you can redistribute it and/or</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    modify it under the terms of the GNU Lesser General Public</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    License as published by the Free Software Foundation; either</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    version 2.1 of the License, or (at your option) any later
version.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    omniEvents is distributed in the hope that it will be useful,</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    but WITHOUT ANY WARRANTY; without even the implied warranty of</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    Lesser General Public License for more details.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    You should have received a copy of the GNU Lesser General
Public</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    License along with this library; if not, write to the Free
Software</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307  USA</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
// Description:</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    Demonstates how to make a standalone EventChannel in your own</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    application, using libomniEvents.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
//    </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
[...]</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
#include <omniEvents/EventChannel.h></span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
/** Signal handler. */</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
void myShutdown(int signum)</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
{</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  OmniEvents::Orb::inst().shutdown(signum);</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
}</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
void * event_channel_task (void *)</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
{</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
      std::cout << "OmniEvents::Orb::inst().run() calling!" <<
std::endl;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
      OmniEvents::Orb::inst().run();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
      std::cout << "OmniEvents::Orb::inst().run() called!" <<
std::endl;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
}</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
#include "channel_factory.h"</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
#include <pthread.h></span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
std::string * ChannelFactory::createChannel(CORBA::ORB_var orb)</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
{</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  //</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  // Start orb.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  // CORBA::ORB_var orb = CORBA::ORB_init(argc,argv);</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  const char* action=""; // Use this variable to help report errors.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  try {</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="initialise OmniEvents::Orb";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // Your code MUST include these two lines.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    OmniEvents::Orb::inst()._orb=CORBA::ORB::_duplicate(orb);</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    OmniEvents::Orb::inst().resolveInitialReferences();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="activate the RootPOA's POAManager";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // You MUST activate the RootPOA's POAManager. You can do this
yourself</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // in the normal way, or you can use the reference that
OmniEvents::Orb</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // has resolved for you.    </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    PortableServer::POAManager_var pman;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    pman=OmniEvents::Orb::inst()._RootPOA->the_POAManager();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    pman->activate();    </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="create EventChannel servant";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // The constructor just allocates memory.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    OmniEvents::EventChannel_i* channelSrv =new
OmniEvents::EventChannel_i();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="activate EventChannel servant";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // activate() creates & activates the EventChannel's POA and
CORBA objects.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    try {</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
      channelSrv->activate("EventChannel");</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    } catch(...)</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    { </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
==>   std::cout << "AdapterAlreadyExists" << std::endl;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    }   </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // From this point, clients may invoke EventChannel operations.    </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="obtain an object reference to the EventChannel";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    CosEventChannelAdmin::EventChannel_var channelRef =channelSrv-
>_this();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // The user interface of this example is simple: The
EventChannel's IOR</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // is dumped to the standard output stream.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="stringify the EventChannel reference";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    CORBA::String_var sior =orb->object_to_string(channelRef.in());</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    cout<<sior.in()<<endl;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
   </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="set signal handlers";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    ::signal(SIGINT , ::myShutdown);</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    ::signal(SIGTERM, ::myShutdown);</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
 </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="collect orphan requests";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // You MUST call this method, it processes orphan (asynchronous)
method</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // calls made by the EventChannel.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // You can safely call it instead of CORBA::ORB::run(). If you
do not</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // want to park the main thread, then you must create a new
thread for this</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // method.</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    //cout<<"Calling OmniEvents::Orb::inst().run()
asynchronusly..."<<endl;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // OmniEvents::Orb::inst().run();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    pthread_t thread;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    pthread_create(&thread    // Thread-Id</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
               ,NULL          // Attributes</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
               ,::event_channel_task // Function</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
               ,NULL);   // Arguments (none)</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
            </span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // OmniEvents::Orb::inst().run();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    std::string * str_iop = new std::string();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    (*str_iop) = sior.in();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    return str_iop;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // OmniEvents::Orb::shutdown() has been called by the
myShutdown() signal</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // handler. (The user pressed Ctrl-C or killed the process.)</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    // In order to make run() return, you MUST call
OmniEvents::Orb::shutdown().</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    action="destroy orb";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
    orb->destroy();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  }</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  catch(CORBA::SystemException& ex) {</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
     cerr<<"Failed to "<<action<<".";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
#if defined(HAVE_OMNIORB4)</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
     cerr<<" "<<ex._name();</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
     if(ex.NP_minorString())</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
         cerr<<" ("<<ex.NP_minorString()<<")";</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
#endif</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
     cerr<<endl;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
     ::exit(1);</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  }</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  catch(CORBA::Exception& ex) {</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
     cerr<<"Failed to "<<action<<"."</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
#if defined(HAVE_OMNIORB4)</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
       " "<<ex._name()</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
#endif</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
       <<endl;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
     ::exit(1);</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  }</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
  return 0;</span></font>
</div>
<div align="left">
<font face="Courier" size="2">
<span style=" font-size:10pt">
}</span></font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
Greetings</span></font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
<br />
</span>
</font>
</div>
<div align="left">
<font face="Arial" size="2">
<span style=" font-size:10pt">
Sebastian</span></font>
</div>
</body>
</html>