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

  1 karl  1.11 //%2006////////////////////////////////////////////////////////////////////////
  2 chip  1.1  //
  3            // 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            // 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.5  // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 chip  1.1  //
 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.11 // 
 21 chip  1.1  // 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:  Chip Vincent (cvincent@us.ibm.com)
 33            //
 34 aruran.ms 1.8  // Modified By:  Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3614
 35 vijay.eli 1.9  //              Vijay Eli, IBM, (vijayeli@in.ibm.com) for Bug# 3613
 36 aruran.ms 1.10 //              Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3613
 37 chip      1.1  //
 38                //%/////////////////////////////////////////////////////////////////////////////
 39                
 40                #include "NormalizationPropertyOwner.h"
 41                
 42                PEGASUS_NAMESPACE_BEGIN
 43                
 44                static struct ConfigPropertyRow properties[] =
 45                {
 46 chip      1.7  #ifdef PEGASUS_USE_RELEASE_CONFIG_OPTIONS
 47 chip      1.3      { "enableNormalization", "false", IS_STATIC, 0, 0, IS_VISIBLE },
 48 chip      1.7  #else
 49                    { "enableNormalization", "true", IS_STATIC, 0, 0, IS_VISIBLE },
 50                #endif
 51 chip      1.3      { "excludeModulesFromNormalization", "", IS_STATIC, 0, 0, IS_VISIBLE }
 52 chip      1.1  };
 53                
 54                const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 55                
 56                NormalizationPropertyOwner::NormalizationPropertyOwner(void)
 57                {
 58                    _providerObjectNormalizationEnabled.reset(new ConfigProperty());
 59                    _providerObjectNormalizationModuleExclusions.reset(new ConfigProperty());
 60                }
 61                
 62                void NormalizationPropertyOwner::initialize(void)
 63                {
 64                    for(Uint8 i = 0; i < NUM_PROPERTIES; i++)
 65                    {
 66                        if(String::equalNoCase(properties[i].propertyName, "enableNormalization"))
 67                        {
 68                            _providerObjectNormalizationEnabled->propertyName = properties[i].propertyName;
 69                            _providerObjectNormalizationEnabled->defaultValue = properties[i].defaultValue;
 70                            _providerObjectNormalizationEnabled->currentValue = properties[i].defaultValue;
 71                            _providerObjectNormalizationEnabled->plannedValue = properties[i].defaultValue;
 72                            _providerObjectNormalizationEnabled->dynamic = properties[i].dynamic;
 73 chip      1.1              _providerObjectNormalizationEnabled->domain = properties[i].domain;
 74                            _providerObjectNormalizationEnabled->domainSize = properties[i].domainSize;
 75                            _providerObjectNormalizationEnabled->externallyVisible = properties[i].externallyVisible;
 76                        }
 77                        else if(String::equalNoCase(properties[i].propertyName, "excludeModulesFromNormalization"))
 78                        {
 79                            _providerObjectNormalizationModuleExclusions->propertyName = properties[i].propertyName;
 80                            _providerObjectNormalizationModuleExclusions->defaultValue = properties[i].defaultValue;
 81                            _providerObjectNormalizationModuleExclusions->currentValue = properties[i].defaultValue;
 82                            _providerObjectNormalizationModuleExclusions->plannedValue = properties[i].defaultValue;
 83                            _providerObjectNormalizationModuleExclusions->dynamic = properties[i].dynamic;
 84                            _providerObjectNormalizationModuleExclusions->domain = properties[i].domain;
 85                            _providerObjectNormalizationModuleExclusions->domainSize = properties[i].domainSize;
 86                            _providerObjectNormalizationModuleExclusions->externallyVisible = properties[i].externallyVisible;
 87                        }
 88                    }
 89                }
 90                
 91 vijay.eli 1.9  void NormalizationPropertyOwner::getPropertyInfo(const String & name,
 92                                         Array<String> & propertyInfo) const
 93 chip      1.1  {
 94 aruran.ms 1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
 95 chip      1.1  
 96                    propertyInfo.clear();
 97                
 98                    propertyInfo.append(configProperty->propertyName);
 99                    propertyInfo.append(configProperty->defaultValue);
100                    propertyInfo.append(configProperty->currentValue);
101                    propertyInfo.append(configProperty->plannedValue);
102                
103 chip      1.4      if(configProperty->dynamic == IS_DYNAMIC)
104 chip      1.1      {
105                        propertyInfo.append(STRING_TRUE);
106                    }
107                    else
108                    {
109                        propertyInfo.append(STRING_FALSE);
110                    }
111                
112 chip      1.4      if(configProperty->externallyVisible == IS_VISIBLE)
113 chip      1.1      {
114                        propertyInfo.append(STRING_TRUE);
115                    }
116                    else
117                    {
118                        propertyInfo.append(STRING_FALSE);
119                    }
120                }
121                
122 vijay.eli 1.9  String NormalizationPropertyOwner::getDefaultValue(const String & name) const
123 chip      1.1  {
124 aruran.ms 1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
125 chip      1.1  
126                    return(configProperty->defaultValue);
127                }
128                
129 vijay.eli 1.9  String NormalizationPropertyOwner::getCurrentValue(const String & name)const
130 chip      1.1  {
131 aruran.ms 1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
132 chip      1.1  
133                    return(configProperty->currentValue);
134                }
135                
136 vijay.eli 1.9  String NormalizationPropertyOwner::getPlannedValue(const String & name) const
137 chip      1.1  {
138 aruran.ms 1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
139 chip      1.1  
140                    return(configProperty->plannedValue);
141                }
142                
143                void NormalizationPropertyOwner::initCurrentValue(const String & name, const String & value)
144                {
145                    struct ConfigProperty * configProperty = _lookupConfigProperty(name);
146                
147                    configProperty->currentValue = value;
148                }
149                
150                void NormalizationPropertyOwner::initPlannedValue(const String & name, const String & value)
151                {
152                    struct ConfigProperty * configProperty = _lookupConfigProperty(name);
153                
154                    configProperty->plannedValue = value;
155                }
156                
157                void NormalizationPropertyOwner::updateCurrentValue(const String & name, const String & value)
158                {
159                    // make sure the property is dynamic before updating the value.
160 chip      1.1      if(!isDynamic(name))
161                    {
162                        throw NonDynamicConfigProperty(name);
163                    }
164                
165                    struct ConfigProperty * configProperty = _lookupConfigProperty(name);
166                
167                    configProperty->currentValue = value;
168                }
169                
170                void NormalizationPropertyOwner::updatePlannedValue(const String & name, const String & value)
171                {
172                    struct ConfigProperty * configProperty = _lookupConfigProperty(name);
173                
174                    configProperty->plannedValue = value;
175                }
176                
177 vijay.eli 1.9  Boolean NormalizationPropertyOwner::isValid(const String & name,
178                                                 const String & value) const
179 chip      1.1  {
180                    if(String::equalNoCase(name, "enableNormalization"))
181                    {
182                        // valid values are "true" and "false"
183                        if(String::equal(value, "true") || String::equal(value, "false"))
184                        {
185                            return(true);
186                        }
187                    }
188                    else if(String::equalNoCase(name, "excludeModulesFromNormalization"))
189                    {
190                        // valid values must be in the form "n.n.n"
191                
192                        // TODO: validate value
193                
194                        return(true);
195                    }
196                
197                    return(false);
198                }
199                
200 vijay.eli 1.9  Boolean NormalizationPropertyOwner::isDynamic(const String & name) const
201 chip      1.1  {
202 aruran.ms 1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
203 chip      1.1  
204 chip      1.2      return(configProperty->dynamic == IS_DYNAMIC);
205 chip      1.1  }
206                
207 aruran.ms 1.10 struct ConfigProperty * NormalizationPropertyOwner::_lookupConfigProperty(const String & name) const
208 chip      1.1  {
209                    if(String::equalNoCase(name, _providerObjectNormalizationEnabled->propertyName))
210                    {
211                        return(_providerObjectNormalizationEnabled.get());
212                    }
213                    else if(String::equalNoCase(name, _providerObjectNormalizationModuleExclusions->propertyName))
214                    {
215                        return(_providerObjectNormalizationModuleExclusions.get());
216                    }
217                    else
218                    {
219                        throw UnrecognizedConfigProperty(name);
220                    }
221                
222 carson.hovey 1.6      PEGASUS_UNREACHABLE( return(0); )
223 chip         1.1  }
224                   
225                   PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2