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 _configProperties = new ConfigProperty[NUM_PROPERTIES];
70 }
71
72 /** Destructor */
73 DefaultPropertyOwner::~DefaultPropertyOwner()
74 {
|
75 kumpf 1.5 delete [] _configProperties;
|
76 mike 1.2 }
77
78 /**
79 Initialize the config properties.
80 */
81 void DefaultPropertyOwner::initialize()
82 {
83 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
84 {
85 _configProperties[i].propertyName = properties[i].propertyName;
86 _configProperties[i].defaultValue = properties[i].defaultValue;
87 _configProperties[i].currentValue = properties[i].defaultValue;
88 _configProperties[i].plannedValue = properties[i].defaultValue;
89 _configProperties[i].dynamic = properties[i].dynamic;
90 _configProperties[i].domain = properties[i].domain;
91 _configProperties[i].domainSize = properties[i].domainSize;
|
92 kumpf 1.15 _configProperties[i].externallyVisible = properties[i].externallyVisible;
|
93 mike 1.2 }
94 }
95
96
97 /**
98 Get information about the specified property.
99 */
100 void DefaultPropertyOwner::getPropertyInfo(
101 const String& name,
102 Array<String>& propertyInfo)
103 {
104 propertyInfo.clear();
105
106 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
107 {
108 if (String::equalNoCase(_configProperties[i].propertyName, name))
109 {
110 propertyInfo.append(_configProperties[i].propertyName);
111 propertyInfo.append(_configProperties[i].defaultValue);
112 propertyInfo.append(_configProperties[i].currentValue);
113 propertyInfo.append(_configProperties[i].plannedValue);
114 mike 1.2 if (_configProperties[i].dynamic)
|
115 kumpf 1.15 {
116 propertyInfo.append(STRING_TRUE);
117 }
118 else
119 {
120 propertyInfo.append(STRING_FALSE);
121 }
122 if (_configProperties[i].externallyVisible)
|
123 mike 1.2 {
124 propertyInfo.append(STRING_TRUE);
125 }
126 else
127 {
128 propertyInfo.append(STRING_FALSE);
129 }
130 return;
131 }
132 }
133
134 //
135 // specified property name is not found
136 //
137 throw UnrecognizedConfigProperty(name);
138 }
139
140 /**
141 Get default value of the specified property
142 */
143 const String DefaultPropertyOwner::getDefaultValue(const String& name)
144 mike 1.2 {
145 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
146 {
147 if (String::equalNoCase(_configProperties[i].propertyName, name))
148 {
149 return (_configProperties[i].defaultValue);
150 }
151 }
152
153 //
154 // Specified property name could not be found
155 //
156 throw UnrecognizedConfigProperty(name);
157 }
158
159 /**
160 Get current value of the specified property
161 */
162 const String DefaultPropertyOwner::getCurrentValue(const String& name)
163 {
164 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
165 mike 1.2 {
166 if (String::equalNoCase(_configProperties[i].propertyName, name))
167 {
168 return (_configProperties[i].currentValue);
169 }
170 }
171
172 //
173 // Specified property name could not be found
174 //
175 throw UnrecognizedConfigProperty(name);
176 }
177
178 /**
179 Get planned value of the specified property
180 */
181 const String DefaultPropertyOwner::getPlannedValue(const String& name)
182 {
183 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
184 {
185 if (String::equalNoCase(_configProperties[i].propertyName, name))
186 mike 1.2 {
187 return (_configProperties[i].plannedValue);
188 }
189 }
190
191 //
192 // Specified property name could not be found
193 //
194 throw UnrecognizedConfigProperty(name);
195 }
196
197 /**
198 Init current value of the specified property to the specified value
199 */
200 void DefaultPropertyOwner::initCurrentValue(
201 const String& name,
202 const String& value)
203 {
204 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
205 {
206 if (String::equalNoCase(_configProperties[i].propertyName, name))
207 mike 1.2 {
208 _configProperties[i].currentValue = value;
209 return;
210 }
211 }
212
213 //
214 // Specified property name could not be found
215 //
216 throw UnrecognizedConfigProperty(name);
217 }
218
219
220 /**
221 Init planned value of the specified property to the specified value
222 */
223 void DefaultPropertyOwner::initPlannedValue(
224 const String& name,
225 const String& value)
226 {
227 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
228 mike 1.2 {
229 if (String::equalNoCase(_configProperties[i].propertyName, name))
230 {
231 _configProperties[i].plannedValue = value;
232 return;
233 }
234 }
235
236 //
237 // Specified property name could not be found
238 //
239 throw UnrecognizedConfigProperty(name);
240 }
241
242 /**
243 Update current value of the specified property to the specified value
244 */
245 void DefaultPropertyOwner::updateCurrentValue(
246 const String& name,
247 const String& value)
248 {
249 mike 1.2 //
250 // make sure the property is dynamic before updating the value.
251 //
252 if (!isDynamic(name))
253 {
254 throw NonDynamicConfigProperty(name);
255 }
256
257 //
258 // Since the validations done in initCurrrentValue are sufficient and
259 // no additional validations required for update, we shall call
260 // initCurrrentValue.
261 //
262 initCurrentValue(name, value);
263 }
264
265
266 /**
267 Update planned value of the specified property to the specified value
268 */
269 void DefaultPropertyOwner::updatePlannedValue(
270 mike 1.2 const String& name,
271 const String& value)
272 {
273 //
274 // Since the validations done in initPlannedValue are sufficient and
275 // no additional validations required for update, we shall call
276 // initPlannedValue.
277 //
278 initPlannedValue(name, value);
279 }
280
281
282 /**
283 Checks to see if the given value is valid or not.
284 */
285 Boolean DefaultPropertyOwner::isValid(const String& name, const String& value)
286 {
287 //
288 // By default, no validation is done. It can optionally be added here
289 // per property.
290 //
291 mike 1.2 return 1;
292 }
293
294 /**
295 Checks to see if the specified property is dynamic or not.
296 */
297 Boolean DefaultPropertyOwner::isDynamic(const String& name)
298 {
299 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
300 {
301 if (String::equalNoCase(_configProperties[i].propertyName, name))
302 {
303 return (_configProperties[i].dynamic);
304 }
305 }
306
307 //
308 // Specified property name could not be found
309 //
310 throw UnrecognizedConfigProperty(name);
311 }
312 mike 1.2
313
314 PEGASUS_NAMESPACE_END
|