int main(int argc, char * argv[])
{
    CORBA::Object_var obj;

    //----------------------------------------------------------------------------
    // initialize ORB

    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    //----------------------------------------------------------------------------
    // initialize POA

    obj = orb->resolve_initial_references("RootPOA");
    assert(!CORBA::is_nil(obj));
    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
    PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
    poa_manager->activate();

    //----------------------------------------------------------------------------
    // get naming service reference

    obj = orb->resolve_initial_references("NameService");
    assert(!CORBA::is_nil(obj));
    CosNaming::NamingContext_var naming_service =
        CosNaming::NamingContext::_narrow(obj);

    //----------------------------------------------------------------------------
    // get event channel reference

    // resolving name in robots naming context
    CosNaming::Name name;
    name.length(1);
    name[1].id = NOTIFY_EVENT_CHANNEL;

    obj = naming_service->resolve(name);

    // The event channel
    CosNotifyChannelAdmin::EventChannel_var ec =
        CosNotifyChannelAdmin::EventChannel::_narrow(obj);

    //----------------------------------------------------------------------------
    // creating a notification service supplier admin

    // The group operator between admin-proxy's.
    CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
        CosNotifyChannelAdmin::OR_OP;
    // The id of the created adin.
    CosNotifyChannelAdmin::AdminID admin_id;
    // The supplier admin used by supplier.
    CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin;

    consumer_admin = ec->new_for_consumers(ifgop, admin_id);

    //----------------------------------------------------------------------------
    // create a notification service proxy consumer, to send events to

    // Initial qos specified to the factory when creating the EC.
    CosNotification::QoSProperties initial_qos;
    // Initial admin props specified to the factory when creating the EC.
    CosNotification::AdminProperties initial_admin;
    // This proxy's id.
    CosNotifyChannelAdmin::ProxyID proxy_id;
    // The proxy that we are connected to.
    CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxy_supplier;


    obj = consumer_admin->
          obtain_notification_push_supplier(CosNotifyChannelAdmin::STRUCTURED_EVENT,
                                            proxy_id);
    assert(!CORBA::is_nil(obj));

    // narrow
    proxy_supplier =
        CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(obj);

    //----------------------------------------------------------------------------
    // offer/subscription management

    // don't call us on offer changes
    CosNotification::EventTypeSeq_var events =
        proxy_supplier->
        obtain_offered_types(CosNotifyChannelAdmin::NONE_NOW_UPDATES_OFF);

    // tell about the events we gonna subscribe
    CosNotification::EventTypeSeq added;
    CosNotification::EventTypeSeq removed;

    added.length(1);
    added[0].domain_name = string("Robot_Name").c_str();
    added[0].type_name = string("Event_Name").c_str();
    added.length(1);
    // remove default subscription
    removed.length(1);
    removed[0].domain_name = string("*").c_str();
    removed[0].type_name = string("*").c_str();
    consumer_admin->subscription_change(added, removed);

    //----------------------------------------------------------------------------
    // create and connect a supplier class

    class MyConsumer : public POA_CosNotifyComm::StructuredPushConsumer
    {
    public:
        void push_structured_event(CosNotification::StructuredEvent const& event)
        throw()
        {
            cout << "domain name: "
                 << event.header.fixed_header.event_type.domain_name << endl
                 << "type name: "
                 << event.header.fixed_header.event_type.type_name << endl;
        }
        void offer_change(CosNotification::EventTypeSeq const& /*added*/,
                          CosNotification::EventTypeSeq const& /*removed*/)
        throw(CosNotifyComm::InvalidEventType)
        {
            cerr << "offer_change() called" << endl;
        }
        void disconnect_structured_push_consumer() throw()
        {
            cerr << "disconnect_structured_push_consumer() called" << endl;
        }
    };

    MyConsumer * consumer = new MyConsumer();

    // activate supplier with poa
    CosNotifyComm::StructuredPushConsumer_var objref = consumer->_this();
    // connect
    proxy_supplier->connect_structured_push_consumer(objref);


    //----------------------------------------------------------------------------
    // receiving events
    orb->run();

    return 0;
}
示例#2
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

      CORBA::Object_var naming_obj =
        orb->resolve_initial_references ("NameService");

      CosNaming::NamingContext_var naming_context =
        CosNaming::NamingContext::_narrow(naming_obj.in());

      CosNaming::Name name;
      name.length (1);
      name[0].id = CORBA::string_dup("MyEventChannel");
      CORBA::Object_var ecObj = naming_context->resolve(name);

      CosNotifyChannelAdmin::EventChannel_var ec =
        CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());

      CosNotifyChannelAdmin::AdminID adminid;
      CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
        CosNotifyChannelAdmin::AND_OP;

      CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
        ec->new_for_consumers(ifgop, adminid);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (poa_object.in());

      PortableServer::Servant_var<StructuredEventConsumer_i> servant =
        new StructuredEventConsumer_i(orb.in());

      PortableServer::ObjectId_var objectId = poa->activate_object (servant.in());

      CORBA::Object_var consumer_obj = poa->id_to_reference (objectId.in ());

      CosNotifyComm::StructuredPushConsumer_var consumer =
        CosNotifyComm::StructuredPushConsumer::_narrow (consumer_obj.in ());

      CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;

      CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
        consumer_admin->obtain_notification_push_supplier(
          CosNotifyChannelAdmin::STRUCTURED_EVENT,
          consumeradmin_proxy_id);

      CosNotifyChannelAdmin::StructuredProxyPushSupplier_var supplier_proxy;
      supplier_proxy =
      CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(proxy_supplier.in());

      CosNotification::QoSProperties properties (1);

      properties.length (1);
      properties[0].name = CORBA::string_dup (CosNotification::OrderPolicy);
      properties[0].value <<= CosNotification::FifoOrder;

      supplier_proxy->set_qos (properties);
      supplier_proxy->connect_structured_push_consumer(consumer.in());

      CosNotification::EventTypeSeq added (1);
      CosNotification::EventTypeSeq removed (1);
      added.length (1);
      removed.length (1);

      added[0].domain_name = CORBA::string_dup ("OCI_TAO");
      added[0].type_name = CORBA::string_dup ("examples");

      removed[0].domain_name = CORBA::string_dup ("*");
      removed[0].type_name = CORBA::string_dup ("*");

      supplier_proxy->subscription_change(added, removed);

      PortableServer::POAManager_var poa_manager = poa->the_POAManager();

      poa_manager->activate();

      orb->run();
    }
  catch(const CORBA::Exception& ex)
    {
      std::cerr << "Caught exception: " << ex << std::endl;
        return 1;
    }

  return 0;
}
int main(int argc, char * argv[])
{
  CORBA::Object_var obj;

  //----------------------------------------------------------------------------
  // initialize ORB

  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

  //----------------------------------------------------------------------------
  // initialize POA

  obj = orb->resolve_initial_references("RootPOA");
  assert(!CORBA::is_nil(obj));
  PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
  PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
  poa_manager->activate();

  //----------------------------------------------------------------------------
  // get naming service reference

  obj = orb->resolve_initial_references("NameService");
  assert(!CORBA::is_nil(obj));
  CosNaming::NamingContext_var naming_service =
    CosNaming::NamingContext::_narrow(obj);

  //----------------------------------------------------------------------------
  // get event channel reference

  // resolving name in robots naming context
  assert(argc >= 2);
  std::string naming_context = argv[1];

  CosNaming::Name name;
  name.length(2);
  name[0].id = naming_context.c_str();
  name[1].id = string("NotifyEventChannel").c_str();

  obj = naming_service->resolve(name);

  // The event channel
  CosNotifyChannelAdmin::EventChannel_var ec =
    CosNotifyChannelAdmin::EventChannel::_narrow(obj);

  //----------------------------------------------------------------------------
  // creating a notification service supplier admin

  // The group operator between admin-proxy's.
  CosNotifyChannelAdmin::InterFilterGroupOperator ifgop = 
    CosNotifyChannelAdmin::OR_OP;
  // The id of the created adin.
  CosNotifyChannelAdmin::AdminID admin_id;
  // The supplier admin used by supplier.
  CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin;

  supplier_admin = ec->new_for_suppliers(ifgop, admin_id);

  //----------------------------------------------------------------------------
  // create a notification service proxy consumer, to send events to

  // This proxy's id.
  CosNotifyChannelAdmin::ProxyID proxy_id;
   // The proxy that we are connected to.
  CosNotifyChannelAdmin::StructuredProxyPushConsumer_var proxy_consumer;


  obj = supplier_admin->
    obtain_notification_push_consumer(CosNotifyChannelAdmin::STRUCTURED_EVENT,
				      proxy_id);
  assert(!CORBA::is_nil(obj));

  // narrow
  proxy_consumer = 
    CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(obj);

  //----------------------------------------------------------------------------
  // offer/subscription management

  // don't call us on subscription changes
  CosNotification::EventTypeSeq_var events = 
    proxy_consumer->
    obtain_subscription_types(CosNotifyChannelAdmin::NONE_NOW_UPDATES_OFF);

  // register the events we gonna offer
  CosNotification::EventTypeSeq added;
  CosNotification::EventTypeSeq removed;

  added.length(1);
  added[0].domain_name = string("Robot_Name").c_str();
  added[0].type_name = string("Event_Name").c_str();
  // remove default offer
  removed.length(1);
  removed[0].domain_name = string("*").c_str();
  removed[0].type_name = string("*").c_str();
  supplier_admin->offer_change(added, removed);

  //----------------------------------------------------------------------------
  // create and connect a supplier class
  
  class MySupplier : public POA_CosNotifyComm::StructuredPushSupplier
  {
  protected:
    void subscription_change(CosNotification::EventTypeSeq const& added,
			     CosNotification::EventTypeSeq const& removed)
      throw(CosNotifyComm::InvalidEventType) {
      cerr << "subscription_change() called" << endl;
    }
    void disconnect_structured_push_supplier() throw() {
      cerr << "disconnect_structured_push_supplier() called" << endl;
    }
  };

  MySupplier * supplier = new MySupplier();

  // activate supplier with poa
  CosNotifyComm::StructuredPushSupplier_var objref = supplier->_this();
  // connect
  proxy_consumer->connect_structured_push_supplier(objref);

  //----------------------------------------------------------------------------
  // sending an event

  CosNotification::StructuredEvent event;
  event.header.fixed_header.event_type.domain_name =
    CORBA::string_dup("Robot_Name");
  event.header.fixed_header.event_type.type_name =
    string("Event_Name").c_str();

  proxy_consumer->push_structured_event(event);

  proxy_consumer->disconnect_structured_push_consumer();
  supplier_admin->destroy();

  return 0;
}
示例#4
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
  {
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    CORBA::Object_var naming_obj =
      orb->resolve_initial_references ("NameService");

    if (CORBA::is_nil(naming_obj.in())) {
      std::cerr << "Unable to find naming service" << std::endl;
      return 1;
    }

    CosNaming::NamingContext_var naming_context =
      CosNaming::NamingContext::_narrow(naming_obj.in());

    CosNaming::Name name(1);
    name.length (1);
    name[0].id = CORBA::string_dup("NotifyEventChannelFactory");

    CORBA::Object_var obj = naming_context->resolve(name);

    CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
      CosNotifyChannelAdmin::EventChannelFactory::_narrow(obj.in());

    if (CORBA::is_nil(notify_factory.in())) {
      std::cerr << "Unable to find notify factory" << std::endl;
      return 1;
    }

    name.length (1);
    name[0].id = CORBA::string_dup("MyEventChannel");
    CORBA::Object_var ecObj = naming_context->resolve(name);

    CosNotifyChannelAdmin::EventChannel_var ec =
      CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());

    if (CORBA::is_nil (ec.in())) {
      std::cerr << "Unable to find event channel" << std::endl;
      return 1;
    }

    CosNotifyChannelAdmin::AdminID adminid;
    CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
      CosNotifyChannelAdmin::AND_OP;

    CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
      ec->new_for_consumers(ifgop,
                            adminid);

    if (CORBA::is_nil (consumer_admin.in())) {
      std::cerr << "Unable to find consumer admin" << std::endl;
      return 1;
    }

    CosNotifyFilter::FilterFactory_var ffact =
      ec->default_filter_factory ();

    // setup a filter at the consumer admin
    CosNotifyFilter::Filter_var ca_filter =
      ffact->create_filter (TCL_GRAMMAR);

    if (CORBA::is_nil (ca_filter.in())) {
      std::cerr << "Unable to create filetr object" << std::endl;
      return 1;
    }

    CosNotifyFilter::ConstraintExpSeq constraint_list (1);
    constraint_list.length (1);
    constraint_list[0].event_types.length (0);
    constraint_list[0].constraint_expr = CORBA::string_dup (CA_FILTER);

    ca_filter->add_constraints (constraint_list);

    consumer_admin ->add_filter (ca_filter.in());

    CosNotification::EventTypeSeq added(1);
    CosNotification::EventTypeSeq removed (0);
    added.length (1);
    removed.length (0);

    added[0].domain_name =  CORBA::string_dup ("*");
    added[0].type_name = CORBA::string_dup ("*");

    consumer_admin->subscription_change (added, removed);

    CORBA::Object_var poa_object =
      orb->resolve_initial_references("RootPOA");

    if (CORBA::is_nil (poa_object.in())) {
      std::cerr << "Unable to initialize the POA." << std::endl;
      return 1;
    }

    PortableServer::POA_var poa =
      PortableServer::POA::_narrow(poa_object.in());

    PortableServer::Servant_var<StructuredEventConsumer_i> servant =
      new StructuredEventConsumer_i(orb.in());
    /*
    CosNotifyComm::StructuredPushConsumer_var consumer =
      servant->_this();
    */

    PortableServer::ObjectId_var oid = poa->activate_object(servant.in());
    CORBA::Object_var consumer_obj = poa->id_to_reference(oid.in());
    CosNotifyComm::StructuredPushConsumer_var consumer =
      CosNotifyComm::StructuredPushConsumer::_narrow(consumer_obj.in());


    CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;

    CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
      consumer_admin->obtain_notification_push_supplier(
                                   CosNotifyChannelAdmin::STRUCTURED_EVENT,
                                   consumeradmin_proxy_id);


    // The proxy that we are connected to.
    CosNotifyChannelAdmin::StructuredProxyPushSupplier_var supplier_proxy;
    supplier_proxy = CosNotifyChannelAdmin::StructuredProxyPushSupplier::
                             _narrow(proxy_supplier.in());

    if (CORBA::is_nil (supplier_proxy.in())) {
      std::cerr << "Unable to create structured push supplier proxy" << std::endl;
      return 1;
    }

    supplier_proxy->connect_structured_push_consumer(consumer.in());

    PortableServer::POAManager_var poa_manager = poa->the_POAManager();

    poa_manager->activate();

    orb->run();
    orb->destroy ();

   }
  catch(const CORBA::Exception& ex) {
    std::cerr << ex << std::endl;
    return 1;
  }
  return 0;
}
示例#5
0
void
TAO_Notify_ThreadPool_Consumer::connect (void)
{
    // Activate the consumer with the default_POA_
    CosNotifyComm::StructuredPushConsumer_var objref = this->_this ();

    CosNotifyChannelAdmin::ProxySupplier_var proxysupplier;

    if (this->proxy_supplier_thread_count_ != 0)
    {
        // Narrow to the extended interface.
        NotifyExt::ConsumerAdmin_var admin_ext = NotifyExt::ConsumerAdmin::_narrow (this->admin_.in ());

        NotifyExt::ThreadPoolParams tp_params = { NotifyExt::CLIENT_PROPAGATED, 0,
                                                  0, static_cast<CORBA::ULong> (this->proxy_supplier_thread_count_),
                                                  0, 0, 0, 0, 0
                                                };

        CosNotification::QoSProperties qos (1);
        qos.length (1);
        qos[0].name = CORBA::string_dup (NotifyExt::ThreadPool);
        qos[0].value <<= tp_params;

        // Obtain the proxy. The QoS is applied to the POA in which the Proxy is hosted.
        proxysupplier = admin_ext->obtain_notification_push_supplier_with_qos (CosNotifyChannelAdmin::STRUCTURED_EVENT
                        , proxy_supplier_id_, qos);
    }
    else
    {
        proxysupplier = this->admin_->obtain_notification_push_supplier (CosNotifyChannelAdmin::STRUCTURED_EVENT
                        , proxy_supplier_id_);
    }

    ACE_ASSERT (!CORBA::is_nil (proxysupplier.in ()));

    // narrow
    this->proxy_supplier_ =
        CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow (proxysupplier.in ());

    ACE_ASSERT (!CORBA::is_nil (proxy_supplier_.in ()));

    this->proxy_supplier_->connect_structured_push_consumer (objref.in ());

    // Call subscription_change to inform the supplier that this consumer is available.
    CosNotification::EventTypeSeq added (1);
    CosNotification::EventTypeSeq removed;

    added.length (1);
    added[0].domain_name = CORBA::string_dup ("TEST_DOMAIN");

    /* We generate a unique Id for the consumer type so that the supplier can distinguish between the consumers.*/
    char type[BUFSIZ];
    ACE_OS::sprintf (type, "TEST_TYPE_%d", this->proxy_supplier_id_);

    added[0].type_name = CORBA::string_dup (type);

    this->proxy_supplier_->subscription_change (added, removed);

    ACE_DEBUG ((LM_DEBUG, "(%P,%t) Created Consumer %d with %d threads at the ProxySupplier\n", proxy_supplier_id_,
                this->proxy_supplier_thread_count_));
}
示例#6
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

      if (parse_args (argc, argv) != 0)
        return 1;

      CORBA::Object_var naming_obj =
        orb->resolve_initial_references ("NameService");

      CosNaming::NamingContext_var naming_context =
        CosNaming::NamingContext::_narrow(naming_obj.in());

      CosNaming::Name name;
      name.length (1);
      name[0].id = CORBA::string_dup("MyEventChannel");
      CORBA::Object_var ecObj = naming_context->resolve(name);

      CosNotifyChannelAdmin::EventChannel_var ec =
        CosNotifyChannelAdmin::EventChannel::_narrow(ecObj.in());

      CosNotifyChannelAdmin::AdminID adminid;
      CosNotifyChannelAdmin::InterFilterGroupOperator ifgop =
        CosNotifyChannelAdmin::AND_OP;

      CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin =
        ec->new_for_consumers(ifgop,
            adminid);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (poa_object.in());

      CORBA::Object_var rtorb_obj = orb->resolve_initial_references ("RTORB");
      RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (rtorb_obj.in ());

      // Create an RT POA with a lane at the given priority.
      CORBA::Policy_var priority_model_policy =
        rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
                DEFAULT_PRIORITY);

      RTCORBA::ThreadpoolLanes lanes (2);
      lanes.length (2);

      lanes[0].lane_priority   = LOW_PRIORITY;
      lanes[0].static_threads  = 2;
      lanes[0].dynamic_threads = 0;
      lanes[1].lane_priority   = HIGH_PRIORITY;
      lanes[1].static_threads  = 2;
      lanes[1].dynamic_threads = 0;


      // Create a thread-pool.
      CORBA::ULong stacksize = 0;
      CORBA::Boolean allow_request_buffering = 0;
      CORBA::ULong max_buffered_requests = 0;
      CORBA::ULong max_request_buffer_size = 0;
      CORBA::Boolean allow_borrowing = 0;

      // Create the thread-pool.
      RTCORBA::ThreadpoolId threadpool_id =
        rt_orb->create_threadpool_with_lanes (stacksize,
                lanes,
                allow_borrowing,
                allow_request_buffering,
                max_buffered_requests,
                max_request_buffer_size);

      // Create a thread-pool policy.
      CORBA::Policy_var lanes_policy =
        rt_orb->create_threadpool_policy (threadpool_id);

      CORBA::PolicyList poa_policy_list(2);
      poa_policy_list.length (2);
      poa_policy_list[0] = priority_model_policy;
      poa_policy_list[1] = lanes_policy;

      PortableServer::POAManager_var poa_manager = poa->the_POAManager ();

      PortableServer::POA_var rt_poa = poa->create_POA ("RT POA",
              poa_manager.in (),
              poa_policy_list);

      PortableServer::Servant_var<StructuredEventConsumer_i> servant =
        new StructuredEventConsumer_i(orb.in());

      PortableServer::ObjectId_var objectId =
        rt_poa->activate_object (servant.in());

      CORBA::Object_var consumer_obj =
        rt_poa->id_to_reference (objectId.in ());

      CosNotifyComm::StructuredPushConsumer_var consumer =
        CosNotifyComm::StructuredPushConsumer::_narrow (consumer_obj.in ());

      NotifyExt::ThreadPoolLanesParams tpl_params;

      tpl_params.priority_model = NotifyExt::CLIENT_PROPAGATED;
      tpl_params.server_priority = DEFAULT_PRIORITY;
      tpl_params.stacksize = 0;
      tpl_params.allow_borrowing = 0;
      tpl_params.allow_request_buffering = 0;
      tpl_params.max_buffered_requests = 0;
      tpl_params.max_request_buffer_size = 0;
      tpl_params.lanes.length (2);
      tpl_params.lanes[0].lane_priority   = LOW_PRIORITY;
      tpl_params.lanes[0].static_threads  = 2;
      tpl_params.lanes[0].dynamic_threads = 0;
      tpl_params.lanes[1].lane_priority   = HIGH_PRIORITY;
      tpl_params.lanes[1].static_threads  = 2;
      tpl_params.lanes[1].dynamic_threads = 0;
      CosNotification::QoSProperties qos;
      qos.length(1);
      qos[0].name = CORBA::string_dup (NotifyExt::ThreadPoolLanes);
      qos[0].value <<= tpl_params;

      consumer_admin->set_qos(qos);
      CORBA::Object_var current_obj =
        orb->resolve_initial_references ("RTCurrent");

      RTCORBA::Current_var current =
        RTCORBA::Current::_narrow (current_obj.in ());
      current->the_priority(HIGH_PRIORITY);

      CosNotifyChannelAdmin::ProxyID consumeradmin_proxy_id;

      CosNotifyChannelAdmin::ProxySupplier_var proxy_supplier =
        consumer_admin->obtain_notification_push_supplier(
          CosNotifyChannelAdmin::STRUCTURED_EVENT,
          consumeradmin_proxy_id);

      CosNotifyChannelAdmin::StructuredProxyPushSupplier_var supplier_proxy;
      supplier_proxy = CosNotifyChannelAdmin::StructuredProxyPushSupplier::
        _narrow(proxy_supplier.in());

      supplier_proxy->connect_structured_push_consumer(consumer.in());

      CosNotification::EventTypeSeq added (1);
      CosNotification::EventTypeSeq removed (1);
      added.length (1);
      removed.length (1);

      added[0].domain_name = CORBA::string_dup ("OCI_TAO");
      added[0].type_name = CORBA::string_dup ("examples");

      removed[0].domain_name = CORBA::string_dup ("*");
      removed[0].type_name = CORBA::string_dup ("*");

      supplier_proxy->subscription_change(added, removed);

      poa_manager->activate();

      // Write a file to let the run_test.pl script know we are ready.
      std::ofstream iorFile( ACE_TEXT_ALWAYS_CHAR(output_file) );
      iorFile << "Ready" << std::endl;
      iorFile.close();

      orb->run();
    }
  catch(const CORBA::Exception& ex)
    {
      std::cerr << "Caught exception: " << ex << std::endl;
        return 1;
    }

  return 0;
}
unsigned int
LogFile::parse()
{
  unsigned int rc = 0;
  ACE_Time_Value timeStamp;
  CosNotification::FixedEventHeader header;

  bool notEof = true;
  while (( logReader_.version() >= 3 &&
              ++counter_ <= logReader_.events() &&
              ( notEof = logReader_.parseTimeStamp(timeStamp) ) ) ||
              ( logReader_.version() < 3 &&
                ( notEof = logReader_.parseTimeStamp(timeStamp) ) ) ) {

    timeVector_.push_back(std::make_pair(timeStamp, logReader_.rdPtr()));

    logReader_.parseEventHeader(header);

    // get domain name slot
    if (strcmp(currentDomainName_,
                (char const *)header.event_type.domain_name) != 0) {
      currentDomainEvents_ =
        eventTypes_.find((char const *)header.event_type.domain_name);
      if (currentDomainEvents_ == eventTypes_.end()) {
        currentDomainEvents_ =
          eventTypes_.insert(std::make_pair((char const *)
                                            CORBA::string_dup(header.event_type.domain_name),
                                            CStringSet())).first;
      }
      currentDomainName_ = currentDomainEvents_->first;
    }
    if (currentDomainEvents_->second.find(header.event_type.type_name) ==
                currentDomainEvents_->second.end())

      currentDomainEvents_->second.insert(CORBA::string_dup(header.event_type.type_name));

    // skip event
    logReader_.skipEventBody();


    // break parsing up to advance status bar
    if (!(timeVector_.size() % 2048))
      break;
  }

  if (timeVector_.size() == 0)
    throw Miro::Exception("Logfile contains no data.");

  // EOF
  if (!notEof ||
              ( logReader_.version() >= 3 && counter_ >= logReader_.events()) ) {
    coursor_ = timeVector_.begin();

    suppliers_.reserve(eventTypes_.size());
    CStringMap::const_iterator first, last = eventTypes_.end();
    for (first = eventTypes_.begin(); first != last; ++first) {
      CosNotifyChannelAdmin::EventChannel_ptr ec =
        channelManager_->getEventChannel(first->first);
      Miro::StructuredPushSupplier * supplier =
        new Miro::StructuredPushSupplier(ec);
      suppliers_.push_back(std::make_pair(first->first, supplier));

      CosNotification::EventTypeSeq offers;
      offers.length(first->second.size());

      CStringSet::const_iterator typeName = first->second.begin();
      for (unsigned int i = 0; i < offers.length(); ++i, ++ typeName) {
        offers[i].domain_name = CORBA::string_dup(first->first);
        offers[i].type_name = CORBA::string_dup(*typeName);
      }
      supplier->setOffers(offers);
      supplier->connect();
    }

    rc = 100;
    parsed_ = true;
  }
  // End Of Work Packet
  else
    rc = logReader_.progress();
  return rc;
}