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

  1 karl  1.16 //%2003////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 karl  1.16 // 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            // IBM Corp.; EMC Corporation, The Open Group.
  7 mike  1.2  //
  8            // Permission is hereby granted, free of charge, to any person obtaining a copy
  9            // of this software and associated documentation files (the "Software"), to
 10            // deal in the Software without restriction, including without limitation the
 11            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 12            // sell copies of the Software, and to permit persons to whom the Software is
 13            // furnished to do so, subject to the following conditions:
 14 kumpf 1.10 // 
 15 mike  1.2  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 16            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 17            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 18            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 19            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 20            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 21            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 22            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 23            //
 24            //==============================================================================
 25            //
 26            // Author: Nag Boranna (nagaraja_boranna@hp.com)
 27            //
 28            // Modified By: Yi Zhou (yi_zhou@hp.com)
 29 kumpf 1.14 //              Warren Otsuka (warren.otsuka@hp.com)
 30 kumpf 1.15 //              Sushma Fernandes, Hewlett-Packard Company
 31            //                     (sushma_fernandes@hp.com)
 32 mike  1.2  //
 33            //%/////////////////////////////////////////////////////////////////////////////
 34            
 35            
 36            ///////////////////////////////////////////////////////////////////////////////
 37            // 
 38            // This file has implementation for the default property owner class.
 39            //
 40            ///////////////////////////////////////////////////////////////////////////////
 41            
 42            #include "DefaultPropertyOwner.h"
 43            
 44            
 45            PEGASUS_USING_STD;
 46            
 47            PEGASUS_NAMESPACE_BEGIN
 48            
 49            
 50            ///////////////////////////////////////////////////////////////////////////////
 51            //  DefaultPropertyOwner
 52            //
 53 mike  1.2  //  When a new property is added with the default owner, make sure to add 
 54            //  the property name and the default attributes of that property in 
 55            //  the table below.
 56            ///////////////////////////////////////////////////////////////////////////////
 57            
 58            static struct ConfigPropertyRow properties[] =
 59            {
 60 kumpf 1.14 #include "DefaultPropertyTable.h"
 61 mike  1.2  };
 62            
 63            const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 64            
 65            
 66            /** Constructors  */
 67            DefaultPropertyOwner::DefaultPropertyOwner()
 68            {
 69 a.arora 1.17     _configProperties.reset(new ConfigProperty[NUM_PROPERTIES]);
 70 mike    1.2  }
 71              
 72              
 73              /**
 74              Initialize the config properties.
 75              */
 76              void DefaultPropertyOwner::initialize()
 77              {
 78                  for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
 79                  {
 80 a.arora 1.17         (_configProperties.get())[i].propertyName = properties[i].propertyName;
 81                      (_configProperties.get())[i].defaultValue = properties[i].defaultValue;
 82                      (_configProperties.get())[i].currentValue = properties[i].defaultValue;
 83                      (_configProperties.get())[i].plannedValue = properties[i].defaultValue;
 84                      (_configProperties.get())[i].dynamic = properties[i].dynamic;
 85                      (_configProperties.get())[i].domain = properties[i].domain;
 86                      (_configProperties.get())[i].domainSize = properties[i].domainSize;
 87                      (_configProperties.get())[i].externallyVisible = properties[i].externallyVisible;
 88 mike    1.2      }
 89              }
 90              
 91              
 92              /** 
 93              Get information about the specified property.
 94              */
 95              void DefaultPropertyOwner::getPropertyInfo(
 96                  const String& name, 
 97                  Array<String>& propertyInfo)
 98              {
 99                  propertyInfo.clear();
100              
101                  for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
102                  {
103 a.arora 1.17         if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
104 mike    1.2          {
105 a.arora 1.17             propertyInfo.append((_configProperties.get())[i].propertyName);
106                          propertyInfo.append((_configProperties.get())[i].defaultValue);
107                          propertyInfo.append((_configProperties.get())[i].currentValue);
108                          propertyInfo.append((_configProperties.get())[i].plannedValue);
109                          if ((_configProperties.get())[i].dynamic)
110 kumpf   1.15             {
111                              propertyInfo.append(STRING_TRUE);
112                          }
113                          else
114                          {
115                              propertyInfo.append(STRING_FALSE);
116                          }
117 a.arora 1.17             if ((_configProperties.get())[i].externallyVisible)
118 mike    1.2              {
119                              propertyInfo.append(STRING_TRUE);
120                          }
121                          else
122                          {
123                              propertyInfo.append(STRING_FALSE);
124                          }
125                          return;
126                      }
127                  }
128              
129                  //
130                  // specified property name is not found
131                  //
132                  throw UnrecognizedConfigProperty(name);
133              }
134              
135              /** 
136              Get default value of the specified property 
137              */
138              const String DefaultPropertyOwner::getDefaultValue(const String& name)
139 mike    1.2  {
140                  for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
141                  {
142 a.arora 1.17         if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
143 mike    1.2          {
144 a.arora 1.17             return ((_configProperties.get())[i].defaultValue);
145 mike    1.2          }
146                  }
147              
148                  //
149                  // Specified property name could not be found
150                  //
151                  throw UnrecognizedConfigProperty(name);
152              }
153              
154              /** 
155              Get current value of the specified property 
156              */
157              const String DefaultPropertyOwner::getCurrentValue(const String& name)
158              {
159                  for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
160                  {
161 a.arora 1.17         if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
162 mike    1.2          {
163 a.arora 1.17             return ((_configProperties.get())[i].currentValue);
164 mike    1.2          }
165                  }
166              
167                  //
168                  // Specified property name could not be found
169                  //
170                  throw UnrecognizedConfigProperty(name);
171              }
172              
173              /** 
174              Get planned value of the specified property 
175              */
176              const String DefaultPropertyOwner::getPlannedValue(const String& name)
177              {
178                  for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
179                  {
180 a.arora 1.17         if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
181 mike    1.2          {
182 a.arora 1.17             return ((_configProperties.get())[i].plannedValue);
183 mike    1.2          }
184                  }
185              
186                  //
187                  // Specified property name could not be found
188                  //
189                  throw UnrecognizedConfigProperty(name);
190              }
191              
192              /** 
193              Init current value of the specified property to the specified value 
194              */
195              void DefaultPropertyOwner::initCurrentValue(
196                  const String& name, 
197                  const String& value)
198              {
199                  for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
200                  {
201 a.arora 1.17         if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
202 mike    1.2          {
203 a.arora 1.17             (_configProperties.get())[i].currentValue = value;
204 mike    1.2              return;
205                      }
206                  }
207              
208                  //
209                  // Specified property name could not be found
210                  //
211                  throw UnrecognizedConfigProperty(name);
212              }
213              
214              
215              /** 
216              Init planned value of the specified property to the specified value 
217              */
218              void DefaultPropertyOwner::initPlannedValue(
219                  const String& name, 
220                  const String& value)
221              {
222                  for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
223                  {
224 a.arora 1.17         if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
225 mike    1.2          {
226 a.arora 1.17             (_configProperties.get())[i].plannedValue = value;
227 mike    1.2              return;
228                      }
229                  }
230              
231                  //
232                  // Specified property name could not be found
233                  //
234                  throw UnrecognizedConfigProperty(name);
235              }
236              
237              /** 
238              Update current value of the specified property to the specified value 
239              */
240              void DefaultPropertyOwner::updateCurrentValue(
241                  const String& name, 
242                  const String& value)
243              {
244                  //
245                  // make sure the property is dynamic before updating the value.
246                  //
247                  if (!isDynamic(name))
248 mike    1.2      {
249                      throw NonDynamicConfigProperty(name); 
250                  }
251              
252                  //
253                  // Since the validations done in initCurrrentValue are sufficient and 
254                  // no additional validations required for update, we shall call 
255                  // initCurrrentValue.
256                  //
257                  initCurrentValue(name, value);
258              }
259              
260              
261              /** 
262              Update planned value of the specified property to the specified value 
263              */
264              void DefaultPropertyOwner::updatePlannedValue(
265                  const String& name, 
266                  const String& value)
267              {
268                  //
269 mike    1.2      // Since the validations done in initPlannedValue are sufficient and 
270                  // no additional validations required for update, we shall call 
271                  // initPlannedValue.
272                  //
273                  initPlannedValue(name, value);
274              }
275              
276              
277              /** 
278              Checks to see if the given value is valid or not.
279              */
280              Boolean DefaultPropertyOwner::isValid(const String& name, const String& value)
281              {
282                  //
283                  // By default, no validation is done. It can optionally be added here
284                  // per property.
285                  //
286                  return 1;
287              }
288              
289              /** 
290 mike    1.2  Checks to see if the specified property is dynamic or not.
291              */
292              Boolean DefaultPropertyOwner::isDynamic(const String& name)
293              {
294                  for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
295                  {
296 a.arora 1.17         if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
297 mike    1.2          {
298 a.arora 1.17             return ((_configProperties.get())[i].dynamic);
299 mike    1.2          }
300                  }
301              
302                  //
303                  // Specified property name could not be found
304                  //
305                  throw UnrecognizedConfigProperty(name);
306              }
307              
308              
309              PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2