TAO_IMR_Op_List Class Reference

List Operation. More...

#include <tao_imr_i.h>

Inheritance diagram for TAO_IMR_Op_List:

Inheritance graph
[legend]
Collaboration diagram for TAO_IMR_Op_List:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_IMR_Op_List (void)
virtual int parse (int argc, ACE_TCHAR **argv)
 Parse arguments.

virtual int run (void)
 Do the work.


Protected Member Functions

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

void display_server_information (const ImplementationRepository::ServerInformation &info)

Protected Attributes

ACE_CString server_name_
 POA server name.

int verbose_server_information_
 If true, more server information is displayed.


Detailed Description

List Operation.

List is used to either list all the servers registered in the IMR or just look at one of them.

Definition at line 192 of file tao_imr_i.h.


Constructor & Destructor Documentation

TAO_IMR_Op_List::TAO_IMR_Op_List void   ) 
 

Definition at line 241 of file tao_imr_i.cpp.

00242 : verbose_server_information_ (0)
00243 {
00244   // Nothing
00245 }


Member Function Documentation

void TAO_IMR_Op_List::display_server_information const ImplementationRepository::ServerInformation &  info  )  [protected]
 

Prints out the information contained in a ServerInformation structure. Specialized to only print server information

Reimplemented from TAO_IMR_Op.

Definition at line 1073 of file tao_imr_i.cpp.

References ACE_DEBUG, TAO_IMR_Op::display_server_information(), LM_DEBUG, and verbose_server_information_.

Referenced by run().

01074 {
01075   if (this->verbose_server_information_)
01076     TAO_IMR_Op::display_server_information (info);
01077   else
01078     ACE_DEBUG ((LM_DEBUG, "<%s>\n", info.server.in ()));
01079 }

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

Parse arguments.

Implements TAO_IMR_Op.

Definition at line 408 of file tao_imr_i.cpp.

References ACE_ERROR, LM_ERROR, print_usage(), and verbose_server_information_.

00409 {
00410   int server_flag = 0;
00411 
00412   if (argc > 1 && argv[1][0] != '-')
00413   {
00414     this->server_name_ = argv[1];
00415     server_flag = 2;
00416   }
00417 
00418   // Skip both the program name and the "list" command
00419   ACE_Get_Opt get_opts (argc, argv, "vh", server_flag);
00420 
00421   int c;
00422 
00423   while ((c = get_opts ()) != -1)
00424     {
00425       switch (c)
00426       {
00427       case 'v': // verbose server display
00428         this->verbose_server_information_ = 1;
00429         break;
00430       case 'h':  // display help
00431         this->print_usage ();
00432         return -1;
00433       default:
00434         ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c));
00435         this->print_usage ();
00436         return -1;
00437       }
00438     }
00439   return 0;
00440 }

void TAO_IMR_Op_List::print_usage void   )  [protected]
 

Prints a message about the usage.

Definition at line 394 of file tao_imr_i.cpp.

References ACE_ERROR, and LM_ERROR.

Referenced by parse().

00395 {
00396   ACE_ERROR ((LM_ERROR, "Lists all or one of the servers in the Implementation Repository\n"
00397     "\n"
00398     "Usage: tao_imr [options] list [name] [command-arguments]\n"
00399     "  where [options] are ORB options\n"
00400     "  where [name] is the optional server name to search for\n"
00401     "  where [command-arguments] can be\n"
00402     "    -v            Verbose: Displays more info for each server when\n"
00403     "                  displaying more than one server\n"
00404     "    -h            Displays this\n"));
00405 }

int TAO_IMR_Op_List::run void   )  [virtual]
 

Do the work.

Implements TAO_IMR_Op.

Definition at line 849 of file tao_imr_i.cpp.

References ACE_ASSERT, ACE_DEBUG, ACE_ERROR, display_server_information(), LM_DEBUG, LM_ERROR, and verbose_server_information_.

00850 {
00851   ACE_ASSERT (! CORBA::is_nil(imr_));
00852 
00853   ImplementationRepository::ServerInformationList_var server_list;
00854   ImplementationRepository::ServerInformationIterator_var server_iter;
00855 
00856   try
00857     {
00858       // If there is a server name, list only that server.  Otherwise, look
00859       // at all of them.
00860       if (this->server_name_.length () == 0)
00861         {
00862           this->imr_->list (0,
00863             server_list.out(),
00864             server_iter.out());
00865 
00866           if (server_list->length() == 0)
00867           {
00868             ACE_DEBUG((LM_DEBUG, "No servers found.\n"));
00869             return TAO_IMR_Op::NORMAL;
00870           }
00871 
00872           for (CORBA::ULong i = 0; i < server_list->length (); i++)
00873             this->display_server_information (server_list[i]);
00874 
00875           ACE_ASSERT (CORBA::is_nil (server_iter.in ()));
00876         }
00877       else
00878         {
00879           ImplementationRepository::ServerInformation_var si;
00880 
00881           this->imr_->find (this->server_name_.c_str (), si);
00882 
00883           this->verbose_server_information_ = 1;
00884 
00885           this->display_server_information (si.in ());
00886         }
00887     }
00888   catch (const ImplementationRepository::NotFound&)
00889     {
00890       ACE_ERROR ((LM_ERROR, "Could not find server <%s>.\n", this->server_name_.c_str ()));
00891       return TAO_IMR_Op::NOT_FOUND;
00892     }
00893   catch (const CORBA::Exception& ex)
00894     {
00895       ex._tao_print_exception ("List");
00896       return TAO_IMR_Op::UNKNOWN;
00897     }
00898 
00899   return TAO_IMR_Op::NORMAL;
00900 }


Member Data Documentation

ACE_CString TAO_IMR_Op_List::server_name_ [protected]
 

POA server name.

Definition at line 205 of file tao_imr_i.h.

int TAO_IMR_Op_List::verbose_server_information_ [protected]
 

If true, more server information is displayed.

Definition at line 208 of file tao_imr_i.h.

Referenced by display_server_information(), parse(), and run().


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 15:56:06 2008 for TAO_Implementation_Repository by doxygen 1.3.6