Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

TAO_IMR_Op_IOR Class Reference

IOR Operation. More...

#include <tao_imr_i.h>

Inheritance diagram for TAO_IMR_Op_IOR:

Inheritance graph
[legend]
Collaboration diagram for TAO_IMR_Op_IOR:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_IMR_Op_IOR (void)
 ~TAO_IMR_Op_IOR (void)
virtual int parse (int argc, ACE_TCHAR **argv)
 Parse arguments. More...

virtual int run (void)
 Do the work. More...


Protected Methods

void print_usage (void)
 Prints a message about the usage. More...


Protected Attributes

ACE_CString server_name_
 POA server name. More...

ACE_CString filename_
 Filename to output to. More...


Detailed Description

IOR Operation.

IOR is used to create a simple IOR for a server that uses the IMR and the Interoperable Naming Service.

Definition at line 211 of file tao_imr_i.h.


Constructor & Destructor Documentation

TAO_IMR_Op_IOR::TAO_IMR_Op_IOR void   
 

Definition at line 219 of file tao_imr_i.cpp.

00220 {
00221   // Nothing
00222 }

TAO_IMR_Op_IOR::~TAO_IMR_Op_IOR void   
 

Definition at line 275 of file tao_imr_i.cpp.

00276 {
00277   // Nothing
00278 }


Member Function Documentation

int TAO_IMR_Op_IOR::parse int    argc,
ACE_TCHAR **    argv
[virtual]
 

Parse arguments.

Implements TAO_IMR_Op.

Definition at line 431 of file tao_imr_i.cpp.

References ACE_TCHAR, filename_, ACE_Get_Opt::opt_arg, print_usage, and server_name_.

00432 {
00433   // Check for enough arguments (we need at least one for the server name)
00434   if (argc < 1)
00435   {
00436     this->print_usage ();
00437     return -1;
00438   }
00439 
00440   // Skip both the program name and the "ior" command
00441   ACE_Get_Opt get_opts (argc, argv, "hf:");
00442 
00443   this->server_name_ = argv[0];
00444   int c;
00445 
00446   while ((c = get_opts ()) != -1)
00447     switch (c)
00448       {
00449       case 'f':  // File name
00450         this->filename_ = get_opts.opt_arg ();
00451         break;
00452       case 'h':  // display help
00453       default:
00454         this->print_usage ();
00455         return -1;
00456       }
00457 
00458   // Success
00459   return 0;
00460 }

void TAO_IMR_Op_IOR::print_usage void    [protected]
 

Prints a message about the usage.

Definition at line 1148 of file tao_imr_i.cpp.

References ACE_ERROR, and LM_ERROR.

Referenced by parse.

01149 {
01150   ACE_ERROR ((LM_ERROR, "Creates an IOR for a server that is registered with the IMR and uses\n"
01151                         "the InterOperable Naming Service.  Please see the documentation for\n"
01152                         "more information on which server configurations work with this command.\n"
01153                         "\n"
01154                         "Usage: tao_imr [options] ior <name> [command-arguments]\n"
01155                         "  where [options] are ORB options\n"
01156                         "  where <name> is the POA name of the server\n"
01157                         "  where [command-arguments] can be\n"
01158                         "    -f filename   filename to output the IOR to\n"
01159                         "    -h            Displays this\n"));
01160 }

int TAO_IMR_Op_IOR::run void    [virtual]
 

Do the work.

Implements TAO_IMR_Op.

Definition at line 809 of file tao_imr_i.cpp.

References ACE_ANY_EXCEPTION, ACE_CATCHANY, ACE_CString, ACE_DEBUG, ACE_ENDTRY, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_ERROR_RETURN, ACE_PRINT_EXCEPTION, ACE_TEXT, ACE_TRY_CHECK, ACE_TRY_NEW_ENV, ACE_OS::fclose, filename_, ACE_OS::fopen, ACE_OS::fprintf, TAO_IMR_Op::imr_locator_, CORBA::is_nil, LM_DEBUG, LM_ERROR, NORMAL, server_name_, ACE_OS_String::strchr, ACE_OS_String::strstr, and UNKNOWN.

00810 {
00811   ACE_TRY_NEW_ENV
00812     {
00813       if (CORBA::is_nil (this->imr_locator_)
00814           || !this->imr_locator_->_stubobj ()
00815           || !this->imr_locator_->_stubobj ()->profile_in_use ())
00816         {
00817           ACE_ERROR_RETURN ((
00818               LM_ERROR,
00819               ACE_TEXT ("Invalid ImR Locator IOR\n")
00820             ),
00821             -1
00822           );
00823         }
00824 
00825       CORBA::String_var imr_str =
00826         this->imr_locator_->_stubobj ()->
00827         profile_in_use ()->to_string (ACE_ENV_SINGLE_ARG_PARAMETER);
00828       ACE_TRY_CHECK;
00829 
00830       // Search for "corbaloc:" alone, without the protocol.  This code
00831       // should be protocol neutral.
00832       const char corbaloc[] = "corbaloc:";
00833       char *pos = ACE_OS::strstr (imr_str.inout (), corbaloc);
00834 
00835       if (pos == 0)
00836         ACE_ERROR_RETURN ((LM_ERROR,
00837                            "Could not parse IMR IOR\n"),
00838                           -1);
00839       else
00840         {
00841           pos = ACE_OS::strchr (pos + sizeof (corbaloc), ':');
00842           pos = ACE_OS::strchr (pos + 1,
00843                                 this->imr_locator_->_stubobj ()->profile_in_use ()->object_key_delimiter ());
00844 
00845           if (pos)
00846             *(pos + 1) = 0;  // Crop the string
00847           else
00848             ACE_ERROR_RETURN ((LM_ERROR,
00849                                "Could not parse IMR IOR\n"),
00850                               -1);
00851         }
00852       ACE_CString ior (imr_str.in ());
00853 
00854       // Add the key
00855       ior += this->server_name_;
00856 
00857       ACE_DEBUG ((LM_DEBUG,
00858                   "%s\n",
00859                   ior.c_str ()));
00860 
00861       if (this->filename_.length () > 0)
00862         {
00863           FILE *file = ACE_OS::fopen (this->filename_.c_str (),
00864                                       "w");
00865 
00866           if (file == 0)
00867             {
00868               ACE_ERROR_RETURN ((LM_ERROR,
00869                                  "Error: Unable to open %s for writing: %p\n",
00870                                  this->filename_.c_str ()),
00871                                 -1);
00872             }
00873 
00874           ACE_OS::fprintf (file,
00875                            "%s",
00876                            ior.c_str ());
00877           ACE_OS::fclose (file);
00878         }
00879     }
00880   ACE_CATCHANY
00881     {
00882       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Ior");
00883       return UNKNOWN;
00884     }
00885   ACE_ENDTRY;
00886 
00887   return NORMAL;
00888 }


Member Data Documentation

ACE_CString TAO_IMR_Op_IOR::filename_ [protected]
 

Filename to output to.

Definition at line 228 of file tao_imr_i.h.

Referenced by parse, and run.

ACE_CString TAO_IMR_Op_IOR::server_name_ [protected]
 

POA server name.

Definition at line 225 of file tao_imr_i.h.

Referenced by parse, and run.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 20:04:33 2003 for TAO_Implementation_Repository by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002