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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2