当前位置: 首页>>代码示例>>C++>>正文


C++ String_var::in方法代码示例

本文整理汇总了C++中corba::String_var::in方法的典型用法代码示例。如果您正苦于以下问题:C++ String_var::in方法的具体用法?C++ String_var::in怎么用?C++ String_var::in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corba::String_var的用法示例。


在下文中一共展示了String_var::in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_i_rh_srv

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

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

      // create, activate and initialize AMI reply handler
      Test_Reply_i test_i_rh_srv(orb.in (),
                                 max_count,
                                 mode_flag);
      PortableServer::ObjectId_var id =
        root_poa->activate_object (&test_i_rh_srv);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      A::AMI_TestHandler_var rh =
        A::AMI_TestHandler::_narrow (object.in ());

      test_i_rh_srv.test_handler ().set_reply_handler (rh.in ());

      // create and activate test servant
      Test_i test_i_srv (orb.in (), rh.in (), max_count, mode_flag);

      id = root_poa->activate_object (&test_i_srv);

      object = root_poa->id_to_reference (id.in ());

      A::Test_var test_var =
        A::Test::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (test_var.in ());

      ACE_DEBUG ((LM_DEBUG, "Servant activated\n"));

      // If the ior_output_file exists, output the ior to it
      if (ior_output_file != 0)
        {
          FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
          if (output_file == 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Cannot open output file for writing IOR: %s",
                               ior_output_file),
                              1);
          ACE_OS::fprintf (output_file, "%s", ior.in ());
          ACE_OS::fclose (output_file);
        }

      poa_manager->activate ();

      A::Test_var opponent;
      do {
        if (mode_flag == A::RM_SLAVE)
          ACE_OS::sleep (ACE_Time_Value (0, 100));

        // get object reference for opponent
        object = orb->string_to_object (input_ior);
        opponent =  A::Test::_narrow (object.in ());
      } while (mode_flag == A::RM_SLAVE && CORBA::is_nil (opponent.in ()));

      if (CORBA::is_nil (opponent.in ()))
      {
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot resolve opponent IOR: %s",
                           input_ior),
                           1);
      }

      // register opponent
      test_i_srv.set_opponent (opponent.in ());
      test_i_rh_srv.test_handler ().set_opponent (opponent.in ());

      // start the show
      if (mode_flag == A::RM_MASTER)
        test_i_rh_srv.test_handler ().start ();

      orb->run ();

      root_poa->destroy (1,  // ethernalize objects
                         0  // wait for completion
                        );
//.........这里部分代码省略.........
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:101,代码来源:main.cpp

示例2: owner_transfer

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

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

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

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

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

      ArrayTest_i *target_servant;
      ACE_NEW_RETURN (target_servant,ArrayTest_i,1);

      PortableServer::ServantBase_var owner_transfer(target_servant);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (target_servant);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      ArrayTest_var atobj =
        ArrayTest::_narrow (object.in ());

      ServerAdmin_i *servant;
      ACE_NEW_RETURN (servant, ServerAdmin_i(atobj.in()),1);

      // safely releases previous reference and takes ownership of this one.
      owner_transfer = servant;

      id = root_poa->activate_object (servant);
      object = root_poa->id_to_reference (id.in ());
      ServerAdmin_var saobj = ServerAdmin::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (saobj.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                              1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:79,代码来源:server.cpp

示例3: owner_transfer

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

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

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

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

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

      CORBA::Object_var tmp =
        orb->string_to_object(ior);

      Test::Oneway_Buffering_Admin_var admin =
        Test::Oneway_Buffering_Admin::_narrow(tmp.in ());

      if (CORBA::is_nil (admin.in ()))
        {
          ACE_ERROR_RETURN ((LM_DEBUG,
                             "Nil Oneway_Buffering_Admin reference <%s>\n",
                             ior),
                            1);
        }

      Oneway_Buffering *oneway_buffering_impl;
      ACE_NEW_RETURN (oneway_buffering_impl,
                      Oneway_Buffering (orb.in (),
                                        admin.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(oneway_buffering_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (oneway_buffering_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Test::Oneway_Buffering_var oneway_buffering =
        Test::Oneway_Buffering::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (oneway_buffering.in ());

      // If the ior_output_file exists, output the ior to it
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught in server:");
      return 1;
    }

  return 0;
}
开发者ID:chenbk85,项目名称:ACE-Middleware,代码行数:85,代码来源:server.cpp

示例4: topicNameFor

std::string MultiTopicDataReaderBase::topicNameFor(DDS::DataReader_ptr reader)
{
  DDS::TopicDescription_var td = reader->get_topicdescription();
  CORBA::String_var topic = td->get_name();
  return topic.in();
}
开发者ID:binary42,项目名称:OCI,代码行数:6,代码来源:MultiTopicDataReaderBase.cpp

示例5: owner_transfer

int
Server_Task::svc (void)
{
  try
    {
      CORBA::Object_var poa_object =
        sorb_->resolve_initial_references ("RootPOA");

      if (CORBA::is_nil (poa_object.in ()))
        {
          ACE_ERROR ((LM_ERROR,
                      " (%P|%t) Unable to initialize the POA\n"));
          return 1;
        }

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

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

      poa_manager->activate ();

      Bug1495_i *server_impl = 0;
      ACE_NEW_RETURN (server_impl,
                      Bug1495_i (sorb_.in ()),
                      0);
      PortableServer::ServantBase_var owner_transfer (server_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (server_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Bug1495_Regression::Bug1495_var bug1495 =
        Bug1495_Regression::Bug1495::_narrow (object.in ());

      CORBA::String_var ior = sorb_->object_to_string (bug1495.in ());

      if (output_ != 0)
        {
          FILE *output_file = ACE_OS::fopen (output_, "w");

          if (output_file == 0)
            {
              ACE_ERROR ((LM_ERROR,
                          "Cannot open output file for writing the "
                          "thread server IOR: %s", output_));
              return 1;
            }

          ACE_OS::fprintf (output_file, "%s", ior.in ());
          ACE_OS::fclose (output_file);
        }

      // sleep for a few seconds and hope the remote server picks up the
      // ior.
      ACE_OS::sleep (5);

      // Signal the manual event to wake the main thread up.
      me_.signal ();

      // The ORB will run for 15 seconds and shut down.
      ACE_Time_Value tv (15, 0);
      sorb_->run (tv);

      ACE_DEBUG ((LM_DEBUG,
                   "Event loop finished for the thread server.\n"));

      root_poa->destroy (1, 1);

      sorb_->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught an exception in server task: ");
      return 1;
    }

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:81,代码来源:Server_Task.cpp

示例6: server_impl

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());
      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

      Simple_Server_i server_impl (orb.in ());

      PortableServer::ObjectId_var id =
        root_poa->activate_object (&server_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Simple_Server_var server =
        Simple_Server::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (server.in ());

      CORBA::Object_var table_object =
        orb->resolve_initial_references("IORTable");

      IORTable::Table_var table =
        IORTable::Table::_narrow (table_object.in ());
      if (CORBA::is_nil (table.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the IORTable.\n"),
                          1);
      table->bind ("Simple_Server", ior.in ());

      ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));

      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
开发者ID:OspreyHub,项目名称:ATCD,代码行数:73,代码来源:server.cpp

示例7: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Auto_Ptr< sig_i > sig_impl;
  int status = 0;
  try
  {
    Supplier_Client client;
    status = client.init (argc, argv);

    if (status == 0)
    {
      CosNotifyChannelAdmin::EventChannel_var ec =
        client.create_event_channel ("MyEventChannel", 0);

      CORBA::ORB_ptr orb = client.orb ();

      sig_impl.reset( new sig_i( orb ) );
      sig_var sig = sig_impl->_this ();

      CORBA::String_var ior =
        orb->object_to_string (sig.in ());

      // If the ior_output_file exists, output the ior to it
      if (ior_output_file != 0)
      {
        FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
        if (output_file == 0)
          ACE_ERROR_RETURN ((LM_ERROR,
          "Cannot open output file %s for "
          "writing IOR: %C",
          ior_output_file,
          ior.in ()),
          1);
        ACE_OS::fprintf (output_file, "%s", ior.in ());
        ACE_OS::fclose (output_file);
      }

      CosNotifyChannelAdmin::SupplierAdmin_var admin =
        create_supplieradmin (ec.in ());
      if (!CORBA::is_nil (admin.in ()))
      {
        create_suppliers(admin.in (), client.root_poa ());

        sig_impl->wait_for_startup();

        ACE_DEBUG((LM_DEBUG, "1 supplier sending %d events...\n", max_events));
        for (int i = 0; i < max_events; ++i)
        {
          SendEvent (i);
        }
        ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", max_events));

        sig_impl->wait_for_completion();

        ACE_OS::unlink (ior_output_file);

        ec->destroy();
      }
    }
  }
  catch (const CORBA::Exception& e)
  {
    e._tao_print_exception ("Error: Supplier exception: ");
    status = 1;
  }

  return status;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:68,代码来源:Structured_Supplier.cpp

示例8: catch

//////////////////
// Internal method
void
TAO::PG_Object_Group::distribute_iogr (void)
{
  // Check if the object group is configured to distribute
  if (!this->distribute_)
    return;

  // assume internals is locked
  CORBA::String_var iogr =
    this->orb_->object_to_string (this->reference_.in());

//  size_t n_rep = 0; // for dump_ior below
  for (MemberMap_Iterator it = this->members_.begin();
       it != this->members_.end ();
       ++it)
    {
      MemberInfo const * info = (*it).int_id_;
      //
      // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface
      // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_);
      // but it doesn work: error message at replica is:
      // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0]
      // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed
      // back to using _narrow
      PortableGroup::TAO_UpdateObjectGroup_var uog =
        PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_.in ());
      if (!CORBA::is_nil (uog.in ()))
        {
          try
            {
              if (TAO_debug_level > 3)
                {
                  ORBSVCS_DEBUG ((LM_DEBUG,
                              "PG (%P|%t) -  Object_Group pushing "
                              "IOGR to %s member: %[email protected]%s.\n",
                              (info->is_primary_ ? "Primary" : "Backup"),
                              this->role_.c_str (),
                              static_cast<const char *> (info->location_[0].id)
                              ));
                }
              //        dump_ior ("group", "iogr", this->tagged_component_.object_group_ref_version, iogr);
              //        CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in());
              //        dump_ior (info->location_[0].id, "ior", (this->tagged_component_.object_group_ref_version * 100) + n_rep++, replica_ior);
              uog->tao_update_object_group (iogr.in (),
                                            this->tagged_component_.object_group_ref_version,
                                            info->is_primary_);
            }
          catch (const CORBA::Exception&)
            {
              // we expect an exception
              // tao_update_object_group is not a real method
            }
        }
      else
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      "TAO::PG_Object_Group::distribute iogr can't "
                      "narrow member reference to "
                      "PortableGroup::TAO_UpdateObjectGroup.\n"
                      ));
        }
    }
}
开发者ID:bjovke,项目名称:ACE_TAO,代码行数:65,代码来源:PG_Object_Group.cpp

示例9: receiver_owner_transfer

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

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

      Sender_i *sender_impl;
      ACE_NEW_RETURN (sender_impl,
                      Sender_i (orb.in ()),
                      1);
      PortableServer::ServantBase_var receiver_owner_transfer(sender_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (sender_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Test::Sender_var sender =
        Test::Sender::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (sender.in ());

      // If the ior_output_file exists, output the ior to it
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                              1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      Server_Task server_task (orb.in (),
                               ACE_Thread_Manager::instance ());

      if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1) == -1)
        {
          ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
        }
      ACE_Thread_Manager::instance ()->wait ();

      ACE_DEBUG ((LM_DEBUG, "Now terminating test\n"));

      CORBA::ULong activeobjects = sender_impl->get_active_objects ();
      if (((number_of_oneways * activeobjects) !=
            sender_impl->get_number_received ()) && activeobjects != 0)
        {
          ACE_ERROR ((LM_ERROR, "Error, expected %d oneways, received %d\n",
                      number_of_oneways,
                      sender_impl->get_number_received()));
        }
      else
        {
          if (sender_impl->get_number_received () == 0)
            {
              ACE_ERROR ((LM_ERROR, "Error: Received no calls\n"));
            }
          else
            {
              ACE_DEBUG ((LM_DEBUG, "Corrected amount received\n"));
            }
        }

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:97,代码来源:server.cpp

示例10: ACE_TMAIN

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    int status = 0;
    ACE_Auto_Ptr< sig_i > sig_impl;
    try
    {
        Supplier_Client client;
        status = client.init (argc, argv);

        if (status == 0)
        {
            static const char* ec_name = "MyEventChannel";
            CosNotifyChannelAdmin::EventChannel_var ec =
                client.create_event_channel (ec_name, 0);

            static const int max = 20;
            int count = 0;
            while(ACE_OS::access(ACE_TEXT_ALWAYS_CHAR(notify2ior), R_OK) == -1 && count < max)
            {
                ACE_OS::sleep (1);
                count++;
            }
            if (count >= max)
            {
                ACE_ERROR_RETURN ((LM_ERROR,
                                   "ERROR: Timed out waiting for the "
                                   "second notify service\n"),
                                  1);
            }
            ACE_OS::sleep (2);

            // Due to the way that connections are handled, we need to
            // perform the new event channel creation twice to flush out
            // the connection to the first notification service
            try
            {
                ec = client.create_event_channel (ec_name, 0);
            }
            catch (const CORBA::TRANSIENT&)
            {
            }
            catch (const CORBA::COMM_FAILURE&)
            {
            }

            ec = client.create_event_channel (ec_name, 0);

            CORBA::ORB_ptr orb = client.orb ();

            // Activate the signaler with the POA
            sig_impl.reset( new sig_i( orb ) );
            sig_var sig = sig_impl->_this ();

            CORBA::String_var ior =
                orb->object_to_string (sig.in ());

            // If the ior_output_file exists, output the ior to it
            if (ior_output_file != 0)
            {
                FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
                if (output_file == 0)
                    ACE_ERROR_RETURN ((LM_ERROR,
                                       "Cannot open output file %s for "
                                       "writing IOR: %C",
                                       ior_output_file,
                                       ior.in ()),
                                      1);
                ACE_OS::fprintf (output_file, "%s", ior.in ());
                ACE_OS::fclose (output_file);
            }

            CosNotifyChannelAdmin::SupplierAdmin_var admin =
                create_supplieradmin (ec.in ());
            if (!CORBA::is_nil (admin.in ()))
            {
                create_suppliers (admin.in (), client.root_poa ());

                sig_impl->wait_for_startup();

                ACE_DEBUG((LM_DEBUG, "1 supplier sending %d events...\n", max_events));
                for (int i = 0; i < max_events; ++i)
                {
                    ACE_DEBUG((LM_DEBUG, "+"));
                    SendEvent (i);
                }
                ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", max_events));

                sig_impl->wait_for_completion();

                ACE_OS::unlink (ior_output_file);

                supplier_1->disconnect();

                ec->destroy();
            }
        }
    }
    catch (const CORBA::Exception& e)
    {
        e._tao_print_exception ("Error: ");
//.........这里部分代码省略.........
开发者ID:akostrikov,项目名称:ATCD,代码行数:101,代码来源:Structured_Supplier.cpp

示例11: owner_transfer

int
ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  int status = 0;

#if defined (TAO_HAS_MONITOR_FRAMEWORK) && (TAO_HAS_MONITOR_FRAMEWORK == 1)

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

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

      CORBA::Object_var obj =
        orb->string_to_object (monitor_ior);
      CosNotification::NotificationServiceMonitorControl_var nsm =
        CosNotification::NotificationServiceMonitorControl::_narrow (obj.in ());

      if (CORBA::is_nil (nsm.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Monitor: Unable to locate the "
                             "Notification Service Monitor\n"),
                            1);
        }

      MonitorTestInterface_i* mti = 0;
      ACE_NEW_RETURN (mti, MonitorTestInterface_i (nsm.in ()), 1);
      PortableServer::ServantBase_var owner_transfer (mti);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");
      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      PortableServer::ObjectId_var id = root_poa->activate_object (mti);
      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      MonitorTestInterface_var test =
        MonitorTestInterface::_narrow (object.in ());
      CORBA::String_var ior = orb->object_to_string (test.in ());

      // Test the case where there are no consumers or suppliers first
      // before we write out our IOR
      mti->running (MonitorTestInterface::NotifyService);

      FILE *output_file= ACE_OS::fopen (ACE_TEXT_ALWAYS_CHAR(ior_output_file), ACE_TEXT ("w"));

      if (output_file == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Cannot open output file for writing IOR: %s\n",
                             ior_output_file),
                             1);
        }

      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();
      poa_manager->activate ();

      orb->run ();
      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("test_monitor: ");
      status++;
    }

#else
  ACE_UNUSED_ARG (argc);
  ACE_UNUSED_ARG (argv);
#endif /* TAO_HAS_MONITOR_FRAMEWORK==1 */

  return status;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:82,代码来源:test_monitor.cpp

示例12: policies

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

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

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

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

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

      // Make all oneways "reliable."
      {
        CORBA::Object_var manager_object =
          orb->resolve_initial_references("ORBPolicyManager");
        CORBA::PolicyManager_var policy_manager =
          CORBA::PolicyManager::_narrow(manager_object.in());

        if (CORBA::is_nil (policy_manager.in ()))
          ACE_ERROR_RETURN ((LM_ERROR,
                             " (%P|%t) Panic: nil PolicyManager\n"),
                            1);
        CORBA::Any policy_value;
        policy_value <<= Messaging::SYNC_WITH_SERVER;
        CORBA::PolicyList policies(1); policies.length(1);
        policies[0] =
          orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
                              policy_value);

        policy_manager->set_policy_overrides (policies,
                                              CORBA::ADD_OVERRIDE);

        policies[0]->destroy ();
      }

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

      Service *service_impl;
      ACE_NEW_RETURN (service_impl,
                      Service(orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(service_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (service_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Test::Service_var service =
        Test::Service::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (service.in ());

      // If the ior_output_file exists, output the ior to it
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                              1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "Event loop finished\n"));

      service_impl->dump_results ();

      root_poa->destroy (1, 1);

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:96,代码来源:server.cpp

示例13: writing

// Initialize the server.
template <class Servant> int
Server<Servant>::init (const char *servant_name,
                       int argc,
                       ACE_TCHAR *argv[])
{
  // Call the init of <TAO_ORB_Manager> to initialize the ORB and
  // create a child POA under the root POA.
  if (this->orb_manager_.init_child_poa (argc,
                                         argv,
                                         "child_poa") == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       ACE_TEXT ("init_child_poa")),
                      -1);

  this->argc_ = argc;
  this->argv_ = argv;

  int retval = this->parse_args ();

  if (retval != 0)
    return retval;

  CORBA::ORB_var orb = this->orb_manager_.orb ();

  // Stash our ORB pointer for later reference.
  this->servant_->orb (orb.in ());

  if (this->naming_ == 1)
    {
      // Call naming service
      if (this->register_name (servant_name) == -1)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("\n Naming Service\n")),
                          -1);

      return 0;
    }

  // Activate the servant in its own child POA.

  // Make sure that you check for failures here via the try?!
  try
    {
      CORBA::String_var str  =
        this->orb_manager_.activate_under_child_poa (servant_name,
                                                     this->servant_.in ());

      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("The IOR is: <%C>\n"),
                  str.in ()));

      if (this->ins_ && this->test_for_ins (str.in ()) != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           ACE_TEXT ("test_for_ins (): failed\n")),
                          -1);

      if (this->ior_output_file_)
        {
          FILE *fh = ACE_OS::fopen (this->ior_output_file_, "w");
          if (fh == 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("Unable to open %s for writing (%p)\n"),
                               this->ior_output_file_,
                               ACE_TEXT ("fopen")),
                              -1);
          ACE_OS::fprintf (fh, "%s", str.in ());
          ACE_OS::fclose (fh);
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("\tException in activation of POA");
      return -1;
    }

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:79,代码来源:Simple_util.cpp

示例14: servant

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      Server_ORBInitializer *temp_initializer = 0;
      ACE_NEW_RETURN (temp_initializer,
                      Server_ORBInitializer,
                      -1);  // No exceptions yet!
      PortableInterceptor::ORBInitializer_var orb_initializer =
        temp_initializer;

      PortableInterceptor::register_orb_initializer (orb_initializer.in ());

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

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

      if (CORBA::is_nil (poa_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize the POA.\n"),
                          1);

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

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

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

      test_i servant (orb.in ());

      PortableServer::ObjectId_var id =
        root_poa->activate_object (&servant);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      CORBA::Object_var obj = CORBA::Object::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (obj.in ());

      ACE_DEBUG ((LM_DEBUG,
                  "Servant:\n<%C>\n",
                  ior.in ()));

      poa_manager->activate ();

      // Write IOR to a file.
      FILE *output_file= ACE_OS::fopen (ior_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file <%s> for writing "
                           "IOR: %C",
                           ior_file,
                           ior.in ()),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      // Run the ORB event loop.
      orb->run ();

      root_poa->destroy (1, 1);

      orb->destroy ();

      ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n"));
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Caught exception:");
      return -1;
    }

  return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:81,代码来源:server.cpp

示例15: catch

  void
  Receiver_exec_i::get_one (void)
  {
    ShapeType_var shape_info;
    ::CCM_DDS::ReadInfo_var readinfo;

    try
      {
        ::Shapes::Getter_var getter =
          this->ciao_context_->get_connection_info_get_fresh_data ();
        if (! ::CORBA::is_nil (getter.in ()))
          {
            ::CORBA::Object_var cmp = getter->_get_component ();
            if (::CORBA::is_nil (cmp.in ()))
              {
                ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::get_one - "
                                      "Unable to get component interface\n"));
                throw ::CORBA::INTERNAL ();
              }
            ::Shapes::CCM_DDS_Event_var conn =
              ::Shapes::CCM_DDS_Event::_narrow (cmp.in ());
            if (::CORBA::is_nil (conn.in ()))
              {
                ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::get_one - "
                                      "Unable to narrow connector interface\n"));
                throw ::CORBA::INTERNAL ();
              }
            CORBA::String_var topic = conn->topic_name ();

            if (getter->get_one (shape_info.out (), readinfo.out ()))
              {
                ACE_Time_Value time;
                time <<= readinfo->source_timestamp;
                ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("GET_ONE ReadInfo -> ")
                                      ACE_TEXT ("date = %#T\n"), &time));
                ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("GET_ONE ShapeType : ")
                    ACE_TEXT ("received shape_info <%C> for <%C> at X <%u> Y <%u> size <%u>\n"),
                    topic.in (),
                    shape_info->color.in (),
                    shape_info->x,
                    shape_info->y,
                    shape_info->shapesize));
              }
            else
              {
                ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("GET_ONE No data available for <%C>\n"),
                        shape_info->color.in ()));
              }
          }
        else
          {
            ACE_ERROR ((LM_ERROR, "Receiver_exec_i::get_one - "
                      "ERROR: Getter seems nil\n"));
          }
      }
    catch(const CCM_DDS::NonExistent& )
      {
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("ShapeType_Read_One: no shape_info receieved\n")));
      }

  }
开发者ID:CCJY,项目名称:ATCD,代码行数:61,代码来源:Shapes_Receiver_exec.cpp


注:本文中的corba::String_var::in方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。