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

Repository_Configuration Class Reference

Maintains the server configurations. More...

#include <Repository_Configuration.h>

Collaboration diagram for Repository_Configuration:

Collaboration graph
[legend]
List of all members.

Public Methods

 Repository_Configuration (const char *repository_mode)
 Default Constructor. More...

 ~Repository_Configuration ()
 Destructor. More...

const ACE_Configuration_Section_Keyroot_section ()
int open ()
int open (const char *file_name)
 opens a configuration based on a file name. More...

int open_section (const ACE_Configuration_Section_Key &base, const char *sub_section, int create, ACE_Configuration_Section_Key &result)
int remove_section (const ACE_Configuration_Section_Key &key, const char *sub_section, int recursive)
int enumerate_sections (const ACE_Configuration_Section_Key &key, int Index, ACE_CString &name)
int set_string_value (const ACE_Configuration_Section_Key &key, const char *name, const ACE_CString &value)
int set_integer_value (const ACE_Configuration_Section_Key &key, const char *name, u_int value)
int get_string_value (const ACE_Configuration_Section_Key &key, const char *name, ACE_CString &value)
int get_integer_value (const ACE_Configuration_Section_Key &key, const char *name, u_int &value)

Private Attributes

ACE_Configurationconfig_

Detailed Description

Maintains the server configurations.

Class to help maintain the xml and non-win32 registry configuration.

Definition at line 28 of file Repository_Configuration.h.


Constructor & Destructor Documentation

Repository_Configuration::Repository_Configuration const char *    repository_mode
 

Default Constructor.

Definition at line 12 of file Repository_Configuration.cpp.

References ACE_ERROR, ACE_NEW, config_, LM_ERROR, ACE_Configuration_Win32Registry::resolve_key, and ACE_OS_String::strcmp.

00013   : config_ (0)
00014 {
00015   /// Default Constructor
00016   if (ACE_OS::strcmp (repository_mode, "x") == 0)
00017     {
00018       /// XML Mode : Dont do anything special
00019     }
00020   else if (ACE_OS::strcmp (repository_mode, "w") == 0)
00021     {
00022 #if defined (ACE_WIN32)
00023       /// Win32 Repository.
00024       HKEY root =
00025         ACE_Configuration_Win32Registry::resolve_key(HKEY_LOCAL_MACHINE,
00026                                                      "Software\\TAO\\IR");
00027       ACE_NEW (this->config_,
00028                ACE_Configuration_Win32Registry(root));
00029 
00030 #endif /* ACE_WIN32 */
00031     }
00032  else if (ACE_OS::strcmp (repository_mode, "h") == 0)
00033     {
00034       ACE_NEW (this->config_,
00035                ACE_Configuration_Heap);
00036 
00037       if (this->config_ == 0)
00038         {
00039           ACE_ERROR ((LM_ERROR,
00040                       "Initialization of config_ didnt happen correctly\n"));
00041         }
00042     }
00043 }

Repository_Configuration::~Repository_Configuration  
 

Destructor.

Definition at line 45 of file Repository_Configuration.cpp.

References config_.

00046 {
00047   /// Destructor
00048   if (this->config_ != 0)
00049     delete this->config_;
00050 }


Member Function Documentation

int Repository_Configuration::enumerate_sections const ACE_Configuration_Section_Key   key,
int    Index,
ACE_CString   name
 

Definition at line 156 of file Repository_Configuration.cpp.

References ACE_CString, config_, and ACE_Configuration::enumerate_sections.

Referenced by Server_Repository::init.

00159 {
00160   if (this->config_ == 0)
00161     {
00162       return 0;
00163       /// @@ May be I need to write the initial DTD etc stuff here.
00164     }
00165   else
00166     {
00167       return this->config_->enumerate_sections (key,
00168                                               Index,
00169                                               name);
00170     }
00171 
00172   return 0;
00173 
00174 }

int Repository_Configuration::get_integer_value const ACE_Configuration_Section_Key   key,
const char *    name,
u_int &    value
 

Definition at line 235 of file Repository_Configuration.cpp.

References config_, and ACE_Configuration::get_integer_value.

Referenced by Server_Repository::init.

00238 {
00239   if (this->config_ == 0)
00240     {
00241       /// @@ May be I need to write the initial DTD etc stuff here.
00242     }
00243   else
00244     {
00245       return this->config_->get_integer_value (key,
00246                                                name,
00247                                                value);
00248     }
00249 
00250   return 0;
00251 
00252  }

int Repository_Configuration::get_string_value const ACE_Configuration_Section_Key   key,
const char *    name,
ACE_CString   value
 

Definition at line 216 of file Repository_Configuration.cpp.

References ACE_CString, config_, and ACE_Configuration::get_string_value.

Referenced by Server_Repository::init.

00219 {
00220   if (this->config_ == 0)
00221     {
00222       /// @@ May be I need to write the initial DTD etc stuff here.
00223     }
00224   else
00225     {
00226       return this->config_->get_string_value (key,
00227                                             name,
00228                                             value);
00229     }
00230 
00231   return 0;
00232 }

int Repository_Configuration::open const char *    file_name
 

opens a configuration based on a file name.

Definition at line 84 of file Repository_Configuration.cpp.

References ACE_ERROR_RETURN, config_, ACE_OS::fclose, ACE_OS::fopen, ACE_OS::fprintf, LM_ERROR, and ACE_Configuration_Heap::open.

00085 {
00086   if (this->config_ == 0)
00087     {
00088       FILE *fp = ACE_OS::fopen (file_name, "w");
00089 
00090       if (fp == 0)
00091         {
00092           ACE_ERROR_RETURN ((LM_ERROR,
00093                              "Couldnt open the file %s\n", file_name),
00094                             -1);
00095         }
00096 
00097       // @@@ Initial setup: write the DTD here.
00098       ACE_OS::fprintf (fp,
00099                        "<?xml version=\"1.0\"?>\n");
00100       ACE_OS::fprintf (fp,
00101                        "<!DOCTYPE SERVER_REPOSITORY>\n");
00102       ACE_OS::fclose (fp);
00103     }
00104   else
00105     {
00106       ACE_Configuration_Heap *heap =
00107         ACE_dynamic_cast (ACE_Configuration_Heap *,
00108                           this->config_);
00109 
00110       return heap->open (file_name);
00111     }
00112   return 0;
00113 }

int Repository_Configuration::open  
 

Definition at line 59 of file Repository_Configuration.cpp.

References config_, and ACE_Configuration_Heap::open.

Referenced by Options::initialize_file_persistence, Options::initialize_non_persistence, and Options::initialize_xml_persistence.

00060 {
00061   // This method would have been called only if some kind of
00062   // persistence is to be used: either the ACE_Configuration_Heap
00063   // or the XML format of the file.
00064   if (this->config_ == 0)
00065     {
00066       // The persistence file type is to be in XML format. Dont do
00067       // anything here. Just return.
00068       return 0;
00069     }
00070   else
00071     {
00072       // Open the configuration heap.
00073       ACE_Configuration_Heap *heap =
00074         ACE_dynamic_cast (ACE_Configuration_Heap *,
00075                           this->config_);
00076 
00077       return heap->open ();
00078     }
00079   return 0;
00080 }

int Repository_Configuration::open_section const ACE_Configuration_Section_Key   base,
const char *    sub_section,
int    create,
ACE_Configuration_Section_Key   result
 

Definition at line 116 of file Repository_Configuration.cpp.

References config_, and ACE_Configuration::open_section.

Referenced by Server_Repository::add, and Server_Repository::init.

00120 {
00121   if (this->config_ == 0)
00122     {
00123       /// @@ May be I need to write the initial DTD etc stuff here.
00124     }
00125   else
00126     {
00127       return this->config_->open_section (base,
00128                                           sub_section,
00129                                           create,
00130                                           result);
00131     }
00132   return 0;
00133 
00134 }

int Repository_Configuration::remove_section const ACE_Configuration_Section_Key   key,
const char *    sub_section,
int    recursive
 

Definition at line 137 of file Repository_Configuration.cpp.

References config_, and ACE_Configuration::remove_section.

Referenced by Server_Repository::remove.

00140 {
00141   if (this->config_ == 0)
00142     {
00143       /// @@ May be I need to write the initial DTD etc stuff here.
00144     }
00145   else
00146     {
00147       return this->config_->remove_section (key,
00148                                           sub_section,
00149                                           recursive);
00150     }
00151 
00152   return 0;
00153 }

const ACE_Configuration_Section_Key & Repository_Configuration::root_section  
 

Definition at line 53 of file Repository_Configuration.cpp.

References config_, and ACE_Configuration::root_section.

Referenced by Server_Repository::init.

00054 {
00055   return this->config_->root_section ();
00056 }

int Repository_Configuration::set_integer_value const ACE_Configuration_Section_Key   key,
const char *    name,
u_int    value
 

Definition at line 197 of file Repository_Configuration.cpp.

References config_, and ACE_Configuration::set_integer_value.

Referenced by Server_Repository::add.

00200 {
00201   if (this->config_ == 0)
00202     {
00203       /// @@ May be I need to write the initial DTD etc stuff here.
00204     }
00205   else
00206     {
00207       return this->config_->set_integer_value (key,
00208                                              name,
00209                                              value);
00210     }
00211 
00212   return 0;
00213 }

int Repository_Configuration::set_string_value const ACE_Configuration_Section_Key   key,
const char *    name,
const ACE_CString   value
 

Definition at line 177 of file Repository_Configuration.cpp.

References ACE_CString, config_, and ACE_Configuration::set_string_value.

Referenced by Server_Repository::add.

00180 {
00181   if (this->config_ == 0)
00182     {
00183       /// @@ May be I need to write the initial DTD etc stuff here.
00184     }
00185   else
00186     {
00187       return this->config_->set_string_value (key,
00188                                             name,
00189                                             value);
00190     }
00191 
00192   return 0;
00193 
00194 }


Member Data Documentation

ACE_Configuration* Repository_Configuration::config_ [private]
 

Definition at line 76 of file Repository_Configuration.h.

Referenced by enumerate_sections, get_integer_value, get_string_value, open, open_section, remove_section, Repository_Configuration, root_section, set_integer_value, set_string_value, and ~Repository_Configuration.


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