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 246 of file tao_imr_i.cpp.

00247 : verbose_server_information_ (0)
00248 {
00249   // Nothing
00250 }


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 1105 of file tao_imr_i.cpp.

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

Referenced by run().

01106 {
01107   if (this->verbose_server_information_)
01108     TAO_IMR_Op::display_server_information (info);
01109   else
01110     ACE_DEBUG ((LM_DEBUG, "<%s>\n", info.server.in ()));
01111 }

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

Parse arguments.

Implements TAO_IMR_Op.

Definition at line 413 of file tao_imr_i.cpp.

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

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

void TAO_IMR_Op_List::print_usage void   )  [protected]
 

Prints a message about the usage.

Definition at line 399 of file tao_imr_i.cpp.

References ACE_ERROR, and LM_ERROR.

Referenced by parse().

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

int TAO_IMR_Op_List::run void   )  [virtual]
 

Do the work.

Implements TAO_IMR_Op.

Definition at line 863 of file tao_imr_i.cpp.

References ACE_ANY_EXCEPTION, ACE_ASSERT, ACE_CATCH, ACE_CATCHANY, ACE_DEBUG, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_ERROR, ACE_PRINT_EXCEPTION, ACE_TRY, ACE_TRY_CHECK, display_server_information(), LM_DEBUG, LM_ERROR, and verbose_server_information_.

00864 {
00865   ACE_ASSERT (! CORBA::is_nil(imr_));
00866 
00867   ImplementationRepository::ServerInformationList_var server_list;
00868   ImplementationRepository::ServerInformationIterator_var server_iter;
00869 
00870   ACE_DECLARE_NEW_CORBA_ENV;
00871   ACE_TRY
00872     {
00873       // If there is a server name, list only that server.  Otherwise, look
00874       // at all of them.
00875       if (this->server_name_.length () == 0)
00876         {
00877           this->imr_->list (0,
00878             server_list.out(),
00879             server_iter.out()
00880             ACE_ENV_ARG_PARAMETER);
00881           ACE_TRY_CHECK;
00882 
00883           if (server_list->length() == 0)
00884           {
00885             ACE_DEBUG((LM_DEBUG, "No servers found.\n"));
00886             return TAO_IMR_Op::NORMAL;
00887           }
00888 
00889           for (CORBA::ULong i = 0; i < server_list->length (); i++)
00890             this->display_server_information (server_list[i]);
00891 
00892           ACE_ASSERT (CORBA::is_nil (server_iter.in ()));
00893         }
00894       else
00895         {
00896           ImplementationRepository::ServerInformation_var si;
00897 
00898           this->imr_->find (this->server_name_.c_str (), si ACE_ENV_ARG_PARAMETER);
00899           ACE_TRY_CHECK;
00900 
00901           this->verbose_server_information_ = 1;
00902 
00903           this->display_server_information (si.in ());
00904         }
00905     }
00906   ACE_CATCH (ImplementationRepository::NotFound, ex)
00907     {
00908       ACE_ERROR ((LM_ERROR, "Could not find server <%s>.\n", this->server_name_.c_str ()));
00909       return TAO_IMR_Op::NOT_FOUND;
00910     }
00911   ACE_CATCHANY
00912     {
00913       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "List");
00914       return TAO_IMR_Op::UNKNOWN;
00915     }
00916   ACE_ENDTRY;
00917 
00918   return TAO_IMR_Op::NORMAL;
00919 }


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 Thu Nov 9 13:37:29 2006 for TAO_Implementation_Repository by doxygen 1.3.6