diff options
Diffstat (limited to 'TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp')
| -rw-r--r-- | TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp b/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp index 2e0865eac9d..2097b73a3a3 100644 --- a/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp +++ b/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp @@ -1,11 +1,40 @@ // $Id$ #include "Messenger_i.h" +#include "ace/Get_Opt.h" #include <iostream> #include <fstream> // 1. Define a "task" class for implenting the thread pool threads. #include "ace/Task.h" +const ACE_TCHAR *ior_output_file = ACE_TEXT ("test.ior"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + class ORB_Task : public ACE_Task_Base { public: @@ -38,6 +67,9 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) PortableServer::POAManager_var mgr = poa->the_POAManager(); mgr->activate(); + if (parse_args (argc, argv) != 0) + return 1; + // Create a servant. PortableServer::Servant_var<Messenger_i> messenger_servant = new Messenger_i; @@ -47,10 +79,11 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) poa->activate_object( messenger_servant.in() ); CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() ); CORBA::String_var str = orb->object_to_string( messenger_obj.in() ); - std::ofstream iorFile( "Messenger.ior" ); + std::ofstream iorFile(ACE_TEXT_ALWAYS_CHAR (ior_output_file)); iorFile << str.in() << std::endl; iorFile.close(); - std::cout << "IOR written to file Messenger.ior" << std::endl; + std::cout << "IOR written to file " << + ACE_TEXT_ALWAYS_CHAR (ior_output_file) << std::endl; // 3. Create and activate threads for the thread pool. ORB_Task task (orb.in()); |
