(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            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            
 35            #ifndef Pegasus_ConfigFileHandler_h
 36            #define Pegasus_ConfigFileHandler_h
 37            
 38            #include <cctype>
 39            #include <Pegasus/Config/Linkage.h>
 40            #include <Pegasus/Config/ConfigExceptions.h>
 41            #include <Pegasus/Config/ConfigFile.h>
 42 kumpf 1.15 #include <Pegasus/Common/Constants.h>
 43 a.arora 1.9  #include <Pegasus/Common/AutoPtr.h>
 44 mike    1.2  
 45              
 46              PEGASUS_NAMESPACE_BEGIN
 47              
 48              
 49              ////////////////////////////////////////////////////////////////////////////////
 50              //  ConfigFileHandler Class
 51              ////////////////////////////////////////////////////////////////////////////////
 52              
 53              struct ConfigTable;
 54              
 55              /**
 56 david.dillard 1.13   This class provides methods to read/write config properties
 57 mike          1.2    from the config file.
 58                    */
 59                    class PEGASUS_CONFIG_LINKAGE ConfigFileHandler
 60                    {
 61                    public:
 62                    
 63 david.dillard 1.13     /**
 64 mike          1.2      Default constructor.
 65                    
 66                        @param        currentFile current config file name.
 67                        @param        plannedFile planned config file name.
 68                        @exception  NoSuchFile  if file cannot be opened.
 69                        @exception  FileNotReadable  if file is not readable.
 70                        */
 71                        ConfigFileHandler (
 72 kumpf         1.15         const String& currentFile = PEGASUS_CURRENT_CONFIG_FILE_PATH,
 73                            const String& plannedFile = PEGASUS_PLANNED_CONFIG_FILE_PATH,
 74 mike          1.2          const Boolean offLine = false);
 75                    
 76                    
 77                        /** Destructor. */
 78                        ~ConfigFileHandler ();
 79                    
 80                    
 81 david.dillard 1.13     /**
 82                        Overwrites config properties in the current config file with the
 83                        the config properties from the planned config file.
 84 mike          1.2  
 85                        The content of the current config file will be copied in to a
 86 david.dillard 1.13     backup (.bak) file before copying planned file contents over the
 87 mike          1.2      current file.
 88                    
 89                        @exception  CannotRenameFile  if failed to create the backup file.
 90 kumpf         1.8      @exception  CannotOpenFile  if failed to set permissions on the config file.
 91 mike          1.2      */
 92                        void copyPlannedFileOverCurrentFile();
 93                    
 94                    
 95 david.dillard 1.13     /**
 96 mike          1.2      Load the config properties from the config files.
 97                    
 98                        @exception ConfigFileSyntaxError if file contains a syntax error.
 99                        */
100                        void loadAllConfigProperties ();
101                    
102                    
103 david.dillard 1.13     /**
104 mike          1.2      Load the config properties from the current config file.
105                    
106                        @exception ConfigFileSyntaxError if file contains a syntax error.
107                        */
108                        void loadCurrentConfigProperties ();
109                    
110                    
111 david.dillard 1.13     /**
112 mike          1.2      Load the config properties from the planned config file.
113                    
114                        @exception ConfigFileSyntaxError if file contains a syntax error.
115                        */
116                        void loadPlannedConfigProperties ();
117                    
118                    
119 david.dillard 1.13     /**
120                        Update the specified property name and value in the current
121                        config file.
122 mike          1.2  
123                        @param  name   name of the property to be updated.
124                        @param  value  value of the property to be updated.
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                            Boolean unset);
132 mike          1.2  
133                    
134 david.dillard 1.13     /**
135                        Update the specified property name and value in the planned
136                        config file.
137 mike          1.2  
138                        @param  name   name of the property to be updated.
139                        @param  value  value of the property to be updated.
140 kumpf         1.3      @param  unset  specifies whether the property should be updated or unset.
141 mike          1.2      @return true   if the property updated successfully, else false.
142                        */
143 kumpf         1.3      Boolean updatePlannedValue(
144 kumpf         1.5          const CIMName& name,
145 kumpf         1.3          const String& value,
146                            Boolean unset);
147 mike          1.2  
148                    
149 david.dillard 1.13     /**
150                        Get the current property value for the specified property name.
151 mike          1.2  
152                        @param  name   name of the property.
153 kumpf         1.3      @param  value  value of the property (output parameter).
154                        @return true if the property is found and returned, false otherwise.
155 mike          1.2      */
156 vijay.eli     1.12     Boolean getCurrentValue (const CIMName& name, String& value) const;
157 mike          1.2  
158                    
159 david.dillard 1.13     /**
160                        Get the planned 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 getPlannedValue (const CIMName& name, String& value) const;
167 mike          1.2  
168                    
169 david.dillard 1.13     /**
170 mike          1.2      Get all current property names.
171                    
172                        @param  propertyNames   string array to hold the property names.
173                        */
174 kumpf         1.5      void getAllCurrentPropertyNames (Array<CIMName>& propertyNames);
175 mike          1.2  
176                    
177 david.dillard 1.13     /**
178 mike          1.2      Get all current property names and values.
179                    
180                        @param  propertyNames   string array to hold the property names.
181                        @param  propertyValues  string array to hold the property values.
182                        */
183                        void getAllCurrentProperties (
184 david.dillard 1.13         Array<CIMName>& propertyNames,
185 mike          1.2          Array<String>& propertyValues);
186                    
187                    
188 david.dillard 1.13     /**
189 mike          1.2      Get all planned config property names.
190                    
191                        @param  propertyNames   string array to hold the property names.
192                        */
193 kumpf         1.5      void getAllPlannedPropertyNames (Array<CIMName>& propertyNames);
194 mike          1.2  
195                    
196 david.dillard 1.13     /**
197 mike          1.2      Get all planned config property names and values.
198                    
199                        @param  propertyNames   string array to hold the property names.
200                        @param  propertyValues  string array to hold the property values.
201                        */
202                        void getAllPlannedProperties(
203 david.dillard 1.13         Array<CIMName>& propertyNames,
204 mike          1.2          Array<String>& propertyValues);
205                    
206                    private:
207                    
208                        /**
209                        Tables to store the current and planned config properties.
210                        */
211                        ConfigTable* _currentConfig;
212                    
213                        ConfigTable* _plannedConfig;
214                    
215                        /**
216                        File handlers for the current and planned config files.
217                        */
218 a.arora       1.9      AutoPtr<ConfigFile>  _currentConfFile; //PEP101
219 david.dillard 1.13 
220 a.arora       1.9      AutoPtr<ConfigFile>  _plannedConfFile; //PEP101
221 mike          1.2  
222                        /**
223                        Flag indicating whether the current config files exists or not.
224                        */
225                        Boolean      _currentFileExist;
226                    
227                        /**
228                        Flag indicating whether the planned config files exists or not.
229                        */
230                        Boolean      _plannedFileExist;
231                    
232                        /**
233                        Flag indicating whether config file is accessed off line or not.
234                        */
235                        Boolean      _offLine;
236                    
237                    };
238                    
239                    PEGASUS_NAMESPACE_END
240                    
241                    #endif /* Pegasus_ConfigFileHandler_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2