ACE_Name_Options Class Reference

Manages the options for the ACE Name_Server. More...

#include <Naming_Context.h>

List of all members.

Public Member Functions

 ACE_Name_Options (void)
 ~ACE_Name_Options (void)
void parse_args (int argc, ACE_TCHAR *argv[])
 Parse arguments.
void nameserver_port (int port)
 Set the port number.
int nameserver_port (void)
 Get the port number.
ACE_Naming_Context::Context_Scope_Type context (void)
 Get the context.
void context (ACE_Naming_Context::Context_Scope_Type)
 Set the context.
void nameserver_host (const ACE_TCHAR *host)
 Set the host name.
const ACE_TCHARnameserver_host (void)
 Get the host name.
void namespace_dir (const ACE_TCHAR *dir)
 Set name space directory.
const ACE_TCHARnamespace_dir (void)
 Get name space directory.
void process_name (const ACE_TCHAR *dir)
 Set process name.
const ACE_TCHARprocess_name (void)
 Get process name.
void database (const ACE_TCHAR *)
 Set database name.
const ACE_TCHARdatabase (void)
 Get database name.
void base_address (char *address)
 Set base address of the underlying allocator.
char * base_address (void)
 Get base address of the underlying allocator.
bool use_registry (void) const
 Get use of registry in naming.
void use_registry (bool x)
 Set use of registry in naming.
int debug (void)
 Return debug status.
int verbose (void)
 Return verbose status.

Private Attributes

int debugging_
 Extra debugging info.
int verbosity_
 Extra verbose messages.
bool use_registry_
 Use Win32 Registry.
int nameserver_port_
 Port to connect to nameserver process.
const ACE_TCHARnameserver_host_
 Hostname of nameserver.
ACE_TCHARnamespace_dir_
 Directory to hold name_bindings.
const ACE_TCHARprocess_name_
 Name of this process.
const ACE_TCHARdatabase_
 Name of the database that stores the name/value/type bindings.
char * base_address_
 Base address of the underlying allocator.
ACE_Naming_Context::Context_Scope_Type context_
 The context in which the naming database will be created.


Detailed Description

Manages the options for the ACE Name_Server.

Definition at line 280 of file Naming_Context.h.


Constructor & Destructor Documentation

ACE_Name_Options::ACE_Name_Options ( void   ) 

Definition at line 417 of file Naming_Context.cpp.

References ACE_DIRECTORY_SEPARATOR_STR, ACE_ERROR, ACE_TEXT, ACE_TRACE, ACE::get_temp_dir(), LM_ERROR, ACE_OS::malloc(), MAXPATHLEN, namespace_dir_, ACE_OS::strcat(), ACE_OS::strcpy(), and ACE_OS::strdup().

00418   : debugging_ (0),
00419     verbosity_ (0),
00420     use_registry_ (false),
00421     nameserver_port_ (ACE_DEFAULT_SERVER_PORT),
00422     nameserver_host_ (ACE_OS::strdup (ACE_DEFAULT_SERVER_HOST)),
00423     process_name_ (0),
00424     database_ (ACE_OS::strdup (ACE_DEFAULT_LOCALNAME)),
00425     base_address_ (ACE_DEFAULT_BASE_ADDR)
00426 {
00427   ACE_TRACE ("ACE_Name_Options::ACE_Name_Options");
00428 
00429 #if defined (ACE_DEFAULT_NAMESPACE_DIR)
00430   this->namespace_dir_ = ACE_OS::strdup (ACE_DEFAULT_NAMESPACE_DIR);
00431 #else /* ACE_DEFAULT_NAMESPACE_DIR */
00432   size_t pathsize = (MAXPATHLEN + 1) * sizeof (ACE_TCHAR);
00433   this->namespace_dir_ = static_cast <ACE_TCHAR *> (ACE_OS::malloc (pathsize));
00434 
00435   if (ACE::get_temp_dir (this->namespace_dir_, MAXPATHLEN) == -1)
00436     {
00437       ACE_ERROR ((LM_ERROR,
00438                   ACE_TEXT ("Temporary path too long, ")
00439                   ACE_TEXT ("defaulting to current directory\n")));
00440       ACE_OS::strcpy (this->namespace_dir_, ACE_TEXT ("."));
00441       ACE_OS::strcat (this->namespace_dir_, ACE_DIRECTORY_SEPARATOR_STR);
00442     }
00443 #endif /* ACE_DEFAULT_NAMESPACE_DIR */
00444 }

ACE_Name_Options::~ACE_Name_Options ( void   ) 

Definition at line 446 of file Naming_Context.cpp.

References ACE_TRACE, and ACE_OS::free().

00447 {
00448   ACE_TRACE ("ACE_Name_Options::~ACE_Name_Options");
00449 
00450   ACE_OS::free ((void *) this->nameserver_host_);
00451   ACE_OS::free ((void *) this->namespace_dir_ );
00452   ACE_OS::free ((void *) this->process_name_ );
00453   ACE_OS::free ((void *) this->database_ );
00454 }


Member Function Documentation

char * ACE_Name_Options::base_address ( void   ) 

Get base address of the underlying allocator.

Definition at line 518 of file Naming_Context.cpp.

References ACE_TRACE, and base_address_.

Referenced by parse_args().

00519 {
00520   ACE_TRACE ("ACE_Name_Options::base_address");
00521   return this->base_address_;
00522 }

void ACE_Name_Options::base_address ( char *  address  ) 

Set base address of the underlying allocator.

Definition at line 525 of file Naming_Context.cpp.

References ACE_TRACE, and base_address_.

00526 {
00527   ACE_TRACE ("ACE_Name_Options::base_address");
00528   this->base_address_ = base_address;
00529 }

void ACE_Name_Options::context ( ACE_Naming_Context::Context_Scope_Type   ) 

Set the context.

Definition at line 539 of file Naming_Context.cpp.

References ACE_TRACE, and context_.

00540 {
00541   ACE_TRACE ("ACE_Name_Options::context");
00542   this->context_ = context;
00543 }

ACE_Naming_Context::Context_Scope_Type ACE_Name_Options::context ( void   ) 

Get the context.

Definition at line 532 of file Naming_Context.cpp.

References ACE_TRACE, and context_.

Referenced by parse_args().

00533 {
00534   ACE_TRACE ("ACE_Name_Options::context");
00535   return this->context_;
00536 }

const ACE_TCHAR * ACE_Name_Options::database ( void   ) 

Get database name.

Definition at line 503 of file Naming_Context.cpp.

References ACE_TRACE, and database_.

Referenced by parse_args().

00504 {
00505   ACE_TRACE ("ACE_Name_Options::database");
00506   return this->database_;
00507 }

void ACE_Name_Options::database ( const ACE_TCHAR  ) 

Set database name.

Definition at line 510 of file Naming_Context.cpp.

References ACE_TRACE, database_, ACE_OS::free(), and ACE_OS::strdup().

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i().

00511 {
00512   ACE_TRACE ("ACE_Name_Options::database");
00513   ACE_OS::free ((void *) this->database_);
00514   this->database_ = ACE_OS::strdup (db);
00515 }

ACE_INLINE int ACE_Name_Options::debug ( void   ) 

Return debug status.

Definition at line 39 of file Naming_Context.inl.

References ACE_TRACE, and debugging_.

00040 {
00041   ACE_TRACE ("ACE_Name_Options::debug");
00042   return this->debugging_;
00043 }

const ACE_TCHAR * ACE_Name_Options::nameserver_host ( void   ) 

Get the host name.

Definition at line 496 of file Naming_Context.cpp.

References ACE_TRACE, and nameserver_host_.

Referenced by parse_args().

00497 {
00498   ACE_TRACE ("ACE_Name_Options::nameserver_host");
00499   return this->nameserver_host_;
00500 }

void ACE_Name_Options::nameserver_host ( const ACE_TCHAR host  ) 

Set the host name.

Definition at line 488 of file Naming_Context.cpp.

References ACE_TRACE, ACE_OS::free(), nameserver_host_, and ACE_OS::strdup().

Referenced by ACE_Naming_Context::open().

00489 {
00490   ACE_TRACE ("ACE_Name_Options::nameserver_host");
00491   ACE_OS::free ((void *) this->nameserver_host_);
00492   this->nameserver_host_ = ACE_OS::strdup (host);
00493 }

int ACE_Name_Options::nameserver_port ( void   ) 

Get the port number.

Definition at line 464 of file Naming_Context.cpp.

References ACE_TRACE, and nameserver_port_.

Referenced by parse_args().

00465 {
00466   ACE_TRACE ("ACE_Name_Options::nameserver_port");
00467   return this->nameserver_port_;
00468 }

void ACE_Name_Options::nameserver_port ( int  port  ) 

Set the port number.

Definition at line 457 of file Naming_Context.cpp.

References ACE_TRACE, and nameserver_port_.

Referenced by ACE_Naming_Context::open().

00458 {
00459   ACE_TRACE ("ACE_Name_Options::nameserver_port");
00460   this->nameserver_port_ = port;
00461 }

ACE_INLINE const ACE_TCHAR * ACE_Name_Options::namespace_dir ( void   ) 

Get name space directory.

Definition at line 32 of file Naming_Context.inl.

References ACE_TRACE, and namespace_dir_.

Referenced by parse_args().

00033 {
00034   ACE_TRACE ("ACE_Name_Options::namespace_dir");
00035   return this->namespace_dir_;
00036 }

void ACE_Name_Options::namespace_dir ( const ACE_TCHAR dir  ) 

Set name space directory.

Definition at line 471 of file Naming_Context.cpp.

References ACE_TRACE, ACE_OS::free(), namespace_dir_, and ACE_OS::strdup().

Referenced by ACE_Local_Name_Space<, ACE_LOCK >::create_manager_i().

00472 {
00473   ACE_TRACE ("ACE_Name_Options::namespace_dir");
00474   ACE_OS::free ((void *) this->namespace_dir_ );
00475   this->namespace_dir_ = ACE_OS::strdup (dir);
00476 }

void ACE_Name_Options::parse_args ( int  argc,
ACE_TCHAR argv[] 
)

Parse arguments.

Definition at line 546 of file Naming_Context.cpp.

References ACE_LOG_MSG, ACE_TEXT, ACE_TRACE, ACE_OS::atoi(), ACE_OS::atop(), base_address(), context(), database(), debugging_, ACE_OS::fprintf(), nameserver_host(), nameserver_port(), namespace_dir(), ACE_Naming_Context::NET_LOCAL, ACE_Naming_Context::NODE_LOCAL, ACE_Naming_Context::PROC_LOCAL, process_name(), ACE_Trace::start_tracing(), ACE_Trace::stop_tracing(), ACE_OS::strcasecmp(), ACE_OS::strcmp(), use_registry_, and verbosity_.

Referenced by ACE_Naming_Context::init().

00547 {
00548   ACE_TRACE ("ACE_Name_Options::parse_args");
00549 
00550   const ACE_TCHAR* program_name = 0;
00551 
00552   // Argc can be 0 on some platforms like VxWorks.
00553   if (argc > 0)
00554     program_name = argv[0];
00555 
00556   ACE_LOG_MSG->open (program_name);
00557   this->process_name (program_name);
00558 
00559   // Default is to use the PROC_LOCAL context...
00560   this->context (ACE_Naming_Context::PROC_LOCAL);
00561 
00562   // Make the database name the same as the process name by default
00563   // (note that this makes a copy of the process_name_ so that we can
00564   // clean it up in the destructor).
00565   this->database (this->process_name ());
00566 
00567   ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("b:c:dh:l:P:p:s:T:vr"));
00568 
00569   for (int c; (c = get_opt ()) != -1; )
00570     switch (c)
00571       {
00572       case 'c':
00573         {
00574           if (ACE_OS::strcmp (get_opt.opt_arg (), ACE_TEXT ("PROC_LOCAL")) == 0)
00575             this->context (ACE_Naming_Context::PROC_LOCAL);
00576           else if (ACE_OS::strcmp (get_opt.opt_arg (), ACE_TEXT ("NODE_LOCAL")) == 0)
00577             this->context (ACE_Naming_Context::NODE_LOCAL);
00578           else if (ACE_OS::strcmp (get_opt.opt_arg (), ACE_TEXT ("NET_LOCAL")) == 0)
00579             this->context (ACE_Naming_Context::NET_LOCAL);
00580         }
00581         break;
00582       case 'd':
00583         this->debugging_ = 1;
00584         break;
00585       case 'r':
00586         this->use_registry_ = true;
00587         break;
00588       case 'h':
00589         this->nameserver_host (get_opt.opt_arg ());
00590         break;
00591       case 'l':
00592         this->namespace_dir (get_opt.opt_arg ());
00593         break;
00594       case 'P':
00595         this->process_name (get_opt.opt_arg ());
00596         break;
00597       case 'p':
00598         this->nameserver_port (ACE_OS::atoi (get_opt.opt_arg ()));
00599         break;
00600       case 's':
00601         this->database (get_opt.opt_arg ());
00602         break;
00603       case 'b':
00604         this->base_address
00605           (static_cast<char *> (ACE_OS::atop (get_opt.opt_arg ())));
00606         break;
00607       case 'T':
00608 #if defined (ACE_HAS_TRACE)
00609         if (ACE_OS::strcasecmp (get_opt.opt_arg (), ACE_TEXT ("ON")) == 0)
00610           ACE_Trace::start_tracing ();
00611         else if (ACE_OS::strcasecmp (get_opt.opt_arg (), ACE_TEXT ("OFF")) == 0)
00612           ACE_Trace::stop_tracing ();
00613 #endif /* ACE_HAS_TRACE */
00614         break;
00615       case 'v':
00616         this->verbosity_ = 1;
00617         break;
00618       default:
00619         ACE_OS::fprintf (stderr, "%s\n"
00620                          "\t[-d] (enable debugging)\n"
00621                          "\t[-h nameserver host]\n"
00622                          "\t[-l namespace directory]\n"
00623                          "\t[-P processname]\n"
00624                          "\t[-p nameserver port]\n"
00625                          "\t[-s database name]\n"
00626                          "\t[-b base address]\n"
00627                          "\t[-v] (verbose) \n"
00628                          "\t[-r] (use Win32 Registry) \n",
00629                          argv[0]);
00630         /* NOTREACHED */
00631         break;
00632       }
00633 }

ACE_INLINE const ACE_TCHAR * ACE_Name_Options::process_name ( void   ) 

Get process name.

Definition at line 25 of file Naming_Context.inl.

References ACE_TRACE, and process_name_.

Referenced by parse_args().

00026 {
00027   ACE_TRACE ("ACE_Name_Options::process_name");
00028   return this->process_name_;
00029 }

void ACE_Name_Options::process_name ( const ACE_TCHAR dir  ) 

Set process name.

Definition at line 479 of file Naming_Context.cpp.

References ACE_DIRECTORY_SEPARATOR_CHAR, ACE_TRACE, ACE::basename(), ACE_OS::free(), process_name_, and ACE_OS::strdup().

00480 {
00481   ACE_TRACE ("ACE_Name_Options::process_name");
00482   const ACE_TCHAR *t = ACE::basename (pname, ACE_DIRECTORY_SEPARATOR_CHAR);
00483   ACE_OS::free ((void *) this->process_name_ );
00484   this->process_name_ = ACE_OS::strdup (t);
00485 }

ACE_INLINE void ACE_Name_Options::use_registry ( bool  x  ) 

Set use of registry in naming.

Definition at line 11 of file Naming_Context.inl.

References ACE_TRACE, and use_registry_.

00012 {
00013   ACE_TRACE ("ACE_Name_Options::use_registry");
00014   this->use_registry_ = x;
00015 }

ACE_INLINE bool ACE_Name_Options::use_registry ( void   )  const

Get use of registry in naming.

Definition at line 4 of file Naming_Context.inl.

References ACE_TRACE, and use_registry_.

00005 {
00006   ACE_TRACE ("ACE_Name_Options::use_registry");
00007   return this->use_registry_;
00008 }

ACE_INLINE int ACE_Name_Options::verbose ( void   ) 

Return verbose status.

Definition at line 18 of file Naming_Context.inl.

References ACE_TRACE, and verbosity_.

00019 {
00020   ACE_TRACE ("ACE_Name_Options::verbose");
00021   return this->verbosity_;
00022 }


Member Data Documentation

char* ACE_Name_Options::base_address_ [private]

Base address of the underlying allocator.

Definition at line 371 of file Naming_Context.h.

Referenced by base_address().

ACE_Naming_Context::Context_Scope_Type ACE_Name_Options::context_ [private]

The context in which the naming database will be created.

Definition at line 374 of file Naming_Context.h.

Referenced by context().

const ACE_TCHAR* ACE_Name_Options::database_ [private]

Name of the database that stores the name/value/type bindings.

Definition at line 368 of file Naming_Context.h.

Referenced by database().

int ACE_Name_Options::debugging_ [private]

Extra debugging info.

Definition at line 347 of file Naming_Context.h.

Referenced by debug(), and parse_args().

const ACE_TCHAR* ACE_Name_Options::nameserver_host_ [private]

Hostname of nameserver.

Definition at line 359 of file Naming_Context.h.

Referenced by nameserver_host().

int ACE_Name_Options::nameserver_port_ [private]

Port to connect to nameserver process.

Definition at line 356 of file Naming_Context.h.

Referenced by nameserver_port().

ACE_TCHAR* ACE_Name_Options::namespace_dir_ [private]

Directory to hold name_bindings.

Definition at line 362 of file Naming_Context.h.

Referenced by ACE_Name_Options(), and namespace_dir().

const ACE_TCHAR* ACE_Name_Options::process_name_ [private]

Name of this process.

Definition at line 365 of file Naming_Context.h.

Referenced by process_name().

bool ACE_Name_Options::use_registry_ [private]

Use Win32 Registry.

Definition at line 353 of file Naming_Context.h.

Referenced by parse_args(), and use_registry().

int ACE_Name_Options::verbosity_ [private]

Extra verbose messages.

Definition at line 350 of file Naming_Context.h.

Referenced by parse_args(), and verbose().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:22 2010 for ACE by  doxygen 1.4.7