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

Options Class Reference

Maintains the global options. More...

#include <Options.h>

Collaboration diagram for Options:

Collaboration graph
[legend]
List of all members.

Public Methods

 Options ()
 Default Constructor. More...

 ~Options ()
 Destructor. More...

int init (int argc, char *argv[])
 Parse the command-line arguments and initialize the options. More...

int service (void) const
 Service Mode. More...

unsigned int debug (void) const
 Debug level for the Implementation Repository. More...

FILE * output_file (void) const
 Returns the file where the IOR should be stored. More...

Repository_Configurationconfig (void) const
 Returns the configuration object. More...

char * repository_mode (void)
char * file_name (void) const
 Returns the file addr. More...

const char * convert_str (ImplementationRepository::ActivationMode mode)
 Converts the activation mode to a const char *. Needed to put the activation mode into the XML file or print it out. More...

ImplementationRepository::ActivationMode convert_mode (const char *mode)
const ACE_Time_Valuestartup_timeout (void) const
 Returns the timeout value for program starting. More...

const ACE_Time_Valueping_interval (void) const
 Returns the timeout value for program starting. More...

CORBA::ORB_ptr orb (void) const
 Returns a pointer to the ORB. More...

int multicast (void) const
 Will we listen for multicast location requests? More...

int readonly (void) const
 Do we allow modifications to the servers? More...


Private Methods

int parse_args (int &argc, char *argv[])
 Parses and pulls out arguments for the ImR. More...

void print_usage (void) const
 Print the usage information. More...

int initialize_file_persistence (const char *filename)
 Initialize file persistence. More...

int initialize_registry_persistence (void)
 Initialize Registry persistence. More...

int initialize_non_persistence (void)
 Initialize default heap for no persistence. More...

int initialize_xml_persistence (const char *file_name)
 Initialize XML file persistence. More...

int run_service_command (const char *command)
 Run a service command. More...

int load_registry_options (ACE_ARGV &orb_options)
 Loads ORB options from the registry. More...


Private Attributes

Repository_Configurationrepo_config_
 The persistent configuration object. More...

char repo_mode_
 Mode of the Server Repository: if XML (x) or non-XML (n). More...

char * file_name_
 The persistent file option. More...

unsigned int debug_
 Debug level. More...

FILE * ior_output_file_
 File where the IOR of the server object is stored. More...

int multicast_
 Will we listen for multicast location requests? More...

CORBA::ORB_var orb_
 The ORB for the Implementation Repository. More...

ACE_Time_Value ping_interval_
 The amount of time between successive "are you started yet?" pings. More...

int service_
 Are we running as a service? More...

ACE_Time_Value startup_timeout_
 The amount of time to wait for a server to response after starting it. More...

int readonly_
 Can the server_repository be modified? More...


Detailed Description

Maintains the global options.

This is where all the settings for TAO's Implementation Repository is stored.

Definition at line 37 of file Options.h.


Constructor & Destructor Documentation

Options::Options  
 

Default Constructor.

Default Constructor. Assigns default values to all the member variables.

Definition at line 33 of file Options.cpp.

00034   : repo_config_ (0)
00035   , repo_mode_ ('p')
00036   , debug_ (1)
00037   , ior_output_file_ (0)
00038   , multicast_ (0)
00039   , ping_interval_ (0, 200)
00040   , service_ (0)
00041   , startup_timeout_ (5)
00042   , readonly_ (0)
00043 {
00044 }

Options::~Options  
 

Destructor.

Destructor. Just deletes this->repo_config_.

Definition at line 50 of file Options.cpp.

References repo_config_.

00051 {
00052   delete this->repo_config_;
00053 }


Member Function Documentation

Repository_Configuration * Options::config void    const
 

Returns the configuration object.

Returns:
The ACE_Configuration object that is used to store data.

Definition at line 695 of file Options.cpp.

References repo_config_.

00696 {
00697   return this->repo_config_;
00698 }

ImplementationRepository::ActivationMode Options::convert_mode const char *    mode
 

Definition at line 731 of file Options.cpp.

References ACE_OS_String::strcmp.

00732 {
00733   if (ACE_OS::strcmp (mode, "NORMAL") == 0)
00734     return ImplementationRepository::NORMAL;
00735   else if (ACE_OS::strcmp (mode, "MANUAL") == 0)
00736     return ImplementationRepository::MANUAL;
00737   else if (ACE_OS::strcmp (mode, "PER_CLIENT") == 0)
00738     return ImplementationRepository::PER_CLIENT;
00739   else //if (ACE_OS::strcmp (mode, "AUTO_START") == 0)
00740     return ImplementationRepository::AUTO_START;
00741 }

const char * Options::convert_str ImplementationRepository::ActivationMode    mode
 

Converts the activation mode to a const char *. Needed to put the activation mode into the XML file or print it out.

Definition at line 713 of file Options.cpp.

00714 {
00715   switch (mode)
00716     {
00717     case ImplementationRepository::NORMAL:
00718       return "NORMAL";
00719     case ImplementationRepository::MANUAL:
00720       return "MANUAL";
00721     case ImplementationRepository::PER_CLIENT:
00722       return "PER_CLIENT";
00723     case ImplementationRepository::AUTO_START:
00724       return "AUTO_START";
00725     default:
00726       return "UNKNOWN";
00727     };
00728 }

unsigned int Options::debug void    const
 

Debug level for the Implementation Repository.

Debug level for the IR.

Return values:
0  Quiet
1  Trace messages
2  Detailed messages

Definition at line 656 of file Options.cpp.

References debug_.

Referenced by load_registry_options.

00657 {
00658   return this->debug_;
00659 }

char * Options::file_name void    const
 

Returns the file addr.

Definition at line 707 of file Options.cpp.

References file_name_.

Referenced by initialize_xml_persistence.

00708 {
00709   return this->file_name_;
00710 }

int Options::init int    argc,
char *    argv[]
 

Parse the command-line arguments and initialize the options.

Return values:
0  Success
-1  Error parsing args
1  Success but we should exit.

Definition at line 229 of file Options.cpp.

References ACE_CATCHANY, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_ERROR, ACE_TRY_CHECK, ACE_TRY_NEW_ENV, ACE_ARGV::add, ACE_ARGV::argc, ACE_ARGV::argv, initialize_non_persistence, LM_ERROR, load_registry_options, orb_, CORBA::ORB_init, parse_args, and repo_config_.

00230 {
00231   ACE_ARGV orb_args;
00232   int i = 0;
00233   int result = 0;
00234 
00235   // Make an initial pass through and grab the arguments that we recognize.
00236 
00237   result = this->parse_args (argc, argv);
00238 
00239   if (result != 0)
00240     return result;
00241 
00242   // Save the leftovers to a ACE_ARGV class
00243 
00244   for (i = 1; i < argc; ++i)
00245     {
00246       if (orb_args.add (argv[i]) == -1)
00247         {
00248           ACE_ERROR ((LM_ERROR, "Error: Could not save argument"));
00249           return -1;
00250         }
00251     }
00252 
00253 #if defined (ACE_WIN32)
00254   // Load any arguments from the registry
00255 
00256   if (this->load_registry_options (orb_args) != 0)
00257     return -1;
00258 #endif /* ACE_WIN32 */
00259 
00260   // Make another pass to catch any ImR arguments that may be in the
00261   // registry
00262 
00263   int orb_argc = orb_args.argc ();
00264 
00265   result = this->parse_args (orb_argc, orb_args.argv ());
00266 
00267   if (result != 0)
00268     return result;
00269 
00270   // Now initialize the orb and pass it the leftover arguments
00271 
00272   ACE_TRY_NEW_ENV
00273     {
00274       this->orb_ = CORBA::ORB_init (orb_argc,
00275                                     orb_args.argv (),
00276                                     0
00277                                     ACE_ENV_ARG_PARAMETER);
00278       ACE_TRY_CHECK;
00279     }
00280   ACE_CATCHANY
00281     {
00282       ACE_ERROR ((LM_ERROR, "Error: Cannot initialize ORB\n"));
00283       return -1;
00284     }
00285   ACE_ENDTRY;
00286 
00287   // If there are any arguments left (besides the executable filename)
00288   // then they were not picked up by us or the orb and must be
00289   // unrecognized.
00290 
00291   if (orb_argc > 1)
00292     {
00293       // Just print out the first option as an error
00294       ACE_ERROR ((LM_ERROR,
00295                   "Unrecognized option: %s\n",
00296                   orb_args.argv ()[1]));
00297       return -1;
00298     }
00299 
00300   // If no persistent implementation specified, use a simple heap.
00301   if (this->repo_config_ == 0)
00302     if (this->initialize_non_persistence () != 0)
00303       return -1;
00304 
00305   // Indicates successful parsing of command line.
00306   return 0;
00307 }

int Options::initialize_file_persistence const char *    filename [private]
 

Initialize file persistence.

The most portable form of persistence is file persistence. Here we assign an ACE_Configuration_Heap object using

Parameters:
filename  as the file.
Return values:
0  Success
-1  Failure

Definition at line 345 of file Options.cpp.

References ACE_ERROR, ACE_NEW_RETURN, ACE_TEXT, LM_ERROR, Repository_Configuration::open, and repo_config_.

Referenced by parse_args.

00346 {
00347   if (this->repo_config_ != 0)
00348   {
00349     ACE_ERROR ((LM_ERROR,
00350                 "Error: initialize_file_persistence (): "
00351                 "Configuration already defined. \n"
00352                 "Did you pass multiple persistence options?\n"));
00353     return -1;
00354   }
00355 
00356   Repository_Configuration *repo_config = 0;
00357   
00358   ACE_NEW_RETURN (repo_config,
00359                   Repository_Configuration ("h"),
00360                   -1);
00361 
00362   if (repo_config->open (filename) == 0)
00363     {
00364       this->repo_config_ = repo_config;
00365       return 0;
00366     }
00367 
00368   ACE_ERROR ((LM_ERROR,
00369               ACE_TEXT ("Error: Opening persistent heap file '%s'\n"),
00370               filename));
00371 
00372   return -1;
00373 
00374   return 0;
00375 }

int Options::initialize_non_persistence void    [private]
 

Initialize default heap for no persistence.

In cases where persistence isn't needed, create an object of the ACE_Configuration_Heap class to be used. Initializes this->repo_config_ to an opened ACE_Configuration_Heap.

Return values:
0  Success
-1  Failure

Definition at line 420 of file Options.cpp.

References ACE_ERROR, ACE_NEW_RETURN, ACE_TEXT, LM_ERROR, Repository_Configuration::open, and repo_config_.

Referenced by init.

00421 {
00422   Repository_Configuration *repo_config = 0;
00423   ACE_NEW_RETURN (repo_config,
00424                   Repository_Configuration ("h"),
00425                   -1);
00426 
00427   if (repo_config->open () == 0)
00428     {
00429       this->repo_config_ = repo_config;
00430       return 0;
00431     }
00432 
00433   delete repo_config;
00434   repo_config = 0;
00435 
00436   ACE_ERROR ((LM_ERROR,
00437              ACE_TEXT ("Error: Opening Configuration heap\n")));
00438   return -1;
00439 }

int Options::initialize_registry_persistence void    [private]
 

Initialize Registry persistence.

On Windows, we have the option of using the Registry to store the server data. Assigns a ACE_Configuration_Win32Registry to this->repo_config_. On non-Win32 systems, just returns an error.

Todo:
Where in the registry should this be stored?
Return values:
0  Success
-1  Failure

Definition at line 389 of file Options.cpp.

References ACE_ERROR, ACE_ERROR_RETURN, ACE_NEW_RETURN, LM_ERROR, and repo_config_.

Referenced by parse_args.

00390 {
00391 #if defined (ACE_WIN32)
00392   if (this->repo_config_ != 0)
00393   {
00394     ACE_ERROR ((LM_ERROR,
00395                 "Error: initialize_registry_persistence (): "
00396                 "Configuration already defined. \n"
00397                 "Did you pass multiple persistence options?\n"));
00398     return -1;
00399   }
00400 
00401   ACE_NEW_RETURN (this->repo_config_,
00402                   Repository_Configuration ("w"),
00403                   -1);
00404   return 0;
00405 #else /* ACE_WIN32 */
00406   ACE_ERROR_RETURN ((LM_ERROR, "Registry not supported on this platform"), -1);
00407 #endif /* ACE_WIN32 */
00408 }

int Options::initialize_xml_persistence const char *    file_name [private]
 

Initialize XML file persistence.

Definition at line 443 of file Options.cpp.

References ACE_ERROR, ACE_NEW_RETURN, ACE_TEXT, file_name, file_name_, LM_ERROR, Repository_Configuration::open, and repo_config_.

Referenced by parse_args.

00444 {
00445   this->file_name_ = ACE_const_cast (char *, file_name);
00446 
00447   Repository_Configuration *repo_config = 0;
00448   ACE_NEW_RETURN (repo_config,
00449                   Repository_Configuration ("x"),
00450                   -1);
00451 
00452   if (repo_config->open (file_name) == 0)
00453     {
00454       this->repo_config_ = repo_config;
00455       return 0;
00456     }
00457 
00458   delete repo_config;
00459   repo_config = 0;
00460 
00461   ACE_ERROR ((LM_ERROR,
00462               ACE_TEXT ("Error: Opening Configuration XML file\n")));
00463 
00464   return -1;
00465 }

int Options::load_registry_options ACE_ARGV   orb_options [private]
 

Loads ORB options from the registry.

We will only load from the registry if we are a service. The location we store options in is HKEY_LOCAL_MACHINE: SYSTEM\CurrentControlSet\Services\TAOImplRepo\Parameters

The only key currently supported is ORBOptions

Todo:
Is there a better way to handle the hKey? (as in a auto_ptr)

Definition at line 525 of file Options.cpp.

References ACE_DEBUG, ACE_DEFAULT_ARGV_BUFSIZ, ACE_ERROR, ACE_NEW_RETURN, ACE_ARGV::add, debug, LM_DEBUG, LM_ERROR, service, SERVICE_REG_PATH, SERVICE_REG_ROOT, and SERVICE_REG_VALUE_NAME.

Referenced by init.

00526 {
00527 #if defined (ACE_WIN32)
00528   // Only if we are running as a service
00529   if (!this->service ())
00530   {
00531     if (this->debug () > 1)
00532       ACE_DEBUG ((LM_DEBUG,
00533                   "Not running as a service, will not load data from "
00534                   "registry\n"));
00535     return 0;
00536   }
00537 
00538   HKEY hKey = 0;
00539   BYTE buffer[ACE_DEFAULT_ARGV_BUFSIZ] = {0};
00540 
00541   if (ACE_TEXT_RegOpenKeyEx (SERVICE_REG_ROOT,
00542                              SERVICE_REG_PATH,
00543                              0,
00544                              KEY_READ,
00545                              &hKey) != ERROR_SUCCESS)
00546     {
00547       if (this->debug () > 1)
00548         {
00549           ACE_DEBUG ((LM_DEBUG, "Could not open Registry Key, skipping\n"));
00550         }
00551 
00552       return 0;
00553     }
00554 
00555   DWORD dwType = 0;
00556   DWORD dwSize = sizeof (buffer);
00557 
00558   if (ACE_TEXT_RegQueryValueEx (hKey,
00559                                 SERVICE_REG_VALUE_NAME,
00560                                 NULL,
00561                                 &dwType,
00562                                 buffer,
00563                                 &dwSize) != ERROR_SUCCESS)
00564     {
00565       if (this->debug () > 1)
00566         {
00567           ACE_DEBUG ((LM_DEBUG, "Could not read Registry Key, skipping\n"));
00568           ::RegCloseKey (hKey);
00569           return 0;
00570         }
00571     }
00572 
00573   if (dwType != REG_MULTI_SZ)
00574     {
00575       ACE_ERROR ((LM_ERROR, "Error: ORB Options registry key not MULTI_SZ\n"));
00576      ::RegCloseKey (hKey);
00577       return -1;
00578     }
00579 
00580   // Skip the case where there are no arguments
00581   if (dwSize > 1)
00582     {
00583       // Create an argv array
00584       char **orb_argv = 0;
00585 
00586       ACE_NEW_RETURN (orb_argv, char *[dwSize], -1);
00587 
00588       char *tchar_buffer = ACE_reinterpret_cast (char *, buffer);
00589       orb_argv[0] = tchar_buffer;
00590 
00591       if (this->debug () > 1)
00592         ACE_DEBUG ((LM_DEBUG,
00593                     "Registry Argument Added: %s\n",
00594                     orb_argv[0]));
00595 
00596       int orb_argv_pos = 1;
00597 
00598       for (unsigned int buffer_pos = 0;
00599            buffer_pos < dwSize / sizeof (char ) - 2;
00600            ++buffer_pos)
00601         {
00602           if (tchar_buffer[buffer_pos] == 0)
00603             {
00604               if (this->debug () > 1)
00605                 ACE_DEBUG ((LM_DEBUG,
00606                             "Registry Argument Added: %s\n",
00607                             &tchar_buffer[buffer_pos] + 1));
00608 
00609               orb_argv[orb_argv_pos++] = &tchar_buffer[buffer_pos] + 1;
00610             }
00611         }
00612 
00613       orb_argv[orb_argv_pos] = 0;
00614 
00615       orb_options.add (orb_argv);
00616 
00617       delete [] orb_argv;
00618     }
00619 
00620   if (::RegCloseKey (hKey) != ERROR_SUCCESS)
00621     {
00622       ACE_ERROR ((LM_ERROR, "Error: Could close Registry Key\n"));
00623       return -1;
00624     }
00625 
00626   return 0;
00627 #else /* ACE_WIN32 */
00628   ACE_UNUSED_ARG (orb_options);
00629   ACE_ERROR ((LM_ERROR, "Service not supported on this platform"));
00630 
00631   return -1;
00632 #endif /* ACE_WIN32 */
00633 }

int Options::multicast void    const
 

Will we listen for multicast location requests?

Return values:
0  Do not listen for multicast location requests.
1  Do Listen.

Definition at line 758 of file Options.cpp.

References multicast_.

00759 {
00760   return this->multicast_;
00761 }

CORBA::ORB_ptr Options::orb void    const
 

Returns a pointer to the ORB.

Returns:
A pointer to the ORB.

Definition at line 747 of file Options.cpp.

00748 {
00749   return CORBA::ORB::_duplicate (this->orb_.in ());
00750 }

FILE * Options::output_file void    const
 

Returns the file where the IOR should be stored.

Returns:
The file where the IOR will be stored.

Definition at line 666 of file Options.cpp.

References ior_output_file_.

00667 {
00668   return this->ior_output_file_;
00669 }

int Options::parse_args int &    argc,
char *    argv[]
[private]
 

Parses and pulls out arguments for the ImR.

parse_args uses an ACE_Arg_Shifter to grab all the options that are specific to the ImR.

Return values:
0  Success
-1  Error parsing args
1  Success but we should exit.

Definition at line 65 of file Options.cpp.

References ACE_ERROR, ACE_ERROR_RETURN, ACE_TEXT, ACE_OS::atoi, ACE_Arg_Shifter::consume_arg, debug_, ACE_OS::fopen, ACE_Arg_Shifter::get_current, ACE_Arg_Shifter::ignore_arg, initialize_file_persistence, initialize_registry_persistence, initialize_xml_persistence, ior_output_file_, ACE_Arg_Shifter::is_anything_left, LM_ERROR, multicast_, print_usage, readonly_, repo_mode_, run_service_command, service_, startup_timeout_, and ACE_OS_String::strcasecmp.

Referenced by init.

00066 {
00067   ACE_Arg_Shifter shifter (argc, argv);
00068 
00069   while (shifter.is_anything_left ())
00070     {
00071       if (ACE_OS::strcasecmp (shifter.get_current (),
00072                               ACE_TEXT ("-c")) == 0)
00073         {
00074           // Run the service command
00075           shifter.consume_arg ();
00076 
00077           if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
00078             {
00079               ACE_ERROR ((LM_ERROR, "Error: -c option needs a command\n"));
00080               return -1;
00081             }
00082 
00083           if (this->run_service_command (shifter.get_current ()) != 0)
00084             return -1;
00085 
00086           // Since we just ran a command, we will exit right away.
00087           return 1;
00088         }
00089       else if (ACE_OS::strcasecmp (shifter.get_current (),
00090                                    ACE_TEXT ("-d")) == 0)
00091         {
00092           // Set the debug level
00093           shifter.consume_arg ();
00094 
00095           if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
00096             {
00097               ACE_ERROR ((LM_ERROR, "Error: -d option needs a debuglevel\n"));
00098               return -1;
00099             }
00100 
00101           this->debug_ = ACE_OS::atoi (shifter.get_current ());
00102         }
00103       else if (ACE_OS::strcasecmp (shifter.get_current (),
00104                                    ACE_TEXT ("-l")) == 0)
00105         {
00106           // Lock the database
00107           this->readonly_ = 1;
00108         }
00109       else if (ACE_OS::strcasecmp (shifter.get_current (),
00110                                    ACE_TEXT ("-m")) == 0)
00111         {
00112           // multicast?
00113           shifter.consume_arg ();
00114 
00115           if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
00116             {
00117               ACE_ERROR ((LM_ERROR, "Error: -m option requires 1/0\n"));
00118               return -1;
00119             }
00120 
00121           this->multicast_ = ACE_OS::atoi (shifter.get_current ());
00122         }
00123       else if (ACE_OS::strcasecmp (shifter.get_current (),
00124                                    ACE_TEXT ("-o")) == 0)
00125         {
00126           // Output the IOR to a file.
00127           shifter.consume_arg ();
00128 
00129           if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
00130             {
00131               ACE_ERROR ((LM_ERROR, "Error: -o option needs a filename\n"));
00132               return -1;
00133             }
00134 
00135           this->ior_output_file_ = ACE_OS::fopen (shifter.get_current (), "w");
00136           if (this->ior_output_file_ == 0)
00137             ACE_ERROR_RETURN ((LM_ERROR,
00138                                "Error: Unable to open %s for writing: %p\n",
00139                                shifter.get_current ()), -1);
00140         }
00141       else if (ACE_OS::strcasecmp (shifter.get_current (),
00142                                    ACE_TEXT ("-p")) == 0)
00143         {
00144           // Initialize file persistence
00145           shifter.consume_arg ();
00146 
00147           if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
00148             {
00149               ACE_ERROR ((LM_ERROR, "Error: -p option needs a filename\n"));
00150               return -1;
00151             }
00152 
00153           if (this->initialize_file_persistence (shifter.get_current ()) != 0)
00154             return -1;
00155         }
00156       else if (ACE_OS::strcasecmp (shifter.get_current (),
00157                                    ACE_TEXT ("-r")) == 0)
00158         {
00159           // win32 registry implementation
00160           if (this->initialize_registry_persistence () != 0)
00161             return -1;
00162         }
00163       else if (ACE_OS::strcasecmp (shifter.get_current (),
00164                                    ACE_TEXT ("-x")) == 0)
00165         {
00166           // Initialize file persistence. The file is going to be of
00167           // XML format.
00168           shifter.consume_arg ();
00169 
00170           if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
00171             {
00172               ACE_ERROR ((LM_ERROR, "Error: -x option needs a filename\n"));
00173               return -1;
00174             }
00175 
00176           /// Use XML for repository
00177           if (this->initialize_xml_persistence (shifter.get_current ()) != 0)
00178             return -1;
00179 
00180           this->repo_mode_ = 'x';
00181         }
00182       else if (ACE_OS::strcasecmp (shifter.get_current (),
00183                                    ACE_TEXT ("-s")) == 0)
00184         {
00185           // Run as a service
00186           this->service_ = 1;
00187         }
00188       else if (ACE_OS::strcasecmp (shifter.get_current (),
00189                                    ACE_TEXT ("-t")) == 0)
00190         {
00191           // Set timeout value
00192           shifter.consume_arg ();
00193 
00194           if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
00195             {
00196               ACE_ERROR ((LM_ERROR, "Error: -t option needs a value\n"));
00197               return -1;
00198             }
00199 
00200           this->startup_timeout_ =
00201             ACE_Time_Value (ACE_OS::atoi (shifter.get_current ()));
00202         }
00203       else if ((ACE_OS::strcasecmp (shifter.get_current (),
00204                                     ACE_TEXT ("-?")) == 0)
00205                || (ACE_OS::strcasecmp (shifter.get_current (),
00206                                        ACE_TEXT ("-h")) == 0))
00207         {
00208           this->print_usage ();
00209           return 1;
00210         }
00211       else
00212         {
00213           shifter.ignore_arg ();
00214           continue;
00215         }
00216 
00217       shifter.consume_arg ();
00218     }
00219 
00220   return 0;
00221 }

const ACE_Time_Value & Options::ping_interval void    const
 

Returns the timeout value for program starting.

Returns:
The amount of time to wait between pings

Definition at line 686 of file Options.cpp.

References ping_interval_.

00687 {
00688   return this->ping_interval_;
00689 }

void Options::print_usage void    const [private]
 

Print the usage information.

Just print out the usage message to STDERR

Definition at line 314 of file Options.cpp.

References ACE_ERROR, and LM_ERROR.

Referenced by parse_args.

00315 {
00316   ACE_ERROR ((LM_ERROR,
00317               "Usage:\n"
00318               "\n"
00319               "ImR_Activator [-c cmd] [-d lvl] [-l] [-m 0/1] [-o file]"
00320               " [-r|-p file|-x file] [-r] [-s] [-t secs]\n"
00321               "\n"
00322               "  -c command  Runs service commands ('install' or 'remove')\n"
00323               "  -d level    Sets the debug level\n"
00324               "  -l          Lock the database\n"
00325               "  -m [0/1]    Turn on(1)/off(0) multicast (default: 1)\n"
00326               "  -o file     Outputs the ImR's IOR to a file\n"
00327               "  -p file     Use file for storing/loading settings\n"
00328               "  -x file     Use XML file for storing/loading setting\n"
00329               "  -r          Use the registry for storing/loading settings\n"
00330               "  -s          Runs as a service (NT Only)\n"
00331               "  -t secs     Timeout used for killing unresponsive servers\n")
00332              );
00333 }

int Options::readonly void    const
 

Do we allow modifications to the servers?

Return values:
0  Normal operation.
1  Do not let server info be modified.

Definition at line 768 of file Options.cpp.

References readonly_.

00769 {
00770   return this->readonly_;
00771 }

char * Options::repository_mode void   
 

Definition at line 701 of file Options.cpp.

References repo_mode_.

00702 {
00703   return &this->repo_mode_;
00704 }

int Options::run_service_command const char *    command [private]
 

Run a service command.

Executes the various commands that are useful for a NT service. Right now these include 'install' and 'remove'. Others, such as 'start' and 'stop' can be added, but the 'net' program in Windows already handles these commands.

Todo:
Finish implementing Options::run_service_command

Update to unicode

Definition at line 477 of file Options.cpp.

References ACE_ERROR, ACE_TEXT, ACE_Singleton::instance, LM_ERROR, ACE_OS_String::strcat, and ACE_OS_String::strcmp.

Referenced by parse_args.

00478 {
00479 #if defined (ACE_WIN32)
00480   SERVICE::instance ()->name (IMR_SERVICE_NAME, IMR_DISPLAY_NAME);
00481 
00482   if (ACE_OS::strcmp (command, ACE_TEXT ("install")) == 0)
00483     {
00484       char pathname[_MAX_PATH * 2 + 3];  // +3 for the ' -s' at the end
00485 
00486       if (ACE_TEXT_GetModuleFileName(NULL, pathname, _MAX_PATH * 2) == 0)
00487         {
00488           ACE_ERROR ((LM_ERROR, "Error: Could not get module file name.\n"));
00489           return -1;
00490         }
00491 
00492       // Append the command used for running the implrepo as
00493       ACE_OS::strcat (pathname, ACE_TEXT (" -s"));
00494 
00495       return SERVICE::instance ()->insert (SERVICE_AUTO_START,
00496                                            SERVICE_ERROR_IGNORE,
00497                                            pathname);
00498     }
00499   else if (ACE_OS::strcmp (command, ACE_TEXT ("remove")) == 0)
00500     {
00501       return SERVICE::instance ()->remove ();
00502     }
00503 
00504   ACE_ERROR ((LM_ERROR, "Error: Unrecognized command: %s\n", command));
00505   return -1;
00506 
00507 #else /* ACE_WIN32 */
00508   ACE_UNUSED_ARG (command);
00509   ACE_ERROR ((LM_ERROR, "Service not supported on this platform"));
00510 
00511   return -1;
00512 #endif /* ACE_WIN32 */
00513 }

int Options::service void    const
 

Service Mode.

Standalone Mode

Return values:
0  Run as standalone service
1  Run as a service (only on NT right now)

Definition at line 642 of file Options.cpp.

References service_.

Referenced by load_registry_options.

00643 {
00644   return this->service_;
00645 }

const ACE_Time_Value & Options::startup_timeout void    const
 

Returns the timeout value for program starting.

Returns:
The amount of time to wait for a server to start.

Definition at line 676 of file Options.cpp.

References startup_timeout_.

00677 {
00678   return this->startup_timeout_;
00679 }


Member Data Documentation

unsigned int Options::debug_ [private]
 

Debug level.

Definition at line 122 of file Options.h.

Referenced by debug, and parse_args.

char* Options::file_name_ [private]
 

The persistent file option.

Definition at line 119 of file Options.h.

Referenced by file_name, and initialize_xml_persistence.

FILE* Options::ior_output_file_ [private]
 

File where the IOR of the server object is stored.

Definition at line 125 of file Options.h.

Referenced by output_file, and parse_args.

int Options::multicast_ [private]
 

Will we listen for multicast location requests?

Definition at line 128 of file Options.h.

Referenced by multicast, and parse_args.

CORBA::ORB_var Options::orb_ [private]
 

The ORB for the Implementation Repository.

Definition at line 131 of file Options.h.

Referenced by init.

ACE_Time_Value Options::ping_interval_ [private]
 

The amount of time between successive "are you started yet?" pings.

Definition at line 134 of file Options.h.

Referenced by ping_interval.

int Options::readonly_ [private]
 

Can the server_repository be modified?

Definition at line 143 of file Options.h.

Referenced by parse_args, and readonly.

Repository_Configuration* Options::repo_config_ [private]
 

The persistent configuration object.

Definition at line 113 of file Options.h.

Referenced by config, init, initialize_file_persistence, initialize_non_persistence, initialize_registry_persistence, initialize_xml_persistence, and ~Options.

char Options::repo_mode_ [private]
 

Mode of the Server Repository: if XML (x) or non-XML (n).

Definition at line 116 of file Options.h.

Referenced by parse_args, and repository_mode.

int Options::service_ [private]
 

Are we running as a service?

Definition at line 137 of file Options.h.

Referenced by parse_args, and service.

ACE_Time_Value Options::startup_timeout_ [private]
 

The amount of time to wait for a server to response after starting it.

Definition at line 140 of file Options.h.

Referenced by parse_args, and startup_timeout.


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