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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2