Пример #1
0
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  Aggregator manager;

  try
    {
      ACE_Argv_Type_Converter converter (argc, argv);
      // Initilaize the ORB, POA etc.
      manager.init (converter.get_argc(), converter.get_ASCII_argv());

      // the command line arguments
      if (parse_args (argc, argv) == -1)
        return -1;

      // Merge the different IORS
      manager.make_merged_iors ();

      // Set properties. This is the most important portion of the
      // test
      manager.set_properties ();

      // Write IOR to file
      manager.write_to_file ();
    }
  catch (const CORBA::Exception& e)
    {
      e._tao_print_exception(ACE_TEXT("Caught"));
      return -1;
    }

  return 0;
}
Пример #2
0
void testQtReactor (int argc, ACE_TCHAR *argv[])
{
  // Qt specific code
  ACE_DEBUG ((LM_INFO, ACE_TEXT ("Testing QtReactor\n")));

  ACE_Argv_Type_Converter ct (argc, argv);
  QTestApplication app (argc, ct.get_ASCII_argv ());

  ACE_QtReactor    qtReactor (&app);
  ACE_Reactor      reactor (&qtReactor);
  HandlersRegister handlersRegister (&reactor);
  ACE_Time_Value   testTime (TotalTestTime / 1000, (TotalTestTime % 1000) * 1000);

  if (0 <= handlersRegister.scheduleTimers (testTime)  &&
      0 <= handlersRegister.registerDgramHandlers () &&
      0 <= handlersRegister.registerTCPHandlers ())
    {

      app.exec (TotalTestTime);

      if (0  != handlersRegister.analyze ())
        ACE_ERROR ((LM_ERROR, ACE_TEXT ("QtReactor_Test failed.\n")));
      else
        ACE_ERROR ((LM_INFO, ACE_TEXT ("QtReactor_Test passed.\n")));
    }
}
Пример #3
0
int
Supplier_Client::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_Argv_Type_Converter argcon (argc, argv);
  ACE_Get_Opt get_opts (argcon.get_argc (),
                        argcon.get_TCHAR_argv (), ACE_TEXT ("o:"));
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
  {
    case 'o':
      ior_output_file = get_opts.optarg;
      break;

    default:
      ACE_ERROR_RETURN ((LM_ERROR,
        "usage: %s "
        "-o <iorfile> "
        "\n",
        argv [0]),
        -1);
  }

  // Indicates successful parsing of the command line
  return 0;
}
Пример #4
0
// main entry point
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Argv_Type_Converter atc (argc, argv);
  walkapp get (atc.get_argc (), atc.get_ASCII_argv ());
  if (get.valid())
     return get.run();
  else
    walkapp::usage();
  return 1;
}
Пример #5
0
static int
test_argv_type_converter (void)
{
  char *argv[20];
  argv[0] = ACE_OS_String::strdup ("one");
  argv[1] = ACE_OS_String::strdup ("two");
  argv[2] = ACE_OS_String::strdup ("three");
  argv[3] = ACE_OS_String::strdup ("four");
  argv[4] = 0;

  char *save_argv[20];
  ACE_OS_String::memcpy (save_argv, argv, sizeof (argv));

  int argc = 4;

  {
    ACE_Argv_Type_Converter ct2 (argc, argv);
  }

  {
    ACE_Argv_Type_Converter ct (argc, argv);
    ct.get_argc (); ct.get_TCHAR_argv ();
    consume_arg ( ct.get_argc (), ct.get_TCHAR_argv ());
  }
  {
    ACE_Argv_Type_Converter ct3 (argc, argv);
    ct3.get_argc (); ct3.get_ASCII_argv ();
    consume_arg ( ct3.get_argc (), ct3.get_TCHAR_argv ());
  }

  {
    for (size_t i = 0; i < 4; i++)
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT (" (%d) %C\n"),
                  i,
                  argv[i]));
  }

  for (size_t i = 0; save_argv[i]; ++i)
    ACE_OS_Memory::free (save_argv[i]);

  return 0;
}
Пример #6
0
void
SubDriver::init(int& argc, ACE_TCHAR* argv[])
{
  // initialize the orb
  ACE_Argv_Type_Converter conv (argc, argv);
  orb_ = CORBA::ORB_init (conv.get_argc (),
                          conv.get_ASCII_argv (),
                          OpenDDS::DCPS::DEFAULT_ORB_NAME);

  TheServiceParticipant->set_ORB (orb_.in());

  OpenDDS::DCPS::TransportImpl_rch transport_impl
    = TheTransportFactory->create_transport_impl (ALL_TRAFFIC, ACE_TEXT("SimpleTcp"), OpenDDS::DCPS::DONT_AUTO_CONFIG);

  OpenDDS::DCPS::TransportConfiguration_rch config
    = TheTransportFactory->create_configuration (ALL_TRAFFIC, ACE_TEXT("SimpleTcp"));

  OpenDDS::DCPS::SimpleTcpConfiguration* tcp_config
    = static_cast <OpenDDS::DCPS::SimpleTcpConfiguration*> (config.in ());

  tcp_config->local_address_ = this->sub_addr_;
  tcp_config->local_address_str_ = this->sub_addr_str_;

  if (transport_impl->configure(config.in ()) != 0)
    {
      ACE_ERROR((LM_ERROR,
                 "(%P|%t) Failed to configure the transport impl\n"));
      throw TestException();
    }

  // Indicate that the subscriber is ready to accept connection
  FILE* readers_ready = ACE_OS::fopen (sub_ready_filename_.c_str (), ACE_TEXT("w"));
  if (readers_ready == 0)
  {
    ACE_ERROR ((LM_ERROR,
      ACE_TEXT("(%P|%t) ERROR: Unable to create subscriber ready file\n")));
  }
  else
    ACE_OS::fclose(readers_ready);
  // And we are done with the init().
}
Пример #7
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  if (parse_args (argc,
                  argv) == -1)
    return -1;

  try
    {
      ACE_Argv_Type_Converter satc (argc, argv);
      CORBA::ORB_var sorb =
        CORBA::ORB_init (satc.get_argc (),
                         satc.get_TCHAR_argv (),
                         server_orb.c_str ());

      ACE_Manual_Event me;
      Server_Task server_task (output,
                               sorb.in (),
                               me,
                               ACE_Thread_Manager::instance ());

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

      // Wait for the server thread to do some processing
      me.wait ();

      ACE_Argv_Type_Converter catc (argc, argv);
      CORBA::ORB_var corb =
        CORBA::ORB_init (catc.get_argc (),
                         catc.get_TCHAR_argv (),
                         client_orb.c_str ());

      Client_Task client_task (input,
                               corb.in (),
                               syncMode,
                               ACE_Thread_Manager::instance ());

      if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
                                1,
                                1) == -1)
        {
          ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
        }

      ACE_Thread_Manager::instance ()->wait ();
    }
  catch (const CORBA::Exception&)
    {
      // Ignore exceptions..
    }
  return 0;
}
Пример #8
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  if (parse_args (argc,
                  argv) == -1)
    return -1;

  try
    {
      ACE_Argv_Type_Converter satc (argc, argv);
      CORBA::ORB_var sorb =
        CORBA::ORB_init (satc.get_argc (),
                         satc.get_TCHAR_argv (),
                         server_orb.c_str ());

      ACE_Manual_Event me;
      Server_Task server_task (output,
                               simple_test_output,
                               sorb.in (),
                               me,
                               ACE_Thread_Manager::instance ());

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

      // Wait for the server thread to do some processing
      me.wait ();

      ACE_Argv_Type_Converter catc (argc, argv);
      CORBA::ORB_var corb =
        CORBA::ORB_init (catc.get_argc (),
                         catc.get_TCHAR_argv (),
                         client_orb.c_str ());

      Client_Task client_task (input,
                               simple_test_input,
                               corb.in (),
                               ACE_Thread_Manager::instance ());

      if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
                                1,
                                1) == -1)
        {
          ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
        }

      // Wait for the client and server to finish
      ACE_Thread_Manager::instance ()->wait ();

      // Now that all threads have completed we can destroy the ORB
      sorb->destroy ();
      if (server_orb != client_orb)
        {
          corb->destroy ();
        }

      CORBA::ULong errors = client_task.error_count () + server_task.error_count ();
      if (errors == 0)
        {
          ACE_DEBUG((LM_DEBUG, "(%P|%t) test passed\n"));
        }
      else
        {
          ACE_DEBUG((LM_DEBUG, "(%P|%t) test failed - error_count=%u\n", errors));
          return 1;
        }
    }
  catch (const CORBA::Exception&)
    {
      // Ignore exceptions..
    }
  return 0;
}
Пример #9
0
int run_main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("FlReactor_Test"));

  Fl_Window window (300, 370);

  Test_Window tw (10, 75, window.w () - 20, window.h ()-90);
  window.resizable (&tw);

  Fl_Hor_Slider slider (60, 5, window.w () - 70, 30, "Sides:");
  slider.align (FL_ALIGN_LEFT);
  slider.callback (sides_cb, &tw);
  slider.value (tw.sides ());
  slider.step (1);
  slider.bounds (3, 10);

  ACE_FlReactor reactor;
  ACE_Reactor r (&reactor);

  Fl_Box *box = new Fl_Box (FL_UP_BOX, 10, 40,
                            window.w () - 20, 30,
                            "Setting up");
  box->labelfont (FL_BOLD);

  Acceptor acceptor (&tw, box);

  ACE_INET_Addr address;

  if (acceptor.open (address, &r) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n",
                       "open acceptor"),
                      -1);

  acceptor.acceptor ().get_local_addr (address);

  const int bufsiz = 128;
  ACE_TCHAR buf[bufsiz];

  address.addr_to_string (buf, bufsiz, 0);

  char msg[2 * bufsiz];
  ACE_OS::sprintf (msg, "Listening on <%s>\n",
                   ACE_TEXT_ALWAYS_CHAR (buf));

  box->label (msg);
  box->redraw ();

  window.end ();

  ACE_Argv_Type_Converter ct (argc, argv);

  window.show (argc, ct.get_ASCII_argv ());
  tw.show ();

  int const retval = Fl::run ();

  ACE_END_TEST;

  return retval;
}
Пример #10
0
int
DllORB::init (int argc, ACE_TCHAR *argv[])
{
  int threadCnt = 1;

  try
    {
      ACE_Arg_Shifter as (argc, argv);
      const ACE_TCHAR *currentArg = 0;
      while (as.is_anything_left ())
        {
          if ((currentArg = as.get_the_parameter (ACE_TEXT ("-NumThreads"))))
            {
              int num = ACE_OS::atoi (currentArg);
              if (num >= 1)
                threadCnt = num;
              as.consume_arg ();
            }
        else
          as.ignore_arg ();
        }

      if (failPrePostInit_ < 3)
        {
          ACE_DEBUG ((LM_INFO,
                      ACE_TEXT ("Pre-ORB initialization ...\n")));
          // -----------------------------------------------------------------
          // Pre-ORB initialization steps necessary for proper DLL ORB
          // support.
          // -----------------------------------------------------------------
          // Make sure TAO's singleton manager is initialized, and set to not
          // register itself with the ACE_Object_Manager since it is under the
          // control of the Service Configurator.  If we register with the
          // ACE_Object_Manager, then the ACE_Object_Manager will still hold
          // (dangling) references to instances of objects created by this
          // module and destroyed by this object when it is dynamically
          // unloaded.
          int register_with_object_manager = 0;
          TAO_Singleton_Manager * p_tsm = TAO_Singleton_Manager::instance ();
          int result = p_tsm->init (register_with_object_manager);

          if (result == -1)
            {
              if (failPrePostInit_ == 0)
                {
                  ACE_DEBUG ((LM_ERROR,
                              ACE_TEXT ("Pre-ORB initialization failed.\n")));
                  return -1;
                }
              else if (failPrePostInit_ < 2)
                {
                  ACE_DEBUG ((LM_WARNING,
                              ACE_TEXT ("Pre-ORB initialization failed (ignored due to FailPrePostInit setting).\n")));
                }
              else
                {
                  ACE_DEBUG ((LM_INFO,
                              ACE_TEXT ("Pre-ORB initialization failed (ignored due to FailPrePostInit setting).\n")));
                }
            }
          else
            {
              ACE_DEBUG ((LM_INFO,
                          ACE_TEXT ("Pre-ORB initialization done.\n")));
            }
        }

      // Initialize the ORB
      ACE_Argv_Type_Converter argcon (argc, argv);
      mv_orb_ = CORBA::ORB_init (argcon.get_argc (), argcon.get_TCHAR_argv ());
      if (CORBA::is_nil (mv_orb_.in ()))
        {
          ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil ORB\n")));
          return -1;
        }

      CORBA::Object_var v_poa =
        mv_orb_->resolve_initial_references ("RootPOA");

      mv_rootPOA_ = PortableServer::POA::_narrow (v_poa.in ());
      if (CORBA::is_nil (mv_rootPOA_.in ()))
        {
          ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil RootPOA\n")));
          return -1;
        }

      mv_poaManager_ = mv_rootPOA_->the_POAManager ();
      if (CORBA::is_nil (mv_poaManager_.in ()))
        {
          ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil POAManager\n")));
          return -1;
        }

      mv_poaManager_->activate ();
    }
  catch (...)
  {
    ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: exception\n")));
    return -1;
  }

  mp_barrier_ = new ACE_Thread_Barrier (threadCnt + 1);

  this->activate (THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, threadCnt);
  mp_barrier_->wait ();

  return 0;
}
Пример #11
0
// ****************************************************************
/// Note that the argument vector will be corrupted upon return
int
TAO::ORB::open_global_services (int argc, ACE_TCHAR **argv)
{
  {
    // Count of the number of (times we did this for all) ORBs.
    static int orb_init_count = 0;

    // Using ACE_Static_Object_Lock::instance() precludes ORB_init()
    // from being called within a static object CTOR.
    ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
            guard,
            *ACE_Static_Object_Lock::instance (),
            -1));

    // Make sure TAO's singleton manager is initialized.
    // We need to initialize before TAO_default_environment() is called
    // since that call instantiates a TAO_TSS_Singleton.
    if (TAO_Singleton_Manager::instance ()->init () == -1)
      return -1;

    // Prevent multiple initializations.
    if (++orb_init_count > 1)
      return 0;
  }

  // Prevent any other thread from going through ORB initialization before the
  // uber-gestalt is initialized.
  ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
          guard,
          TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
          -1));

  if (TAO_debug_level > 2)
    {
      TAOLIB_DEBUG ((LM_DEBUG,
      ACE_TEXT ("TAO (%P|%t) Initializing the ")
      ACE_TEXT ("process-wide service context\n")));
    }

  ACE_Service_Gestalt* theone = ACE_Service_Config::global ();
  ACE_Service_Config_Guard auto_config_guard (theone);

  // Construct an argument vector specific to the process-wide
  // (global) Service Configurator instance.
  // Be certain to copy the program name so that service configurator
  // has something to skip!
  ACE_ARGV global_svc_config_argv (true); // only this ctor allows
  // subsequent use of add()!
  global_svc_config_argv.add ((argc <= 0 || argv == 0) ?
            ACE_TEXT ("") : argv[0], true);

  // Will expand the environment variables, if any were used.
  // Is this a good thing? I guess it provides greater flexibility
  // for deployment,so let's leave it. Will also quote arguments.
  ACE_ARGV copyargv (argc, argv, true, true);

  // Adjust to proper type
  int tmpargc = copyargv.argc (); // use copied count, not original
  ACE_Argv_Type_Converter cvtargv (tmpargc, copyargv.argv());

  tmpargc = cvtargv.get_argc ();
  ACE_TCHAR **tmpargv = cvtargv.get_TCHAR_argv ();

  // Collect global SC parameters. True means "immediately
  // apply global setting" like debug flag, etc.
  if (parse_global_args_i (tmpargc,
         tmpargv,
         global_svc_config_argv,
         true) == -1)
    return -1;

  bool skip_service_config_open = false; // by default we shouldn't

  if (using_global_gestalt_i (tmpargc,
                              tmpargv,
                              skip_service_config_open))
    {
      if (parse_svcconf_args_i (tmpargc,
              tmpargv,
              global_svc_config_argv) == -1)
        return -1;
    }

  bool ignore_default_svc_conf_file = false;

  if (parse_private_args_i (tmpargc,
          tmpargv,
          global_svc_config_argv,
          skip_service_config_open,
          ignore_default_svc_conf_file) == -1)
    return -1;

  // register_global_services_i depends on the parsing of at least the
  // -ORBNegotiateCodesets option, and must be invoked after all the
  // parsing methods, but still must preceed the opening of other services.

  register_global_services_i (theone);

  // Perform the open magic (unless SC::open() has been called already)
  int global_svc_config_argc = global_svc_config_argv.argc ();
  int status = open_private_services_i (theone,
                                        global_svc_config_argc,
                                        global_svc_config_argv.argv (),
                                        skip_service_config_open,
                                        ignore_default_svc_conf_file);

  // okay?
  if (status == -1)
    {
      if (errno != ENOENT)
        {
          if (TAO_debug_level > 0)
            {
              TAOLIB_ERROR ((LM_ERROR,
                          ACE_TEXT ("TAO (%P|%t) - Failed to open process-")
                          ACE_TEXT ("wide service configuration context\n")));
            }
          return -1;
        }
      else
        {
          if (TAO_debug_level > 4)
            TAOLIB_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("TAO (%P|%t) - Did not find default ")
                        ACE_TEXT ("svc.conf\n")));
          status = 0;
        }
    }

  if (status > 0)
    {
      // one or more directives failed, but we don't know which
      if (TAO_debug_level > 0)
        {
          TAOLIB_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - process-wide service ")
                      ACE_TEXT ("configuration context had %d failed ")
                      ACE_TEXT ("directives\n"), status));
        }
    }

  if (TAO_debug_level > 2)
    TAOLIB_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO (%P|%t) - Completed initializing the ")
                ACE_TEXT ("process-wide service context\n")));

  if (TAO_debug_level > 4)
    TAOLIB_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO (%P|%t) - Default ORB services initialization begins\n")));

  // Load more ORB-related services
  register_additional_services_i (theone);

  if (TAO_debug_level > 4)
    TAOLIB_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO (%P|%t) - Default ORB services initialization completed\n")));

  // Notify all other threads that may be waiting, that the global
  // gestalt has been initialized.
  is_ubergestalt_ready = true;
  ACE_MT (if (TAO_Ubergestalt_Ready_Condition::instance ()->
              broadcast () == -1)
            return -1);

  return 0;
}
Пример #12
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
    if (parse_args (argc,
                    argv) == -1)
        return -1;

    try
    {
        // Keep a copy of the ORB options args
        ACE_ARGV orb_args;
        for (int i = 1; i < argc; ++i)
        {
            if (orb_args.add (argv[i]) == -1)
                return -1;
        }

        ACE_Argv_Type_Converter satc (argc, argv);
        // This eats all orb-specific options!
        CORBA::ORB_var sorb =
            CORBA::ORB_init (satc.get_argc (),
                             satc.get_TCHAR_argv (),
                             server_orb.c_str ());

        ACE_Manual_Event me;
        Server_Task server_task (output,
                                 sorb.in (),
                                 me,
                                 ACE_Thread_Manager::instance ());

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

        // Wait for the server thread to do some processing
        me.wait ();

        // Restore the orb-specific options.
        argc = orb_args.argc ();
        for (int i = 1; i < argc; ++i)
        {
            argv[i] = const_cast<ACE_TCHAR*> (orb_args[i]);
        }
        ACE_Argv_Type_Converter catc (argc, argv);
        CORBA::ORB_var corb =
            CORBA::ORB_init (catc.get_argc(),
                             catc.get_TCHAR_argv(),
                             client_orb.c_str ());

        Client_Task client_task (input,
                                 corb.in (),
                                 ACE_Thread_Manager::instance ());

        if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
                                  1,
                                  1) == -1)
        {
            ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
        }

        // Wait for the client and server to finish
        ACE_Thread_Manager::instance ()->wait ();

        // Now that all threads have completed we can destroy the ORB
        sorb->destroy ();
        if (server_orb != client_orb)
        {
            corb->destroy ();
        }
    }
    catch (const CORBA::Exception&)
    {
        // Ignore exceptions..
    }
    return 0;
}
Пример #13
0
int
ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  int status = 0;
  ACE_Auto_Ptr<sig_i> sig_impl;
  try
    {
      Supplier_Client client;
      ACE_Argv_Type_Converter argcon (argc, argv);
      status = client.init (argcon.get_argc (), argcon.get_TCHAR_argv ());

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

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

          // If the ior_output_file exists, output the ior to it
          if (ior_output_file != 0)
            {
              CORBA::String_var ior =
                client.orb ()->object_to_string (sig.in ());

              FILE *output_file= ACE_OS::fopen (ior_output_file, ACE_TEXT ("w"));
              ACE_ASSERT (output_file != 0);
              ACE_OS::fprintf (output_file, "%s", ior.in ());
              ACE_OS::fclose (output_file);
            }

          CosNotifyChannelAdmin::SupplierAdmin_var admin =
            create_supplieradmin (ec.in ());
          ACE_ASSERT (!CORBA::is_nil (admin.in ()));

          create_suppliers (admin.in (), client.root_poa ());

          sig_impl->wait_for_startup ();

          // If this is changed, you should update max_events
          // found in Notify_Push_Consumer.cpp
          int batch_size = 4;
          int num_events = 80 / batch_size;
          ACE_DEBUG ((LM_DEBUG,
                      "1 supplier sending %d batches of %d events...\n",
                      num_events, batch_size));
          CosNotification::EventBatch events;
          events.length(batch_size);
          for (int i = 0; i < num_events; ++i)
            {
              supplier_1->send_events (events);
            }
          ACE_DEBUG ((LM_DEBUG, "\nSupplier sent %d events.\n", num_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: ");
    status = 1;
  }

  return status;
}
Пример #14
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Argv_Type_Converter atc (argc, argv);
  try
    {
      if (0 != DRV_init (atc.get_argc (), atc.get_TCHAR_argv ()))
        {
          throw Bailout ();
        }

      // Parse arguments.
      DRV_parse_args (atc.get_argc (), atc.get_ASCII_argv ());

      // If a version message is requested, print it and exit cleanly.
      if (idl_global->compile_flags () & IDL_CF_VERSION)
        {
          DRV_version ();
          DRV_cleanup ();
          return 0;
        }

      // If a usage message is requested, print it and exit cleanly.
      if (idl_global->compile_flags () & IDL_CF_ONLY_USAGE)
        {
          DRV_usage ();
          DRV_cleanup ();
          return 0;
        }

      // If there are no input files, and we are not using the
      // directory recursion option, there's no sense going any further.
      if (0 == DRV_nfiles && 0 == idl_global->recursion_start ())
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("IDL: No input files\n")));

          throw Bailout ();
        }

      AST_Generator *gen = be_util::generator_init ();

      if (0 == gen)
        {
          ACE_ERROR ((
              LM_ERROR,
              ACE_TEXT ("IDL: DRV_generator_init() failed to create ")
              ACE_TEXT ("generator, exiting\n")
            ));

          throw Bailout ();
        }
      else
        {
          idl_global->set_gen (gen);
        }

      // Initialize AST and load predefined types.
      FE_populate ();

      // Does various things in various backends.
      BE_post_init (DRV_files, DRV_nfiles);

      FILE *output_file = 0;

      if (idl_global->multi_file_input ())
        {
          output_file =
            ACE_OS::fopen (idl_global->big_file_name (), "w");
        }

      for (DRV_file_index = 0;
           DRV_file_index < DRV_nfiles;
           ++DRV_file_index)
        {
          if (idl_global->multi_file_input ())
            {
              ACE_OS::fprintf (output_file,
                               "#include \"%s\"\n",
                               DRV_files[DRV_file_index]);
            }
          else
            {
              DRV_drive (DRV_files[DRV_file_index]);
            }
        }

      if (idl_global->multi_file_input ())
        {
          ACE_OS::fclose (output_file);
          DRV_drive (idl_global->big_file_name ());
          ACE_OS::unlink (idl_global->big_file_name ());
        }
    }
  catch (Bailout)
    {
      // Incrementing here may be redundant, but the error count
      // is the exit value, and we want to make sure it isn't 0
      // if there was in fact an error. If a non-zero value is
      // off by 1, it's not so important.
      idl_global->set_err_count (idl_global->err_count () + 1);
    }

  int retval = idl_global->err_count ();
  DRV_cleanup ();

  return retval;
}
Пример #15
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  int status = 0;

  try
    {
#if TAO_HAS_INTERCEPTORS == 1
      PortableInterceptor::ORBInitializer_ptr temp_initializer =
        PortableInterceptor::ORBInitializer::_nil ();

      ACE_NEW_RETURN (temp_initializer,
                      Client_ORBInitializer,
                      -1);  // No exceptions yet!
      PortableInterceptor::ORBInitializer_var orb_initializer =
        temp_initializer;

      PortableInterceptor::register_orb_initializer (orb_initializer.in ());
#endif  /* TAO_HAS_INTERCEPTORS == 1 */

      ACE_Argv_Type_Converter narrow (argc, argv);
      CORBA::ORB_var orb =
        CORBA::ORB_init (narrow.get_argc (), narrow.get_ASCII_argv (), "ClientORB");

      ACE_Argv_Type_Converter wide (narrow.get_argc (), narrow.get_ASCII_argv ());
      if (::parse_args (wide.get_argc (), wide.get_TCHAR_argv ()) != 0)
        return -1;

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

      hello::GoodDay_var server =
        hello::GoodDay::_narrow (object.in ());

      if (CORBA::is_nil (server.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT ("Object reference <%s> is nil\n"),
                             ior),
                            1);
        }

      for (int i = 1; i <= 3; ++i)
        {
          ACE_DEBUG ((LM_INFO,
                      ACE_TEXT ("CLIENT: Issuing request %d.\n"),
                      i));

          CORBA::Short number = server->number ();

          ACE_DEBUG ((LM_INFO,
                      ACE_TEXT ("CLIENT: Request %d returns %d.\n"),
                      i,
                      number));
        }

      server->shutdown ();

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

  return status;
}
Пример #16
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
    if (parse_args (argc,
                    argv) == -1)
        return -1;

    try
    {
        // Start the Naming Service tasks
        NamingTask name_service ("NamingORBA", argc, argv);
        name_service.activate();
        // Wait for the Naming Service initialized.
        name_service.waitInit();

        ACE_Argv_Type_Converter satc (argc, argv);
        CORBA::ORB_var sorb =
            CORBA::ORB_init (satc.get_argc (),
                             satc.get_TCHAR_argv (),
                             server_orb.c_str ());

        ACE_Manual_Event me;
        Server_Task server_task (name_service.root (),
                                 sorb.in (),
                                 me,
                                 ACE_Thread_Manager::instance ());

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

        // Wait for the server thread to do some processing
        me.wait ();

        ACE_Argv_Type_Converter catc (argc, argv);
        CORBA::ORB_var corb =
            CORBA::ORB_init (catc.get_argc (),
                             catc.get_TCHAR_argv (),
                             client_orb.c_str ());

        Client_Task client_task (name_service.root (),
                                 corb.in (),
                                 ACE_Thread_Manager::instance (),
                                 result);

        if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
                                  1,
                                  1) == -1)
        {
            ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
        }

        // Wait for the client and server to finish
        ACE_Thread_Manager::instance ()->wait ();

        // Now that all threads have completed we can destroy the ORB
        sorb->destroy ();
        if (server_orb != client_orb)
        {
            corb->destroy ();
        }
    }
    catch (const CORBA::Exception&)
    {
        // Ignore exceptions..
    }
    return 0;
}
Пример #17
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      parse_args (argc, argv);

      if (client_orb)
        {
          ACE_Argv_Type_Converter conv (argc, argv);
          // Client creates the orb.
          orb = CORBA::ORB_init (conv.get_argc (),
                                 conv.get_ASCII_argv (),
                                 OpenDDS::DCPS::DEFAULT_ORB_NAME);

          TheServiceParticipant->set_ORB(orb.in());

          // Client runs the orb.
          CORBA::Object_var obj =
            orb->resolve_initial_references ("RootPOA");

          poa = PortableServer::POA::_narrow (obj.in ());

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

          poa_manager->activate ();

          orb_task = new ORB_Task (orb.in ());
          if (orb_task->activate (THR_NEW_LWP | THR_JOINABLE, 1) == -1)
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("OPENDDS_DCPS_Service_Participant::get_domain_participant_factory, ")
                          ACE_TEXT ("Failed to activate the orb task.")));
              return 1;
            }

          dpf = TheParticipantFactory;
       }
      else
        {
          dpf = TheParticipantFactoryWithArgs(argc, argv);
          poa = TheServiceParticipant->the_poa();
        }


      int ret = run_domain_test ();
      TEST_CHECK (ret == 0);
      ACE_DEBUG((LM_DEBUG,
        ACE_TEXT("(%P|%t) main: ")
        ACE_TEXT("(ret == 0)")
        ACE_TEXT("\n")
      ));

      for (ssize_t i = 0; i < 6; i ++)
      {
        run_next_sample_test (i);
        run_next_send_sample_test (i);
        run_next_instance_sample_test (i);
      }

      if (client_orb)
        {
          orb->shutdown (0);
          orb_task->wait ();
        }

      TheTransportFactory->release();
      TheServiceParticipant->shutdown ();

      if (client_orb)
        {
          orb->destroy ();
        }

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

  return 0;
}