(file) Return to ConfigFileHandler.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Config

  1 martin 1.17 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.18 //
  3 martin 1.17 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.18 //
 10 martin 1.17 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.18 //
 17 martin 1.17 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.18 //
 20 martin 1.17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.18 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.18 //
 28 martin 1.17 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             
 33             #ifndef Pegasus_ConfigFileHandler_h
 34             #define Pegasus_ConfigFileHandler_h
 35             
 36             #include <cctype>
 37             #include <Pegasus/Config/Linkage.h>
 38             #include <Pegasus/Config/ConfigExceptions.h>
 39             #include <Pegasus/Config/ConfigFile.h>
 40 kumpf  1.15 #include <Pegasus/Common/Constants.h>
 41 a.arora 1.9  #include <Pegasus/Common/AutoPtr.h>
 42 mike    1.2  
 43              
 44              PEGASUS_NAMESPACE_BEGIN
 45              
 46              
 47              ////////////////////////////////////////////////////////////////////////////////
 48              //  ConfigFileHandler Class
 49              ////////////////////////////////////////////////////////////////////////////////
 50              
 51              struct ConfigTable;
 52              
 53              /**
 54 david.dillard 1.13   This class provides methods to read/write config properties
 55 mike          1.2    from the config file.
 56                    */
 57                    class PEGASUS_CONFIG_LINKAGE ConfigFileHandler
 58                    {
 59                    public:
 60                    
 61 david.dillard 1.13     /**
 62 mike          1.2      Default constructor.
 63                    
 64                        @param        currentFile current config file name.
 65                        @param        plannedFile planned config file name.
 66                        @exception  NoSuchFile  if file cannot be opened.
 67                        @exception  FileNotReadable  if file is not readable.
 68                        */
 69                        ConfigFileHandler (
 70 kumpf         1.15         const String& currentFile = PEGASUS_CURRENT_CONFIG_FILE_PATH,
 71                            const String& plannedFile = PEGASUS_PLANNED_CONFIG_FILE_PATH,
 72 mike          1.2          const Boolean offLine = false);
 73                    
 74                    
 75                        /** Destructor. */
 76                        ~ConfigFileHandler ();
 77                    
 78                    
 79 david.dillard 1.13     /**
 80                        Overwrites config properties in the current config file with the
 81                        the config properties from the planned config file.
 82 mike          1.2  
 83                        The content of the current config file will be copied in to a
 84 david.dillard 1.13     backup (.bak) file before copying planned file contents over the
 85 mike          1.2      current file.
 86                    
 87                        @exception  CannotRenameFile  if failed to create the backup file.
 88 kumpf         1.8      @exception  CannotOpenFile  if failed to set permissions on the config file.
 89 mike          1.2      */
 90                        void copyPlannedFileOverCurrentFile();
 91                    
 92                    
 93 david.dillard 1.13     /**
 94 mike          1.2      Load the config properties from the config files.
 95                    
 96                        @exception ConfigFileSyntaxError if file contains a syntax error.
 97                        */
 98                        void loadAllConfigProperties ();
 99                    
100                    
101 david.dillard 1.13     /**
102 mike          1.2      Load the config properties from the current config file.
103                    
104                        @exception ConfigFileSyntaxError if file contains a syntax error.
105                        */
106                        void loadCurrentConfigProperties ();
107                    
108                    
109 david.dillard 1.13     /**
110 mike          1.2      Load the config properties from the planned config file.
111                    
112                        @exception ConfigFileSyntaxError if file contains a syntax error.
113                        */
114                        void loadPlannedConfigProperties ();
115                    
116                    
117 david.dillard 1.13     /**
118                        Update the specified property name and value in the current
119                        config file.
120 mike          1.2  
121                        @param  name   name of the property to be updated.
122                        @param  value  value of the property to be updated.
123 venkat.puvvada 1.19     @param  userName  User requesting the update
124 venkat.puvvada 1.20     @param timeoutSeconds Timeout in seconds to complete the update.
125 kumpf          1.3      @param  unset  specifies whether the property should be updated or unset.
126 mike           1.2      @return true   if the property updated successfully, else false.
127                         */
128 kumpf          1.3      Boolean updateCurrentValue(
129 kumpf          1.5          const CIMName& name,
130 kumpf          1.3          const String& value,
131 venkat.puvvada 1.19         const String& userName,
132 venkat.puvvada 1.20         Uint32 timeoutSeconds,
133 kumpf          1.3          Boolean unset);
134 mike           1.2  
135                     
136 david.dillard  1.13     /**
137                         Update the specified property name and value in the planned
138                         config file.
139 mike           1.2  
140                         @param  name   name of the property to be updated.
141                         @param  value  value of the property to be updated.
142 kumpf          1.3      @param  unset  specifies whether the property should be updated or unset.
143 mike           1.2      @return true   if the property updated successfully, else false.
144                         */
145 kumpf          1.3      Boolean updatePlannedValue(
146 kumpf          1.5          const CIMName& name,
147 kumpf          1.3          const String& value,
148                             Boolean unset);
149 mike           1.2  
150                     
151 david.dillard  1.13     /**
152                         Get the current property value for the specified property name.
153 mike           1.2  
154                         @param  name   name of the property.
155 kumpf          1.3      @param  value  value of the property (output parameter).
156                         @return true if the property is found and returned, false otherwise.
157 mike           1.2      */
158 vijay.eli      1.12     Boolean getCurrentValue (const CIMName& name, String& value) const;
159 mike           1.2  
160                     
161 david.dillard  1.13     /**
162                         Get the planned property value for the specified property name.
163 mike           1.2  
164                         @param  name   name of the property.
165 kumpf          1.3      @param  value  value of the property (output parameter).
166                         @return true if the property is found and returned, false otherwise.
167 mike           1.2      */
168 vijay.eli      1.12     Boolean getPlannedValue (const CIMName& name, String& value) const;
169 mike           1.2  
170                     
171 david.dillard  1.13     /**
172 mike           1.2      Get all current property names.
173                     
174                         @param  propertyNames   string array to hold the property names.
175                         */
176 kumpf          1.5      void getAllCurrentPropertyNames (Array<CIMName>& propertyNames);
177 mike           1.2  
178                     
179 david.dillard  1.13     /**
180 mike           1.2      Get all current property names and values.
181                     
182                         @param  propertyNames   string array to hold the property names.
183                         @param  propertyValues  string array to hold the property values.
184                         */
185                         void getAllCurrentProperties (
186 david.dillard  1.13         Array<CIMName>& propertyNames,
187 mike           1.2          Array<String>& propertyValues);
188                     
189                     
190 david.dillard  1.13     /**
191 mike           1.2      Get all planned config property names.
192                     
193                         @param  propertyNames   string array to hold the property names.
194                         */
195 kumpf          1.5      void getAllPlannedPropertyNames (Array<CIMName>& propertyNames);
196 mike           1.2  
197                     
198 david.dillard  1.13     /**
199 mike           1.2      Get all planned config property names and values.
200                     
201                         @param  propertyNames   string array to hold the property names.
202                         @param  propertyValues  string array to hold the property values.
203                         */
204                         void getAllPlannedProperties(
205 david.dillard  1.13         Array<CIMName>& propertyNames,
206 mike           1.2          Array<String>& propertyValues);
207                     
208                     private:
209                     
210                         /**
211                         Tables to store the current and planned config properties.
212                         */
213                         ConfigTable* _currentConfig;
214                     
215                         ConfigTable* _plannedConfig;
216                     
217                         /**
218                         File handlers for the current and planned config files.
219                         */
220 a.arora        1.9      AutoPtr<ConfigFile>  _currentConfFile; //PEP101
221 david.dillard  1.13 
222 a.arora        1.9      AutoPtr<ConfigFile>  _plannedConfFile; //PEP101
223 mike           1.2  
224                         /**
225                         Flag indicating whether the current config files exists or not.
226                         */
227                         Boolean      _currentFileExist;
228                     
229                         /**
230                         Flag indicating whether the planned config files exists or not.
231                         */
232                         Boolean      _plannedFileExist;
233                     
234                         /**
235                         Flag indicating whether config file is accessed off line or not.
236                         */
237                         Boolean      _offLine;
238                     
239                     };
240                     
241                     PEGASUS_NAMESPACE_END
242                     
243                     #endif /* Pegasus_ConfigFileHandler_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2