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 //%/////////////////////////////////////////////////////////////////////////////
33
34 #include "NormalizationPropertyOwner.h"
35
36 PEGASUS_NAMESPACE_BEGIN
37
38 static struct ConfigPropertyRow properties[] =
39 {
|
40 chip 1.7 #ifdef PEGASUS_USE_RELEASE_CONFIG_OPTIONS
|
41 chip 1.3 { "enableNormalization", "false", IS_STATIC, 0, 0, IS_VISIBLE },
|
42 chip 1.7 #else
43 { "enableNormalization", "true", IS_STATIC, 0, 0, IS_VISIBLE },
44 #endif
|
45 chip 1.3 { "excludeModulesFromNormalization", "", IS_STATIC, 0, 0, IS_VISIBLE }
|
46 chip 1.1 };
47
48 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
49
|
50 kumpf 1.12 NormalizationPropertyOwner::NormalizationPropertyOwner()
|
51 chip 1.1 {
52 _providerObjectNormalizationEnabled.reset(new ConfigProperty());
53 _providerObjectNormalizationModuleExclusions.reset(new ConfigProperty());
54 }
55
|
56 kumpf 1.12 void NormalizationPropertyOwner::initialize()
|
57 chip 1.1 {
|
58 kumpf 1.12 for (Uint8 i = 0; i < NUM_PROPERTIES; i++)
|
59 chip 1.1 {
|
60 kumpf 1.12 if (String::equalNoCase(
61 properties[i].propertyName, "enableNormalization"))
|
62 chip 1.1 {
|
63 kumpf 1.12 _providerObjectNormalizationEnabled->propertyName =
64 properties[i].propertyName;
65 _providerObjectNormalizationEnabled->defaultValue =
66 properties[i].defaultValue;
67 _providerObjectNormalizationEnabled->currentValue =
68 properties[i].defaultValue;
69 _providerObjectNormalizationEnabled->plannedValue =
70 properties[i].defaultValue;
71 _providerObjectNormalizationEnabled->dynamic =
72 properties[i].dynamic;
73 _providerObjectNormalizationEnabled->domain =
74 properties[i].domain;
75 _providerObjectNormalizationEnabled->domainSize =
76 properties[i].domainSize;
77 _providerObjectNormalizationEnabled->externallyVisible =
78 properties[i].externallyVisible;
|
79 chip 1.1 }
|
80 kumpf 1.12 else if (String::equalNoCase(properties[i].propertyName,
81 "excludeModulesFromNormalization"))
|
82 chip 1.1 {
|
83 kumpf 1.12 _providerObjectNormalizationModuleExclusions->propertyName =
84 properties[i].propertyName;
85 _providerObjectNormalizationModuleExclusions->defaultValue =
86 properties[i].defaultValue;
87 _providerObjectNormalizationModuleExclusions->currentValue =
88 properties[i].defaultValue;
89 _providerObjectNormalizationModuleExclusions->plannedValue =
90 properties[i].defaultValue;
91 _providerObjectNormalizationModuleExclusions->dynamic =
92 properties[i].dynamic;
93 _providerObjectNormalizationModuleExclusions->domain =
94 properties[i].domain;
95 _providerObjectNormalizationModuleExclusions->domainSize =
96 properties[i].domainSize;
97 _providerObjectNormalizationModuleExclusions->externallyVisible =
98 properties[i].externallyVisible;
|
99 chip 1.1 }
100 }
101 }
102
|
103 kumpf 1.12 void NormalizationPropertyOwner::getPropertyInfo(
104 const String& name,
105 Array<String>& propertyInfo) const
|
106 chip 1.1 {
|
107 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
108 chip 1.1
109 propertyInfo.clear();
110
111 propertyInfo.append(configProperty->propertyName);
112 propertyInfo.append(configProperty->defaultValue);
113 propertyInfo.append(configProperty->currentValue);
114 propertyInfo.append(configProperty->plannedValue);
115
|
116 kumpf 1.12 if (configProperty->dynamic == IS_DYNAMIC)
|
117 chip 1.1 {
118 propertyInfo.append(STRING_TRUE);
119 }
120 else
121 {
122 propertyInfo.append(STRING_FALSE);
123 }
124
|
125 kumpf 1.12 if (configProperty->externallyVisible == IS_VISIBLE)
|
126 chip 1.1 {
127 propertyInfo.append(STRING_TRUE);
128 }
129 else
130 {
131 propertyInfo.append(STRING_FALSE);
132 }
133 }
134
|
135 kumpf 1.12 String NormalizationPropertyOwner::getDefaultValue(const String& name) const
|
136 chip 1.1 {
|
137 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
138 chip 1.1
|
139 kumpf 1.12 return configProperty->defaultValue;
|
140 chip 1.1 }
141
|
142 kumpf 1.12 String NormalizationPropertyOwner::getCurrentValue(const String& name) const
|
143 chip 1.1 {
|
144 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
145 chip 1.1
|
146 kumpf 1.12 return configProperty->currentValue;
|
147 chip 1.1 }
148
|
149 kumpf 1.12 String NormalizationPropertyOwner::getPlannedValue(const String& name) const
|
150 chip 1.1 {
|
151 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
152 chip 1.1
|
153 kumpf 1.12 return configProperty->plannedValue;
|
154 chip 1.1 }
155
|
156 kumpf 1.12 void NormalizationPropertyOwner::initCurrentValue(
157 const String& name,
158 const String& value)
|
159 chip 1.1 {
|
160 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
161 chip 1.1
162 configProperty->currentValue = value;
163 }
164
|
165 kumpf 1.12 void NormalizationPropertyOwner::initPlannedValue(
166 const String& name,
167 const String& value)
|
168 chip 1.1 {
169 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
170
171 configProperty->plannedValue = value;
172 }
173
|
174 kumpf 1.12 void NormalizationPropertyOwner::updateCurrentValue(
175 const String& name,
176 const String& value)
|
177 chip 1.1 {
178 // make sure the property is dynamic before updating the value.
|
179 kumpf 1.12 if (!isDynamic(name))
|
180 chip 1.1 {
181 throw NonDynamicConfigProperty(name);
182 }
183
184 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
185
186 configProperty->currentValue = value;
187 }
188
|
189 kumpf 1.12 void NormalizationPropertyOwner::updatePlannedValue(
190 const String& name,
191 const String& value)
|
192 chip 1.1 {
|
193 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
194 chip 1.1
195 configProperty->plannedValue = value;
196 }
197
|
198 kumpf 1.12 Boolean NormalizationPropertyOwner::isValid(
199 const String& name,
200 const String& value) const
|
201 chip 1.1 {
|
202 kumpf 1.12 if (String::equalNoCase(name, "enableNormalization"))
|
203 chip 1.1 {
204 // valid values are "true" and "false"
|
205 kumpf 1.12 if (String::equal(value, "true") || String::equal(value, "false"))
|
206 chip 1.1 {
|
207 kumpf 1.12 return true;
|
208 chip 1.1 }
209 }
|
210 kumpf 1.12 else if (String::equalNoCase(name, "excludeModulesFromNormalization"))
|
211 chip 1.1 {
212 // valid values must be in the form "n.n.n"
213
214 // TODO: validate value
215
|
216 kumpf 1.12 return true;
|
217 chip 1.1 }
218
|
219 kumpf 1.12 return false;
|
220 chip 1.1 }
221
|
222 kumpf 1.12 Boolean NormalizationPropertyOwner::isDynamic(const String& name) const
|
223 chip 1.1 {
|
224 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
225 chip 1.1
|
226 chip 1.2 return(configProperty->dynamic == IS_DYNAMIC);
|
227 chip 1.1 }
228
|
229 kumpf 1.12 struct ConfigProperty* NormalizationPropertyOwner::_lookupConfigProperty(
230 const String& name) const
|
231 chip 1.1 {
|
232 kumpf 1.12 if (String::equalNoCase(
233 name, _providerObjectNormalizationEnabled->propertyName))
|
234 chip 1.1 {
|
235 kumpf 1.12 return _providerObjectNormalizationEnabled.get();
|
236 chip 1.1 }
|
237 kumpf 1.12 else if (String::equalNoCase(
238 name, _providerObjectNormalizationModuleExclusions->propertyName))
|
239 chip 1.1 {
|
240 kumpf 1.12 return _providerObjectNormalizationModuleExclusions.get();
|
241 chip 1.1 }
242 else
243 {
244 throw UnrecognizedConfigProperty(name);
245 }
246
|
247 kumpf 1.12 PEGASUS_UNREACHABLE( return 0; )
|
248 chip 1.1 }
249
250 PEGASUS_NAMESPACE_END
|