1 thilo.boehm 1.1 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 thilo.boehm 1.1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
|
32 thilo.boehm 1.2.2.9 #include <Pegasus/Common/SCMO.h>
33 #include <Pegasus/Common/SCMOClass.h>
34 #include <Pegasus/Common/SCMOInstance.h>
35 #include <Pegasus/Common/SCMODump.h>
|
36 thilo.boehm 1.2.2.29 #include <Pegasus/Common/SCMOClassCache.h>
|
37 thilo.boehm 1.1 #include <Pegasus/Common/CharSet.h>
38 #include <Pegasus/Common/CIMDateTimeRep.h>
39 #include <Pegasus/Common/CIMPropertyRep.h>
|
40 thilo.boehm 1.2.2.13 #include <Pegasus/Common/CIMInstanceRep.h>
41 #include <Pegasus/Common/CIMObjectPathRep.h>
|
42 thilo.boehm 1.2.2.16 #include <Pegasus/Common/CIMNameCast.h>
|
43 thilo.boehm 1.1 #include <Pegasus/Common/CommonUTF.h>
44 #include <Pegasus/Common/StrLit.h>
|
45 thilo.boehm 1.2 #include <Pegasus/Common/XmlWriter.h>
|
46 thilo.boehm 1.2.2.6 #include <Pegasus/Common/System.h>
47 #include <Pegasus/Common/FileSystem.h>
|
48 thilo.boehm 1.2.2.11 #include <Pegasus/Common/StringConversion.h>
|
49 thilo.boehm 1.2.2.25 #include <Pegasus/Common/ArrayIterator.h>
|
50 thilo.boehm 1.2.2.30 #include <Pegasus/Common/PegasusAssert.h>
|
51 marek 1.2.2.52 #include <Pegasus/Common/CIMValueRep.h>
52
53 # if defined PEGASUS_OS_ZOS
54 # include <strings.h>
55 # else
56 # include <string.h>
57 # endif
|
58 thilo.boehm 1.1
|
59 thilo.boehm 1.2.2.6 #ifdef PEGASUS_OS_ZOS
60 #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>
61 #endif
|
62 thilo.boehm 1.1
|
63 thilo.boehm 1.2.2.34 #ifdef PEGASUS_HAS_ICU
64 # include <unicode/platform.h>
65 # include <unicode/urename.h>
66 # include <unicode/ures.h>
67 # include <unicode/ustring.h>
68 # include <unicode/uchar.h>
69 # include <unicode/ucnv.h>
70 #endif
71
|
72 thilo.boehm 1.1 PEGASUS_USING_STD;
73
74 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096
75
|
76 thilo.boehm 1.2.2.8 /**
|
77 thilo.boehm 1.2.2.13 * This macro is used at the SCMODump class
|
78 thilo.boehm 1.2.2.8 * for generating C/C++ runtime independend output.
|
79 thilo.boehm 1.2.2.13 * For example on Linux if fprintf got a NULL pointer
|
80 thilo.boehm 1.2.2.8 * for a string format specification, the string "(null)" is
81 * substituted. On other platforms no string "" is substituded.
82 */
|
83 thilo.boehm 1.2.2.32 #define NULLSTR(x) ((x) == 0 ? "" : (x))
|
84 thilo.boehm 1.1
|
85 thilo.boehm 1.2.2.16 #define NEWCIMSTR(ptr,base) \
|
86 thilo.boehm 1.2.2.57 ((ptr).size == 0 ? \
|
87 thilo.boehm 1.2.2.16 (String()) : \
|
88 thilo.boehm 1.2.2.57 (String(&(base)[(ptr).start],((ptr).size)-1)))
|
89 thilo.boehm 1.2.2.15
|
90 thilo.boehm 1.1 PEGASUS_NAMESPACE_BEGIN
91
|
92 thilo.boehm 1.2.2.34 #define PEGASUS_ARRAY_T SCMOInstance
93 # include "ArrayImpl.h"
94 #undef PEGASUS_ARRAY_T
95
96
|
97 marek 1.2.2.23 const StrLit SCMOClass::_qualifierNameStrLit[72] =
|
98 thilo.boehm 1.1 {
|
99 thilo.boehm 1.2 STRLIT(""),
100 STRLIT("ABSTRACT"),
101 STRLIT("AGGREGATE"),
102 STRLIT("AGGREGATION"),
103 STRLIT("ALIAS"),
|
104 thilo.boehm 1.2.2.1 STRLIT("ARRAYTYPE"),
105 STRLIT("ASSOCIATION"),
|
106 thilo.boehm 1.2 STRLIT("BITMAP"),
107 STRLIT("BITVALUES"),
108 STRLIT("CLASSCONSTRAINT"),
109 STRLIT("COMPOSITION"),
110 STRLIT("CORRELATABLE"),
|
111 thilo.boehm 1.1 STRLIT("COUNTER"),
112 STRLIT("DELETE"),
|
113 thilo.boehm 1.2 STRLIT("DEPRECATED"),
|
114 thilo.boehm 1.1 STRLIT("DESCRIPTION"),
|
115 thilo.boehm 1.2 STRLIT("DISPLAYDESCRIPTION"),
116 STRLIT("DISPLAYNAME"),
117 STRLIT("DN"),
|
118 thilo.boehm 1.1 STRLIT("EMBEDDEDINSTANCE"),
|
119 thilo.boehm 1.2 STRLIT("EMBEDDEDOBJECT"),
120 STRLIT("EXCEPTION"),
121 STRLIT("EXPENSIVE"),
122 STRLIT("EXPERIMENTAL"),
123 STRLIT("GAUGE"),
|
124 thilo.boehm 1.2.2.1 STRLIT("IFDELETED"),
|
125 thilo.boehm 1.2 STRLIT("IN"),
|
126 thilo.boehm 1.2.2.1 STRLIT("INDICATION"),
|
127 thilo.boehm 1.2 STRLIT("INVISIBLE"),
|
128 thilo.boehm 1.1 STRLIT("ISPUNIT"),
|
129 thilo.boehm 1.2 STRLIT("KEY"),
|
130 thilo.boehm 1.1 STRLIT("LARGE"),
|
131 thilo.boehm 1.2 STRLIT("MAPPINGSTRINGS"),
132 STRLIT("MAX"),
133 STRLIT("MAXLEN"),
134 STRLIT("MAXVALUE"),
|
135 thilo.boehm 1.1 STRLIT("METHODCONSTRAINT"),
|
136 thilo.boehm 1.2 STRLIT("MIN"),
137 STRLIT("MINLEN"),
138 STRLIT("MINVALUE"),
139 STRLIT("MODELCORRESPONDENCE"),
140 STRLIT("NONLOCAL"),
141 STRLIT("NONLOCALTYPE"),
142 STRLIT("NULLVALUE"),
143 STRLIT("OCTETSTRING"),
144 STRLIT("OUT"),
145 STRLIT("OVERRIDE"),
|
146 thilo.boehm 1.1 STRLIT("PROPAGATED"),
|
147 thilo.boehm 1.2 STRLIT("PROPERTYCONSTRAINT"),
148 STRLIT("PROPERTYUSAGE"),
149 STRLIT("PROVIDER"),
150 STRLIT("PUNIT"),
151 STRLIT("READ"),
152 STRLIT("REQUIRED"),
153 STRLIT("REVISION"),
154 STRLIT("SCHEMA"),
155 STRLIT("SOURCE"),
156 STRLIT("SOURCETYPE"),
157 STRLIT("STATIC"),
158 STRLIT("SYNTAX"),
159 STRLIT("SYNTAXTYPE"),
160 STRLIT("TERMINAL"),
161 STRLIT("TRIGGERTYPE"),
162 STRLIT("UMLPACKAGEPATH"),
|
163 thilo.boehm 1.1 STRLIT("UNITS"),
|
164 thilo.boehm 1.2 STRLIT("UNKNOWNVALUES"),
|
165 thilo.boehm 1.1 STRLIT("UNSUPPORTEDVALUES"),
|
166 thilo.boehm 1.2 STRLIT("VALUEMAP"),
167 STRLIT("VALUES"),
168 STRLIT("VERSION"),
|
169 thilo.boehm 1.2.2.1 STRLIT("WEAK"),
|
170 thilo.boehm 1.1 STRLIT("WRITE")
171 };
172
|
173 thilo.boehm 1.2 #define _NUM_QUALIFIER_NAMES \
174 (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0]))
|
175 thilo.boehm 1.1
176 /*****************************************************************************
|
177 thilo.boehm 1.2.2.29 * Internal inline functions.
178 *****************************************************************************/
179
180 inline void _deleteArrayExtReference(
181 SCMBDataPtr& theArray,
182 SCMBMgmt_Header** pmem )
183 {
184 SCMBUnion* ptr;
185 // if the array was already set,
186 // the previous references has to be deleted
|
187 thilo.boehm 1.2.2.57 if(theArray.size != 0)
|
188 thilo.boehm 1.2.2.29 {
|
189 thilo.boehm 1.2.2.57 Uint32 oldArraySize=(theArray.size/sizeof(SCMBUnion));
|
190 thilo.boehm 1.2.2.29
191 ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]);
192 for (Uint32 i = 0 ; i < oldArraySize ; i++)
193 {
194 delete ptr[i].extRefPtr;
|
195 thilo.boehm 1.2.2.65 ptr[i].extRefPtr = 0;
|
196 thilo.boehm 1.2.2.35 }
197 }
198 }
|
199 thilo.boehm 1.2.2.29
200 /*****************************************************************************
|
201 thilo.boehm 1.1 * The SCMOClass methods
202 *****************************************************************************/
|
203 thilo.boehm 1.2 SCMOClass::SCMOClass()
|
204 thilo.boehm 1.1 {
|
205 thilo.boehm 1.2.2.59 _initSCMOClass();
|
206 thilo.boehm 1.2.2.60
207 _setBinary("",1,cls.hdr->className,&cls.mem );
208 _setBinary("",1,cls.hdr->nameSpace,&cls.mem );
|
209 thilo.boehm 1.2.2.59 cls.hdr->flags.isEmpty=true;
|
210 thilo.boehm 1.1 }
211
|
212 thilo.boehm 1.2.2.28 inline void SCMOClass::_initSCMOClass()
|
213 thilo.boehm 1.1 {
214 PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
215 - sizeof(SCMBClass_Main)>0);
216
|
217 thilo.boehm 1.2.2.2 cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
|
218 thilo.boehm 1.2.2.32 if (cls.base == 0)
|
219 thilo.boehm 1.1 {
|
220 thilo.boehm 1.2 // Not enough memory!
|
221 thilo.boehm 1.1 throw PEGASUS_STD(bad_alloc)();
222 }
223
|
224 thilo.boehm 1.2.2.28 memset(cls.base,0,sizeof(SCMBClass_Main));
225
|
226 thilo.boehm 1.1 // initalize eye catcher
227 cls.hdr->header.magic=PEGASUS_SCMB_CLASS_MAGIC;
228 cls.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
|
229 thilo.boehm 1.2 // The # of bytes free
|
230 thilo.boehm 1.1 cls.hdr->header.freeBytes=
231 SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBClass_Main);
232
233 // Index to the start of the free space in this instance
234 cls.hdr->header.startOfFreeSpace=sizeof(SCMBClass_Main);
235
236 cls.hdr->refCount=1;
237
|
238 thilo.boehm 1.2.2.28 }
239
|
240 thilo.boehm 1.2.2.38 SCMOClass::SCMOClass(const char* className, const char* nameSpaceName )
241 {
|
242 thilo.boehm 1.2.2.59 Uint32 clsNameLen = strlen(className);
243 Uint32 nsNameLen = strlen(nameSpaceName);
244
245 if (0 == className )
|
246 thilo.boehm 1.2.2.38 {
247 String message("SCMOClass: Class name not set (null pointer)!");
248 throw CIMException(CIM_ERR_FAILED,message );
249 }
250
|
251 thilo.boehm 1.2.2.60 if (0 == nameSpaceName)
|
252 thilo.boehm 1.2.2.38 {
253 String message("SCMOClass: Name Space not set (null pointer)!");
254 throw CIMException(CIM_ERR_FAILED,message );
255 }
256
257 _initSCMOClass();
258
|
259 thilo.boehm 1.2.2.59 _setBinary(className,clsNameLen+1,cls.hdr->className,&cls.mem );
|
260 thilo.boehm 1.2.2.38
|
261 thilo.boehm 1.2.2.59 _setBinary(nameSpaceName,nsNameLen+1,cls.hdr->nameSpace,&cls.mem );
262
263 cls.hdr->flags.isEmpty=true;
|
264 thilo.boehm 1.2.2.38
265 }
266
|
267 thilo.boehm 1.2.2.28 SCMOClass::SCMOClass(
268 const CIMClass& theCIMClass,
269 const char* nameSpaceName)
270 {
271
272 _initSCMOClass();
273
|
274 thilo.boehm 1.1 try
275 {
276 _setString(theCIMClass.getSuperClassName().getString(),
277 cls.hdr->superClassName,
278 &cls.mem );
279 }
280 catch (UninitializedObjectException&)
281 {
282 // there is no Super ClassName
283 cls.hdr->superClassName.start=0;
|
284 thilo.boehm 1.2.2.57 cls.hdr->superClassName.size=0;
|
285 thilo.boehm 1.1 }
286
287 CIMObjectPath theObjectPath=theCIMClass.getPath();
288
289 //set name space
|
290 r.kieninger 1.2.2.22 if (nameSpaceName)
291 {
292 _setBinary(nameSpaceName,
293 strlen(nameSpaceName)+1,
294 cls.hdr->nameSpace,
295 &cls.mem );
296 }
297 else
298 {
299 _setString(theObjectPath.getNameSpace().getString(),
300 cls.hdr->nameSpace,
301 &cls.mem );
302 }
|
303 thilo.boehm 1.1
304 //set class name
305 _setString(theObjectPath.getClassName().getString(),
306 cls.hdr->className,
307 &cls.mem );
308
309 //set class Qualifiers
|
310 thilo.boehm 1.2.2.28 _setClassQualifers(theCIMClass._rep->_qualifiers);
|
311 thilo.boehm 1.1
312 //set properties
|
313 thilo.boehm 1.2.2.28 _setClassProperties(theCIMClass._rep->_properties);
|
314 thilo.boehm 1.1
315 }
316
|
317 thilo.boehm 1.2.2.65 void SCMOClass::_destroyExternalReferences()
318 {
319 _destroyExternalReferencesInternal(cls.mem);
320 }
321
|
322 thilo.boehm 1.2.2.41 const char* SCMOClass::getSuperClassName() const
323 {
324 return _getCharString(cls.hdr->superClassName,cls.base);
325 }
326
|
327 marek 1.2.2.54 const char* SCMOClass::getSuperClassName_l(Uint64 & length) const
328 {
|
329 marek 1.2.2.64 length = cls.hdr->superClassName.size;
330 if (0 == length)
331 {
332 return 0;
333 }
334 else
335 {
336 length--;
337 }
|
338 marek 1.2.2.54 return _getCharString(cls.hdr->superClassName,cls.base);
339 }
340
|
341 thilo.boehm 1.2.2.29 void SCMOClass::getCIMClass(CIMClass& cimClass) const
342 {
343 CIMClass newCimClass(
344 CIMNameCast(NEWCIMSTR(cls.hdr->className,cls.base)),
345 CIMNameCast(NEWCIMSTR(cls.hdr->superClassName,cls.base)));
346
347 // set the name space
348 newCimClass._rep->_reference._rep->_nameSpace=
349 CIMNamespaceNameCast(NEWCIMSTR(cls.hdr->nameSpace,cls.base));
350
351 // Add class qualifier if exist
352 if (0 != cls.hdr->numberOfQualifiers)
353 {
354 SCMBQualifier* qualiArray =
355 (SCMBQualifier*)&(cls.base[cls.hdr->qualifierArray.start]);
356
357 CIMQualifier theCimQualifier;
358
359 Uint32 i, k = cls.hdr->numberOfQualifiers;
360 for ( i = 0 ; i < k ; i++)
361 {
362 thilo.boehm 1.2.2.29 _getCIMQualifierFromSCMBQualifier(
363 theCimQualifier,
364 qualiArray[i],
365 cls.base);
366
367 newCimClass._rep->_qualifiers.addUnchecked(theCimQualifier);
368 }
369 }
370
371 // If properties are in that class
372 if (0 != cls.hdr->propertySet.number)
373 {
374 Uint32 i, k = cls.hdr->propertySet.number;
375 for ( i = 0 ; i < k ; i++)
376 {
377 newCimClass._rep->_properties.append(
378 _getCIMPropertyAtNodeIndex(i));
379 }
380 }
381
382 cimClass = newCimClass;
383 thilo.boehm 1.2.2.29 }
384
385 CIMProperty SCMOClass::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const
386 {
387 CIMValue theCimValue;
388 CIMProperty retCimProperty;
389
390 SCMBClassPropertyNode& clsProp =
391 ((SCMBClassPropertyNode*)
392 &(cls.base[cls.hdr->propertySet.nodeArray.start]))[nodeIdx];
393
394 // get the default value
395 SCMOInstance::_getCIMValueFromSCMBValue(
396 theCimValue,
397 clsProp.theProperty.defaultValue,
398 cls.base);
399
400 // have to check if there is the origin class name set.
401 // An empty origin class name is differnt then a NULL class name
402 if (0 != clsProp.theProperty.originClassName.start)
403 {
404 thilo.boehm 1.2.2.29 retCimProperty = CIMProperty(
405 CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)),
406 theCimValue,
407 theCimValue.getArraySize(),
408 CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)),
409 CIMNameCast(NEWCIMSTR(
410 clsProp.theProperty.originClassName,cls.base)),
411 clsProp.theProperty.flags.propagated);
412 }
413 else
414 {
415 retCimProperty = CIMProperty(
416 CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)),
417 theCimValue,
418 theCimValue.getArraySize(),
419 CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)),
420 CIMName(),
421 clsProp.theProperty.flags.propagated);
422 }
423
424 SCMBQualifier* qualiArray =
425 thilo.boehm 1.2.2.29 (SCMBQualifier*)
426 &(cls.base[clsProp.theProperty.qualifierArray.start]);
427
428 CIMQualifier theCimQualifier;
429 Uint32 i, k = clsProp.theProperty.numberOfQualifiers;
430 for ( i = 0 ; i < k ; i++)
431 {
432 _getCIMQualifierFromSCMBQualifier(
433 theCimQualifier,
434 qualiArray[i],
435 cls.base);
436
437 retCimProperty._rep->_qualifiers.addUnchecked(theCimQualifier);
438 }
439
440 return retCimProperty;
441
442 }
443
444 void SCMOClass::_getCIMQualifierFromSCMBQualifier(
445 CIMQualifier& theCimQualifier,
446 thilo.boehm 1.2.2.29 const SCMBQualifier& scmbQualifier,
447 const char* base)
448
449 {
450
451 CIMName theCimQualiName;
452 CIMValue theCimValue;
453
454 SCMOInstance::_getCIMValueFromSCMBValue(
455 theCimValue,
456 scmbQualifier.value,
457 base);
458
459 if (scmbQualifier.name == QUALNAME_USERDEFINED)
460 {
461 theCimQualiName = NEWCIMSTR(scmbQualifier.userDefName,base);
462 }
463 else
464 {
465 theCimQualiName = String(
466 SCMOClass::qualifierNameStrLit(scmbQualifier.name).str,
467 thilo.boehm 1.2.2.29 SCMOClass::qualifierNameStrLit(scmbQualifier.name).size);
468 }
469
470 theCimQualifier = CIMQualifier(
471 theCimQualiName,
472 theCimValue,
473 scmbQualifier.flavor,
474 scmbQualifier.propagated);
475 }
476
|
477 thilo.boehm 1.1 void SCMOClass::getKeyNamesAsString(Array<String>& keyNames) const
478 {
479 SCMBKeyBindingNode* nodeArray =
480 (SCMBKeyBindingNode*)&(cls.base[cls.hdr->keyBindingSet.nodeArray.start]);
481
482 keyNames.clear();
483
|
484 thilo.boehm 1.2.2.42 for (Uint32 i = 0, k = cls.hdr->keyBindingSet.number; i < k; i++)
|
485 thilo.boehm 1.1 {
|
486 thilo.boehm 1.2 // Append the key property name.
|
487 thilo.boehm 1.2.2.42 keyNames.append(NEWCIMSTR(nodeArray[i].name,cls.base));
|
488 thilo.boehm 1.1 }
489 }
490
|
491 thilo.boehm 1.2.2.10 const char* SCMOClass::_getPropertyNameAtNode(Uint32 propNode) const
492 {
493 SCMBClassPropertyNode* nodeArray =
494 (SCMBClassPropertyNode*)
495 &(cls.base[cls.hdr->propertySet.nodeArray.start]);
496
497 return(_getCharString(nodeArray[propNode].theProperty.name,cls.base));
498 }
499
|
500 thilo.boehm 1.1 SCMO_RC SCMOClass::_getKeyBindingNodeIndex(Uint32& node, const char* name) const
501 {
502
503 Uint32 tag,len,hashIdx;
504
505 len = strlen(name);
|
506 thilo.boehm 1.2.2.2 tag = _generateStringTag((const char*)name, len);
|
507 thilo.boehm 1.1 // get the node index of the hash table
|
508 thilo.boehm 1.2 hashIdx =
|
509 thilo.boehm 1.1 cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE];
510 // there is no entry in the hash table on this hash table index.
511 if (hashIdx == 0)
512 {
513 // property name not found
514 return SCMO_NOT_FOUND;
515 }
516
517 // get the propterty node array
|
518 thilo.boehm 1.2 SCMBKeyBindingNode* nodeArray =
|
519 thilo.boehm 1.1 (SCMBKeyBindingNode*)
520 &(cls.base[cls.hdr->keyBindingSet.nodeArray.start]);
521
|
522 thilo.boehm 1.2 // set property node array index.
|
523 thilo.boehm 1.1 // The hash table index to the node arra in one larger!
524 node = hashIdx - 1;
525
526 do
527 {
528 // do they have the same hash tag ?
529 if (nodeArray[node].nameHashTag == tag)
530 {
531 // Now it is worth to compare the two names
|
532 thilo.boehm 1.2.2.47 if (_equalNoCaseUTF8Strings(nodeArray[node].name,cls.base,name,len))
|
533 thilo.boehm 1.1 {
534 // we found the property !
535 return SCMO_OK;
536 }
537 }
538 // Are we at the end of the chain ?
539 if (!nodeArray[node].hasNext)
540 {
541 // property name not found
542 return SCMO_NOT_FOUND;
543 }
544
545 // get next node index.
546 node = nodeArray[node].nextNode;
547
548 } while ( true );
549
550 // this should never be reached
551 return SCMO_NOT_FOUND;
552
553 }
554 thilo.boehm 1.1
555 SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const
556 {
557
558 Uint32 tag,len,hashIdx;
559
560 len = strlen(name);
|
561 thilo.boehm 1.2.2.2 tag = _generateStringTag((const char*)name, len);
|
562 thilo.boehm 1.1 // get the node index of the hash table
|
563 thilo.boehm 1.2 hashIdx =
|
564 thilo.boehm 1.1 cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE];
565 // there is no entry in the hash table on this hash table index.
566 if (hashIdx == 0)
567 {
568 // property name not found
569 return SCMO_NOT_FOUND;
570 }
571
572 // get the propterty node array
|
573 thilo.boehm 1.2 SCMBClassPropertyNode* nodeArray =
|
574 thilo.boehm 1.1 (SCMBClassPropertyNode*)
575 &(cls.base[cls.hdr->propertySet.nodeArray.start]);
576
|
577 thilo.boehm 1.2 // set property node array index.
|
578 thilo.boehm 1.1 // The hash table index to the node arra in one larger!
579 node = hashIdx - 1;
580
581 do
582 {
583 // do they have the same hash tag ?
584 if (nodeArray[node].theProperty.nameHashTag == tag)
585 {
586 // Now it is worth to compare the two names
|
587 thilo.boehm 1.2.2.47 if (_equalNoCaseUTF8Strings(
|
588 thilo.boehm 1.1 nodeArray[node].theProperty.name,cls.base,name,len))
589 {
590 // we found the property !
591 return SCMO_OK;
592 }
593 }
594 // Are we at the end of the chain ?
595 if (!nodeArray[node].hasNext)
596 {
597 // property name not found
598 return SCMO_NOT_FOUND;
599 }
600
601 // get next node index.
602 node = nodeArray[node].nextNode;
603
604 } while ( true );
605
606 // this should never be reached
607 return SCMO_NOT_FOUND;
608
609 thilo.boehm 1.1 }
610
|
611 thilo.boehm 1.2.2.28 void SCMOClass::_setClassProperties(PropertySet& theCIMProperties)
|
612 thilo.boehm 1.1 {
|
613 thilo.boehm 1.2.2.28 Uint32 noProps = theCIMProperties.size();
|
614 thilo.boehm 1.1 Uint64 start, startKeyIndexList;
615 Uint32 noKeys = 0;
616 Boolean isKey = false;
617
|
618 thilo.boehm 1.2.2.53 Array<Uint32> keyIndex(noProps);
|
619 thilo.boehm 1.1
620 cls.hdr->propertySet.number=noProps;
621
622 // allocate the keyIndexList
623 startKeyIndexList = _getFreeSpace(
624 cls.hdr->keyIndexList,
625 noProps*sizeof(Uint32),
|
626 thilo.boehm 1.2.2.60 &cls.mem);
|
627 thilo.boehm 1.2
|
628 thilo.boehm 1.1 if(noProps != 0)
629 {
|
630 thilo.boehm 1.2 // Allocate key property mask.
631 // Each property needs a bit in the mask.
|
632 thilo.boehm 1.1 // The number of Uint64 in the key mask is :
|
633 thilo.boehm 1.2 // Decrease the number of properties by 1 since
|
634 thilo.boehm 1.1 // the array is starting at 0!
635 // Divided with the number of bits in a Uint64.
636 // e.g. number of Properties = 68
|
637 thilo.boehm 1.2 // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values.
|
638 thilo.boehm 1.1 _getFreeSpace(cls.hdr->keyPropertyMask,
639 sizeof(Uint64)*(((noProps-1)/64)+1),
|
640 thilo.boehm 1.2.2.60 &cls.mem);
|
641 thilo.boehm 1.1
642 // allocate property array and save the start index of the array.
643 start = _getFreeSpace(cls.hdr->propertySet.nodeArray,
644 sizeof(SCMBClassPropertyNode)*noProps,
|
645 thilo.boehm 1.2.2.60 &cls.mem);
|
646 thilo.boehm 1.1
647 // clear the hash table
648 memset(cls.hdr->propertySet.hashTable,
649 0,
650 PEGASUS_PROPERTY_SCMB_HASHSIZE*sizeof(Uint32));
651
652
653 for (Uint32 i = 0; i < noProps; i++)
654 {
655
|
656 thilo.boehm 1.2.2.28 _setProperty(start,&isKey ,theCIMProperties[i]);
|
657 thilo.boehm 1.1 if(isKey)
658 {
|
659 thilo.boehm 1.2 // if the property is a key
|
660 thilo.boehm 1.1 // save the key index
661 keyIndex[noKeys]=i;
662 noKeys++;
663 _setPropertyAsKeyInMask(i);
664 }
665 // Adjust ordered set management structures.
666 _insertPropertyIntoOrderedSet(start,i);
667
668 start = start + sizeof(SCMBClassPropertyNode);
669 }
670
671 cls.hdr->keyBindingSet.number = noKeys;
672
673 if (noKeys != 0)
674 {
675 // allocate key binding array and save the start index of the array.
676 start = _getFreeSpace(cls.hdr->keyBindingSet.nodeArray,
677 sizeof(SCMBKeyBindingNode)*noKeys,
|
678 thilo.boehm 1.2 &cls.mem);
|
679 thilo.boehm 1.1
680 // clear the hash table
681 memset(cls.hdr->keyBindingSet.hashTable,
682 0,
683 PEGASUS_KEYBINDIG_SCMB_HASHSIZE*sizeof(Uint32));
684
685 // fill the key index list
686 memcpy(
687 &(cls.base[startKeyIndexList]),
|
688 thilo.boehm 1.2.2.53 keyIndex.getData(),
|
689 thilo.boehm 1.1 noKeys*sizeof(Uint32));
690
691 for (Uint32 i = 0 ; i < noKeys; i++)
692 {
693
|
694 thilo.boehm 1.2.2.28 _setClassKeyBinding(start,theCIMProperties[keyIndex[i]]);
|
695 thilo.boehm 1.1 // Adjust ordered set management structures.
696 _insertKeyBindingIntoOrderedSet(start,i);
697
698 start = start + sizeof(SCMBKeyBindingNode);
699 }
700
701 }
702 else
703 {
704 cls.hdr->keyBindingSet.nodeArray.start=0;
|
705 thilo.boehm 1.2.2.57 cls.hdr->keyBindingSet.nodeArray.size=0;
|
706 thilo.boehm 1.1 }
707 }
708 else
709 {
710 cls.hdr->propertySet.nodeArray.start=0;
|
711 thilo.boehm 1.2.2.57 cls.hdr->propertySet.nodeArray.size=0;
|
712 thilo.boehm 1.1 cls.hdr->keyPropertyMask.start=0;
|
713 thilo.boehm 1.2.2.57 cls.hdr->keyPropertyMask.size=0;
|
714 thilo.boehm 1.1 cls.hdr->keyBindingSet.nodeArray.start=0;
|
715 thilo.boehm 1.2.2.57 cls.hdr->keyBindingSet.nodeArray.size=0;
|
716 thilo.boehm 1.1 }
717 }
718
719 void SCMOClass::_insertKeyBindingIntoOrderedSet(Uint64 start, Uint32 newIndex)
720 {
721
|
722 thilo.boehm 1.2 SCMBKeyBindingNode* newKeyNode =
|
723 thilo.boehm 1.1 (SCMBKeyBindingNode*)&(cls.base[start]);
724
725 SCMBKeyBindingNode* scmoKeyNodeArray =
726 (SCMBKeyBindingNode*)
727 &(cls.base[cls.hdr->keyBindingSet.nodeArray.start]);
728
729 Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable;
730
731 // calculate the new hash index of the new property.
732 Uint32 hash = newKeyNode->nameHashTag % PEGASUS_KEYBINDIG_SCMB_HASHSIZE;
733
734 // 0 is an invalid index in the hash table
735 if (hashTable[hash] == 0)
736 {
737 hashTable[hash] = newIndex + 1;
738 return;
739 }
740
741 // get the first node of the hash chain.
742 Uint32 nodeIndex = hashTable[hash]-1;
743
744 thilo.boehm 1.1 do
745 {
746 // is this the same note ?
747 if (nodeIndex == newIndex)
748 {
749 // The node is already in the ordered set
750 return;
751 }
752
753 // Are we at the end of the chain ?
754 if (!scmoKeyNodeArray[nodeIndex].hasNext)
755 {
756 // link the new element at the end of the chain
757 scmoKeyNodeArray[nodeIndex].nextNode = newIndex;
758 scmoKeyNodeArray[nodeIndex].hasNext = true;
759 return;
760 }
761
762 nodeIndex = scmoKeyNodeArray[nodeIndex].nextNode;
763
764 } while ( true );
765 thilo.boehm 1.1
766 // this should never be reached
767 }
768
769 void SCMOClass::_insertPropertyIntoOrderedSet(Uint64 start, Uint32 newIndex)
770 {
771
772
|
773 thilo.boehm 1.2 SCMBClassPropertyNode* newPropNode =
|
774 thilo.boehm 1.1 (SCMBClassPropertyNode*)&(cls.base[start]);
775
776 SCMBClassPropertyNode* scmoPropNodeArray =
777 (SCMBClassPropertyNode*)
778 &(cls.base[cls.hdr->propertySet.nodeArray.start]);
779
780 Uint32 *hashTable = cls.hdr->propertySet.hashTable;
781
782 // calcuate the new hash index of the new property.
|
783 thilo.boehm 1.2 Uint32 hash = newPropNode->theProperty.nameHashTag %
|
784 thilo.boehm 1.1 PEGASUS_PROPERTY_SCMB_HASHSIZE;
785
786 // 0 is an invalid index in the hash table
787 if (hashTable[hash] == 0)
788 {
789 hashTable[hash] = newIndex + 1;
790 return;
791 }
792
793 // get the first node of the hash chain.
794 Uint32 nodeIndex = hashTable[hash]-1;
795
796 do
797 {
798 // is this the same note ?
799 if (nodeIndex == newIndex)
800 {
801 // The node is already in the ordered set
802 return;
803 }
804
805 thilo.boehm 1.1 // Are we at the end of the chain ?
806 if (!scmoPropNodeArray[nodeIndex].hasNext)
807 {
808 // link the new element at the end of the chain
809 scmoPropNodeArray[nodeIndex].nextNode = newIndex;
810 scmoPropNodeArray[nodeIndex].hasNext = true;
811 return;
812 }
813
814 // get next node index.
815 nodeIndex = scmoPropNodeArray[nodeIndex].nextNode;
816
817 } while ( true );
818
819 // this should never be reached
820 }
821
822 void SCMOClass::_setClassKeyBinding(
|
823 thilo.boehm 1.2 Uint64 start,
|
824 thilo.boehm 1.1 const CIMProperty& theCIMProperty)
825 {
826 CIMPropertyRep* propRep = theCIMProperty._rep;
827 Uint64 valueStart;
828
829 // First do all _setString(). Can cause reallocation.
830 _setString(propRep->_name.getString(),
831 ((SCMBKeyBindingNode*)&(cls.base[start]))->name,
832 &cls.mem);
|
833 thilo.boehm 1.2
834 SCMBKeyBindingNode* scmoKeyBindNode =
|
835 thilo.boehm 1.1 (SCMBKeyBindingNode*)&(cls.base[start]);
836
837 // calculate the new hash tag
|
838 thilo.boehm 1.2 scmoKeyBindNode->nameHashTag =
|
839 thilo.boehm 1.1 _generateSCMOStringTag(scmoKeyBindNode->name,cls.base);
|
840 thilo.boehm 1.2.2.24 scmoKeyBindNode->type = propRep->_value.getType();
|
841 thilo.boehm 1.1 scmoKeyBindNode->hasNext=false;
842 scmoKeyBindNode->nextNode=0;
843
844 }
845
846 void SCMOClass::_setPropertyAsKeyInMask(Uint32 i)
847 {
848 Uint64 *keyMask;
849
850 // In which Uint64 of key mask is the bit for property i ?
851 // Divide with the number of bits in a Uint64.
852 // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].
853 Uint32 idx = i/64 ;
854
855 // Create a filter to set the bit.
856 // Modulo division with 64. Shift left a bit by the remainder.
|
857 thilo.boehm 1.2 Uint64 filter = ( (Uint64)1 << (i%64));
858
|
859 thilo.boehm 1.1 // Calculate the real pointer to the Uint64 array
|
860 thilo.boehm 1.2.2.38 keyMask = (Uint64*)&(cls.base[cls.hdr->keyPropertyMask.start]);
|
861 thilo.boehm 1.1
862 keyMask[idx] = keyMask[idx] | filter ;
863 }
864
865 Boolean SCMOClass::_isPropertyKey(Uint32 i)
866 {
867 Uint64 *keyMask;
868
869 // In which Uint64 of key mask is the bit for property i ?
870 // Divide with the number of bits in a Uint64.
871 // e.g. number of Properties = 68
872 // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].
873 Uint32 idx = i/64 ;
874
875 // Create a filter to check if the bit is set:
876 // Modulo division with 64. Shift left a bit by the remainder.
|
877 thilo.boehm 1.2 Uint64 filter = ( (Uint64)1 << (i%64));
|
878 thilo.boehm 1.1
879 // Calculate the real pointer to the Uint64 array
|
880 thilo.boehm 1.2.2.38 keyMask = (Uint64*)&(cls.base[cls.hdr->keyPropertyMask.start]);
|
881 thilo.boehm 1.1
882 return keyMask[idx] & filter ;
883
884 }
885
886
887 void SCMOClass::_setProperty(
|
888 thilo.boehm 1.2 Uint64 start,
|
889 thilo.boehm 1.1 Boolean* isKey,
890 const CIMProperty& theCIMProperty)
891 {
892
893 *isKey = false;
894
895 CIMPropertyRep* propRep = theCIMProperty._rep;
896
897 // First do all _setString(). Can cause reallocation.
898
899 _setString(propRep->_name.getString(),
900 ((SCMBClassPropertyNode*)&(cls.base[start]))->theProperty.name,
901 &cls.mem);
902
903 _setString(propRep->_classOrigin.getString(),
904 ((SCMBClassPropertyNode*)
905 &(cls.base[start]))->theProperty.originClassName,
906 &cls.mem);
907
908 _setString(propRep->_referenceClassName.getString(),
909 ((SCMBClassPropertyNode*)&(cls.base[start]))->theProperty.refClassName,
910 thilo.boehm 1.1 &cls.mem);
911
912
|
913 thilo.boehm 1.2 SCMBClassPropertyNode* scmoPropNode =
|
914 thilo.boehm 1.1 (SCMBClassPropertyNode*)&(cls.base[start]);
915
916 // generate new hash tag
|
917 thilo.boehm 1.2 scmoPropNode->theProperty.nameHashTag =
|
918 thilo.boehm 1.1 _generateSCMOStringTag(scmoPropNode->theProperty.name,cls.base);
919
920 scmoPropNode->theProperty.flags.propagated = propRep->_propagated;
921
922 // just for complete intialization.
923 scmoPropNode->hasNext=false;
924 scmoPropNode->nextNode=0;
925
926 // calculate the relative pointer for the default value
|
927 thilo.boehm 1.2 Uint64 valueStart =
|
928 thilo.boehm 1.2.2.2 (char*)&scmoPropNode->theProperty.defaultValue - cls.base;
|
929 thilo.boehm 1.1
930 _setValue(valueStart,propRep->_value);
931
932 *isKey = _setPropertyQualifiers(start,propRep->_qualifiers);
|
933 thilo.boehm 1.2 // reset property node pointer
|
934 thilo.boehm 1.1 scmoPropNode = (SCMBClassPropertyNode*)&(cls.base[start]);
935 scmoPropNode->theProperty.flags.isKey=*isKey;
936 }
937
938 Boolean SCMOClass::_setPropertyQualifiers(
|
939 thilo.boehm 1.2 Uint64 start,
|
940 thilo.boehm 1.1 const CIMQualifierList& theQualifierList)
941 {
942 Uint32 noQuali = theQualifierList.getCount();
943 Uint64 startArray;
944 QualifierNameEnum propName;
945 Boolean isKey = false;
946
|
947 thilo.boehm 1.2 SCMBClassPropertyNode* scmoPropNode =
|
948 thilo.boehm 1.1 (SCMBClassPropertyNode*)&(cls.base[start]);
949
950 scmoPropNode->theProperty.numberOfQualifiers = noQuali;
951
952
953 if (noQuali != 0)
954 {
955 // allocate qualifier array and save the start of the array.
956 startArray = _getFreeSpace(scmoPropNode->theProperty.qualifierArray,
957 sizeof(SCMBQualifier)*noQuali,
|
958 thilo.boehm 1.2 &cls.mem);
|
959 thilo.boehm 1.1 for (Uint32 i = 0; i < noQuali; i++)
960 {
961 propName = _setQualifier(
962 startArray,
963 theQualifierList.getQualifier(i));
964 // Only set once if the property is identified as key.
965 if(!isKey)
966 {
967 isKey = propName==QUALNAME_KEY;
968 }
|
969 thilo.boehm 1.2
|
970 thilo.boehm 1.1 startArray = startArray + sizeof(SCMBQualifier);
971 }
972 }
973 else
974 {
975 scmoPropNode->theProperty.qualifierArray.start=0;
|
976 thilo.boehm 1.2.2.57 scmoPropNode->theProperty.qualifierArray.size=0;
|
977 thilo.boehm 1.1 }
978
979 return isKey;
980 }
|
981 thilo.boehm 1.2.2.28
982 void SCMOClass::_setClassQualifers(const CIMQualifierList& theQualifierList)
|
983 thilo.boehm 1.1 {
984
|
985 thilo.boehm 1.2.2.28 Uint32 noQuali = theQualifierList.getCount();
|
986 thilo.boehm 1.1 Uint64 start;
987
988 cls.hdr->numberOfQualifiers = noQuali;
989
990 if (noQuali != 0)
991 {
992 // allocate qualifier array and save the start of the array.
993 start = _getFreeSpace(cls.hdr->qualifierArray,
994 sizeof(SCMBQualifier)*noQuali,
|
995 thilo.boehm 1.2 &cls.mem);
|
996 thilo.boehm 1.1 for (Uint32 i = 0; i < noQuali; i++)
997 {
|
998 thilo.boehm 1.2.2.28 _setQualifier(start,theQualifierList.getQualifier(i));
|
999 thilo.boehm 1.1 start = start + sizeof(SCMBQualifier);
1000
1001 }
1002
1003 }
1004 else
1005 {
1006 cls.hdr->qualifierArray.start=0;
|
1007 thilo.boehm 1.2.2.57 cls.hdr->qualifierArray.size=0;
|
1008 thilo.boehm 1.1 }
1009 }
1010
1011 QualifierNameEnum SCMOClass::_setQualifier(
|
1012 thilo.boehm 1.2 Uint64 start,
|
1013 thilo.boehm 1.1 const CIMQualifier& theCIMQualifier)
1014 {
1015 Uint64 valueStart;
1016 QualifierNameEnum name;
1017
1018 SCMBQualifier* scmoQual = (SCMBQualifier*)&(cls.base[start]);
1019 name=_getSCMOQualifierNameEnum(theCIMQualifier.getName());
1020
1021 scmoQual->propagated = theCIMQualifier.getPropagated();
1022 scmoQual->name = name;
1023 scmoQual->flavor = theCIMQualifier.getFlavor().cimFlavor;
1024
|
1025 thilo.boehm 1.2.2.2 valueStart = (char*)&scmoQual->value - cls.base;
|
1026 thilo.boehm 1.1
1027 _setValue(valueStart,theCIMQualifier.getValue());
1028
1029 // reset the pointer, because the base pointer could be reallocated.
1030 scmoQual = (SCMBQualifier*)&(cls.base[start]);
1031 if (name == QUALNAME_USERDEFINED)
1032 {
1033 _setString(theCIMQualifier.getName().getString(),
1034 scmoQual->userDefName,&cls.mem);
1035 }
1036
1037 return name;
1038 }
1039
|
1040 thilo.boehm 1.2.2.37 void SCMOClass::_setValue(
1041 Uint64 start,
1042 const CIMValue& theCIMValue)
|
1043 thilo.boehm 1.1 {
1044 Uint64 valueStart;
1045
1046 CIMValueRep* rep = *((CIMValueRep**)&theCIMValue);
1047
1048 SCMBValue* scmoValue = (SCMBValue*)&(cls.base[start]);
1049 scmoValue->valueType = rep->type;
1050 scmoValue->valueArraySize = 0;
1051 scmoValue->flags.isNull = rep->isNull;
1052 scmoValue->flags.isArray = rep->isArray;
|
1053 thilo.boehm 1.2.2.38 scmoValue->flags.isSet = false;
|
1054 thilo.boehm 1.1
1055 if (rep->isNull)
1056 {
1057 return;
1058 }
1059
|
1060 thilo.boehm 1.2.2.13 valueStart = (char*)&scmoValue->value - cls.base;
1061
|
1062 thilo.boehm 1.1 if (scmoValue->flags.isArray)
1063 {
|
1064 thilo.boehm 1.2.2.24 SCMOInstance::_setUnionArrayValue(
|
1065 thilo.boehm 1.2.2.13 valueStart,
1066 &cls.mem,
1067 rep->type,
1068 // Is set to the number of array members by the function.
1069 scmoValue->valueArraySize,
|
1070 thilo.boehm 1.2.2.37 cls.hdr->nameSpace.start,
|
1071 thilo.boehm 1.2.2.57 cls.hdr->nameSpace.size,
|
1072 thilo.boehm 1.2.2.13 rep->u);
|
1073 thilo.boehm 1.1 }
1074 else
|
1075 thilo.boehm 1.2 {
|
1076 thilo.boehm 1.2.2.29 SCMOInstance::_setUnionValue(
1077 valueStart,
1078 &cls.mem,
1079 rep->type,
|
1080 thilo.boehm 1.2.2.37 cls.hdr->nameSpace.start,
|
1081 thilo.boehm 1.2.2.57 cls.hdr->nameSpace.size,
|
1082 thilo.boehm 1.2.2.29 rep->u);
|
1083 thilo.boehm 1.1 }
1084 }
1085
|
1086 thilo.boehm 1.2.2.13 QualifierNameEnum SCMOClass::_getSCMOQualifierNameEnum(
1087 const CIMName& theCIMName)
|
1088 thilo.boehm 1.1 {
|
1089 thilo.boehm 1.2.2.13 // Get the UTF8 CString
1090 CString theCString=theCIMName.getString().getCString();
1091 // Get the real size of the UTF8 sting.
1092 Uint32 length = strlen((const char*)theCString);
|
1093 thilo.boehm 1.1
1094
|
1095 thilo.boehm 1.2.2.13 // The start index is 1, because the at index 0 is a place holder for
1096 // the user defined qualifier name which is not part of the qualifier name
1097 // list.
1098 for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++)
1099 {
|
1100 marek 1.2.2.23 if (qualifierNameStrLit(i).size == length)
|
1101 thilo.boehm 1.1 {
|
1102 thilo.boehm 1.2.2.13 // TBD: Make it more efficent...
1103 if(String::equalNoCase(
1104 theCIMName.getString(),
|
1105 marek 1.2.2.23 qualifierNameStrLit(i).str))
|
1106 thilo.boehm 1.2.2.13 {
1107 return (QualifierNameEnum)i;
1108 }
|
1109 thilo.boehm 1.1 }
|
1110 thilo.boehm 1.2.2.13 }
|
1111 thilo.boehm 1.1
|
1112 thilo.boehm 1.2.2.13 return QUALNAME_USERDEFINED;
1113 }
|
1114 thilo.boehm 1.1
|
1115 thilo.boehm 1.2.2.13 Boolean SCMOClass::_isSamePropOrigin(Uint32 node, const char* origin) const
1116 {
1117 Uint32 len = strlen(origin);
|
1118 thilo.boehm 1.1
|
1119 thilo.boehm 1.2.2.13 SCMBClassPropertyNode* nodeArray =
1120 (SCMBClassPropertyNode*)
1121 &(cls.base[cls.hdr->propertySet.nodeArray.start]);
|
1122 thilo.boehm 1.1
|
1123 thilo.boehm 1.2.2.47 return(_equalNoCaseUTF8Strings(
|
1124 thilo.boehm 1.2.2.13 nodeArray[node].theProperty.originClassName,
1125 cls.base,
1126 origin,
1127 len));
1128 }
|
1129 thilo.boehm 1.1
|
1130 thilo.boehm 1.2.2.37 SCMO_RC SCMOClass::_isNodeSameType(
|
1131 thilo.boehm 1.2.2.13 Uint32 node,
1132 CIMType type,
|
1133 thilo.boehm 1.2.2.37 Boolean isArray,
1134 CIMType& realType) const
|
1135 thilo.boehm 1.2.2.13 {
|
1136 thilo.boehm 1.2.2.37
|
1137 thilo.boehm 1.2.2.13 SCMBClassPropertyNode* nodeArray =
1138 (SCMBClassPropertyNode*)
1139 &(cls.base[cls.hdr->propertySet.nodeArray.start]);
|
1140 thilo.boehm 1.1
|
1141 thilo.boehm 1.2.2.37 // The type stored in the class information is set on realType.
1142 // It must be used in further calls to guaranty consistence.
1143 realType = nodeArray[node].theProperty.defaultValue.valueType;
|
1144 thilo.boehm 1.1
|
1145 thilo.boehm 1.2.2.13 if(nodeArray[node].theProperty.defaultValue.valueType != type)
1146 {
|
1147 thilo.boehm 1.2.2.37 // Accept an property of type instance also
|
1148 thilo.boehm 1.2.2.36 // for an CIMTYPE_OBJECT property.
|
1149 thilo.boehm 1.2.2.37 if (!(type == CIMTYPE_INSTANCE &&
1150 nodeArray[node].theProperty.defaultValue.valueType
|
1151 thilo.boehm 1.2.2.36 == CIMTYPE_OBJECT))
1152 {
1153 return SCMO_WRONG_TYPE;
|
1154 thilo.boehm 1.2.2.37 }
|
1155 thilo.boehm 1.2.2.13 }
|
1156 thilo.boehm 1.1
|
1157 thilo.boehm 1.2.2.13 if (isArray)
1158 {
1159 if (nodeArray[node].theProperty.defaultValue.flags.isArray)
|
1160 thilo.boehm 1.1 {
|
1161 thilo.boehm 1.2.2.13 return SCMO_OK;
|
1162 thilo.boehm 1.1 }
|
1163 thilo.boehm 1.2.2.13 else
|
1164 thilo.boehm 1.1 {
|
1165 thilo.boehm 1.2.2.13 return SCMO_NOT_AN_ARRAY;
|
1166 thilo.boehm 1.1 }
1167
|
1168 thilo.boehm 1.2.2.13 }
|
1169 thilo.boehm 1.1
|
1170 thilo.boehm 1.2.2.13 if (nodeArray[node].theProperty.defaultValue.flags.isArray)
1171 {
1172 return SCMO_IS_AN_ARRAY;
1173 }
|
1174 thilo.boehm 1.1
|
1175 thilo.boehm 1.2.2.13 return SCMO_OK;
|
1176 thilo.boehm 1.1
|
1177 thilo.boehm 1.2.2.13 }
|
1178 thilo.boehm 1.2.2.34
|
1179 thilo.boehm 1.2.2.13 /*****************************************************************************
1180 * The SCMOInstance methods
1181 *****************************************************************************/
|
1182 thilo.boehm 1.1
|
1183 thilo.boehm 1.2.2.13 SCMOInstance::SCMOInstance()
1184 {
|
1185 thilo.boehm 1.2.2.32 inst.base = 0;
|
1186 thilo.boehm 1.2.2.13 }
|
1187 thilo.boehm 1.1
|
1188 thilo.boehm 1.2.2.59 SCMOInstance::SCMOInstance(SCMOClass& baseClass)
|
1189 thilo.boehm 1.2.2.13 {
|
1190 thilo.boehm 1.2.2.28 _initSCMOInstance(new SCMOClass(baseClass));
|
1191 thilo.boehm 1.2.2.13 }
|
1192 thilo.boehm 1.2
|
1193 thilo.boehm 1.2.2.13 SCMOInstance::SCMOInstance(
|
1194 thilo.boehm 1.2.2.59 SCMOClass& baseClass,
|
1195 thilo.boehm 1.2.2.13 Boolean includeQualifiers,
1196 Boolean includeClassOrigin,
1197 const char** propertyList)
1198 {
|
1199 thilo.boehm 1.1
|
1200 thilo.boehm 1.2.2.28 _initSCMOInstance(new SCMOClass(baseClass));
1201
1202 inst.hdr->flags.includeQualifiers=includeQualifiers;
1203 inst.hdr->flags.includeClassOrigin=includeClassOrigin;
|
1204 thilo.boehm 1.1
|
1205 thilo.boehm 1.2.2.13 setPropertyFilter(propertyList);
|
1206 thilo.boehm 1.1
|
1207 thilo.boehm 1.2.2.13 }
|
1208 thilo.boehm 1.1
|
1209 thilo.boehm 1.2.2.59 SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj)
|
1210 thilo.boehm 1.2.2.13 {
|
1211 thilo.boehm 1.2.2.28 _initSCMOInstance(new SCMOClass(baseClass));
|
1212 thilo.boehm 1.1
|
1213 thilo.boehm 1.2.2.13 _setCIMObjectPath(cimObj);
1214 }
|
1215 thilo.boehm 1.1
|
1216 thilo.boehm 1.2.2.59 SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance)
|
1217 thilo.boehm 1.2.2.13 {
|
1218 thilo.boehm 1.1
|
1219 thilo.boehm 1.2.2.28 _initSCMOInstance(new SCMOClass(baseClass));
|
1220 thilo.boehm 1.2.2.13
|
1221 thilo.boehm 1.2.2.28 _setCIMInstance(cimInstance);
|
1222 thilo.boehm 1.1
|
1223 thilo.boehm 1.2.2.13 }
|
1224 thilo.boehm 1.2.2.3
|
1225 thilo.boehm 1.2.2.59 SCMOInstance::SCMOInstance(CIMClass& theCIMClass, const char* altNameSpace)
1226 {
1227 _initSCMOInstance(new SCMOClass(theCIMClass,altNameSpace));
1228
1229 }
1230
1231 SCMOInstance::SCMOInstance(
1232 const CIMInstance& cimInstance,
1233 const char* altNameSpace,
1234 Uint64 altNSLen)
1235 {
1236 SCMOClass theSCMOClass = _getSCMOClass(
1237 cimInstance._rep->_reference,
1238 altNameSpace,
1239 altNSLen);
1240
1241 _initSCMOInstance( new SCMOClass(theSCMOClass));
1242
1243 if(theSCMOClass.isEmpty())
1244 {
1245 // flag the instance as compromized
1246 thilo.boehm 1.2.2.59 inst.hdr->flags.isCompromised=true;
1247 }
1248 else
1249 {
1250 _setCIMInstance(cimInstance);
1251 }
1252 }
1253
1254 SCMOInstance::SCMOInstance(
1255 const CIMObject& cimObject,
1256 const char* altNameSpace,
1257 Uint64 altNSLen)
1258 {
1259 if (cimObject.isClass())
1260 {
1261 CIMClass cimClass(cimObject);
1262
1263 _initSCMOInstance(new SCMOClass(cimClass,altNameSpace));
1264
1265 inst.hdr->flags.isClassOnly=true;
1266 }
1267 thilo.boehm 1.2.2.59 else
1268 {
1269 CIMInstance cimInstance(cimObject);
1270
1271 SCMOClass theSCMOClass = _getSCMOClass(
1272 cimInstance._rep->_reference,
1273 altNameSpace,
1274 altNSLen);
1275
1276 _initSCMOInstance( new SCMOClass(theSCMOClass));
1277
1278 if(theSCMOClass.isEmpty())
1279 {
1280 // flag the instance as compromized
1281 inst.hdr->flags.isCompromised=true;
1282 }
1283 else
1284 {
1285 _setCIMInstance(cimInstance);
1286 }
1287 }
1288 thilo.boehm 1.2.2.59 }
1289
1290 SCMOInstance::SCMOInstance(
1291 const CIMObjectPath& cimObj,
1292 const char* altNameSpace,
1293 Uint64 altNSLen)
1294 {
1295 SCMOClass theSCMOClass = _getSCMOClass(
1296 cimObj,
1297 altNameSpace,
1298 altNSLen);
1299
1300 _initSCMOInstance( new SCMOClass(theSCMOClass));
1301
1302 if(theSCMOClass.isEmpty())
1303 {
1304 // flag the instance as compromized
1305 inst.hdr->flags.isCompromised=true;
1306 }
1307 else
1308 {
1309 thilo.boehm 1.2.2.59 _setCIMObjectPath(cimObj);
1310 }
1311 }
1312
|
1313 thilo.boehm 1.2.2.65 void SCMOInstance::_destroyExternalReferences()
1314 {
1315 _destroyExternalReferencesInternal(inst.mem);
1316 }
1317
|
1318 thilo.boehm 1.2.2.59 SCMOClass SCMOInstance::_getSCMOClass(
1319 const CIMObjectPath& theCIMObj,
1320 const char* altNS,
1321 Uint64 altNSlength)
1322 {
|
1323 thilo.boehm 1.2.2.60 SCMOClass theClass;
|
1324 thilo.boehm 1.2.2.61
|
1325 thilo.boehm 1.2.2.59 if (theCIMObj.getClassName().isNull())
1326 {
1327 return SCMOClass();
1328 }
1329
1330 if (theCIMObj.getNameSpace().isNull())
1331 {
1332 // the name space of the object path is empty,
1333 // use alternative name space.
1334 CString clsName = theCIMObj.getClassName().getString().getCString();
1335
1336 SCMOClassCache* theCache = SCMOClassCache::getInstance();
1337 theClass = theCache->getSCMOClass(
1338 altNS,
1339 altNSlength,
1340 (const char*)clsName,
|
1341 thilo.boehm 1.2.2.61 strlen(clsName));
|
1342 thilo.boehm 1.2.2.59 }
1343 else
1344 {
1345 CString nameSpace = theCIMObj.getNameSpace().getString().getCString();
1346 CString clsName = theCIMObj.getClassName().getString().getCString();
1347
1348 SCMOClassCache* theCache = SCMOClassCache::getInstance();
1349 theClass = theCache->getSCMOClass(
1350 (const char*)nameSpace,
1351 strlen(nameSpace),
1352 (const char*)clsName,
|
1353 thilo.boehm 1.2.2.61 strlen(clsName));
|
1354 thilo.boehm 1.2.2.59 }
1355
|
1356 thilo.boehm 1.2.2.60 return theClass;
|
1357 thilo.boehm 1.2.2.59 }
1358
|
1359 thilo.boehm 1.2.2.65 #define PEGASUS_SIZE_REFERENCE_INDEX_ARRAY 8
|
1360 thilo.boehm 1.2.2.38
|
1361 thilo.boehm 1.2.2.65 void SCMOInstance::_setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem)
|
1362 thilo.boehm 1.2.2.35 {
1363
|
1364 thilo.boehm 1.2.2.67 Uint64 refPtr =(((char *)pInst) - (char *)(*pmem));
|
1365 thilo.boehm 1.2.2.65 SCMBMgmt_Header* memHdr = (*pmem);
|
1366 thilo.boehm 1.2.2.66 // Save the number of external references in the array
1367 Uint32 noExtRef = memHdr->numberExtRef;
|
1368 thilo.boehm 1.2.2.35
|
1369 thilo.boehm 1.2.2.65 // Allocate the external reflerence array
1370 // if it is full or empty ( 0 == 0 ).
|
1371 thilo.boehm 1.2.2.66 if (noExtRef == memHdr->sizeExtRefIndexArray)
|
1372 thilo.boehm 1.2.2.35 {
|
1373 thilo.boehm 1.2.2.65 Uint64 oldArrayStart = memHdr->extRefIndexArray.start;
1374 Uint32 newSize =
1375 memHdr->sizeExtRefIndexArray + PEGASUS_SIZE_REFERENCE_INDEX_ARRAY;
1376
1377 // Allocate the external reference index array
1378 _getFreeSpace(
1379 memHdr->extRefIndexArray,
1380 sizeof(Uint64)*newSize,
1381 pmem);
1382
1383 // reset the pointer. It could be changed due to reallocation !
1384 memHdr = (*pmem);
1385
1386 // Assign new size.
1387 memHdr->sizeExtRefIndexArray=newSize;
1388
1389 // Get absolute pointer to old index array.
1390 Uint64* oldArray = (Uint64*)&(((char*)(*pmem))[oldArrayStart]);
1391 // Get absolute pointer to new index array
1392 Uint64* newArray =
1393 (Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]);
1394 thilo.boehm 1.2.2.65
1395 // Copy all elements of the old array to the new.
1396 // If noExtRef = 0, no elements are copied.
1397 for (Uint32 i = 0 ; i < noExtRef ; i++)
1398 {
1399 newArray[i] = oldArray[i];
|
1400 thilo.boehm 1.2.2.35 }
|
1401 thilo.boehm 1.2.2.65 }
|
1402 thilo.boehm 1.2.2.38
|
1403 thilo.boehm 1.2.2.65 // Get absolute pointer to the array
1404 Uint64* array =
1405 (Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]);
|
1406 thilo.boehm 1.2.2.66 // look in the table if the index is already in the array
1407 for (Uint32 i = 0 ; i < noExtRef ; i++)
1408 {
1409 // is the index already part of the array
|
1410 thilo.boehm 1.2.2.67 if (array[i] == refPtr)
|
1411 thilo.boehm 1.2.2.66 {
1412 // leave.
1413 return;
1414 }
1415 }
1416 // It is not part of the array -> set the new index.
|
1417 thilo.boehm 1.2.2.67 array[noExtRef] = refPtr;
|
1418 thilo.boehm 1.2.2.66 // increment the nuber of external references of this instance.
|
1419 thilo.boehm 1.2.2.65 memHdr->numberExtRef++;
|
1420 thilo.boehm 1.2.2.38
|
1421 thilo.boehm 1.2.2.65 }
1422
|
1423 thilo.boehm 1.2.2.67 SCMOInstance* SCMOInstance::getExtRef(Uint32 idx)
1424 {
1425 Uint64* array =
1426 (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
1427 SCMBUnion* pUnion;
1428 pUnion = (SCMBUnion*)(&(inst.base[array[idx]]));
1429 return pUnion->extRefPtr;
1430 }
1431
1432 void SCMOInstance::putExtRef(Uint32 idx,SCMOInstance* ptr)
1433 {
1434 Uint64* array =
1435 (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
1436 SCMBUnion* pUnion;
1437 pUnion = (SCMBUnion*)(&(inst.base[array[idx]]));
1438 pUnion->extRefPtr = ptr;
1439 }
1440
|
1441 thilo.boehm 1.2.2.65 void SCMOInstance::_copyExternalReferences()
1442 {
1443 Uint32 number = inst.mem->numberExtRef;
1444
1445 if (0 != number)
1446 {
1447 SCMBUnion* pUnion;
1448 Uint64* array =
1449 (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
1450 for (Uint32 i = 0; i < number; i++)
|
1451 thilo.boehm 1.2.2.38 {
|
1452 thilo.boehm 1.2.2.65 pUnion = (SCMBUnion*)(&(inst.base[array[i]]));
1453 if (0 != pUnion)
|
1454 thilo.boehm 1.2.2.38 {
|
1455 thilo.boehm 1.2.2.65 pUnion->extRefPtr = new SCMOInstance(*(pUnion->extRefPtr));
|
1456 thilo.boehm 1.2.2.38 }
|
1457 thilo.boehm 1.2.2.65 }
|
1458 thilo.boehm 1.2.2.38
1459 }
|
1460 thilo.boehm 1.2.2.35
1461 }
1462
|
1463 thilo.boehm 1.2.2.58 void SCMOInstance::_destroyExternalKeyBindings()
|
1464 thilo.boehm 1.2.2.29 {
|
1465 thilo.boehm 1.2.2.65 // Create a pointer to keybinding node array of the class.
|
1466 thilo.boehm 1.2.2.29 Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
1467 SCMBKeyBindingNode* theClassKeyBindNodeArray =
1468 (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
1469
1470 // create a pointer to instanc key binding array.
1471 SCMBKeyBindingValue* theInstanceKeyBindingNodeArray =
1472 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
1473
1474 for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++)
1475 {
1476 if (theInstanceKeyBindingNodeArray[i].isSet)
1477 {
1478 // only references can be a key binding
1479 if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE)
1480 {
1481 delete theInstanceKeyBindingNodeArray[i].data.extRefPtr;
1482 }
1483 }
1484 }// for all key bindings
1485
|
1486 thilo.boehm 1.2.2.38 // Are there user defined key bindings ?
|
1487 thilo.boehm 1.2.2.39 if (0 != inst.hdr->numberUserKeyBindings)
|
1488 thilo.boehm 1.2.2.38 {
1489 SCMBUserKeyBindingElement* theUserDefKBElement =
1490 (SCMBUserKeyBindingElement*)
1491 &(inst.base[inst.hdr->userKeyBindingElement.start]);
1492
|
1493 thilo.boehm 1.2.2.39 for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
|
1494 thilo.boehm 1.2.2.38 {
1495 if (theUserDefKBElement->value.isSet)
1496 {
1497 // only references can be a key binding.
1498 if (theUserDefKBElement->type == CIMTYPE_REFERENCE)
1499 {
1500 delete theUserDefKBElement->value.data.extRefPtr;
1501 }
1502 }
1503
|
1504 thilo.boehm 1.2.2.41 theUserDefKBElement =
|
1505 thilo.boehm 1.2.2.38 (SCMBUserKeyBindingElement*)
1506 &(inst.base[theUserDefKBElement->nextElement.start]);
1507 } // for all user def. key bindings.
1508 }
|
1509 thilo.boehm 1.2.2.58 }
1510
|
1511 thilo.boehm 1.2.2.15 SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const
1512 {
1513
1514 SCMO_RC rc = SCMO_OK;
1515 Uint32 noProps;
1516 CIMObjectPath objPath;
1517
|
1518 thilo.boehm 1.2.2.17 // For better usability define pointers to SCMO Class data structures.
1519 SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;
1520 char* clsbase = inst.hdr->theClass->cls.base;
1521
|
1522 r.kieninger 1.2.2.21 getCIMObjectPath(objPath);
|
1523 thilo.boehm 1.2.2.15
|
1524 thilo.boehm 1.2.2.29 CIMInstance newInstance;
1525 newInstance._rep = new CIMInstanceRep(objPath);
|
1526 thilo.boehm 1.2.2.15
|
1527 thilo.boehm 1.2.2.17 if (inst.hdr->flags.includeQualifiers)
1528 {
1529 SCMBQualifier* qualiArray =
1530 (SCMBQualifier*)&(clsbase[clshdr->qualifierArray.start]);
1531
1532
|
1533 thilo.boehm 1.2.2.29 CIMQualifier theCimQualifier;
|
1534 thilo.boehm 1.2.2.17 Uint32 i, k = clshdr->numberOfQualifiers;
1535
1536 for ( i = 0 ; i < k ; i++)
1537 {
|
1538 thilo.boehm 1.2.2.29 SCMOClass::_getCIMQualifierFromSCMBQualifier(
1539 theCimQualifier,
1540 qualiArray[i],
1541 clsbase);
|
1542 thilo.boehm 1.2.2.17
|
1543 thilo.boehm 1.2.2.29 newInstance._rep->_qualifiers.addUnchecked(theCimQualifier);
|
1544 thilo.boehm 1.2.2.17 }
1545 }
1546
|
1547 thilo.boehm 1.2.2.15 if (inst.hdr->flags.isFiltered)
1548 {
1549 // Get absolut pointer to property filter index map of the instance
1550 Uint32* propertyFilterIndexMap =
1551 (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
1552
1553 for(Uint32 i = 0, k = inst.hdr->filterProperties; i<k; i++)
1554 {
1555 // Get absolut pointer to property filter index map
1556 // of the instance get the real node index of the property.
1557 CIMProperty theProperty=_getCIMPropertyAtNodeIndex(
1558 propertyFilterIndexMap[i]);
1559
|
1560 thilo.boehm 1.2.2.29 newInstance._rep->_properties.append(theProperty);
|
1561 thilo.boehm 1.2.2.15 }
1562
1563 }
1564 else
1565 {
1566 for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)
1567 {
|
1568 thilo.boehm 1.2.2.35 SCMBValue* theInstPropArray =
1569 (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
|
1570 thilo.boehm 1.2.2.15
|
1571 thilo.boehm 1.2.2.35 // was the property set by the provider ?
1572 if(theInstPropArray[i].flags.isSet)
1573 {
1574 // no filtering. Counter is node index
1575 CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i);
1576
1577 newInstance._rep->_properties.append(theProperty);
1578 }
|
1579 thilo.boehm 1.2.2.15 }
1580
1581 }
1582
|
1583 thilo.boehm 1.2.2.29 cimInstance = newInstance;
1584
|
1585 thilo.boehm 1.2.2.15 return rc;
1586 }
1587
|
1588 r.kieninger 1.2.2.21 void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const
|
1589 thilo.boehm 1.2.2.15 {
|
1590 thilo.boehm 1.2.2.29
1591 CIMObjectPath newObjectPath;
1592
|
1593 thilo.boehm 1.2.2.15 // For better usability define pointers to SCMO Class data structures.
1594 SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;
1595 char* clsbase = inst.hdr->theClass->cls.base;
1596
1597 // Address the class keybinding information
1598 SCMBKeyBindingNode* scmoClassArray =
|
1599 thilo.boehm 1.2.2.38 (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
|
1600 thilo.boehm 1.2.2.15
1601 // Address the instance keybinding information
|
1602 thilo.boehm 1.2.2.24 SCMBKeyBindingValue* scmoInstArray =
|
1603 thilo.boehm 1.2.2.38 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
|
1604 thilo.boehm 1.2.2.15
1605 Uint32 numberKeyBindings = inst.hdr->numberKeyBindings;
1606
|
1607 thilo.boehm 1.2.2.24 CIMValue theKeyBindingValue;
1608
|
1609 thilo.boehm 1.2.2.15 for (Uint32 i = 0; i < numberKeyBindings; i ++)
1610 {
|
1611 thilo.boehm 1.2.2.16 if (scmoInstArray[i].isSet)
1612 {
|
1613 thilo.boehm 1.2.2.24 _getCIMValueFromSCMBUnion(
1614 theKeyBindingValue,
1615 scmoClassArray[i].type,
1616 false, // can never be a null value
1617 false, // can never be an array
1618 0,
1619 scmoInstArray[i].data,
1620 inst.base);
|
1621 thilo.boehm 1.2.2.29 newObjectPath._rep->_keyBindings.append(
|
1622 thilo.boehm 1.2.2.16 CIMKeyBinding(
1623 CIMNameCast(NEWCIMSTR(scmoClassArray[i].name,clsbase)),
|
1624 thilo.boehm 1.2.2.24 theKeyBindingValue
1625 ));
|
1626 thilo.boehm 1.2.2.16 }
|
1627 thilo.boehm 1.2.2.15 }
1628
|
1629 thilo.boehm 1.2.2.38 // Are there user defined key bindings ?
|
1630 thilo.boehm 1.2.2.39 if (0 != inst.hdr->numberUserKeyBindings)
|
1631 thilo.boehm 1.2.2.38 {
1632 SCMBUserKeyBindingElement* theUserDefKBElement =
1633 (SCMBUserKeyBindingElement*)
1634 &(inst.base[inst.hdr->userKeyBindingElement.start]);
1635
|
1636 thilo.boehm 1.2.2.39 for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
|
1637 thilo.boehm 1.2.2.38 {
1638 if (theUserDefKBElement->value.isSet)
1639 {
1640 _getCIMValueFromSCMBUnion(
1641 theKeyBindingValue,
1642 theUserDefKBElement->type,
1643 false, // can never be a null value
1644 false, // can never be an array
1645 0,
1646 theUserDefKBElement->value.data,
1647 inst.base);
1648
1649 newObjectPath._rep->_keyBindings.append(
1650 CIMKeyBinding(
1651 CIMNameCast(
1652 NEWCIMSTR(theUserDefKBElement->name,inst.base)),
1653 theKeyBindingValue));
1654 }
|
1655 thilo.boehm 1.2.2.41 theUserDefKBElement =
|
1656 thilo.boehm 1.2.2.38 (SCMBUserKeyBindingElement*)
1657 &(inst.base[theUserDefKBElement->nextElement.start]);
1658 } // for all user def. key bindings.
1659 }
|
1660 thilo.boehm 1.2.2.41
|
1661 thilo.boehm 1.2.2.29 newObjectPath._rep->_host = NEWCIMSTR(inst.hdr->hostName,inst.base);
|
1662 thilo.boehm 1.2.2.38 // Use name space and class name of the instance
|
1663 thilo.boehm 1.2.2.29 newObjectPath._rep->_nameSpace =
|
1664 thilo.boehm 1.2.2.38 CIMNamespaceNameCast(NEWCIMSTR(inst.hdr->instNameSpace,inst.base));
|
1665 thilo.boehm 1.2.2.29 newObjectPath._rep->_className=
|
1666 thilo.boehm 1.2.2.41 CIMNameCast(NEWCIMSTR(inst.hdr->instClassName,inst.base));
|
1667 thilo.boehm 1.2.2.29
1668 cimObj = newObjectPath;
|
1669 thilo.boehm 1.2.2.15 }
1670
1671 CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const
1672 {
1673 CIMValue theValue;
1674 CIMProperty retProperty;
1675
1676 // For better usability define pointers to SCMO Class data structures.
1677 SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;
1678 char* clsbase = inst.hdr->theClass->cls.base;
1679
1680
1681 SCMBClassPropertyNode& clsProp =
1682 ((SCMBClassPropertyNode*)
1683 &(clsbase[clshdr->propertySet.nodeArray.start]))[nodeIdx];
1684
1685 SCMBValue& instValue =
1686 ((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx];
1687
|
1688 thilo.boehm 1.2.2.45 if (instValue.flags.isSet)
1689 {
1690 _getCIMValueFromSCMBValue(theValue,instValue,inst.base);
1691 }
1692 else
1693 {
1694 _getCIMValueFromSCMBValue(
1695 theValue,
1696 clsProp.theProperty.defaultValue,
1697 clsbase);
1698 }
1699
|
1700 thilo.boehm 1.2.2.15
1701
1702 if (inst.hdr->flags.includeClassOrigin)
1703 {
1704 retProperty = CIMProperty(
|
1705 thilo.boehm 1.2.2.16 CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)),
|
1706 thilo.boehm 1.2.2.15 theValue,
1707 theValue.getArraySize(),
|
1708 thilo.boehm 1.2.2.16 CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)),
1709 CIMNameCast(NEWCIMSTR(clsProp.theProperty.originClassName,clsbase)),
|
1710 thilo.boehm 1.2.2.15 clsProp.theProperty.flags.propagated);
1711 }
1712 else
1713 {
1714 retProperty = CIMProperty(
|
1715 thilo.boehm 1.2.2.16 CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)),
|
1716 thilo.boehm 1.2.2.15 theValue,
1717 theValue.getArraySize(),
|
1718 thilo.boehm 1.2.2.16 CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)),
|
1719 thilo.boehm 1.2.2.15 CIMName(),
1720 clsProp.theProperty.flags.propagated);
1721 }
1722
1723 if (inst.hdr->flags.includeQualifiers)
1724 {
1725 SCMBQualifier* qualiArray =
1726 (SCMBQualifier*)
1727 &(clsbase[clsProp.theProperty.qualifierArray.start]);
1728
|
1729 thilo.boehm 1.2.2.29 CIMQualifier theCimQualifier;
|
1730 thilo.boehm 1.2.2.15
1731 Uint32 i, k = clsProp.theProperty.numberOfQualifiers;
1732 for ( i = 0 ; i < k ; i++)
1733 {
|
1734 thilo.boehm 1.2.2.29 SCMOClass::_getCIMQualifierFromSCMBQualifier(
1735 theCimQualifier,
1736 qualiArray[i],
1737 clsbase);
|
1738 thilo.boehm 1.2.2.15
|
1739 thilo.boehm 1.2.2.29 retProperty._rep->_qualifiers.addUnchecked(theCimQualifier);
|
1740 thilo.boehm 1.2.2.15 }
1741 }
1742
1743 return retProperty;
1744 }
1745
|
1746 thilo.boehm 1.2.2.24 void SCMOInstance::_getCIMValueFromSCMBUnion(
|
1747 thilo.boehm 1.2.2.15 CIMValue& cimV,
|
1748 thilo.boehm 1.2.2.24 const CIMType type,
1749 const Boolean isNull,
1750 const Boolean isArray,
1751 const Uint32 arraySize,
1752 const SCMBUnion& scmbUn,
|
1753 thilo.boehm 1.2.2.29 const char * base)
|
1754 thilo.boehm 1.2.2.15 {
|
1755 thilo.boehm 1.2.2.25
|
1756 thilo.boehm 1.2.2.32 const SCMBUnion* pscmbArrayUn = 0;
|
1757 thilo.boehm 1.2.2.25
|
1758 thilo.boehm 1.2.2.24 if (isNull)
|
1759 thilo.boehm 1.2.2.15 {
|
1760 thilo.boehm 1.2.2.24 cimV.setNullValue(type,isArray,arraySize);
|
1761 thilo.boehm 1.2.2.15 return;
1762 }
1763
|
1764 thilo.boehm 1.2.2.25 if (isArray)
1765 {
|
1766 thilo.boehm 1.2.2.28 pscmbArrayUn =(SCMBUnion*)&(base[scmbUn.arrayValue.start]);
|
1767 thilo.boehm 1.2.2.25 }
1768
|
1769 thilo.boehm 1.2.2.24 switch (type)
|
1770 thilo.boehm 1.2.2.15 {
1771
1772 case CIMTYPE_UINT8:
1773 {
|
1774 thilo.boehm 1.2.2.24 if (isArray)
|
1775 thilo.boehm 1.2.2.15 {
|
1776 thilo.boehm 1.2.2.18 Array<Uint8> x;
|
1777 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1778 {
|
1779 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.u8);
|
1780 thilo.boehm 1.2.2.25 }
|
1781 thilo.boehm 1.2.2.18 cimV.set(x);
|
1782 thilo.boehm 1.2.2.15 }
1783 else
1784 {
|
1785 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.u8);
|
1786 thilo.boehm 1.2.2.15 }
1787 break;
1788 }
1789
1790 case CIMTYPE_UINT16:
1791 {
|
1792 thilo.boehm 1.2.2.24 if (isArray)
|
1793 thilo.boehm 1.2.2.15 {
|
1794 thilo.boehm 1.2.2.18 Array<Uint16> x;
|
1795 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1796 {
|
1797 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.u16);
|
1798 thilo.boehm 1.2.2.25 }
|
1799 thilo.boehm 1.2.2.18 cimV.set(x);
|
1800 thilo.boehm 1.2.2.15 }
1801 else
1802 {
|
1803 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.u16);
|
1804 thilo.boehm 1.2.2.15 }
1805 break;
1806 }
1807
1808 case CIMTYPE_UINT32:
1809 {
|
1810 thilo.boehm 1.2.2.24 if (isArray)
|
1811 thilo.boehm 1.2.2.15 {
|
1812 thilo.boehm 1.2.2.18 Array<Uint32> x;
|
1813 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1814 {
|
1815 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.u32);
|
1816 thilo.boehm 1.2.2.25 }
|
1817 thilo.boehm 1.2.2.18 cimV.set(x);
|
1818 thilo.boehm 1.2.2.15 }
1819 else
1820 {
|
1821 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.u32);
|
1822 thilo.boehm 1.2.2.15 }
1823 break;
1824 }
1825
1826 case CIMTYPE_UINT64:
1827 {
|
1828 thilo.boehm 1.2.2.24 if (isArray)
|
1829 thilo.boehm 1.2.2.15 {
|
1830 thilo.boehm 1.2.2.18 Array<Uint64> x;
|
1831 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1832 {
|
1833 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.u64);
|
1834 thilo.boehm 1.2.2.25 }
|
1835 thilo.boehm 1.2.2.18 cimV.set(x);
|
1836 thilo.boehm 1.2.2.15 }
1837 else
1838 {
|
1839 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.u64);
|
1840 thilo.boehm 1.2.2.15 }
1841 break;
1842 }
1843
1844 case CIMTYPE_SINT8:
1845 {
|
1846 thilo.boehm 1.2.2.24 if (isArray)
|
1847 thilo.boehm 1.2.2.15 {
|
1848 thilo.boehm 1.2.2.18 Array<Sint8> x;
|
1849 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1850 {
|
1851 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.s8);
|
1852 thilo.boehm 1.2.2.25 }
|
1853 thilo.boehm 1.2.2.18 cimV.set(x);
|
1854 thilo.boehm 1.2.2.15 }
1855 else
1856 {
|
1857 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.s8);
|
1858 thilo.boehm 1.2.2.15 }
1859 break;
1860 }
1861
1862 case CIMTYPE_SINT16:
1863 {
|
1864 thilo.boehm 1.2.2.24 if (isArray)
|
1865 thilo.boehm 1.2.2.15 {
|
1866 thilo.boehm 1.2.2.18 Array<Sint16> x;
|
1867 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1868 {
|
1869 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.s16);
|
1870 thilo.boehm 1.2.2.25 }
|
1871 thilo.boehm 1.2.2.18 cimV.set(x);
|
1872 thilo.boehm 1.2.2.15 }
1873 else
1874 {
|
1875 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.s16);
|
1876 thilo.boehm 1.2.2.15 }
1877 break;
1878 }
1879
1880 case CIMTYPE_SINT32:
1881 {
|
1882 thilo.boehm 1.2.2.24 if (isArray)
|
1883 thilo.boehm 1.2.2.15 {
|
1884 thilo.boehm 1.2.2.18 Array<Sint32> x;
|
1885 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1886 {
|
1887 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.s32);
|
1888 thilo.boehm 1.2.2.25 }
|
1889 thilo.boehm 1.2.2.18 cimV.set(x);
|
1890 thilo.boehm 1.2.2.15 }
1891 else
1892 {
|
1893 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.s32);
|
1894 thilo.boehm 1.2.2.15 }
1895 break;
1896 }
1897
1898 case CIMTYPE_SINT64:
1899 {
|
1900 thilo.boehm 1.2.2.24 if (isArray)
|
1901 thilo.boehm 1.2.2.15 {
|
1902 thilo.boehm 1.2.2.18 Array<Sint64> x;
|
1903 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1904 {
|
1905 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.s64);
|
1906 thilo.boehm 1.2.2.25 }
|
1907 thilo.boehm 1.2.2.18 cimV.set(x);
|
1908 thilo.boehm 1.2.2.15 }
1909 else
1910 {
|
1911 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.s64);
|
1912 thilo.boehm 1.2.2.15 }
1913 break;
1914 }
1915
1916 case CIMTYPE_REAL32:
1917 {
|
1918 thilo.boehm 1.2.2.24 if (isArray)
|
1919 thilo.boehm 1.2.2.15 {
|
1920 thilo.boehm 1.2.2.18 Array<Real32> x;
|
1921 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1922 {
|
1923 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.r32);
|
1924 thilo.boehm 1.2.2.25 }
|
1925 thilo.boehm 1.2.2.18 cimV.set(x);
|
1926 thilo.boehm 1.2.2.15 }
1927 else
1928 {
|
1929 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.r32);
|
1930 thilo.boehm 1.2.2.15 }
1931 break;
1932 }
1933
1934 case CIMTYPE_REAL64:
1935 {
|
1936 thilo.boehm 1.2.2.24 if (isArray)
|
1937 thilo.boehm 1.2.2.15 {
|
1938 thilo.boehm 1.2.2.18 Array<Real64> x;
|
1939 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1940 {
|
1941 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.r64);
|
1942 thilo.boehm 1.2.2.25 }
|
1943 thilo.boehm 1.2.2.18 cimV.set(x);
|
1944 thilo.boehm 1.2.2.15 }
1945 else
1946 {
|
1947 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.r64);
|
1948 thilo.boehm 1.2.2.15 }
1949 break;
1950 }
1951
1952 case CIMTYPE_CHAR16:
1953 {
|
1954 thilo.boehm 1.2.2.24 if (isArray)
|
1955 thilo.boehm 1.2.2.15 {
|
1956 thilo.boehm 1.2.2.18 Array<Char16> x;
|
1957 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1958 {
|
1959 r.kieninger 1.2.2.55 x.append(Char16(pscmbArrayUn[i].simple.val.c16));
|
1960 thilo.boehm 1.2.2.25 }
|
1961 thilo.boehm 1.2.2.18 cimV.set(x);
|
1962 thilo.boehm 1.2.2.15 }
1963 else
1964 {
|
1965 r.kieninger 1.2.2.55 cimV.set(Char16(scmbUn.simple.val.c16));
|
1966 thilo.boehm 1.2.2.15 }
1967 break;
1968 }
1969
1970 case CIMTYPE_BOOLEAN:
1971 {
|
1972 thilo.boehm 1.2.2.24 if (isArray)
|
1973 thilo.boehm 1.2.2.15 {
|
1974 thilo.boehm 1.2.2.18 Array<Boolean> x;
|
1975 thilo.boehm 1.2.2.25 for (Uint32 i = 0, k = arraySize; i < k ; i++)
1976 {
|
1977 thilo.boehm 1.2.2.28 x.append(pscmbArrayUn[i].simple.val.bin);
|
1978 thilo.boehm 1.2.2.25 }
|
1979 thilo.boehm 1.2.2.18 cimV.set(x);
|
1980 thilo.boehm 1.2.2.15 }
1981 else
1982 {
|
1983 thilo.boehm 1.2.2.25 cimV.set(scmbUn.simple.val.bin);
|
1984 thilo.boehm 1.2.2.15 }
1985 break;
1986 }
1987
1988 case CIMTYPE_STRING:
1989 {
|
1990 thilo.boehm 1.2.2.24 if (isArray)
|
1991 thilo.boehm 1.2.2.15 {
1992
1993 Array<String> x;
1994
|
1995 thilo.boehm 1.2.2.24 for (Uint32 i = 0, k = arraySize; i < k ; i++)
|
1996 thilo.boehm 1.2.2.15 {
|
1997 thilo.boehm 1.2.2.28 x.append(NEWCIMSTR(pscmbArrayUn[i].stringValue,base));
|
1998 thilo.boehm 1.2.2.15 }
1999 cimV.set(x);
2000 }
2001 else
2002 {
|
2003 thilo.boehm 1.2.2.25 cimV.set(NEWCIMSTR(scmbUn.stringValue,base));
|
2004 thilo.boehm 1.2.2.15 }
2005 break;
2006 }
2007
2008 case CIMTYPE_DATETIME:
2009 {
|
2010 thilo.boehm 1.2.2.24 if (isArray)
|
2011 thilo.boehm 1.2.2.15 {
2012 Array<CIMDateTime> x;
2013
|
2014 thilo.boehm 1.2.2.24 for (Uint32 i = 0, k = arraySize; i < k ; i++)
|
2015 thilo.boehm 1.2.2.15 {
|
2016 thilo.boehm 1.2.2.28 x.append(CIMDateTime(&(pscmbArrayUn[i].dateTimeValue)));
|
2017 thilo.boehm 1.2.2.15 }
2018 cimV.set(x);
2019 }
2020 else
2021 {
|
2022 thilo.boehm 1.2.2.25 cimV.set(CIMDateTime(&scmbUn.dateTimeValue));
|
2023 thilo.boehm 1.2.2.15 }
2024 break;
2025
2026 }
2027
|
2028 thilo.boehm 1.2.2.29 case CIMTYPE_REFERENCE:
2029 {
2030 CIMObjectPath theObjPath;
|
2031 thilo.boehm 1.2.2.15
|
2032 thilo.boehm 1.2.2.29 if(isArray)
2033 {
2034 Array<CIMObjectPath> x;
2035 for (Uint32 i = 0, k = arraySize; i < k ; i++)
2036 {
2037 if (0 != pscmbArrayUn[i].extRefPtr)
2038 {
2039 pscmbArrayUn[i].extRefPtr->getCIMObjectPath(theObjPath);
2040 x.append(theObjPath);
2041 }
2042 else
2043 {
|
2044 thilo.boehm 1.2.2.30 // set an empty object
|
2045 thilo.boehm 1.2.2.29 x.append(CIMObjectPath());
2046 }
2047 }
2048 cimV.set(x);
2049 }
2050 else
2051 {
|
2052 thilo.boehm 1.2.2.15
|
2053 thilo.boehm 1.2.2.29 if (0 != scmbUn.extRefPtr)
2054 {
2055 scmbUn.extRefPtr->getCIMObjectPath(theObjPath);
2056 cimV.set(theObjPath);
2057 }
2058 else
2059 {
2060 cimV.set(CIMObjectPath());
2061 }
2062 }
|
2063 thilo.boehm 1.2.2.15 break;
|
2064 thilo.boehm 1.2.2.29 }
2065 case CIMTYPE_OBJECT:
2066 {
|
2067 thilo.boehm 1.2.2.30 CIMInstance theInstance;
2068 CIMClass theClass;
2069
|
2070 thilo.boehm 1.2.2.29 if(isArray)
2071 {
|
2072 thilo.boehm 1.2.2.30 Array<CIMObject> x;
2073 for (Uint32 i = 0, k = arraySize; i < k ; i++)
2074 {
2075 if (0 != pscmbArrayUn[i].extRefPtr)
2076 {
2077 // check if the Object is an emedded instance or class
2078 if(pscmbArrayUn[i].extRefPtr->
2079 inst.hdr->flags.isClassOnly)
2080 {
2081 pscmbArrayUn[i].extRefPtr->
2082 inst.hdr->theClass->getCIMClass(theClass);
2083 x.append(CIMObject(theClass));
2084 }
2085 else
2086 {
2087 pscmbArrayUn[i].extRefPtr->
2088 getCIMInstance(theInstance);
2089 x.append(CIMObject(theInstance));
2090 }
2091 }
2092 else
2093 thilo.boehm 1.2.2.30 {
2094 // set an empty object
2095 x.append(CIMObject());
2096 }
2097 }
2098 cimV.set(x);
|
2099 thilo.boehm 1.2.2.29 }
2100 else
2101 {
2102
|
2103 thilo.boehm 1.2.2.30 if (0 != scmbUn.extRefPtr)
2104 {
2105 // check if the Object is an emedded instance or class
2106 if(scmbUn.extRefPtr->inst.hdr->flags.isClassOnly)
2107 {
2108 scmbUn.extRefPtr->
2109 inst.hdr->theClass->getCIMClass(theClass);
2110 cimV.set(CIMObject(theClass));
2111 }
2112 else
2113 {
2114 scmbUn.extRefPtr->getCIMInstance(theInstance);
2115 cimV.set(CIMObject(theInstance));
2116 }
2117 }
2118 else
2119 {
2120 cimV.set(CIMObject());
2121 }
2122 }
2123 break;
2124 thilo.boehm 1.2.2.30 }
2125
2126 case CIMTYPE_INSTANCE:
2127 {
2128 CIMInstance theInstance;
2129
2130 if(isArray)
2131 {
2132 Array<CIMInstance> x;
2133 for (Uint32 i = 0, k = arraySize; i < k ; i++)
2134 {
2135 if (0 != pscmbArrayUn[i].extRefPtr)
2136 {
2137 pscmbArrayUn[i].extRefPtr->
2138 getCIMInstance(theInstance);
2139 x.append(theInstance);
2140 }
2141 else
2142 {
2143 // set an empty object
2144 x.append(CIMInstance());
2145 thilo.boehm 1.2.2.30 }
2146 }
2147 cimV.set(x);
|
2148 thilo.boehm 1.2.2.29 }
|
2149 thilo.boehm 1.2.2.30 else
2150 {
|
2151 thilo.boehm 1.2.2.15
|
2152 thilo.boehm 1.2.2.30 if (0 != scmbUn.extRefPtr)
2153 {
2154 scmbUn.extRefPtr->getCIMInstance(theInstance);
2155 cimV.set(theInstance);
2156 }
2157 else
2158 {
2159 cimV.set(CIMInstance());
2160 }
2161 }
2162 break;
2163 }
2164 default:
2165 {
2166 PEGASUS_ASSERT(false);
|
2167 thilo.boehm 1.2.2.15 break;
|
2168 thilo.boehm 1.2.2.29 }
|
2169 thilo.boehm 1.2.2.15 }
|
2170 thilo.boehm 1.2.2.24 }
|
2171 thilo.boehm 1.2.2.15
|
2172 thilo.boehm 1.2.2.24 void SCMOInstance::_getCIMValueFromSCMBValue(
2173 CIMValue& cimV,
2174 const SCMBValue& scmbV,
|
2175 thilo.boehm 1.2.2.29 const char * base)
|
2176 thilo.boehm 1.2.2.24 {
|
2177 thilo.boehm 1.2.2.29 SCMOInstance::_getCIMValueFromSCMBUnion(
|
2178 thilo.boehm 1.2.2.24 cimV,
2179 scmbV.valueType,
2180 scmbV.flags.isNull,
2181 scmbV.flags.isArray,
2182 scmbV.valueArraySize,
2183 scmbV.value,
2184 base);
|
2185 thilo.boehm 1.2.2.15 }
2186
|
2187 thilo.boehm 1.2.2.24
|
2188 thilo.boehm 1.2.2.13 void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj)
2189 {
2190 CIMObjectPathRep* objRep = cimObj._rep;
|
2191 thilo.boehm 1.1
|
2192 thilo.boehm 1.2.2.13 CString className = objRep->_className.getString().getCString();
|
2193 thilo.boehm 1.1
|
2194 thilo.boehm 1.2.2.31 // Is the instance from the same class ?
|
2195 thilo.boehm 1.2.2.13 if (!(_equalNoCaseUTF8Strings(
|
2196 thilo.boehm 1.2.2.38 inst.hdr->instClassName,
2197 inst.base,
|
2198 thilo.boehm 1.2.2.13 (const char*)className,
|
2199 thilo.boehm 1.2.2.31 strlen(className))))
|
2200 thilo.boehm 1.2.2.13 {
2201 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,
2202 objRep->_className.getString());
2203 }
|
2204 thilo.boehm 1.2
|
2205 thilo.boehm 1.2.2.13 //set host name
2206 _setString(objRep->_host,inst.hdr->hostName,&inst.mem );
|
2207 thilo.boehm 1.2
|
2208 thilo.boehm 1.2.2.13 for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++)
2209 {
|
2210 thilo.boehm 1.2.2.38 String key = objRep->_keyBindings[i].getValue();
|
2211 thilo.boehm 1.2.2.59 _setKeyBindingFromString(
|
2212 thilo.boehm 1.2.2.13 (const char*)
|
2213 thilo.boehm 1.2.2.38 objRep->_keyBindings[i].getName().getString().getCString(),
2214 _CIMTypeFromKeyBindingType(
2215 (const char*)key.getCString(),
2216 objRep->_keyBindings[i].getType()),
2217 key);
|
2218 thilo.boehm 1.1 }
2219
2220 }
|
2221 thilo.boehm 1.2.2.37 void SCMOInstance::_setCIMValueAtNodeIndex(
2222 Uint32 node,
2223 CIMValueRep* valRep,
2224 CIMType realType)
|
2225 thilo.boehm 1.1 {
|
2226 thilo.boehm 1.2.2.13 SCMBValue* theInstPropNodeArray =
|
2227 thilo.boehm 1.2.2.38 (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
|
2228 thilo.boehm 1.1
2229
|
2230 thilo.boehm 1.2.2.13 SCMBValue& theInstProp = theInstPropNodeArray[node];
|
2231 thilo.boehm 1.2.2.1
|
2232 thilo.boehm 1.2.2.37 theInstProp.valueType=realType;
|
2233 thilo.boehm 1.2.2.13 theInstProp.flags.isNull=valRep->isNull;
2234 theInstProp.flags.isArray=valRep->isArray;
2235 theInstProp.flags.isSet=true;
2236 theInstProp.valueArraySize=0;
|
2237 thilo.boehm 1.2.2.1
|
2238 thilo.boehm 1.2.2.13 if (valRep->isNull)
|
2239 thilo.boehm 1.2.2.1 {
|
2240 thilo.boehm 1.2.2.13 return;
|
2241 thilo.boehm 1.2.2.1 }
2242
|
2243 thilo.boehm 1.2.2.13 Uint64 start = ((const char*)&(theInstProp.value))-inst.base;
|
2244 thilo.boehm 1.2.2.1
|
2245 thilo.boehm 1.2.2.13 if (valRep->isArray)
2246 {
|
2247 thilo.boehm 1.2.2.24 _setUnionArrayValue(
|
2248 thilo.boehm 1.2.2.13 start,
2249 &inst.mem,
|
2250 thilo.boehm 1.2.2.37 realType,
|
2251 thilo.boehm 1.2.2.13 // Is set to the number of array members by the function.
2252 theInstProp.valueArraySize,
|
2253 thilo.boehm 1.2.2.37 inst.hdr->instNameSpace.start,
|
2254 thilo.boehm 1.2.2.57 inst.hdr->instNameSpace.size,
|
2255 thilo.boehm 1.2.2.13 valRep->u);
|
2256 thilo.boehm 1.2.2.1 }
|
2257 thilo.boehm 1.2.2.13 else
|
2258 thilo.boehm 1.2.2.1 {
|
2259 thilo.boehm 1.2.2.37 _setUnionValue(
2260 start,
2261 &inst.mem,
2262 realType,
2263 inst.hdr->instNameSpace.start,
|
2264 thilo.boehm 1.2.2.57 inst.hdr->instNameSpace.size,
|
2265 thilo.boehm 1.2.2.37 valRep->u);
|
2266 thilo.boehm 1.2.2.1 }
|
2267 thilo.boehm 1.2 }
|
2268 thilo.boehm 1.1
|
2269 thilo.boehm 1.2.2.11
|
2270 thilo.boehm 1.2.2.1 Boolean SCMOInstance::isSame(SCMOInstance& theInstance) const
2271 {
2272 return inst.base == theInstance.inst.base;
2273 }
2274
|
2275 thilo.boehm 1.2.2.37 void SCMOInstance::setHostName(const char* hostName)
2276 {
|
2277 thilo.boehm 1.2.2.70 Uint32 len = 0;
2278
2279 _copyOnWrite();
|
2280 thilo.boehm 1.2.2.37
2281 if (hostName!=0)
2282 {
2283
2284 len = strlen((const char*)hostName);
2285 }
|
2286 thilo.boehm 1.2.2.70 // copy including trailing '\0'
2287 _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);
|
2288 thilo.boehm 1.2.2.37 }
2289
|
2290 thilo.boehm 1.2.2.59 void SCMOInstance::setHostName_l(const char* hostName, Uint64 len)
|
2291 thilo.boehm 1.2.2.44 {
|
2292 thilo.boehm 1.2.2.70 _copyOnWrite();
2293
|
2294 thilo.boehm 1.2.2.44 // copy including trailing '\0'
2295 _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);
2296 }
2297
|
2298 thilo.boehm 1.2.2.2 const char* SCMOInstance::getHostName() const
|
2299 thilo.boehm 1.2.2.1 {
|
2300 thilo.boehm 1.2.2.37 return _getCharString(inst.hdr->hostName,inst.base);
2301 }
2302
2303 const char* SCMOInstance::getHostName_l(Uint64& length) const
2304 {
|
2305 marek 1.2.2.64 length = inst.hdr->hostName.size;
2306 if (0 == length)
2307 {
2308 return 0;
2309 }
2310 else
2311 {
2312 length--;
2313 }
|
2314 thilo.boehm 1.2.2.37 return _getCharString(inst.hdr->hostName,inst.base);
2315 }
2316
2317 void SCMOInstance::setClassName(const char* className)
2318 {
|
2319 marek 1.2.2.54 Uint32 len=0;
|
2320 thilo.boehm 1.2.2.70
2321 _copyOnWrite();
2322
|
2323 r.kieninger 1.2.2.43 // flag the instance as compromized
2324 inst.hdr->flags.isCompromised=true;
|
2325 thilo.boehm 1.2.2.37 if (className!=0)
2326 {
2327 len = strlen((const char*)className);
2328 }
|
2329 marek 1.2.2.54 // copy including trailing '\0'
2330 // _setBinary also sets the name to 0 if either className==0 or len+1==1
2331 _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem);
2332 }
|
2333 thilo.boehm 1.2.2.37
|
2334 marek 1.2.2.54 void SCMOInstance::setClassName_l(const char* className, Uint64 len)
2335 {
|
2336 thilo.boehm 1.2.2.70 _copyOnWrite();
2337
|
2338 marek 1.2.2.54 // flag the instance as compromised
2339 inst.hdr->flags.isCompromised=true;
2340 // copy including trailing '\0'
2341 // _setBinary also sets the name to 0 if either className==0 or len+1==1
2342 _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem);
|
2343 thilo.boehm 1.2.2.37 }
2344
2345 const char* SCMOInstance::getClassName() const
2346 {
2347 return _getCharString(inst.hdr->instClassName,inst.base);
2348 }
2349
2350 const char* SCMOInstance::getClassName_l(Uint64 & length) const
2351 {
|
2352 marek 1.2.2.64 length = inst.hdr->instClassName.size;
2353 if (0 == length)
2354 {
2355 return 0;
2356 }
2357 else
2358 {
2359 length--;
2360 }
|
2361 thilo.boehm 1.2.2.37 return _getCharString(inst.hdr->instClassName,inst.base);
2362 }
2363
2364 void SCMOInstance::setNameSpace(const char* nameSpace)
2365 {
2366 Uint32 len;
2367
|
2368 thilo.boehm 1.2.2.70 _copyOnWrite();
2369
|
2370 r.kieninger 1.2.2.43 // flag the instance as compromized
2371 inst.hdr->flags.isCompromised=true;
2372
|
2373 thilo.boehm 1.2.2.37 if (nameSpace!=0)
2374 {
2375
2376 len = strlen((const char*)nameSpace);
2377 }
|
2378 thilo.boehm 1.2.2.70 // copy including trailing '\0'
2379 _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
|
2380 thilo.boehm 1.2.2.37 }
2381
|
2382 thilo.boehm 1.2.2.59 void SCMOInstance::setNameSpace_l(const char* nameSpace, Uint64 len)
|
2383 thilo.boehm 1.2.2.44 {
|
2384 thilo.boehm 1.2.2.70 _copyOnWrite();
2385
|
2386 thilo.boehm 1.2.2.44 // flag the instance as compromized
2387 inst.hdr->flags.isCompromised=true;
2388 // copy including trailing '\0'
2389 _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
2390 }
2391
|
2392 thilo.boehm 1.2.2.37 const char* SCMOInstance::getNameSpace() const
2393 {
2394 return _getCharString(inst.hdr->instNameSpace,inst.base);
2395 }
2396
2397 const char* SCMOInstance::getNameSpace_l(Uint64 & length) const
2398 {
|
2399 marek 1.2.2.64 length = inst.hdr->instNameSpace.size;
2400 if (0 == length)
2401 {
2402 return 0;
2403 }
2404 else
2405 {
2406 length--;
2407 }
|
2408 thilo.boehm 1.2.2.37 return _getCharString(inst.hdr->instNameSpace,inst.base);
|
2409 thilo.boehm 1.2.2.1 }
2410
|
2411 thilo.boehm 1.2.2.10 void SCMOInstance::buildKeyBindingsFromProperties()
2412 {
2413 Uint32* theClassKeyPropList =
|
2414 thilo.boehm 1.2.2.12 (Uint32*) &((inst.hdr->theClass->cls.base)
2415 [(inst.hdr->theClass->cls.hdr->keyIndexList.start)]);
|
2416 thilo.boehm 1.2.2.10
|
2417 thilo.boehm 1.2.2.24 SCMBKeyBindingValue* theKeyBindValueArray;
|
2418 thilo.boehm 1.2.2.12 SCMBValue* theInstPropNodeArray;
|
2419 thilo.boehm 1.2.2.10
2420 Uint32 propNode;
2421
|
2422 thilo.boehm 1.2.2.13 for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)
|
2423 thilo.boehm 1.2.2.10 {
|
2424 r.kieninger 1.2.2.22 // the instance pointers has to be reinitialized each time,
|
2425 thilo.boehm 1.2.2.13 // because in _setKeyBindingFromSCMBUnion()
|
2426 thilo.boehm 1.2.2.12 // a reallocation can take place.
|
2427 thilo.boehm 1.2.2.24 theKeyBindValueArray =
|
2428 thilo.boehm 1.2.2.58 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
|
2429 thilo.boehm 1.2.2.12
2430 theInstPropNodeArray =
2431 (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
2432
|
2433 thilo.boehm 1.2.2.10 // If the keybinding is not set.
|
2434 thilo.boehm 1.2.2.24 if (!theKeyBindValueArray[i].isSet)
|
2435 thilo.boehm 1.2.2.10 {
|
2436 thilo.boehm 1.2.2.13 // get the node index for this key binding form class
|
2437 thilo.boehm 1.2.2.10 propNode = theClassKeyPropList[i];
2438
|
2439 thilo.boehm 1.2.2.46 // if property was set by the provider and it is not null.
2440 if ( theInstPropNodeArray[propNode].flags.isSet &&
2441 !theInstPropNodeArray[propNode].flags.isNull)
2442 {
|
2443 thilo.boehm 1.2.2.70 _copyOnWrite();
2444
|
2445 thilo.boehm 1.2.2.46 _setKeyBindingFromSCMBUnion(
2446 theInstPropNodeArray[propNode].valueType,
2447 theInstPropNodeArray[propNode].value,
2448 inst.base,
2449 theKeyBindValueArray[i]);
|
2450 thilo.boehm 1.2.2.10 }
|
2451 thilo.boehm 1.2.2.11 }
2452 }
2453 }
|
2454 thilo.boehm 1.2.2.10
|
2455 thilo.boehm 1.2.2.11 void SCMOInstance::_setKeyBindingFromSCMBUnion(
|
2456 thilo.boehm 1.2.2.13 CIMType type,
|
2457 thilo.boehm 1.2.2.24 const SCMBUnion& u,
2458 const char * uBase,
2459 SCMBKeyBindingValue& keyData)
|
2460 thilo.boehm 1.2.2.11 {
2461 switch (type)
2462 {
2463 case CIMTYPE_UINT8:
2464 case CIMTYPE_UINT16:
2465 case CIMTYPE_UINT32:
2466 case CIMTYPE_UINT64:
2467 case CIMTYPE_SINT8:
2468 case CIMTYPE_SINT16:
2469 case CIMTYPE_SINT32:
2470 case CIMTYPE_SINT64:
2471 case CIMTYPE_REAL32:
2472 case CIMTYPE_REAL64:
2473 case CIMTYPE_CHAR16:
2474 case CIMTYPE_BOOLEAN:
|
2475 thilo.boehm 1.2.2.39 {
2476 memcpy(&keyData.data,&u,sizeof(SCMBUnion));
2477 keyData.data.simple.hasValue=true;
2478 keyData.isSet=true;
2479 break;
2480 }
|
2481 thilo.boehm 1.2.2.24 case CIMTYPE_DATETIME:
|
2482 thilo.boehm 1.2.2.11 {
|
2483 thilo.boehm 1.2.2.24 memcpy(&keyData.data,&u,sizeof(SCMBUnion));
2484 keyData.isSet=true;
|
2485 thilo.boehm 1.2.2.11 break;
2486 }
2487 case CIMTYPE_STRING:
2488 {
|
2489 thilo.boehm 1.2.2.24 keyData.isSet=true;
|
2490 thilo.boehm 1.2.2.70 // Check if a key binding is set with in the same instance.
2491 // If this is the case, a reallocation can take place and the
2492 // uBase pointer can be invalid and cause a read in freed memory!
|
2493 thilo.boehm 1.2.2.69 if (uBase == inst.base)
2494 {
|
2495 thilo.boehm 1.2.2.70 if (0 != u.stringValue.size )
2496 {
2497 // We are doing a in instance copy of data.
2498 // We can not use the _setBinary() function because
2499 // all real pointer can be in valid after
2500 // the _getFreeSprace() function!
2501 // We have to save all relative pointer on the stack.
2502 Uint64 start;
2503 SCMBDataPtr tmp;
2504 tmp.size = u.stringValue.size;
2505 tmp.start = u.stringValue.start;
2506
2507 // In this function a reallocation may take place!
2508 // The keyData.data.stringValue is set
2509 // before the rallocation.
2510 start = _getFreeSpace(
2511 keyData.data.stringValue,
2512 u.stringValue.size,
2513 &inst.mem);
2514 // Copy the string,
2515 // but using the own base pointer and the saved relative
2516 thilo.boehm 1.2.2.70 // string pointer.
2517 memcpy(
2518 &(inst.base[start]),
2519 _getCharString(tmp,inst.base),
2520 tmp.size);
2521 }
2522 else
2523 {
2524 keyData.data.stringValue.size=0;
2525 keyData.data.stringValue.start=0;
2526 }
|
2527 thilo.boehm 1.2.2.69
2528 }
2529 else
2530 {
2531 _setBinary(
2532 &uBase[u.stringValue.start],
2533 u.stringValue.size,
2534 keyData.data.stringValue,
2535 &inst.mem);
2536 }
2537
|
2538 thilo.boehm 1.2.2.11 break;
|
2539 thilo.boehm 1.2.2.10 }
|
2540 thilo.boehm 1.2.2.15 case CIMTYPE_REFERENCE:
|
2541 r.kieninger 1.2.2.22 {
|
2542 thilo.boehm 1.2.2.29 if(0 != keyData.data.extRefPtr)
2543 {
2544 delete keyData.data.extRefPtr;
2545 }
2546
2547 if(u.extRefPtr)
2548 {
2549 keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr);
|
2550 thilo.boehm 1.2.2.65 keyData.isSet=true;
2551 // This function can cause a reallocation !
2552 // Pointers can be invalid after the call.
2553 _setExtRefIndex(&(keyData.data),&inst.mem);
|
2554 thilo.boehm 1.2.2.29 }
2555 else
2556 {
|
2557 thilo.boehm 1.2.2.65 keyData.isSet=true;
|
2558 thilo.boehm 1.2.2.29 keyData.data.extRefPtr=0;
2559 }
2560 break;
2561 }
|
2562 thilo.boehm 1.2.2.30 case CIMTYPE_OBJECT:
2563 case CIMTYPE_INSTANCE:
|
2564 thilo.boehm 1.2.2.29 {
2565 // From PEP 194: EmbeddedObjects cannot be keys.
2566 throw TypeMismatchException();
|
2567 thilo.boehm 1.2.2.11 break;
|
2568 r.kieninger 1.2.2.22 }
|
2569 thilo.boehm 1.2.2.30 default:
2570 {
2571 PEGASUS_ASSERT(false);
2572 break;
2573 }
|
2574 thilo.boehm 1.2.2.10 }
2575 }
|
2576 thilo.boehm 1.2.2.11
|
2577 thilo.boehm 1.2.2.28 void SCMOInstance::_initSCMOInstance(SCMOClass* pClass)
|
2578 thilo.boehm 1.2 {
2579 PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
2580 - sizeof(SCMBInstance_Main)>0);
|
2581 thilo.boehm 1.1
2582
|
2583 thilo.boehm 1.2.2.2 inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
|
2584 thilo.boehm 1.2.2.32 if (inst.base == 0)
|
2585 thilo.boehm 1.2 {
2586 // Not enough memory!
2587 throw PEGASUS_STD(bad_alloc)();
|
2588 thilo.boehm 1.1 }
2589
|
2590 thilo.boehm 1.2.2.38 memset(inst.base,0,sizeof(SCMBInstance_Main));
2591
|
2592 thilo.boehm 1.2 // initalize eye catcher
2593 inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;
2594 inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
2595 // The # of bytes free
2596 inst.hdr->header.freeBytes=
2597 SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main);
2598 // Index to the start of the free space in this instance
2599 inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main);
|
2600 thilo.boehm 1.1
|
2601 thilo.boehm 1.2 inst.hdr->refCount=1;
|
2602 thilo.boehm 1.1
|
2603 thilo.boehm 1.2 //Assign the SCMBClass structure this instance based on.
2604 inst.hdr->theClass = pClass;
|
2605 thilo.boehm 1.1
|
2606 thilo.boehm 1.2.2.37 // Copy name space name and class name of the class
2607 _setBinary(
2608 _getCharString(inst.hdr->theClass->cls.hdr->className,
2609 inst.hdr->theClass->cls.base),
|
2610 thilo.boehm 1.2.2.57 inst.hdr->theClass->cls.hdr->className.size,
|
2611 thilo.boehm 1.2.2.37 inst.hdr->instClassName,
2612 &inst.mem);
2613
2614 _setBinary(
2615 _getCharString(inst.hdr->theClass->cls.hdr->nameSpace,
2616 inst.hdr->theClass->cls.base),
|
2617 thilo.boehm 1.2.2.57 inst.hdr->theClass->cls.hdr->nameSpace.size,
|
2618 thilo.boehm 1.2.2.37 inst.hdr->instNameSpace,
2619 &inst.mem);
2620
|
2621 thilo.boehm 1.2.2.38 // Number of key bindings
2622 inst.hdr->numberKeyBindings =
2623 inst.hdr->theClass->cls.hdr->keyBindingSet.number;
2624
2625 // Number of properties
2626 inst.hdr->numberProperties =
2627 inst.hdr->theClass->cls.hdr->propertySet.number;
2628
|
2629 thilo.boehm 1.2 // Allocate the SCMOInstanceKeyBindingArray
2630 _getFreeSpace(
2631 inst.hdr->keyBindingArray,
|
2632 thilo.boehm 1.2.2.24 sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
|
2633 thilo.boehm 1.2.2.60 &inst.mem);
|
2634 thilo.boehm 1.1
|
2635 thilo.boehm 1.2 // Allocate the SCMBInstancePropertyArray
2636 _getFreeSpace(
2637 inst.hdr->propertyArray,
2638 sizeof(SCMBValue)*inst.hdr->numberProperties,
|
2639 thilo.boehm 1.2.2.60 &inst.mem);
|
2640 thilo.boehm 1.1
2641 }
2642
|
2643 thilo.boehm 1.2.2.28 void SCMOInstance::_setCIMInstance(const CIMInstance& cimInstance)
2644 {
2645 CIMPropertyRep* propRep;
2646 Uint32 propNode;
2647 Uint64 valueStart;
2648 SCMO_RC rc;
|
2649 thilo.boehm 1.2.2.37 CIMType realType;
|
2650 thilo.boehm 1.2.2.28
2651 CIMInstanceRep* instRep = cimInstance._rep;
2652
2653 // Test if the instance has qualifiers.
2654 // The instance level qualifiers are stored on the associated SCMOClass.
2655 inst.hdr->flags.includeQualifiers=(instRep->_qualifiers.getCount()>0);
2656
2657 _setCIMObjectPath(instRep->_reference);
2658
2659 // Copy all properties
2660 for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++)
2661 {
2662 propRep = instRep->_properties[i]._rep;
2663 // if not already detected that qualifiers are specified and
2664 // there are qualifers at that property.
2665 if (!inst.hdr->flags.includeQualifiers &&
2666 propRep->getQualifierCount() > 0)
2667 {
2668 includeQualifiers();
2669 }
2670 // if not already detected that class origins are specified and
2671 thilo.boehm 1.2.2.28 // there is a class origin specified at that property.
|
2672 thilo.boehm 1.2.2.29 if (!inst.hdr->flags.includeClassOrigin &&
|
2673 thilo.boehm 1.2.2.28 !propRep->_classOrigin.isNull())
2674 {
2675 includeClassOrigins();
2676 }
2677
2678 // get the property node index for the property
2679 rc = inst.hdr->theClass->_getProperyNodeIndex(
2680 propNode,
2681 (const char*)propRep->_name.getString().getCString());
2682
2683 if (rc != SCMO_OK)
2684 {
2685 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY,
2686 propRep->_name.getString());
2687 }
|
2688 thilo.boehm 1.2.2.37 // The type stored in the class information is set on realType.
2689 // It must be used in further calls to guaranty consistence.
|
2690 thilo.boehm 1.2.2.28 rc = inst.hdr->theClass->_isNodeSameType(
2691 propNode,
2692 propRep->_value._rep->type,
|
2693 thilo.boehm 1.2.2.37 propRep->_value._rep->isArray,
2694 realType);
|
2695 thilo.boehm 1.2.2.28 if (rc == SCMO_OK)
2696 {
|
2697 thilo.boehm 1.2.2.37 _setCIMValueAtNodeIndex(propNode, propRep->_value._rep,realType);
|
2698 thilo.boehm 1.2.2.28 }
2699 else
2700 {
2701 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH,
2702 propRep->_name.getString());
2703 }
2704 }
2705 }
2706
|
2707 thilo.boehm 1.2 SCMO_RC SCMOInstance::getProperty(
2708 const char* name,
2709 CIMType& type,
|
2710 thilo.boehm 1.2.2.25 const SCMBUnion** pOutVal,
|
2711 thilo.boehm 1.2 Boolean& isArray,
2712 Uint32& size ) const
|
2713 thilo.boehm 1.1 {
|
2714 thilo.boehm 1.2 Uint32 node;
|
2715 thilo.boehm 1.2.2.2 const char* pname;
|
2716 thilo.boehm 1.2 SCMO_RC rc = SCMO_OK;
|
2717 thilo.boehm 1.1
|
2718 thilo.boehm 1.2.2.32 *pOutVal = 0;
|
2719 thilo.boehm 1.2 isArray = false;
2720 size = 0;
|
2721 thilo.boehm 1.1
|
2722 thilo.boehm 1.2 rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
2723 if (rc != SCMO_OK)
2724 {
2725 return rc;
2726 }
|
2727 thilo.boehm 1.1
|
2728 thilo.boehm 1.2 // is filtering on ?
2729 if (inst.hdr->flags.isFiltered)
|
2730 thilo.boehm 1.1 {
|
2731 thilo.boehm 1.2 // Is the property NOT in the property filter ?
2732 if(!_isPropertyInFilter(node))
|
2733 thilo.boehm 1.1 {
|
2734 thilo.boehm 1.2 // The named propery is not part of this instance
2735 // due to filtering.
2736 return SCMO_NOT_FOUND;
|
2737 thilo.boehm 1.1 }
2738 }
2739
|
2740 thilo.boehm 1.2.2.25 return _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size);
|
2741 thilo.boehm 1.1 }
2742
|
2743 thilo.boehm 1.2 SCMO_RC SCMOInstance::getPropertyAt(
2744 Uint32 idx,
|
2745 thilo.boehm 1.2.2.2 const char** pname,
|
2746 thilo.boehm 1.2 CIMType& type,
|
2747 thilo.boehm 1.2.2.25 const SCMBUnion** pOutVal,
|
2748 thilo.boehm 1.2 Boolean& isArray,
2749 Uint32& size ) const
|
2750 thilo.boehm 1.1 {
|
2751 thilo.boehm 1.2.2.32 *pname = 0;
2752 *pOutVal = 0;
|
2753 thilo.boehm 1.2 isArray = false;
2754 size = 0;
2755 Uint32 node;
|
2756 thilo.boehm 1.1
|
2757 thilo.boehm 1.2 // is filtering on ?
2758 if (inst.hdr->flags.isFiltered)
|
2759 thilo.boehm 1.1 {
|
2760 thilo.boehm 1.2 // check the number of properties part of the filter
2761 if (idx >= inst.hdr->filterProperties)
|
2762 thilo.boehm 1.1 {
|
2763 thilo.boehm 1.2 return SCMO_INDEX_OUT_OF_BOUND;
|
2764 thilo.boehm 1.1 }
2765
|
2766 thilo.boehm 1.2 // Get absolut pointer to property filter index map of the instance
2767 Uint32* propertyFilterIndexMap =
2768 (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
|
2769 thilo.boehm 1.1
|
2770 thilo.boehm 1.2 // get the real node index of the property.
2771 node = propertyFilterIndexMap[idx];
2772 }
2773 else
2774 {
2775 // the index is used as node index.
2776 node = idx;
2777 if (node >= inst.hdr->numberProperties)
|
2778 thilo.boehm 1.1 {
|
2779 thilo.boehm 1.2 return SCMO_INDEX_OUT_OF_BOUND;
|
2780 thilo.boehm 1.1 }
|
2781 thilo.boehm 1.2 }
|
2782 thilo.boehm 1.1
|
2783 thilo.boehm 1.2.2.25 return _getPropertyAtNodeIndex(node,pname,type,pOutVal,isArray,size);
|
2784 thilo.boehm 1.2 }
|
2785 thilo.boehm 1.1
|
2786 thilo.boehm 1.2 SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const
2787 {
|
2788 thilo.boehm 1.2.2.5 SCMO_RC rc;
|
2789 thilo.boehm 1.2.2.32 if(name==0)
|
2790 thilo.boehm 1.2 {
2791 return SCMO_INVALID_PARAMETER;
|
2792 thilo.boehm 1.1 }
2793
|
2794 thilo.boehm 1.2.2.5 rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
2795
2796 return rc;
2797
|
2798 thilo.boehm 1.1 }
|
2799 thilo.boehm 1.2.2.25
|
2800 thilo.boehm 1.2 SCMO_RC SCMOInstance::setPropertyWithOrigin(
2801 const char* name,
2802 CIMType type,
|
2803 thilo.boehm 1.2.2.27 const SCMBUnion* pInVal,
|
2804 thilo.boehm 1.2 Boolean isArray,
2805 Uint32 size,
2806 const char* origin)
2807 {
|
2808 thilo.boehm 1.2.2.70 // In this function no _copyOnWrite(), it does not change the instance.
2809
|
2810 thilo.boehm 1.2 Uint32 node;
2811 SCMO_RC rc;
|
2812 thilo.boehm 1.2.2.37 CIMType realType;
|
2813 thilo.boehm 1.1
|
2814 thilo.boehm 1.2 rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
2815 if (rc != SCMO_OK)
2816 {
2817 return rc;
2818 }
|
2819 thilo.boehm 1.1
|
2820 thilo.boehm 1.2.2.1 // Is the traget type OK ?
|
2821 thilo.boehm 1.2.2.37 // The type stored in the class information is set on realType.
2822 // It must be used in further calls to guaranty consistence.
2823 rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray,realType);
|
2824 thilo.boehm 1.2.2.1 if (rc != SCMO_OK)
2825 {
2826 return rc;
|
2827 thilo.boehm 1.2.2.3 }
|
2828 thilo.boehm 1.2.2.1
|
2829 thilo.boehm 1.2 // is filtering on ?
2830 if (inst.hdr->flags.isFiltered)
2831 {
2832 // Is the property NOT in the property filter ?
2833 if(!_isPropertyInFilter(node))
2834 {
2835 // The named propery is not part of this instance
2836 // due to filtering.
2837 return SCMO_NOT_FOUND;
2838 }
2839 }
|
2840 thilo.boehm 1.1
|
2841 thilo.boehm 1.2 // check class origin if set.
|
2842 thilo.boehm 1.2.2.32 if (origin!= 0)
|
2843 thilo.boehm 1.1 {
|
2844 thilo.boehm 1.2 if(!inst.hdr->theClass->_isSamePropOrigin(node,origin))
2845 {
2846 return SCMO_NOT_SAME_ORIGIN;
2847 }
|
2848 thilo.boehm 1.1 }
|
2849 thilo.boehm 1.2
|
2850 thilo.boehm 1.2.2.3
|
2851 thilo.boehm 1.2.2.37 _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
|
2852 thilo.boehm 1.2
2853 return SCMO_OK;
|
2854 thilo.boehm 1.1 }
2855
|
2856 thilo.boehm 1.2.2.70 SCMO_RC SCMOInstance::setPropertyWithNodeIndex(
2857 Uint32 node,
2858 CIMType type,
2859 const SCMBUnion* pInVal,
2860 Boolean isArray,
2861 Uint32 size)
2862 {
2863 // In this function no _copyOnWrite(), it does not change the instance.
|
2864 thilo.boehm 1.2.2.1
|
2865 thilo.boehm 1.2.2.70 SCMO_RC rc;
2866 CIMType realType;
|
2867 thilo.boehm 1.2
|
2868 thilo.boehm 1.2.2.70 if (node >= inst.hdr->numberProperties)
2869 {
2870 return SCMO_INDEX_OUT_OF_BOUND;
2871 }
|
2872 thilo.boehm 1.1
|
2873 thilo.boehm 1.2.2.70 // is filtering on ?
2874 if (inst.hdr->flags.isFiltered)
2875 {
2876 // Is the property NOT in the property filter ?
2877 if(!_isPropertyInFilter(node))
2878 {
2879 // The proptery of the is not set due to filtering.
2880 return SCMO_OK;
2881 }
2882 }
|
2883 thilo.boehm 1.2.2.1
|
2884 thilo.boehm 1.2.2.70 // Is the traget type OK ?
2885 // The type stored in the class information is set on realType.
2886 // It must be used in further calls to guaranty consistence.
2887 rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray,realType);
2888 if (rc != SCMO_OK)
2889 {
2890 return rc;
2891 }
|
2892 thilo.boehm 1.2.2.13
|
2893 thilo.boehm 1.2.2.70 _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
2894
2895 return SCMO_OK;
2896 }
|
2897 thilo.boehm 1.2.2.13
2898 void SCMOInstance::_setPropertyAtNodeIndex(
2899 Uint32 node,
2900 CIMType type,
|
2901 thilo.boehm 1.2.2.27 const SCMBUnion* pInVal,
|
2902 thilo.boehm 1.2.2.13 Boolean isArray,
2903 Uint32 size)
2904 {
|
2905 thilo.boehm 1.2.2.70
2906 _copyOnWrite();
2907
|
2908 thilo.boehm 1.2.2.13 SCMBValue* theInstPropNodeArray =
|
2909 thilo.boehm 1.2.2.38 (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
|
2910 thilo.boehm 1.2.2.13
2911
2912 theInstPropNodeArray[node].flags.isSet=true;
2913 theInstPropNodeArray[node].valueType=type;
2914 theInstPropNodeArray[node].flags.isArray=isArray;
2915 if (isArray)
2916 {
2917 theInstPropNodeArray[node].valueArraySize=size;
2918 }
2919
|
2920 thilo.boehm 1.2.2.32 if (pInVal==0)
|
2921 thilo.boehm 1.2.2.13 {
2922 theInstPropNodeArray[node].flags.isNull=true;
2923 }
2924 else
2925 {
|
2926 thilo.boehm 1.2.2.25 _setSCMBUnion(
2927 pInVal,
2928 type,
2929 isArray,
2930 size,
2931 theInstPropNodeArray[node].value);
|
2932 thilo.boehm 1.2.2.13 }
2933 }
2934
2935 void SCMOInstance::_setSCMBUnion(
|
2936 thilo.boehm 1.2.2.27 const SCMBUnion* pInVal,
|
2937 thilo.boehm 1.2.2.13 CIMType type,
2938 Boolean isArray,
2939 Uint32 size,
|
2940 thilo.boehm 1.2.2.24 SCMBUnion & u)
|
2941 thilo.boehm 1.2.2.13 {
2942
2943 switch (type)
2944 {
2945 case CIMTYPE_BOOLEAN:
2946 case CIMTYPE_UINT8:
2947 case CIMTYPE_SINT8:
2948 case CIMTYPE_UINT16:
2949 case CIMTYPE_SINT16:
2950 case CIMTYPE_UINT32:
2951 case CIMTYPE_SINT32:
2952 case CIMTYPE_UINT64:
2953 case CIMTYPE_SINT64:
2954 case CIMTYPE_REAL32:
2955 case CIMTYPE_REAL64:
|
2956 thilo.boehm 1.2.2.41 case CIMTYPE_CHAR16:
|
2957 thilo.boehm 1.2.2.39 {
2958 if (isArray)
2959 {
2960 _setBinary(pInVal,size*sizeof(SCMBUnion),
2961 u.arrayValue,
2962 &inst.mem );
2963 }
2964 else
2965 {
2966 memcpy(&u,pInVal,sizeof(SCMBUnion));
2967 u.simple.hasValue=true;
2968 }
2969 break;
2970 }
|
2971 thilo.boehm 1.2.2.13 case CIMTYPE_DATETIME:
2972 {
2973 if (isArray)
2974 {
|
2975 thilo.boehm 1.2.2.25 _setBinary(pInVal,size*sizeof(SCMBUnion),
2976 u.arrayValue,
|
2977 thilo.boehm 1.2.2.13 &inst.mem );
2978 }
2979 else
2980 {
|
2981 thilo.boehm 1.2.2.25 memcpy(&u,pInVal,sizeof(SCMBUnion));
|
2982 thilo.boehm 1.2.2.39
|
2983 thilo.boehm 1.2.2.13 }
2984 break;
2985 }
2986 case CIMTYPE_STRING:
2987 {
2988 if (isArray)
2989 {
|
2990 thilo.boehm 1.2.2.25 SCMBUnion* ptr;
|
2991 thilo.boehm 1.2.2.13 Uint64 startPtr;
2992
2993 startPtr = _getFreeSpace(
|
2994 thilo.boehm 1.2.2.25 u.arrayValue,
2995 size*sizeof(SCMBUnion),
|
2996 thilo.boehm 1.2.2.60 &inst.mem);
|
2997 thilo.boehm 1.2.2.13
2998 for (Uint32 i = 0; i < size; i++)
2999 {
|
3000 thilo.boehm 1.2.2.25 ptr = (SCMBUnion*)&(inst.base[startPtr]);
|
3001 thilo.boehm 1.2.2.13 // Copy the sting including the trailing '\0'
|
3002 thilo.boehm 1.2.2.25 _setBinary(
3003 pInVal[i].extString.pchar,
3004 pInVal[i].extString.length+1,
3005 ptr[i].stringValue,
3006 &inst.mem );
|
3007 thilo.boehm 1.2.2.13 }
3008 }
3009 else
3010 {
3011 // Copy the sting including the trailing '\0'
3012 _setBinary(
|
3013 thilo.boehm 1.2.2.25 pInVal->extString.pchar,
3014 pInVal->extString.length+1,
3015 u.stringValue,
|
3016 thilo.boehm 1.2.2.13 &inst.mem );
3017 }
3018 break;
3019 }
3020
|
3021 thilo.boehm 1.2.2.29 case CIMTYPE_REFERENCE:
|
3022 thilo.boehm 1.2.2.30 case CIMTYPE_OBJECT:
|
3023 thilo.boehm 1.2.2.29 case CIMTYPE_INSTANCE:
3024 {
3025 if(isArray)
3026 {
3027 SCMBUnion* ptr;
3028 Uint64 startPtr;
|
3029 thilo.boehm 1.2.2.13
|
3030 thilo.boehm 1.2.2.29 // if the array was previously set, delete the references !
3031 _deleteArrayExtReference(u.arrayValue,&inst.mem);
|
3032 thilo.boehm 1.2.2.13
|
3033 thilo.boehm 1.2.2.29 // get new array
3034 startPtr = _getFreeSpace(
3035 u.arrayValue,
3036 size*sizeof(SCMBUnion),
|
3037 thilo.boehm 1.2.2.60 &inst.mem);
|
3038 thilo.boehm 1.2.2.13
|
3039 thilo.boehm 1.2.2.29 ptr = (SCMBUnion*)&(inst.base[startPtr]);
3040
3041 for (Uint32 i = 0 ; i < size ; i++)
3042 {
3043 if(pInVal[i].extRefPtr)
3044 {
3045 ptr[i].extRefPtr=
3046 new SCMOInstance(*(pInVal[i].extRefPtr));
|
3047 thilo.boehm 1.2.2.65
3048 // This function can cause a reallocation !
3049 // Pointers can be invalid after the call.
3050 _setExtRefIndex(&(ptr[i]),&inst.mem);
|
3051 thilo.boehm 1.2.2.29 }
3052 else
3053 {
3054 ptr[i].extRefPtr = 0;
3055 }
3056 }
|
3057 thilo.boehm 1.2.2.13
|
3058 thilo.boehm 1.2.2.29 }
3059 else
3060 {
3061 if(0 != u.extRefPtr)
3062 {
3063 delete u.extRefPtr;
3064 }
3065
3066 if(pInVal->extRefPtr)
3067 {
3068 u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr));
|
3069 thilo.boehm 1.2.2.65 // This function can cause a reallocation !
3070 // Pointers can be invalid after the call.
3071 _setExtRefIndex(&u,&inst.mem);
3072
|
3073 thilo.boehm 1.2.2.29 }
3074 else
3075 {
3076 u.extRefPtr = 0;
3077 }
3078 }
|
3079 thilo.boehm 1.2.2.13 break;
|
3080 thilo.boehm 1.2.2.29 }
|
3081 thilo.boehm 1.2.2.30 default:
3082 {
3083 PEGASUS_ASSERT(false);
3084 break;
3085 }
|
3086 thilo.boehm 1.2.2.13 }
3087 }
3088
|
3089 thilo.boehm 1.2.2.30 void SCMOInstance::_setUnionArrayValue(
|
3090 thilo.boehm 1.2.2.13 Uint64 start,
3091 SCMBMgmt_Header** pmem,
3092 CIMType type,
3093 Uint32& n,
|
3094 thilo.boehm 1.2.2.37 Uint64 startNS,
|
3095 thilo.boehm 1.2.2.59 Uint64 sizeNS,
|
3096 thilo.boehm 1.2.2.13 Union& u)
3097 {
3098 SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
|
3099 thilo.boehm 1.2.2.25 SCMBUnion* ptargetUnion;
|
3100 thilo.boehm 1.2.2.13 Uint64 arrayStart;
|
3101 thilo.boehm 1.2.2.25 Uint32 loop;
|
3102 thilo.boehm 1.2.2.13
3103 switch (type)
3104 {
3105 case CIMTYPE_BOOLEAN:
3106 {
3107 Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u);
|
3108 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3109 loop = n = x->size();
|
3110 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3111 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3112 loop*sizeof(SCMBUnion),
|
3113 thilo.boehm 1.2.2.60 pmem);
|
3114 thilo.boehm 1.2.2.25
3115 ConstArrayIterator<Boolean> iterator(*x);
3116
3117 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3118 for (Uint32 i = 0; i < loop; i++)
3119 {
3120 ptargetUnion[i].simple.val.bin = iterator[i];
3121 ptargetUnion[i].simple.hasValue = true;
3122 }
|
3123 thilo.boehm 1.2.2.13 break;
3124 }
3125
3126 case CIMTYPE_UINT8:
3127 {
3128 Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u);
|
3129 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3130 loop = n = x->size();
|
3131 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3132 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3133 loop*sizeof(SCMBUnion),
|
3134 thilo.boehm 1.2.2.60 pmem);
|
3135 thilo.boehm 1.2.2.25
3136 ConstArrayIterator<Uint8> iterator(*x);
3137
3138 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3139 for (Uint32 i = 0; i < loop; i++)
3140 {
3141 ptargetUnion[i].simple.val.u8 = iterator[i];
3142 ptargetUnion[i].simple.hasValue = true;
3143 }
|
3144 thilo.boehm 1.2.2.13 break;
3145 }
3146
3147 case CIMTYPE_SINT8:
3148 {
3149 Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u);
|
3150 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3151 loop = n = x->size();
|
3152 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3153 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3154 loop*sizeof(SCMBUnion),
|
3155 thilo.boehm 1.2.2.60 pmem);
|
3156 thilo.boehm 1.2.2.25
3157 ConstArrayIterator<Sint8> iterator(*x);
3158
3159 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3160 for (Uint32 i = 0; i < loop; i++)
3161 {
3162 ptargetUnion[i].simple.val.s8 = iterator[i];
3163 ptargetUnion[i].simple.hasValue = true;
3164 }
|
3165 thilo.boehm 1.2.2.13 break;
3166 }
3167
3168 case CIMTYPE_UINT16:
3169 {
3170 Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u);
|
3171 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3172 loop = n = x->size();
|
3173 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3174 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3175 loop*sizeof(SCMBUnion),
|
3176 thilo.boehm 1.2.2.60 pmem);
|
3177 thilo.boehm 1.2.2.25
3178 ConstArrayIterator<Uint16> iterator(*x);
|
3179 thilo.boehm 1.2.2.13
|
3180 thilo.boehm 1.2.2.25 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3181 for (Uint32 i = 0; i < loop; i++)
3182 {
3183 ptargetUnion[i].simple.val.u16 = iterator[i];
3184 ptargetUnion[i].simple.hasValue = true;
3185 }
|
3186 thilo.boehm 1.2.2.13 break;
3187 }
3188
3189 case CIMTYPE_SINT16:
3190 {
3191 Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u);
|
3192 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3193 loop = n = x->size();
|
3194 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3195 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3196 loop*sizeof(SCMBUnion),
|
3197 thilo.boehm 1.2.2.60 pmem);
|
3198 thilo.boehm 1.2.2.25
3199 ConstArrayIterator<Sint16> iterator(*x);
3200
3201 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3202 for (Uint32 i = 0; i < loop; i++)
3203 {
3204 ptargetUnion[i].simple.val.s16 = iterator[i];
3205 ptargetUnion[i].simple.hasValue = true;
3206 }
|
3207 thilo.boehm 1.2.2.13 break;
3208 }
3209
3210 case CIMTYPE_UINT32:
3211 {
3212 Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u);
|
3213 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3214 loop = n = x->size();
|
3215 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3216 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3217 loop*sizeof(SCMBUnion),
|
3218 thilo.boehm 1.2.2.60 pmem);
|
3219 thilo.boehm 1.2.2.25
3220 ConstArrayIterator<Uint32> iterator(*x);
3221
3222 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3223 for (Uint32 i = 0; i < loop; i++)
3224 {
3225 ptargetUnion[i].simple.val.u32 = iterator[i];
3226 ptargetUnion[i].simple.hasValue = true;
3227 }
|
3228 thilo.boehm 1.2.2.13 break;
3229 }
3230
3231 case CIMTYPE_SINT32:
3232 {
3233 Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u);
|
3234 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3235 loop = n = x->size();
|
3236 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3237 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3238 loop*sizeof(SCMBUnion),
|
3239 thilo.boehm 1.2.2.60 pmem);
|
3240 thilo.boehm 1.2.2.25
3241 ConstArrayIterator<Sint32> iterator(*x);
3242
3243 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3244 for (Uint32 i = 0; i < loop; i++)
3245 {
3246 ptargetUnion[i].simple.val.s32 = iterator[i];
3247 ptargetUnion[i].simple.hasValue = true;
3248 }
|
3249 thilo.boehm 1.2.2.13 break;
3250 }
3251
3252 case CIMTYPE_UINT64:
3253 {
3254 Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u);
|
3255 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3256 loop = n = x->size();
|
3257 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3258 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3259 loop*sizeof(SCMBUnion),
|
3260 thilo.boehm 1.2.2.60 pmem);
|
3261 thilo.boehm 1.2.2.25
3262 ConstArrayIterator<Uint64> iterator(*x);
3263
3264 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3265 for (Uint32 i = 0; i < loop; i++)
3266 {
3267 ptargetUnion[i].simple.val.u64 = iterator[i];
3268 ptargetUnion[i].simple.hasValue = true;
3269 }
|
3270 thilo.boehm 1.2.2.13 break;
3271 }
3272
3273 case CIMTYPE_SINT64:
3274 {
3275 Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u);
|
3276 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3277 loop = n = x->size();
|
3278 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3279 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3280 loop*sizeof(SCMBUnion),
|
3281 thilo.boehm 1.2.2.60 pmem);
|
3282 thilo.boehm 1.2.2.25
3283 ConstArrayIterator<Sint64> iterator(*x);
3284
3285 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3286 for (Uint32 i = 0; i < loop; i++)
3287 {
3288 ptargetUnion[i].simple.val.s64 = iterator[i];
3289 ptargetUnion[i].simple.hasValue = true;
3290 }
|
3291 thilo.boehm 1.2.2.13 break;
3292 }
3293
3294 case CIMTYPE_REAL32:
3295 {
3296 Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u);
|
3297 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3298 loop = n = x->size();
|
3299 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3300 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3301 loop*sizeof(SCMBUnion),
|
3302 thilo.boehm 1.2.2.60 pmem);
|
3303 thilo.boehm 1.2.2.25
3304 ConstArrayIterator<Real32> iterator(*x);
3305
3306 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3307 for (Uint32 i = 0; i < loop; i++)
3308 {
3309 ptargetUnion[i].simple.val.r32 = iterator[i];
3310 ptargetUnion[i].simple.hasValue = true;
3311 }
|
3312 thilo.boehm 1.2.2.13 break;
3313 }
3314
3315 case CIMTYPE_REAL64:
3316 {
3317 Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u);
|
3318 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3319 loop = n = x->size();
|
3320 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3321 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3322 loop*sizeof(SCMBUnion),
|
3323 thilo.boehm 1.2.2.60 pmem);
|
3324 thilo.boehm 1.2.2.25
3325 ConstArrayIterator<Real64> iterator(*x);
3326
3327 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3328 for (Uint32 i = 0; i < loop; i++)
3329 {
3330 ptargetUnion[i].simple.val.r64 = iterator[i];
3331 ptargetUnion[i].simple.hasValue = true;
3332 }
|
3333 thilo.boehm 1.2.2.13 break;
3334 }
3335
3336 case CIMTYPE_CHAR16:
3337 {
3338 Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u);
|
3339 thilo.boehm 1.2.2.25 // n can be invalid after re-allocation in _getFreeSpace !
3340 loop = n = x->size();
|
3341 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3342 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
3343 loop*sizeof(SCMBUnion),
|
3344 thilo.boehm 1.2.2.60 pmem);
|
3345 thilo.boehm 1.2.2.25
3346 ConstArrayIterator<Char16> iterator(*x);
3347
3348 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3349 for (Uint32 i = 0; i < loop; i++)
3350 {
3351 ptargetUnion[i].simple.val.c16 = iterator[i];
3352 ptargetUnion[i].simple.hasValue = true;
3353 }
|
3354 thilo.boehm 1.2.2.13 break;
3355 }
3356
3357 case CIMTYPE_STRING:
3358 {
3359 Array<String> *x = reinterpret_cast<Array<String>*>(&u);
|
3360 thilo.boehm 1.2.2.24 // n can be invalid after re-allocation in _getFreeSpace !
|
3361 thilo.boehm 1.2.2.25 loop = n = x->size();
|
3362 thilo.boehm 1.2.2.13
3363 arrayStart = _getFreeSpace(
|
3364 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
|
3365 thilo.boehm 1.2.2.29 loop*sizeof(SCMBUnion),
|
3366 thilo.boehm 1.2.2.13 pmem);
3367
|
3368 thilo.boehm 1.2.2.25 ConstArrayIterator<String> iterator(*x);
3369
3370 for (Uint32 i = 0; i < loop ; i++)
|
3371 thilo.boehm 1.2.2.13 {
3372 // the pointer has to be set eache loop,
3373 // because a reallocation may take place.
|
3374 thilo.boehm 1.2.2.25 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3375 _setString( iterator[i],ptargetUnion[i].stringValue, pmem );
|
3376 thilo.boehm 1.2.2.13 }
3377
3378 break;
3379 }
3380
3381 case CIMTYPE_DATETIME:
3382 {
3383 Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u);
|
3384 thilo.boehm 1.2.2.24 // n can be invalid after reallocation in _getFreeSpace !
|
3385 thilo.boehm 1.2.2.25 loop = n = x->size();
3386
|
3387 thilo.boehm 1.2.2.13 arrayStart = _getFreeSpace(
|
3388 thilo.boehm 1.2.2.25 scmoUnion->arrayValue,
|
3389 thilo.boehm 1.2.2.29 loop*sizeof(SCMBUnion),
|
3390 thilo.boehm 1.2.2.13 pmem);
3391
|
3392 thilo.boehm 1.2.2.25 ConstArrayIterator<CIMDateTime> iterator(*x);
3393
3394 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
|
3395 thilo.boehm 1.2
|
3396 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < loop ; i++)
|
3397 thilo.boehm 1.2.2.13 {
|
3398 thilo.boehm 1.2.2.25 memcpy(
3399 &(ptargetUnion[i].dateTimeValue),
3400 iterator[i]._rep,
3401 sizeof(SCMBDateTime));
|
3402 thilo.boehm 1.2.2.13 }
3403 break;
3404 }
|
3405 thilo.boehm 1.1
|
3406 thilo.boehm 1.2.2.29 case CIMTYPE_REFERENCE:
3407 {
3408 Array<CIMObjectPath> *x =
3409 reinterpret_cast<Array<CIMObjectPath>*>(&u);
|
3410 thilo.boehm 1.1
|
3411 thilo.boehm 1.2.2.29 // if the array was previously set, delete the references !
3412 _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
|
3413 thilo.boehm 1.1
|
3414 thilo.boehm 1.2.2.29 // n can be invalid after reallocation in _getFreeSpace !
3415 loop = n = x->size();
|
3416 thilo.boehm 1.1
|
3417 thilo.boehm 1.2.2.29 arrayStart = _getFreeSpace(
3418 scmoUnion->arrayValue,
3419 loop*sizeof(SCMBUnion),
3420 pmem);
3421
3422 ConstArrayIterator<CIMObjectPath> iterator(*x);
3423
3424 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3425
3426 for (Uint32 i = 0; i < loop ; i++)
3427 {
|
3428 thilo.boehm 1.2.2.65
|
3429 thilo.boehm 1.2.2.59 ptargetUnion[i].extRefPtr =
3430 new SCMOInstance(
3431 iterator[i],
3432 &(((const char*)*pmem)[startNS]),
3433 sizeNS-1);
3434 // Was the conversion successful?
3435 if (ptargetUnion[i].extRefPtr->isEmpty())
|
3436 thilo.boehm 1.2.2.29 {
|
3437 thilo.boehm 1.2.2.59 // N0, delete the SCMOInstance.
3438 delete ptargetUnion[i].extRefPtr;
|
3439 thilo.boehm 1.2.2.29 ptargetUnion[i].extRefPtr = 0;
3440 }
|
3441 thilo.boehm 1.2.2.65 else
3442 {
3443 _setExtRefIndex(&(ptargetUnion[i]),pmem);
3444 }
|
3445 thilo.boehm 1.2.2.29 }
|
3446 thilo.boehm 1.2.2.13
3447 break;
|
3448 thilo.boehm 1.2.2.29 }
3449 case CIMTYPE_OBJECT:
3450 {
|
3451 thilo.boehm 1.2.2.30 Array<CIMObject> *x =
3452 reinterpret_cast<Array<CIMObject>*>(&u);
3453
3454 // if the array was previously set, delete the references !
3455 _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
3456
3457 // n can be invalid after reallocation in _getFreeSpace !
3458 loop = n = x->size();
3459
3460 arrayStart = _getFreeSpace(
3461 scmoUnion->arrayValue,
3462 loop*sizeof(SCMBUnion),
3463 pmem);
3464
3465 ConstArrayIterator<CIMObject> iterator(*x);
3466
3467 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3468
3469 SCMOClass* theRefClass;
3470
3471 for (Uint32 i = 0; i < loop ; i++)
3472 thilo.boehm 1.2.2.30 {
3473 if (iterator[i].isUninitialized())
3474 {
3475 // the Object was empty.
3476 ptargetUnion[i].extRefPtr = 0;
3477 }
3478 else
3479 {
3480 if (iterator[i].isClass())
3481 {
3482 CIMClass theClass(iterator[i]);
|
3483 thilo.boehm 1.2.2.59
3484 ptargetUnion[i].extRefPtr =
3485 new SCMOInstance(
3486 theClass,
3487 (&((const char*)*pmem)[startNS]));
|
3488 thilo.boehm 1.2.2.30 // marke as class only !
3489 ptargetUnion[i].extRefPtr->
3490 inst.hdr->flags.isClassOnly=true;
|
3491 thilo.boehm 1.2.2.65
3492 // This function can cause a reallocation !
3493 // Pointers can be invalid after the call.
3494 _setExtRefIndex(&(ptargetUnion[i]),pmem);
|
3495 thilo.boehm 1.2.2.30 }
3496 else
3497 {
3498 CIMInstance theInst(iterator[i]);
3499
|
3500 thilo.boehm 1.2.2.59 ptargetUnion[i].extRefPtr =
3501 new SCMOInstance(
3502 theInst,
3503 &(((const char*)*pmem)[startNS]),
3504 sizeNS-1);
3505 // Was the conversion successful?
3506 if (ptargetUnion[i].extRefPtr->isEmpty())
3507 {
3508 // N0, delete the SCMOInstance.
3509 delete ptargetUnion[i].extRefPtr;
3510 ptargetUnion[i].extRefPtr = 0;
3511 }
|
3512 thilo.boehm 1.2.2.65 else
3513 {
3514 // This function can cause a reallocation !
3515 // Pointers can be invalid after the call.
3516 _setExtRefIndex(&(ptargetUnion[i]),pmem);
3517 }
|
3518 thilo.boehm 1.2.2.30 }
3519 }
3520 }
3521
|
3522 thilo.boehm 1.2.2.29 break;
3523 }
3524 case CIMTYPE_INSTANCE:
3525 {
|
3526 thilo.boehm 1.2.2.30 Array<CIMInstance> *x =
3527 reinterpret_cast<Array<CIMInstance>*>(&u);
3528
3529 // if the array was previously set, delete the references !
3530 _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
3531
3532 // n can be invalid after reallocation in _getFreeSpace !
3533 loop = n = x->size();
3534
3535 arrayStart = _getFreeSpace(
3536 scmoUnion->arrayValue,
3537 loop*sizeof(SCMBUnion),
3538 pmem);
3539
3540 ConstArrayIterator<CIMInstance> iterator(*x);
3541
3542 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3543
3544 for (Uint32 i = 0; i < loop ; i++)
3545 {
3546 if (iterator[i].isUninitialized())
3547 thilo.boehm 1.2.2.30 {
3548 // the Instance was empty.
3549 ptargetUnion[i].extRefPtr = 0;
3550 }
3551 else
3552 {
|
3553 thilo.boehm 1.2.2.59 ptargetUnion[i].extRefPtr =
3554 new SCMOInstance(
3555 iterator[i],
3556 &(((const char*)*pmem)[startNS]),
3557 sizeNS-1);
3558 // Was the conversion successful?
3559 if (ptargetUnion[i].extRefPtr->isEmpty())
|
3560 thilo.boehm 1.2.2.30 {
|
3561 thilo.boehm 1.2.2.59 // N0, delete the SCMOInstance.
3562 delete ptargetUnion[i].extRefPtr;
|
3563 thilo.boehm 1.2.2.30 ptargetUnion[i].extRefPtr = 0;
3564 }
|
3565 thilo.boehm 1.2.2.65 else
3566 {
3567 // This function can cause a reallocation !
3568 // Pointers can be invalid after the call.
3569 _setExtRefIndex(&(ptargetUnion[i]),pmem);
3570 }
3571
|
3572 thilo.boehm 1.2.2.30 }
3573 }
3574
3575 break;
3576 }
3577 default:
3578 {
3579 PEGASUS_ASSERT(false);
|
3580 thilo.boehm 1.2.2.29 break;
3581 }
|
3582 thilo.boehm 1.2 }
|
3583 thilo.boehm 1.1 }
3584
|
3585 thilo.boehm 1.2.2.13
|
3586 thilo.boehm 1.2.2.29 void SCMOInstance::_setUnionValue(
|
3587 thilo.boehm 1.2.2.13 Uint64 start,
3588 SCMBMgmt_Header** pmem,
|
3589 thilo.boehm 1.2 CIMType type,
|
3590 thilo.boehm 1.2.2.37 Uint64 startNS,
|
3591 thilo.boehm 1.2.2.59 Uint64 sizeNS,
|
3592 thilo.boehm 1.2.2.13 Union& u)
|
3593 thilo.boehm 1.1 {
|
3594 thilo.boehm 1.2.2.13 SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
|
3595 thilo.boehm 1.1
3596 switch (type)
3597 {
3598 case CIMTYPE_BOOLEAN:
3599 {
|
3600 thilo.boehm 1.2.2.25 scmoUnion->simple.val.bin = u._booleanValue;
3601 scmoUnion->simple.hasValue=true;
|
3602 thilo.boehm 1.1 break;
3603 }
3604
3605 case CIMTYPE_UINT8:
|
3606 thilo.boehm 1.2 {
|
3607 thilo.boehm 1.2.2.25 scmoUnion->simple.val.u8 = u._uint8Value;
3608 scmoUnion->simple.hasValue=true;
|
3609 thilo.boehm 1.1 break;
3610 }
3611
3612 case CIMTYPE_SINT8:
3613 {
|
3614 thilo.boehm 1.2.2.25 scmoUnion->simple.val.s8 = u._sint8Value;
3615 scmoUnion->simple.hasValue=true;
|
3616 thilo.boehm 1.1 break;
3617 }
3618
3619 case CIMTYPE_UINT16:
3620 {
|
3621 thilo.boehm 1.2.2.25 scmoUnion->simple.val.u16 = u._uint16Value;
3622 scmoUnion->simple.hasValue=true;
|
3623 thilo.boehm 1.1 break;
3624 }
3625
3626 case CIMTYPE_SINT16:
3627 {
|
3628 thilo.boehm 1.2.2.25 scmoUnion->simple.val.s16 = u._sint16Value;
3629 scmoUnion->simple.hasValue=true;
|
3630 thilo.boehm 1.1 break;
3631 }
3632
3633 case CIMTYPE_UINT32:
3634 {
|
3635 thilo.boehm 1.2.2.25 scmoUnion->simple.val.u32 = u._uint32Value;
3636 scmoUnion->simple.hasValue=true;
|
3637 thilo.boehm 1.1 break;
3638 }
3639
3640 case CIMTYPE_SINT32:
3641 {
|
3642 thilo.boehm 1.2.2.25 scmoUnion->simple.val.s32 = u._sint32Value;
3643 scmoUnion->simple.hasValue=true;
|
3644 thilo.boehm 1.1 break;
3645 }
3646
3647 case CIMTYPE_UINT64:
3648 {
|
3649 thilo.boehm 1.2.2.25 scmoUnion->simple.val.u64 = u._uint64Value;
3650 scmoUnion->simple.hasValue=true;
|
3651 thilo.boehm 1.1 break;
3652 }
3653
3654 case CIMTYPE_SINT64:
3655 {
|
3656 thilo.boehm 1.2.2.25 scmoUnion->simple.val.s64 = u._sint64Value;
3657 scmoUnion->simple.hasValue=true;
|
3658 thilo.boehm 1.1 break;
3659 }
3660
3661 case CIMTYPE_REAL32:
3662 {
|
3663 thilo.boehm 1.2.2.25 scmoUnion->simple.val.r32 = u._real32Value;
3664 scmoUnion->simple.hasValue=true;
|
3665 thilo.boehm 1.1 break;
3666 }
3667
3668 case CIMTYPE_REAL64:
3669 {
|
3670 thilo.boehm 1.2.2.25 scmoUnion->simple.val.r64 = u._real64Value;
3671 scmoUnion->simple.hasValue=true;
|
3672 thilo.boehm 1.1 break;
3673 }
3674
3675 case CIMTYPE_CHAR16:
3676 {
|
3677 thilo.boehm 1.2.2.25 scmoUnion->simple.val.c16 = u._char16Value;
3678 scmoUnion->simple.hasValue=true;
|
3679 thilo.boehm 1.1 break;
3680 }
3681
|
3682 thilo.boehm 1.2.2.13 case CIMTYPE_STRING:
|
3683 thilo.boehm 1.2.2.3 {
|
3684 thilo.boehm 1.2.2.13 _setString(*((String*)((void*)&u)),
|
3685 thilo.boehm 1.2.2.25 scmoUnion->stringValue,
|
3686 thilo.boehm 1.2.2.13 pmem );
|
3687 thilo.boehm 1.2.2.3 break;
3688 }
3689
|
3690 thilo.boehm 1.2.2.13 case CIMTYPE_DATETIME:
|
3691 thilo.boehm 1.1 {
|
3692 thilo.boehm 1.2.2.13 memcpy(
|
3693 thilo.boehm 1.2.2.25 &scmoUnion->dateTimeValue,
|
3694 thilo.boehm 1.2.2.13 (*((CIMDateTime*)((void*)&u)))._rep,
3695 sizeof(SCMBDateTime));
|
3696 thilo.boehm 1.1 break;
3697 }
3698
|
3699 thilo.boehm 1.2.2.25 case CIMTYPE_REFERENCE:
|
3700 thilo.boehm 1.2.2.29 {
3701 if (0 != scmoUnion->extRefPtr)
3702 {
3703 delete scmoUnion->extRefPtr;
3704 scmoUnion->extRefPtr = 0;
3705 }
3706
3707 if (0 == u._referenceValue)
3708 {
|
3709 thilo.boehm 1.2.2.59 scmoUnion->extRefPtr = 0;
|
3710 thilo.boehm 1.2.2.29 return;
3711 }
3712
3713 CIMObjectPath* theCIMObj =
3714 (CIMObjectPath*)((void*)&u._referenceValue);
3715
|
3716 thilo.boehm 1.2.2.59 scmoUnion->extRefPtr =
3717 new SCMOInstance(
3718 *theCIMObj,
3719 &(((const char*)*pmem)[startNS]),
3720 sizeNS-1);
|
3721 thilo.boehm 1.2.2.37
|
3722 thilo.boehm 1.2.2.59 // Was the conversion successful?
3723 if (scmoUnion->extRefPtr->isEmpty())
|
3724 thilo.boehm 1.2.2.29 {
|
3725 thilo.boehm 1.2.2.59 // N0, delete the SCMOInstance.
3726 delete scmoUnion->extRefPtr;
|
3727 thilo.boehm 1.2.2.29 scmoUnion->extRefPtr = 0;
3728 }
|
3729 thilo.boehm 1.2.2.65 else
3730 {
3731 // This function can cause a reallocation !
3732 // Pointers can be invalid after the call.
3733 _setExtRefIndex(scmoUnion,pmem);
3734 }
|
3735 thilo.boehm 1.2.2.59
|
3736 thilo.boehm 1.2.2.29 break;
3737 }
|
3738 thilo.boehm 1.2.2.25 case CIMTYPE_OBJECT:
|
3739 thilo.boehm 1.2.2.29 {
|
3740 thilo.boehm 1.2.2.30 if (0 != scmoUnion->extRefPtr)
3741 {
3742 delete scmoUnion->extRefPtr;
3743 scmoUnion->extRefPtr = 0;
3744 }
3745
3746 if (0 == u._referenceValue)
3747 {
3748 scmoUnion->extRefPtr=0;
3749 return;
3750 }
3751
3752 CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue);
3753 SCMOClass* theRefClass;
3754
3755 if (theCIMObject->isUninitialized())
3756 {
3757 // the Object was empty.
3758 scmoUnion->extRefPtr = 0;
3759 }
3760 else
3761 thilo.boehm 1.2.2.30 {
3762 if (theCIMObject->isClass())
3763 {
3764 CIMClass theClass(*theCIMObject);
|
3765 thilo.boehm 1.2.2.59
3766 scmoUnion->extRefPtr =
3767 new SCMOInstance(
3768 theClass,
3769 (&((const char*)*pmem)[startNS]));
|
3770 thilo.boehm 1.2.2.30 // marke as class only !
3771 scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true;
|
3772 thilo.boehm 1.2.2.65
3773 // This function can cause a reallocation !
3774 // Pointers can be invalid after the call.
3775 _setExtRefIndex(scmoUnion,pmem);
|
3776 thilo.boehm 1.2.2.30 }
3777 else
3778 {
|
3779 thilo.boehm 1.2.2.59 CIMInstance theCIMInst(*theCIMObject);
|
3780 thilo.boehm 1.2.2.30
|
3781 thilo.boehm 1.2.2.59 scmoUnion->extRefPtr =
3782 new SCMOInstance(
3783 theCIMInst,
3784 &(((const char*)*pmem)[startNS]),
3785 sizeNS-1);
|
3786 thilo.boehm 1.2.2.30
|
3787 thilo.boehm 1.2.2.59 // Was the conversion successful?
3788 if (scmoUnion->extRefPtr->isEmpty())
3789 {
3790 // N0, delete the SCMOInstance.
3791 delete scmoUnion->extRefPtr;
3792 scmoUnion->extRefPtr = 0;
3793 }
|
3794 thilo.boehm 1.2.2.65 else
3795 {
3796 // This function can cause a reallocation !
3797 // Pointers can be invalid after the call.
3798 _setExtRefIndex(scmoUnion,pmem);
3799 }
|
3800 thilo.boehm 1.2.2.30 }
3801 }
|
3802 thilo.boehm 1.2.2.29 break;
3803 }
|
3804 thilo.boehm 1.2.2.25 case CIMTYPE_INSTANCE:
3805 {
|
3806 thilo.boehm 1.2.2.30 if (0 != scmoUnion->extRefPtr)
3807 {
3808 delete scmoUnion->extRefPtr;
3809 scmoUnion->extRefPtr = 0;
3810 }
3811
3812 if (0 == u._referenceValue)
3813 {
3814 scmoUnion->extRefPtr=0;
3815 return;
3816 }
3817
3818 CIMInstance* theCIMInst =
3819 (CIMInstance*)((void*)&u._instanceValue);
3820
3821 if (theCIMInst->isUninitialized())
3822 {
3823 // the Instance was empty.
3824 scmoUnion->extRefPtr = 0;
3825 }
3826 else
3827 thilo.boehm 1.2.2.30 {
|
3828 thilo.boehm 1.2.2.59 scmoUnion->extRefPtr =
3829 new SCMOInstance(
3830 *theCIMInst,
3831 &(((const char*)*pmem)[startNS]),
3832 sizeNS-1);
3833
3834 // Was the conversion successful?
3835 if (scmoUnion->extRefPtr->isEmpty())
3836 {
3837 // N0, delete the SCMOInstance.
3838 delete scmoUnion->extRefPtr;
3839 scmoUnion->extRefPtr = 0;
3840 }
|
3841 thilo.boehm 1.2.2.65 else
3842 {
3843 // This function can cause a reallocation !
3844 // Pointers can be invalid after the call.
3845 _setExtRefIndex(scmoUnion,pmem);
3846 }
|
3847 thilo.boehm 1.2.2.30 }
3848 break;
3849 }
3850 default:
3851 {
3852 PEGASUS_ASSERT(false);
|
3853 thilo.boehm 1.1 break;
|
3854 thilo.boehm 1.2.2.25 }
|
3855 thilo.boehm 1.2 }
3856 }
3857
3858 SCMO_RC SCMOInstance::_getPropertyAtNodeIndex(
3859 Uint32 node,
|
3860 thilo.boehm 1.2.2.2 const char** pname,
|
3861 thilo.boehm 1.2 CIMType& type,
|
3862 thilo.boehm 1.2.2.25 const SCMBUnion** pvalue,
|
3863 thilo.boehm 1.2 Boolean& isArray,
3864 Uint32& size ) const
3865 {
3866 SCMBValue* theInstPropNodeArray =
3867 (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
3868
3869 // create a pointer to property node array of the class.
3870 Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;
3871 SCMBClassPropertyNode* theClassPropNodeArray =
3872 (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];
3873
3874 // the property name is always from the class.
3875 // return the absolut pointer to the property name,
3876 // the caller has to copy the name!
3877 *pname=_getCharString(
3878 theClassPropNodeArray[node].theProperty.name,
3879 inst.hdr->theClass->cls.base);
3880
3881 // the property was set by the provider.
3882 if (theInstPropNodeArray[node].flags.isSet)
3883 {
|
3884 thilo.boehm 1.1
|
3885 thilo.boehm 1.2 type = theInstPropNodeArray[node].valueType;
3886 isArray = theInstPropNodeArray[node].flags.isArray;
3887 if (isArray)
|
3888 thilo.boehm 1.1 {
|
3889 thilo.boehm 1.2 size = theInstPropNodeArray[node].valueArraySize;
|
3890 thilo.boehm 1.1 }
|
3891 thilo.boehm 1.2
3892 if (theInstPropNodeArray[node].flags.isNull)
|
3893 thilo.boehm 1.1 {
|
3894 thilo.boehm 1.2 return SCMO_NULL_VALUE;
|
3895 thilo.boehm 1.1 }
|
3896 thilo.boehm 1.2
3897 // calculate the relative index for the value.
3898 Uint64 start =
|
3899 thilo.boehm 1.2.2.2 (const char*)&(theInstPropNodeArray[node].value) -
|
3900 thilo.boehm 1.2 inst.base;
3901
3902 // the caller has to copy the value !
|
3903 thilo.boehm 1.2.2.24 *pvalue = _resolveSCMBUnion(type,isArray,size,start,inst.base);
|
3904 thilo.boehm 1.2
3905 return SCMO_OK;
3906 }
3907
3908 // the get the defaults out of the class.
3909 type = theClassPropNodeArray[node].theProperty.defaultValue.valueType;
3910 isArray =
3911 theClassPropNodeArray[node].theProperty.defaultValue.flags.isArray;
3912 if (isArray)
3913 {
3914 size = theClassPropNodeArray[node].
3915 theProperty.defaultValue.valueArraySize;
3916 }
3917
3918 if (theClassPropNodeArray[node].theProperty.defaultValue.flags.isNull)
3919 {
3920 return SCMO_NULL_VALUE;
3921 }
3922
3923 // calcutate the relativ start address of the value
3924 Uint64 start =
|
3925 thilo.boehm 1.2.2.2 (const char*)
|
3926 thilo.boehm 1.2 &(theClassPropNodeArray[node].theProperty.defaultValue.value) -
3927 (inst.hdr->theClass->cls.base);
3928
|
3929 thilo.boehm 1.2.2.24 *pvalue = _resolveSCMBUnion(
|
3930 thilo.boehm 1.2 type,
3931 isArray,
3932 size,
3933 start,
3934 (inst.hdr->theClass->cls.base)
3935 );
3936
3937 return SCMO_OK;
3938
3939 }
3940
|
3941 thilo.boehm 1.2.2.14 SCMOInstance SCMOInstance::clone(Boolean objectPathOnly) const
|
3942 thilo.boehm 1.2 {
|
3943 thilo.boehm 1.2.2.14 if (objectPathOnly)
3944 {
|
3945 thilo.boehm 1.2.2.15 // Create a new, empty SCMOInstance
|
3946 thilo.boehm 1.2.2.14 SCMOInstance newInst(*(this->inst.hdr->theClass));
3947
|
3948 thilo.boehm 1.2.2.15 // Copy the host name to tha new instance-
|
3949 thilo.boehm 1.2.2.14 _setBinary(
3950 _resolveDataPtr(this->inst.hdr->hostName,this->inst.base),
|
3951 thilo.boehm 1.2.2.57 this->inst.hdr->hostName.size,
|
3952 thilo.boehm 1.2.2.14 newInst.inst.hdr->hostName,
3953 &newInst.inst.mem);
3954
|
3955 thilo.boehm 1.2.2.41 newInst.inst.hdr->flags.isCompromised =
|
3956 thilo.boehm 1.2.2.39 this->inst.hdr->flags.isCompromised;
3957
|
3958 thilo.boehm 1.2.2.41 // If the instance contains a user set class and/or name space name
3959 if (this->inst.hdr->flags.isCompromised)
3960 {
3961 // Copy the class name to tha new instance-
3962 _setBinary(
3963 _resolveDataPtr(this->inst.hdr->instClassName,this->inst.base),
|
3964 thilo.boehm 1.2.2.57 this->inst.hdr->instClassName.size,
|
3965 thilo.boehm 1.2.2.41 newInst.inst.hdr->instClassName,
3966 &newInst.inst.mem);
3967
3968 // Copy the name space name to tha new instance-
3969 _setBinary(
3970 _resolveDataPtr(this->inst.hdr->instNameSpace,this->inst.base),
|
3971 thilo.boehm 1.2.2.57 this->inst.hdr->instNameSpace.size,
|
3972 thilo.boehm 1.2.2.41 newInst.inst.hdr->instNameSpace,
3973 &newInst.inst.mem);
3974 }
3975
|
3976 thilo.boehm 1.2.2.15 // Copy the key bindings to that new instance.
|
3977 thilo.boehm 1.2.2.14 this->_copyKeyBindings(newInst);
3978
3979 return newInst;
3980 }
3981
|
3982 thilo.boehm 1.2 SCMOInstance newInst;
|
3983 thilo.boehm 1.2.2.70 newInst.inst.base = inst.base;
3984 newInst._clone();
3985
3986 return newInst;
3987 }
3988
3989 void SCMOInstance::_clone()
3990 {
3991 char* newBase;
3992 newBase = (char*)malloc(inst.mem->totalSize);
3993 if (0 == newBase )
|
3994 thilo.boehm 1.2 {
3995 throw PEGASUS_STD(bad_alloc)();
|
3996 thilo.boehm 1.1 }
3997
|
3998 thilo.boehm 1.2.2.70 memcpy( newBase,inst.base,inst.mem->totalSize);
3999
4000 // make new new memory block to mine.
4001 inst.base = newBase;
4002 // reset the refcounter of this instance
4003 inst.hdr->refCount = 1;
|
4004 thilo.boehm 1.2.2.35 // keep the ref counter of the class correct !
|
4005 thilo.boehm 1.2.2.70 inst.hdr->theClass = new SCMOClass(*(inst.hdr->theClass));
|
4006 thilo.boehm 1.2.2.35 // keep the ref count for external references
|
4007 thilo.boehm 1.2.2.70 _copyExternalReferences();
|
4008 thilo.boehm 1.2
4009 }
4010
|
4011 thilo.boehm 1.2.2.14 void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const
4012 {
4013 Uint32 noBindings = inst.hdr->numberKeyBindings;
4014
|
4015 thilo.boehm 1.2.2.24 SCMBKeyBindingValue* sourceArray =
|
4016 thilo.boehm 1.2.2.38 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
|
4017 thilo.boehm 1.2.2.24
4018 // Address the class keybinding information
4019 const SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;
4020 const char * clsbase = inst.hdr->theClass->cls.base;
4021 SCMBKeyBindingNode* scmoClassArray =
|
4022 thilo.boehm 1.2.2.38 (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
|
4023 thilo.boehm 1.2.2.24
4024 SCMBKeyBindingValue* targetArray;
|
4025 thilo.boehm 1.2.2.14
4026 for (Uint32 i = 0; i < noBindings; i++)
4027 {
|
4028 thilo.boehm 1.2.2.15 // hast to be set every time, because of reallocation.
|
4029 thilo.boehm 1.2.2.24 targetArray=(SCMBKeyBindingValue*)&(targetInst.inst.base)
|
4030 thilo.boehm 1.2.2.14 [targetInst.inst.hdr->keyBindingArray.start];
|
4031 thilo.boehm 1.2.2.16 if(sourceArray[i].isSet)
4032 {
|
4033 thilo.boehm 1.2.2.24 // this has to be done on the target instance to keep constantness.
4034 targetInst._setKeyBindingFromSCMBUnion(
4035 scmoClassArray[i].type,
4036 sourceArray[i].data,
4037 inst.base,
4038 targetArray[i]);
|
4039 thilo.boehm 1.2.2.16 }
|
4040 thilo.boehm 1.2.2.14 }
4041
|
4042 thilo.boehm 1.2.2.38 // Are there user defined key bindings ?
|
4043 thilo.boehm 1.2.2.39 if (0 != inst.hdr->numberUserKeyBindings)
|
4044 thilo.boehm 1.2.2.38 {
4045 SCMBUserKeyBindingElement* theUserDefKBElement =
4046 (SCMBUserKeyBindingElement*)
4047 &(inst.base[inst.hdr->userKeyBindingElement.start]);
4048
|
4049 thilo.boehm 1.2.2.39 for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
|
4050 thilo.boehm 1.2.2.38 {
4051 if (theUserDefKBElement->value.isSet)
4052 {
4053 targetInst._setUserDefinedKeyBinding(*theUserDefKBElement,
4054 inst.base);
4055 }
4056
|
4057 thilo.boehm 1.2.2.41 theUserDefKBElement =
|
4058 thilo.boehm 1.2.2.38 (SCMBUserKeyBindingElement*)
4059 &(inst.base[theUserDefKBElement->nextElement.start]);
4060 } // for all user def. key bindings.
4061 }
4062 }
4063
4064
4065 void SCMOInstance::_setUserDefinedKeyBinding(
4066 SCMBUserKeyBindingElement& theInsertElement,
4067 char* elementBase)
4068 {
4069
4070 SCMBUserKeyBindingElement* ptrNewElement;
4071
4072 // get an exsiting or new user defined key binding
4073 ptrNewElement = _getUserDefinedKeyBinding(
4074 _getCharString(theInsertElement.name,elementBase),
4075 // lenght is without the trailing '\0'
|
4076 thilo.boehm 1.2.2.57 theInsertElement.name.size-1,
|
4077 thilo.boehm 1.2.2.38 theInsertElement.type);
4078
4079 // Copy the data
4080 _setKeyBindingFromSCMBUnion(
4081 theInsertElement.type,
4082 theInsertElement.value.data,
4083 elementBase,
4084 ptrNewElement->value);
4085
4086 }
4087
4088
4089 SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBindingAt(
4090 Uint32 index ) const
4091 {
4092
4093 // Get the start element
4094 SCMBUserKeyBindingElement *ptrNewElement =
4095 (SCMBUserKeyBindingElement*)
4096 &(inst.base[inst.hdr->userKeyBindingElement.start]);
4097
4098 thilo.boehm 1.2.2.38 // calculate the index within the user defined key bindings
4099 index = index - inst.hdr->numberKeyBindings;
4100
4101 // traverse trough the user defindes key binding nodes.
4102 for (Uint32 i = 0; i < index; i ++)
4103 {
4104 PEGASUS_ASSERT(ptrNewElement->nextElement.start != 0);
4105 ptrNewElement = (SCMBUserKeyBindingElement*)
4106 &(inst.base[ptrNewElement->nextElement.start]);
4107 }
4108
4109 return ptrNewElement;
|
4110 thilo.boehm 1.2.2.14 }
|
4111 thilo.boehm 1.2.2.38
4112 SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBinding(
4113 const char* name,
4114 Uint32 nameLen,
4115 CIMType type)
4116 {
4117 SCMBDataPtr newElement;
4118 SCMBUserKeyBindingElement* ptrNewElement;
4119 Uint32 node;
4120
4121 // is the key binding already stored as user defind in the instance ?
4122 if (SCMO_OK == _getUserKeyBindingNodeIndex(node,name))
4123 {
|
4124 thilo.boehm 1.2.2.41 ptrNewElement = _getUserDefinedKeyBindingAt(node);
|
4125 thilo.boehm 1.2.2.38 }
4126 else // Not found, create a new user defined key binding.
4127 {
4128
4129 _getFreeSpace(newElement,
4130 sizeof(SCMBUserKeyBindingElement),
4131 &inst.mem);
4132
4133 ptrNewElement =
4134 (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
4135
4136 // link new first user defined key binding element into chain:
|
4137 thilo.boehm 1.2.2.41 // - Assing the start point of user key binding element chain
|
4138 thilo.boehm 1.2.2.38 // to the next element of the new element.
|
4139 thilo.boehm 1.2.2.41 ptrNewElement->nextElement.start =
|
4140 thilo.boehm 1.2.2.38 inst.hdr->userKeyBindingElement.start;
|
4141 thilo.boehm 1.2.2.57 ptrNewElement->nextElement.size =
4142 inst.hdr->userKeyBindingElement.size;
|
4143 thilo.boehm 1.2.2.41 // - Assing the the new element
4144 // to the start point of user key binding element chain
|
4145 thilo.boehm 1.2.2.38 inst.hdr->userKeyBindingElement.start = newElement.start;
|
4146 thilo.boehm 1.2.2.57 inst.hdr->userKeyBindingElement.size = newElement.size;
|
4147 thilo.boehm 1.2.2.38 // Adjust the couter of user defined key bindings.
|
4148 thilo.boehm 1.2.2.39 inst.hdr->numberUserKeyBindings++;
|
4149 thilo.boehm 1.2.2.38
4150
4151 // Copy the type
4152 ptrNewElement->type = type;
|
4153 thilo.boehm 1.2.2.41 ptrNewElement->value.isSet=false;
|
4154 thilo.boehm 1.2.2.38
4155 // Copy the key binding name including the trailing '\0'
4156 _setBinary(name,nameLen+1,ptrNewElement->name,&inst.mem);
4157
4158 // reset the pointer. May the instance was reallocated.
4159 ptrNewElement =
4160 (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
4161
4162 }
4163
4164
4165 return ptrNewElement;
4166
4167 }
4168
|
4169 thilo.boehm 1.2 Uint32 SCMOInstance::getPropertyCount() const
4170 {
|
4171 thilo.boehm 1.2.2.5 if (inst.hdr->flags.isFiltered)
4172 {
4173 return(inst.hdr->filterProperties);
4174 }
4175
|
4176 thilo.boehm 1.2 return(inst.hdr->numberProperties);
|
4177 thilo.boehm 1.1 }
4178
|
4179 thilo.boehm 1.2.2.25 SCMBUnion * SCMOInstance::_resolveSCMBUnion(
|
4180 thilo.boehm 1.2 CIMType type,
4181 Boolean isArray,
4182 Uint32 size,
4183 Uint64 start,
|
4184 thilo.boehm 1.2.2.2 char* base) const
|
4185 thilo.boehm 1.1 {
|
4186 thilo.boehm 1.2
4187 SCMBUnion* u = (SCMBUnion*)&(base[start]);
4188
|
4189 thilo.boehm 1.2.2.32 SCMBUnion* av = 0;
|
4190 thilo.boehm 1.2.2.3
|
4191 thilo.boehm 1.2 if (isArray)
4192 {
|
4193 thilo.boehm 1.2.2.3 if (size == 0)
4194 {
|
4195 thilo.boehm 1.2.2.32 return 0;
|
4196 thilo.boehm 1.2.2.3 }
|
4197 thilo.boehm 1.2.2.38 av = (SCMBUnion*)&(base[u->arrayValue.start]);
|
4198 thilo.boehm 1.2 }
4199
|
4200 thilo.boehm 1.1 switch (type)
4201 {
4202 case CIMTYPE_BOOLEAN:
4203 case CIMTYPE_UINT8:
4204 case CIMTYPE_SINT8:
4205 case CIMTYPE_UINT16:
4206 case CIMTYPE_SINT16:
4207 case CIMTYPE_UINT32:
4208 case CIMTYPE_SINT32:
4209 case CIMTYPE_UINT64:
4210 case CIMTYPE_SINT64:
4211 case CIMTYPE_REAL32:
4212 case CIMTYPE_REAL64:
4213 case CIMTYPE_CHAR16:
|
4214 thilo.boehm 1.2 case CIMTYPE_DATETIME:
|
4215 thilo.boehm 1.2.2.29 case CIMTYPE_REFERENCE:
|
4216 thilo.boehm 1.2.2.30 case CIMTYPE_OBJECT:
|
4217 thilo.boehm 1.2.2.29 case CIMTYPE_INSTANCE:
|
4218 thilo.boehm 1.1 {
|
4219 thilo.boehm 1.2 if(isArray)
4220 {
|
4221 thilo.boehm 1.2.2.25 return (av);
|
4222 thilo.boehm 1.2 }
4223 else
4224 {
|
4225 thilo.boehm 1.2.2.25 return(u);
|
4226 thilo.boehm 1.2 }
|
4227 thilo.boehm 1.1 break;
4228 }
4229
4230 case CIMTYPE_STRING:
4231 {
|
4232 thilo.boehm 1.2.2.25 SCMBUnion *ptr;
|
4233 thilo.boehm 1.1
|
4234 thilo.boehm 1.2 if (isArray)
4235 {
|
4236 thilo.boehm 1.2.2.25
4237 ptr = (SCMBUnion*)malloc(size*sizeof(SCMBUnion));
|
4238 thilo.boehm 1.2.2.32 if (ptr == 0 )
|
4239 thilo.boehm 1.2 {
4240 throw PEGASUS_STD(bad_alloc)();
4241 }
4242
4243 for(Uint32 i = 0; i < size; i++)
4244 {
4245 // resolv relative pointer to absolute pointer
|
4246 thilo.boehm 1.2.2.25 ptr[i].extString.pchar =
4247 (char*)_getCharString(av[i].stringValue,base);
4248 // lenght with out the trailing /0 !
|
4249 thilo.boehm 1.2.2.57 ptr[i].extString.length = av[i].stringValue.size-1;
|
4250 thilo.boehm 1.2 }
4251 }
4252 else
4253 {
|
4254 thilo.boehm 1.2.2.25 ptr = (SCMBUnion*)malloc(sizeof(SCMBUnion));
|
4255 thilo.boehm 1.2.2.28 ptr->extString.pchar =
|
4256 thilo.boehm 1.2.2.25 (char*)_getCharString(u->stringValue,base);
4257 // lenght with out the trailing /0 !
|
4258 thilo.boehm 1.2.2.57 ptr->extString.length = u->stringValue.size-1;
|
4259 thilo.boehm 1.2 }
|
4260 thilo.boehm 1.1
|
4261 thilo.boehm 1.2.2.25 return(ptr);
|
4262 thilo.boehm 1.1 break;
4263 }
|
4264 thilo.boehm 1.2 default:
|
4265 thilo.boehm 1.2.2.30 {
4266 PEGASUS_ASSERT(false);
4267 break;
4268 }
|
4269 thilo.boehm 1.2 }
|
4270 thilo.boehm 1.2.2.32 return 0;
|
4271 thilo.boehm 1.1 }
4272
|
4273 thilo.boehm 1.2.2.58 void SCMOInstance::clearKeyBindings()
4274 {
|
4275 thilo.boehm 1.2.2.70 _copyOnWrite();
4276
|
4277 thilo.boehm 1.2.2.58 // First destroy all external references in the key bindings
4278 _destroyExternalKeyBindings();
4279
4280 // reset user keybindings
4281 inst.hdr->numberUserKeyBindings = 0;
4282 inst.hdr->userKeyBindingElement.start = 0;
4283 inst.hdr->userKeyBindingElement.size = 0;
4284
4285 // Allocate a clean the SCMOInstanceKeyBindingArray
4286 _getFreeSpace(
4287 inst.hdr->keyBindingArray,
4288 sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
|
4289 thilo.boehm 1.2.2.60 &inst.mem);
|
4290 thilo.boehm 1.2.2.58 }
4291
|
4292 marek 1.2.2.23 Uint32 SCMOInstance::getKeyBindingCount() const
|
4293 thilo.boehm 1.1 {
|
4294 thilo.boehm 1.2.2.38 // count of class keys + user definded keys
4295 return(inst.hdr->numberKeyBindings+
|
4296 thilo.boehm 1.2.2.39 inst.hdr->numberUserKeyBindings);
|
4297 thilo.boehm 1.1 }
4298
4299
|
4300 thilo.boehm 1.2 SCMO_RC SCMOInstance::getKeyBindingAt(
4301 Uint32 node,
|
4302 thilo.boehm 1.2.2.2 const char** pname,
|
4303 thilo.boehm 1.2.2.24 CIMType& type,
|
4304 thilo.boehm 1.2.2.25 const SCMBUnion** pvalue) const
|
4305 thilo.boehm 1.1 {
|
4306 thilo.boehm 1.2.2.24 SCMO_RC rc;
|
4307 thilo.boehm 1.2.2.32 const SCMBUnion* pdata=0;
|
4308 thilo.boehm 1.2.2.24 Uint32 pnameLen=0;
4309
|
4310 thilo.boehm 1.2.2.32 *pname = 0;
4311 *pvalue = 0;
|
4312 thilo.boehm 1.1
|
4313 thilo.boehm 1.2.2.38 // count of class keys + user definded keys
4314 if (node >= (inst.hdr->numberKeyBindings+
|
4315 thilo.boehm 1.2.2.39 inst.hdr->numberUserKeyBindings))
|
4316 thilo.boehm 1.2 {
4317 return SCMO_INDEX_OUT_OF_BOUND;
4318 }
|
4319 thilo.boehm 1.1
|
4320 thilo.boehm 1.2.2.24 rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,&pdata);
4321 if (rc != SCMO_OK)
4322 {
4323 return rc;
4324 }
4325
4326 *pvalue = _resolveSCMBUnion(
4327 type,
4328 false, // A key binding can never be an array.
4329 0,
4330 (char*)pdata-inst.base,
4331 inst.base);
4332
4333 return SCMO_OK;
4334
|
4335 thilo.boehm 1.1 }
4336
|
4337 thilo.boehm 1.2 SCMO_RC SCMOInstance::getKeyBinding(
4338 const char* name,
|
4339 thilo.boehm 1.2.2.24 CIMType& type,
|
4340 thilo.boehm 1.2.2.25 const SCMBUnion** pvalue) const
|
4341 thilo.boehm 1.1 {
|
4342 thilo.boehm 1.2 SCMO_RC rc;
4343 Uint32 node;
|
4344 thilo.boehm 1.2.2.32 const char* pname=0;
4345 const SCMBUnion* pdata=0;
|
4346 thilo.boehm 1.2.2.24 Uint32 pnameLen=0;
4347
|
4348 thilo.boehm 1.2.2.32 *pvalue = 0;
|
4349 thilo.boehm 1.1
|
4350 thilo.boehm 1.2 rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);
4351 if (rc != SCMO_OK)
|
4352 thilo.boehm 1.1 {
|
4353 thilo.boehm 1.2.2.38 // look at the user defined key bindings.
4354 rc = _getUserKeyBindingNodeIndex(node,name);
4355 if (rc != SCMO_OK)
4356 {
4357 return rc;
|
4358 thilo.boehm 1.2.2.41 }
|
4359 thilo.boehm 1.1 }
4360
|
4361 thilo.boehm 1.2.2.24 rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata);
|
4362 thilo.boehm 1.2.2.38
|
4363 thilo.boehm 1.2.2.24 if (rc != SCMO_OK)
4364 {
4365 return rc;
4366 }
|
4367 thilo.boehm 1.1
|
4368 thilo.boehm 1.2.2.24 *pvalue = _resolveSCMBUnion(
4369 type,
4370 false, // A key binding can never be an array.
4371 0,
4372 (char*)pdata-inst.base,
4373 inst.base);
|
4374 thilo.boehm 1.1
|
4375 thilo.boehm 1.2.2.24 return SCMO_OK;
|
4376 marek 1.2.2.23 }
|
4377 thilo.boehm 1.1
|
4378 thilo.boehm 1.2.2.24
4379 SCMO_RC SCMOInstance::_getKeyBindingDataAtNodeIndex(
|
4380 marek 1.2.2.23 Uint32 node,
4381 const char** pname,
4382 Uint32 & pnameLen,
|
4383 thilo.boehm 1.2.2.24 CIMType & type,
4384 const SCMBUnion** pdata) const
|
4385 marek 1.2.2.23 {
|
4386 thilo.boehm 1.2.2.38 if (node < inst.hdr->numberKeyBindings)
4387 {
4388 SCMBKeyBindingValue* theInstKeyBindValueArray =
4389 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
|
4390 thilo.boehm 1.1
|
4391 thilo.boehm 1.2.2.38 // create a pointer to key binding node array of the class.
4392 Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
4393 SCMBKeyBindingNode* theClassKeyBindNodeArray =
4394 (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
4395
4396 type = theClassKeyBindNodeArray[node].type;
4397
|
4398 thilo.boehm 1.2.2.41 // First resolve pointer to the key binding name
|
4399 thilo.boehm 1.2.2.57 pnameLen = theClassKeyBindNodeArray[node].name.size;
|
4400 thilo.boehm 1.2.2.38 *pname = _getCharString(
4401 theClassKeyBindNodeArray[node].name,
4402 inst.hdr->theClass->cls.base);
4403
4404 // There is no value set in the instance
4405 if (!theInstKeyBindValueArray[node].isSet)
4406 {
4407 return SCMO_NULL_VALUE;
4408 }
|
4409 thilo.boehm 1.1
|
4410 thilo.boehm 1.2.2.38 *pdata = &(theInstKeyBindValueArray[node].data);
4411 }
4412 else // look at the user defined key bindings
4413 {
|
4414 thilo.boehm 1.2.2.5
|
4415 thilo.boehm 1.2.2.41 SCMBUserKeyBindingElement* theElem = _getUserDefinedKeyBindingAt(node);
|
4416 thilo.boehm 1.2.2.38
4417 type = theElem->type;
4418
|
4419 thilo.boehm 1.2.2.57 pnameLen = theElem->name.size;
|
4420 thilo.boehm 1.2.2.38 *pname = _getCharString(theElem->name,inst.base);
4421
4422 // There is no value set in the instance
4423 if (!theElem->value.isSet)
4424 {
4425 return SCMO_NULL_VALUE;
4426 }
4427
4428 *pdata = &(theElem->value.data);
4429
4430 }
|
4431 thilo.boehm 1.1
|
4432 thilo.boehm 1.2.2.38 return SCMO_OK;
4433 }
4434
4435 SCMO_RC SCMOInstance::_getUserKeyBindingNodeIndex(
|
4436 thilo.boehm 1.2.2.41 Uint32& node,
|
4437 thilo.boehm 1.2.2.38 const char* name) const
4438 {
|
4439 thilo.boehm 1.2.2.41
|
4440 thilo.boehm 1.2.2.38 Uint32 len = strlen(name);
4441 node = 0;
4442 SCMBUserKeyBindingElement* theUserDefKBElement;
4443
4444 Uint64 elementStart = inst.hdr->userKeyBindingElement.start;
4445
4446 while (elementStart != 0)
|
4447 thilo.boehm 1.2 {
|
4448 thilo.boehm 1.2.2.38 SCMBUserKeyBindingElement* theUserDefKBElement =
4449 (SCMBUserKeyBindingElement*)&(inst.base[elementStart]);
4450
|
4451 thilo.boehm 1.2.2.47 if (_equalNoCaseUTF8Strings(
4452 theUserDefKBElement->name,inst.base,name,len))
|
4453 thilo.boehm 1.2.2.38 {
4454 // the node index of a user defined key binding has an offset
4455 // by the number of key bindings defined in the class
4456 node = node + inst.hdr->numberKeyBindings;
4457 return SCMO_OK;
4458 }
4459 node = node + 1;
4460 elementStart = theUserDefKBElement->nextElement.start;
|
4461 thilo.boehm 1.2 }
|
4462 thilo.boehm 1.1
|
4463 thilo.boehm 1.2.2.38 return SCMO_NOT_FOUND;
|
4464 thilo.boehm 1.1
|
4465 thilo.boehm 1.2.2.38 }
4466
4467 CIMType SCMOInstance::_CIMTypeFromKeyBindingType(
|
4468 thilo.boehm 1.2.2.41 const char* key,
|
4469 thilo.boehm 1.2.2.38 CIMKeyBinding::Type t)
4470 {
4471 switch( t )
4472 {
4473 case CIMKeyBinding::NUMERIC:
4474 {
4475 if( *(key)=='-' )
4476 {
4477 Sint64 x;
|
4478 thilo.boehm 1.2.2.41 // check if it is realy an integer
|
4479 thilo.boehm 1.2.2.38 if (StringConversion::stringToSignedInteger(key, x))
4480 {
4481 return CIMTYPE_SINT64;
4482 }
4483 else
4484 {
4485 return CIMTYPE_REAL64;
|
4486 thilo.boehm 1.2.2.41 }
|
4487 thilo.boehm 1.2.2.38 }
4488 else
4489 {
4490 Uint64 x;
|
4491 thilo.boehm 1.2.2.41 // check if it is realy an integer
|
4492 thilo.boehm 1.2.2.38 if (StringConversion::stringToUnsignedInteger(key, x))
4493 {
4494 return CIMTYPE_UINT64;
4495 }
4496 else
4497 {
4498 return CIMTYPE_REAL64;
|
4499 thilo.boehm 1.2.2.41 }
|
4500 thilo.boehm 1.2.2.38 }
4501 break;
4502 }
|
4503 thilo.boehm 1.2.2.41
|
4504 thilo.boehm 1.2.2.38
4505 case CIMKeyBinding::STRING:
4506 {
4507 return CIMTYPE_STRING;
4508 break;
|
4509 thilo.boehm 1.2.2.41 }
|
4510 thilo.boehm 1.2.2.38
4511 case CIMKeyBinding::BOOLEAN:
4512 {
4513 return CIMTYPE_BOOLEAN;
4514 break;
4515 }
4516
4517 case CIMKeyBinding::REFERENCE:
4518 {
4519 return CIMTYPE_REFERENCE;
4520 break;
4521 }
4522
4523 default:
4524 return CIMTYPE_UINT64;
4525 }
4526 return CIMTYPE_UINT64;
|
4527 thilo.boehm 1.1 }
4528
|
4529 thilo.boehm 1.2.2.33 Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindingValue(
|
4530 thilo.boehm 1.2.2.29 const String& kbs,
|
4531 thilo.boehm 1.2.2.24 CIMType type,
4532 SCMBKeyBindingValue& scmoKBV
4533 )
4534 {
4535 scmoKBV.isSet=false;
|
4536 thilo.boehm 1.2.2.39 // If it not a simple value, it will be over written.
4537 scmoKBV.data.simple.hasValue=false;
|
4538 thilo.boehm 1.2.2.24
|
4539 thilo.boehm 1.2.2.29 if ( kbs.size() == 0 && type != CIMTYPE_STRING)
|
4540 thilo.boehm 1.2.2.24 {
4541 // The string is empty ! Do nothing.
|
4542 thilo.boehm 1.2.2.33 return false;
|
4543 thilo.boehm 1.2.2.24 }
|
4544 thilo.boehm 1.2.2.29
|
4545 thilo.boehm 1.2.2.32 CString a = kbs.getCString();
4546 const char* v = a;
|
4547 thilo.boehm 1.2.2.29
|
4548 thilo.boehm 1.2.2.24 switch (type)
4549 {
4550 case CIMTYPE_UINT8:
4551 {
4552 Uint64 x;
4553 if (StringConversion::stringToUnsignedInteger(v, x) &&
4554 StringConversion::checkUintBounds(x, type))
4555 {
|
4556 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.u8 = Uint8(x);
|
4557 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4558 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4559 }
4560 break;
4561 }
4562 case CIMTYPE_UINT16:
4563 {
4564 Uint64 x;
4565 if (StringConversion::stringToUnsignedInteger(v, x) &&
4566 StringConversion::checkUintBounds(x, type))
4567 {
|
4568 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.u16 = Uint16(x);
|
4569 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4570 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4571 }
4572 break;
4573 }
4574
4575 case CIMTYPE_UINT32:
4576 {
4577 Uint64 x;
4578 if (StringConversion::stringToUnsignedInteger(v, x) &&
4579 StringConversion::checkUintBounds(x, type))
4580 {
|
4581 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.u32 = Uint32(x);
|
4582 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4583 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4584 }
4585 break;
4586 }
4587
4588 case CIMTYPE_UINT64:
4589 {
4590 Uint64 x;
4591 if (StringConversion::stringToUnsignedInteger(v, x))
4592 {
|
4593 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.u64 = x;
|
4594 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4595 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4596 }
4597 break;
4598 }
4599
4600 case CIMTYPE_SINT8:
4601 {
4602 Sint64 x;
4603 if (StringConversion::stringToSignedInteger(v, x) &&
4604 StringConversion::checkSintBounds(x, type))
4605 {
|
4606 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.s8 = Sint8(x);
|
4607 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4608 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4609 }
4610 break;
4611 }
4612
4613 case CIMTYPE_SINT16:
4614 {
4615 Sint64 x;
4616 if (StringConversion::stringToSignedInteger(v, x) &&
4617 StringConversion::checkSintBounds(x, type))
4618 {
|
4619 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.s16 = Sint16(x);
|
4620 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4621 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4622 }
4623 break;
4624 }
4625
4626 case CIMTYPE_SINT32:
4627 {
4628 Sint64 x;
4629 if (StringConversion::stringToSignedInteger(v, x) &&
4630 StringConversion::checkSintBounds(x, type))
4631 {
|
4632 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.s32 = Sint32(x);
|
4633 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4634 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4635 }
4636 break;
4637 }
4638
4639 case CIMTYPE_SINT64:
4640 {
4641 Sint64 x;
4642 if (StringConversion::stringToSignedInteger(v, x))
4643 {
|
4644 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.s64 = x;
|
4645 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4646 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4647 }
4648 break;
4649 }
4650
4651 case CIMTYPE_DATETIME:
4652 {
4653 CIMDateTime tmp;
4654
4655 try
4656 {
4657 tmp.set(v);
4658 }
4659 catch (InvalidDateTimeFormatException&)
4660 {
4661 return false;
4662 }
4663
4664 memcpy(
|
4665 thilo.boehm 1.2.2.25 &(scmoKBV.data.dateTimeValue),
|
4666 thilo.boehm 1.2.2.24 tmp._rep,
4667 sizeof(SCMBDateTime));
4668 scmoKBV.isSet=true;
4669 break;
4670 }
4671
4672 case CIMTYPE_REAL32:
4673 {
4674 Real64 x;
4675
|
4676 thilo.boehm 1.2.2.38 if (StringConversion::stringToReal64(v, x))
|
4677 thilo.boehm 1.2.2.24 {
|
4678 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.r32 = Real32(x);
|
4679 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4680 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4681 }
4682 break;
4683 }
4684
4685 case CIMTYPE_REAL64:
4686 {
4687 Real64 x;
4688
|
4689 thilo.boehm 1.2.2.38 if (StringConversion::stringToReal64(v, x))
|
4690 thilo.boehm 1.2.2.24 {
|
4691 thilo.boehm 1.2.2.38 scmoKBV.data.simple.val.r64 = x;
|
4692 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4693 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4694 }
4695 break;
4696 }
4697
4698 case CIMTYPE_CHAR16:
4699 {
|
4700 thilo.boehm 1.2.2.29 if (kbs.size() == 1)
|
4701 thilo.boehm 1.2.2.24 {
|
4702 thilo.boehm 1.2.2.29 scmoKBV.data.simple.val.c16 = kbs[0];
|
4703 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4704 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4705 }
4706 break;
4707 }
4708 case CIMTYPE_BOOLEAN:
4709 {
|
4710 thilo.boehm 1.2.2.29 if (String::equalNoCase(kbs,"TRUE"))
|
4711 thilo.boehm 1.2.2.24 {
|
4712 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.bin = true;
|
4713 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4714 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4715 }
|
4716 thilo.boehm 1.2.2.29 else if (String::equalNoCase(kbs,"FALSE"))
|
4717 thilo.boehm 1.2.2.24 {
|
4718 thilo.boehm 1.2.2.25 scmoKBV.data.simple.val.bin = false;
|
4719 thilo.boehm 1.2.2.39 scmoKBV.data.simple.hasValue=true;
|
4720 thilo.boehm 1.2.2.24 scmoKBV.isSet=true;
4721 }
4722 break;
4723 }
4724
4725 case CIMTYPE_STRING:
4726 {
4727 scmoKBV.isSet=true;
4728 // Can cause reallocation !
|
4729 thilo.boehm 1.2.2.29 _setString(kbs,scmoKBV.data.stringValue,&inst.mem);
|
4730 thilo.boehm 1.2.2.24 return true;
4731 break;
4732 }
4733 case CIMTYPE_REFERENCE:
4734 {
|
4735 thilo.boehm 1.2.2.29 if (0 != scmoKBV.data.extRefPtr)
4736 {
4737 delete scmoKBV.data.extRefPtr;
4738 scmoKBV.data.extRefPtr = 0;
4739 scmoKBV.isSet=false;
4740 }
4741 // TBD: Optimize parsing and SCMOInstance creation.
4742 CIMObjectPath theCIMObj(kbs);
|
4743 thilo.boehm 1.2.2.37
|
4744 thilo.boehm 1.2.2.59 scmoKBV.data.extRefPtr = new SCMOInstance(theCIMObj);
4745 scmoKBV.isSet=true;
4746
4747 // Was the conversion successful?
4748 if (scmoKBV.data.extRefPtr->isEmpty())
|
4749 thilo.boehm 1.2.2.29 {
|
4750 thilo.boehm 1.2.2.59 // N0, delete the SCMOInstance.
4751 delete scmoKBV.data.extRefPtr;
|
4752 thilo.boehm 1.2.2.29 scmoKBV.data.extRefPtr = 0;
|
4753 thilo.boehm 1.2.2.59 scmoKBV.isSet=false;
|
4754 thilo.boehm 1.2.2.29 }
|
4755 thilo.boehm 1.2.2.65 else
4756 {
4757 // This function can cause a reallocation !
4758 // Pointers can be invalid after the call.
4759 _setExtRefIndex(&(scmoKBV.data),&inst.mem);
4760 }
|
4761 thilo.boehm 1.2.2.24 break;
4762 }
|
4763 thilo.boehm 1.2.2.30 case CIMTYPE_OBJECT:
4764 case CIMTYPE_INSTANCE:
4765 {
4766 // From PEP 194: EmbeddedObjects cannot be keys.
4767 throw TypeMismatchException();
4768 break;
4769 }
4770 default:
4771 {
4772 PEGASUS_ASSERT(false);
4773 break;
4774 }
|
4775 thilo.boehm 1.2.2.24 }
4776
4777 return scmoKBV.isSet;
4778 }
4779
4780 SCMO_RC SCMOInstance::_setKeyBindingFromString(
|
4781 thilo.boehm 1.2 const char* name,
|
4782 thilo.boehm 1.2.2.38 CIMType type,
|
4783 thilo.boehm 1.2.2.24 String cimKeyBinding)
|
4784 thilo.boehm 1.1 {
|
4785 thilo.boehm 1.2 SCMO_RC rc;
|
4786 thilo.boehm 1.1 Uint32 node;
4787
|
4788 thilo.boehm 1.2.2.32 if (0 == name)
|
4789 thilo.boehm 1.2.2.20 {
4790 return SCMO_INVALID_PARAMETER;
4791 }
|
4792 thilo.boehm 1.2.2.41
|
4793 thilo.boehm 1.2.2.38 if (SCMO_OK == inst.hdr->theClass->_getKeyBindingNodeIndex(node,name))
|
4794 thilo.boehm 1.1 {
|
4795 thilo.boehm 1.2.2.38 // create a pointer to keybinding node array of the class.
4796 Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
4797 SCMBKeyBindingNode* theClassKeyBindNodeArray =
4798 (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
4799
4800 // create a pointer to instance keybinding values
4801 SCMBKeyBindingValue* theInstKeyBindValueArray =
4802 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
4803
4804 // If the set was not successful, the conversion was not successful
4805 if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
4806 cimKeyBinding,
4807 theClassKeyBindNodeArray[node].type,
4808 theInstKeyBindValueArray[node]))
4809 {
4810 return SCMO_TYPE_MISSMATCH;
4811 }
4812
4813 return SCMO_OK;
|
4814 thilo.boehm 1.1 }
4815
|
4816 thilo.boehm 1.2.2.38 // the key binig does not belong to the associated class
4817 // add/set it as user defined key binding.
4818 SCMBUserKeyBindingElement* ptrNewElement;
|
4819 thilo.boehm 1.2
|
4820 thilo.boehm 1.2.2.38 ptrNewElement = _getUserDefinedKeyBinding( name,strlen(name),type);
|
4821 thilo.boehm 1.2.2.24
|
4822 thilo.boehm 1.2.2.38 // Copy the data.
|
4823 thilo.boehm 1.2.2.35 // If the set was not successful, the conversion was not successful
|
4824 thilo.boehm 1.2.2.33 if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
|
4825 thilo.boehm 1.2.2.29 cimKeyBinding,
|
4826 thilo.boehm 1.2.2.38 type,
4827 ptrNewElement->value))
|
4828 thilo.boehm 1.1 {
|
4829 thilo.boehm 1.2 return SCMO_TYPE_MISSMATCH;
|
4830 thilo.boehm 1.1 }
4831
|
4832 thilo.boehm 1.2 return SCMO_OK;
|
4833 thilo.boehm 1.1 }
4834
|
4835 r.kieninger 1.2.2.22 SCMO_RC SCMOInstance::setKeyBinding(
4836 const char* name,
4837 CIMType type,
|
4838 thilo.boehm 1.2.2.27 const SCMBUnion* keyvalue)
|
4839 r.kieninger 1.2.2.22 {
4840 SCMO_RC rc;
4841 Uint32 node;
4842
|
4843 thilo.boehm 1.2.2.32 if (0 == name)
|
4844 r.kieninger 1.2.2.22 {
4845 return SCMO_INVALID_PARAMETER;
4846 }
4847
|
4848 thilo.boehm 1.2.2.38 if (0 == keyvalue)
4849 {
4850 return SCMO_INVALID_PARAMETER;
4851 }
4852
|
4853 thilo.boehm 1.2.2.70 _copyOnWrite();
4854
|
4855 r.kieninger 1.2.2.22 rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);
4856 if (rc != SCMO_OK)
4857 {
|
4858 thilo.boehm 1.2.2.38 // the key bindig does not belong to the associated class
4859 // add/set it as user defined key binding.
4860 SCMBUserKeyBindingElement *theNode;
4861
4862 theNode = _getUserDefinedKeyBinding( name,strlen(name),type);
4863
|
4864 thilo.boehm 1.2.2.41 // Is this a new node or an existing user key binding?
|
4865 thilo.boehm 1.2.2.38 if (theNode->value.isSet && (theNode->type != type))
|
4866 thilo.boehm 1.2.2.41 {
|
4867 thilo.boehm 1.2.2.38 return SCMO_TYPE_MISSMATCH;
4868
|
4869 thilo.boehm 1.2.2.41 }
|
4870 thilo.boehm 1.2.2.38
4871 theNode->value.isSet=true;
4872
4873 _setSCMBUnion(
4874 keyvalue,
4875 type,
4876 false, // a key binding can never be an array.
4877 0,
4878 theNode->value.data);
4879
4880 return SCMO_OK;
|
4881 r.kieninger 1.2.2.22 }
4882
4883 return setKeyBindingAt(node, type, keyvalue);
4884 }
4885
4886 SCMO_RC SCMOInstance::setKeyBindingAt(
4887 Uint32 node,
4888 CIMType type,
|
4889 thilo.boehm 1.2.2.27 const SCMBUnion* keyvalue)
|
4890 r.kieninger 1.2.2.22 {
4891 SCMO_RC rc;
4892
|
4893 thilo.boehm 1.2.2.32 if (0 == keyvalue)
|
4894 r.kieninger 1.2.2.22 {
4895 return SCMO_INVALID_PARAMETER;
4896 }
4897
|
4898 thilo.boehm 1.2.2.38 // count of class keys + user definded keys
4899 if (node >= (inst.hdr->numberKeyBindings+
|
4900 thilo.boehm 1.2.2.39 inst.hdr->numberUserKeyBindings))
|
4901 thilo.boehm 1.2.2.24 {
4902 return SCMO_INDEX_OUT_OF_BOUND;
4903 }
4904
|
4905 thilo.boehm 1.2.2.70 _copyOnWrite();
4906
4907 // create a pointer to keybinding node array of the class.
4908 Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
4909 SCMBKeyBindingNode* theClassKeyBindNodeArray =
4910 (SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]);
4911
|
4912 thilo.boehm 1.2.2.38 // is the node a user defined key binding ?
4913 if (node >= inst.hdr->numberKeyBindings)
|
4914 thilo.boehm 1.2.2.41 {
|
4915 thilo.boehm 1.2.2.38 SCMBUserKeyBindingElement* theNode = _getUserDefinedKeyBindingAt(node);
4916
4917 // Does the new value for the user defined keybinding match?
4918 if (theNode->type != type)
4919 {
4920 return SCMO_TYPE_MISSMATCH;
4921 }
4922
4923 _setSCMBUnion(
4924 keyvalue,
4925 type,
4926 false, // a key binding can never be an array.
4927 0,
4928 theNode->value.data);
4929
4930 return SCMO_OK;
4931
|
4932 thilo.boehm 1.2.2.24 }
|
4933 r.kieninger 1.2.2.22
|
4934 thilo.boehm 1.2.2.24 SCMBKeyBindingValue* theInstKeyBindValueArray =
|
4935 thilo.boehm 1.2.2.38 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
4936
4937
4938 if (theClassKeyBindNodeArray[node].type == type)
4939 {
4940
4941 // Has to be set first,
4942 // because reallocaton can take place in _setSCMBUnion()
4943 theInstKeyBindValueArray[node].isSet=true;
4944
4945 _setSCMBUnion(
4946 keyvalue,
4947 type,
4948 false, // a key binding can never be an array.
4949 0,
4950 theInstKeyBindValueArray[node].data);
|
4951 r.kieninger 1.2.2.22
|
4952 thilo.boehm 1.2.2.38 return SCMO_OK;
|
4953 r.kieninger 1.2.2.22
|
4954 thilo.boehm 1.2.2.38 }
|
4955 thilo.boehm 1.2.2.24
|
4956 thilo.boehm 1.2.2.38 // The type does not match.
|
4957 thilo.boehm 1.2.2.41 return _setKeyBindingTypeTolerate(
4958 theClassKeyBindNodeArray[node].type,
4959 type,
|
4960 thilo.boehm 1.2.2.24 keyvalue,
|
4961 thilo.boehm 1.2.2.38 theInstKeyBindValueArray[node]);
|
4962 thilo.boehm 1.2.2.41
|
4963 thilo.boehm 1.2.2.38 }
4964
4965 /**
|
4966 thilo.boehm 1.2.2.41 * Set a SCMO user defined key binding using the class CIM type tolerating
4967 * CIM key binding types converted to CIM types by fuction
4968 * _CIMTypeFromKeyBindingType().
4969 *
|
4970 thilo.boehm 1.2.2.38 * @parm classType The type of the key binding in the class definition
4971 * @parm setType The type of the key binding to be set.
4972 * @param keyValue A pointer to the key binding to be set.
4973 * @param kbValue Out parameter, the SCMO keybinding to be set.
|
4974 thilo.boehm 1.2.2.41 *
|
4975 thilo.boehm 1.2.2.38 **/
4976 SCMO_RC SCMOInstance::_setKeyBindingTypeTolerate(
4977 CIMType classType,
4978 CIMType setType,
4979 const SCMBUnion* keyValue,
4980 SCMBKeyBindingValue& kbValue)
4981 {
4982 if (setType == CIMTYPE_UINT64 )
4983 {
4984 switch (classType)
4985 {
4986
4987 case CIMTYPE_UINT8:
4988 {
4989 kbValue.isSet=true;
4990 kbValue.data.simple.hasValue=true;
4991 kbValue.data.simple.val.u8=Uint8(keyValue->simple.val.u64);
4992 return SCMO_OK;
4993 break;
4994 }
4995 case CIMTYPE_UINT16:
4996 thilo.boehm 1.2.2.38 {
4997 kbValue.isSet=true;
4998 kbValue.data.simple.hasValue=true;
4999 kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64);
5000 return SCMO_OK;
5001 break;
5002 }
5003 case CIMTYPE_UINT32:
5004 {
5005 kbValue.isSet=true;
5006 kbValue.data.simple.hasValue=true;
5007 kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64);
5008 return SCMO_OK;
5009 break;
5010 }
5011 case CIMTYPE_UINT64:
5012 {
5013 kbValue.isSet=true;
5014 kbValue.data.simple.hasValue=true;
5015 kbValue.data.simple.val.u64=keyValue->simple.val.u64;
5016 return SCMO_OK;
5017 thilo.boehm 1.2.2.38 break;
5018 }
5019 default:
5020 {
5021 return SCMO_TYPE_MISSMATCH;
5022 break;
5023 }
5024 }
5025 }
5026
5027 if (setType == CIMTYPE_SINT64)
5028 {
5029 switch (classType)
5030 {
5031
5032 case CIMTYPE_SINT8:
5033 {
5034 kbValue.isSet=true;
5035 kbValue.data.simple.hasValue=true;
5036 kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64);
5037 return SCMO_OK;
5038 thilo.boehm 1.2.2.38 break;
5039 }
5040 case CIMTYPE_SINT16:
5041 {
5042 kbValue.isSet=true;
5043 kbValue.data.simple.hasValue=true;
5044 kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64);
5045 return SCMO_OK;
5046 break;
5047 }
5048 case CIMTYPE_SINT32:
5049 {
5050 kbValue.isSet=true;
5051 kbValue.data.simple.hasValue=true;
5052 kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64);
5053 return SCMO_OK;
5054 break;
5055 }
5056 case CIMTYPE_SINT64:
5057 {
5058 kbValue.isSet=true;
5059 thilo.boehm 1.2.2.38 kbValue.data.simple.hasValue=true;
5060 kbValue.data.simple.val.s64=keyValue->simple.val.s64;
5061 return SCMO_OK;
5062 break;
5063 }
5064 default:
5065 {
5066 return SCMO_TYPE_MISSMATCH;
5067 break;
5068 }
5069 }
5070 }
5071
5072 if (setType == CIMTYPE_REAL64)
5073 {
5074 switch (classType)
5075 {
5076 case CIMTYPE_REAL32:
5077 {
5078 kbValue.isSet=true;
5079 kbValue.data.simple.hasValue=true;
5080 thilo.boehm 1.2.2.38 kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64);
5081 return SCMO_OK;
5082 break;
5083 }
5084 case CIMTYPE_REAL64:
5085 {
5086 kbValue.isSet=true;
5087 kbValue.data.simple.hasValue=true;
5088 kbValue.data.simple.val.r64=keyValue->simple.val.r64;
5089 return SCMO_OK;
5090 break;
5091 }
5092 default:
5093 {
5094 return SCMO_TYPE_MISSMATCH;
5095 break;
5096 }
5097 }
5098 }
5099 else
5100 {
|
5101 thilo.boehm 1.2.2.63 // If type defined in the class and the provided type does not match
5102 // at this point, no convertaion can be done and the provided type
5103 // is handlend as type missmatch.
5104 if (classType != setType)
5105 {
5106 return SCMO_TYPE_MISSMATCH;
5107 }
5108
|
5109 thilo.boehm 1.2.2.38 switch (classType)
5110 {
|
5111 thilo.boehm 1.2.2.63 case CIMTYPE_DATETIME:
|
5112 thilo.boehm 1.2.2.38 case CIMTYPE_BOOLEAN:
5113 case CIMTYPE_UINT64:
5114 case CIMTYPE_SINT64:
5115 case CIMTYPE_REAL64:
5116 case CIMTYPE_STRING:
5117 case CIMTYPE_REFERENCE:
5118 {
5119 kbValue.isSet=true;
5120 _setSCMBUnion(keyValue,classType,false, 0,kbValue.data);
5121 return SCMO_OK;
5122 break;
5123 }
5124 default:
5125 {
5126 return SCMO_TYPE_MISSMATCH;
5127 break;
5128 }
5129 }
5130 }
5131
5132 return SCMO_TYPE_MISSMATCH;
|
5133 r.kieninger 1.2.2.22
5134 }
5135
|
5136 thilo.boehm 1.2.2.61 static int _indexComp(const void* left, const void* right)
5137 {
5138 return((*(Uint32 *)left)-(*(Uint32 *)right));
5139 }
|
5140 thilo.boehm 1.2.2.17
|
5141 thilo.boehm 1.2 void SCMOInstance::setPropertyFilter(const char **propertyList)
|
5142 thilo.boehm 1.1 {
|
5143 thilo.boehm 1.2 SCMO_RC rc;
5144 Uint32 node,i = 0;
5145
|
5146 thilo.boehm 1.2.2.70 _copyOnWrite();
5147
|
5148 thilo.boehm 1.2.2.5 if (inst.hdr->propertyFilter.start == 0)
5149 {
5150 // Allocate the SCMBPropertyFilter
5151 _getFreeSpace(
5152 inst.hdr->propertyFilter,
5153 sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1),
|
5154 thilo.boehm 1.2.2.60 &inst.mem);
|
5155 thilo.boehm 1.2.2.5
5156 // Allocate the SCMBPropertyFilterIndexMap
5157 _getFreeSpace(
5158 inst.hdr->propertyFilterIndexMap,
5159 sizeof(Uint32)*inst.hdr->numberProperties,
|
5160 thilo.boehm 1.2.2.60 &inst.mem);
|
5161 thilo.boehm 1.2.2.5 }
|
5162 thilo.boehm 1.2 // Get absolut pointer to property filter index map of the instance
5163 Uint32* propertyFilterIndexMap =
5164 (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
|
5165 thilo.boehm 1.1
|
5166 thilo.boehm 1.2 // All properties are accepted
|
5167 thilo.boehm 1.2.2.32 if (propertyList == 0)
|
5168 thilo.boehm 1.1 {
|
5169 thilo.boehm 1.2 // Clear filtering:
5170 // Switch filtering off.
5171 inst.hdr->flags.isFiltered = false;
5172
5173 // Clear filter index map
5174 memset(
5175 propertyFilterIndexMap,
5176 0,
|
5177 thilo.boehm 1.2.2.15 sizeof(Uint32)*inst.hdr->numberProperties);
|
5178 thilo.boehm 1.1
|
5179 thilo.boehm 1.2 //reset number filter properties to all
5180 inst.hdr->filterProperties = inst.hdr->numberProperties;
|
5181 thilo.boehm 1.1
|
5182 thilo.boehm 1.2 return;
|
5183 thilo.boehm 1.1 }
|
5184 thilo.boehm 1.2
5185 // Switch filtering on.
5186 inst.hdr->flags.isFiltered = true;
5187
5188 // intit the filter with the key properties
5189 inst.hdr->filterProperties=_initPropFilterWithKeys();
5190
5191 // add the properties to the filter.
|
5192 thilo.boehm 1.2.2.32 while (propertyList[i] != 0)
|
5193 thilo.boehm 1.1 {
|
5194 thilo.boehm 1.2 // the hash index of the property if the property name is found
5195 rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]);
5196
|
5197 thilo.boehm 1.2.2.15 // if property is already in the filter
5198 // ( eg. key properties ) do not add them !
5199 if (rc == SCMO_OK && !_isPropertyInFilter(node))
|
5200 thilo.boehm 1.1 {
|
5201 thilo.boehm 1.2 // The property name was found. Otherwise ignore this property name.
5202 // insert the hash index into the filter index map
5203 propertyFilterIndexMap[inst.hdr->filterProperties]=node;
5204 // increase number of properties in filter.
5205 inst.hdr->filterProperties++;
5206 // set bit in the property filter
5207 _setPropertyInPropertyFilter(node);
|
5208 thilo.boehm 1.1 }
|
5209 thilo.boehm 1.2 // Proceed with the next property name.
5210 i++;
|
5211 thilo.boehm 1.1 }
5212
|
5213 thilo.boehm 1.2.2.61 // sort the filter index to be in order as properties stored in the class.
5214 qsort(
5215 propertyFilterIndexMap,
5216 inst.hdr->filterProperties,
5217 sizeof(Uint32),
5218 _indexComp);
|
5219 thilo.boehm 1.1 }
5220
|
5221 thilo.boehm 1.2 Uint32 SCMOInstance::_initPropFilterWithKeys()
5222 {
5223
5224 // Get absolut pointer to the key property mask of the class.
5225 Uint64 idx = inst.hdr->theClass->cls.hdr->keyPropertyMask.start;
5226 Uint64* keyMask =(Uint64*)&(inst.hdr->theClass->cls.base)[idx];
5227
5228 // Get absolut pointer to property filter mask
5229 Uint64* propertyFilterMask =
5230 (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);
5231
5232 // copy the key mask to the property filter mask
5233 memcpy(
5234 propertyFilterMask,
5235 keyMask,
5236 sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));
5237
5238 // Get absolut pointer to key index list of the class
5239 idx=inst.hdr->theClass->cls.hdr->keyIndexList.start;
5240 Uint32* keyIndex = (Uint32*)&(inst.hdr->theClass->cls.base)[idx];
5241
5242 thilo.boehm 1.2 // Get absolut pointer to property filter index map of the instance
5243 Uint32* propertyFilterIndexMap =
5244 (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
5245
5246 Uint32 noKeys = inst.hdr->theClass->cls.hdr->keyBindingSet.number;
5247 memcpy(propertyFilterIndexMap,keyIndex,sizeof(Uint32)*noKeys);
5248
5249 // return the number of properties already in the filter index map
5250 return noKeys;
5251
5252 }
5253
5254 void SCMOInstance::_clearPropertyFilter()
5255 {
5256 Uint64 *propertyFilter;
5257
5258 // Calculate the real pointer to the Uint64 array
|
5259 thilo.boehm 1.2.2.38 propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);
|
5260 thilo.boehm 1.2
5261 // the number of Uint64 in the key mask is :
5262 // Decrease the number of properties by 1
5263 // since the array is starting at index 0!
5264 // Divide with the number of bits in a Uint64.
5265 // e.g. number of Properties = 68
5266 // (68 - 1) / 64 = 1 --> The mask consists of 2 Uint64
5267
5268 memset(propertyFilter,
5269 0,
5270 sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));
5271
5272 }
5273 void SCMOInstance::_setPropertyInPropertyFilter(Uint32 i)
|
5274 thilo.boehm 1.1 {
|
5275 thilo.boehm 1.2 Uint64 *propertyFilter;
5276
5277 // In which Uint64 of key mask is the bit for property i ?
5278 // Divide with the number of bits in a Uint64.
5279 // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].
5280 Uint32 idx = i/64 ;
5281
5282 // Create a filter to set the bit.
5283 // Modulo division with 64. Shift left a bit by the remainder.
5284 Uint64 filter = ( (Uint64)1 << (i%64));
5285
5286 // Calculate the real pointer to the Uint64 array
5287 propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);
|
5288 thilo.boehm 1.1
|
5289 thilo.boehm 1.2 propertyFilter[idx] = propertyFilter[idx] | filter ;
|
5290 thilo.boehm 1.1 }
|
5291 thilo.boehm 1.2
5292 Boolean SCMOInstance::_isPropertyInFilter(Uint32 i) const
|
5293 thilo.boehm 1.1 {
|
5294 thilo.boehm 1.2 Uint64 *propertyFilter;
|
5295 thilo.boehm 1.1
|
5296 thilo.boehm 1.2 // In which Uint64 of key mask is the bit for property i ?
5297 // Divide with the number of bits in a Uint64.
5298 // e.g. number of Properties = 68
5299 // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].
5300 Uint32 idx = i/64 ;
|
5301 thilo.boehm 1.1
|
5302 thilo.boehm 1.2 // Create a filter to check if the bit is set:
5303 // Modulo division with 64. Shift left a bit by the remainder.
5304 Uint64 filter = ( (Uint64)1 << (i%64));
|
5305 thilo.boehm 1.1
|
5306 thilo.boehm 1.2 // Calculate the real pointer to the Uint64 array
|
5307 thilo.boehm 1.2.2.38 propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);
|
5308 thilo.boehm 1.1
|
5309 thilo.boehm 1.2 // If the bit is set the property is NOT filtered.
5310 // So the result has to be negated!
5311 return propertyFilter[idx] & filter ;
|
5312 thilo.boehm 1.1
5313 }
5314
|
5315 thilo.boehm 1.2 /******************************************************************************
5316 * SCMODump Print and Dump functions
5317 *****************************************************************************/
|
5318 thilo.boehm 1.2.2.6 SCMODump::SCMODump()
5319 {
5320 _out = stdout;
5321 _fileOpen = false;
5322
5323 #ifdef PEGASUS_OS_ZOS
5324 setEBCDICEncoding(fileno(_out));
5325 #endif
5326
5327 }
5328
|
5329 thilo.boehm 1.2.2.38 SCMODump::SCMODump(const char* filename)
|
5330 thilo.boehm 1.2.2.6 {
5331 openFile(filename);
5332 }
5333
|
5334 thilo.boehm 1.2.2.38 void SCMODump::openFile(const char* filename)
|
5335 thilo.boehm 1.2.2.6 {
5336 const char* pegasusHomeDir = getenv("PEGASUS_HOME");
5337
|
5338 thilo.boehm 1.2.2.32 if (pegasusHomeDir == 0)
|
5339 thilo.boehm 1.2.2.6 {
5340 pegasusHomeDir = ".";
5341 }
5342
5343 _filename = pegasusHomeDir;
5344 _filename.append("/");
5345 _filename.append(filename);
5346
|
5347 thilo.boehm 1.2.2.7 _out = fopen((const char*)_filename.getCString(),"w+");
|
5348 thilo.boehm 1.2.2.6
5349 _fileOpen = true;
5350
5351 #ifdef PEGASUS_OS_ZOS
5352 setEBCDICEncoding(fileno(_out));
5353 #endif
5354
5355 }
5356
5357 void SCMODump::deleteFile()
5358 {
5359 if(_fileOpen)
5360 {
5361 closeFile();
5362 }
5363
5364 System::removeFile((const char*)_filename.getCString());
5365
5366 }
5367 void SCMODump::closeFile()
5368 {
5369 thilo.boehm 1.2.2.6 if (_fileOpen)
5370 {
5371 fclose(_out);
5372 _fileOpen=false;
5373 _out = stdout;
5374 }
5375 }
5376
5377 SCMODump::~SCMODump()
5378 {
5379 if (_fileOpen)
5380 {
5381 fclose(_out);
5382 _fileOpen=false;
5383 }
5384 }
5385
5386 Boolean SCMODump::compareFile(String master)
5387 {
5388
5389 if (!_fileOpen)
5390 thilo.boehm 1.2.2.6 {
5391 return false;
5392 }
5393
5394 closeFile();
5395
5396 return (FileSystem::compareFiles(_filename, master));
5397 }
5398
|
5399 thilo.boehm 1.2.2.4 void SCMODump::dumpSCMOInstance(SCMOInstance& testInst) const
5400 {
5401 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5402 char* instbase = testInst.inst.base;
5403
|
5404 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nDump of SCMOInstance\n");
|
5405 thilo.boehm 1.2.2.4 // The magic number for SCMO class
|
5406 thilo.boehm 1.2.2.6 fprintf(_out,"\nheader.magic=%08X",insthdr->header.magic);
|
5407 thilo.boehm 1.2.2.4 // Total size of the instance memory block( # bytes )
|
5408 thilo.boehm 1.2.2.6 fprintf(_out,"\nheader.totalSize=%llu",insthdr->header.totalSize);
|
5409 thilo.boehm 1.2.2.7 // The reference counter for this c++ class
|
5410 thilo.boehm 1.2.2.6 fprintf(_out,"\nrefCount=%i",insthdr->refCount.get());
5411 fprintf(_out,"\ntheClass: %p",insthdr->theClass);
5412 fprintf(_out,"\n\nThe Flags:");
5413 fprintf(_out,"\n includeQualifiers: %s",
|
5414 thilo.boehm 1.2.2.4 (insthdr->flags.includeQualifiers ? "True" : "False"));
|
5415 thilo.boehm 1.2.2.6 fprintf(_out,"\n includeClassOrigin: %s",
|
5416 thilo.boehm 1.2.2.4 (insthdr->flags.includeClassOrigin ? "True" : "False"));
|
5417 thilo.boehm 1.2.2.6 fprintf(_out,"\n isFiltered: %s",
|
5418 thilo.boehm 1.2.2.4 (insthdr->flags.isFiltered ? "True" : "False"));
|
5419 thilo.boehm 1.2.2.37 fprintf(_out,"\n isClassOnly: %s",
5420 (insthdr->flags.isClassOnly ? "True" : "False"));
5421 fprintf(_out,"\n isCompromised: %s",
5422 (insthdr->flags.isCompromised ? "True" : "False"));
5423 fprintf(_out,"\n\ninstNameSpace: \'%s\'",
5424 NULLSTR(_getCharString(insthdr->instNameSpace,instbase)));
5425 fprintf(_out,"\n\ninstClassName: \'%s\'",
5426 NULLSTR(_getCharString(insthdr->instClassName,instbase)));
|
5427 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nhostName: \'%s\'",
|
5428 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(insthdr->hostName,instbase)));
|
5429 thilo.boehm 1.2.2.4
5430 dumpSCMOInstanceKeyBindings(testInst);
5431
5432 dumpSCMOInstancePropertyFilter(testInst);
5433
5434 dumpInstanceProperties(testInst);
|
5435 thilo.boehm 1.2.2.6 fprintf(_out,"\n\n");
|
5436 thilo.boehm 1.2.2.4
5437 }
5438
|
5439 thilo.boehm 1.2.2.13 void SCMODump::dumpSCMOInstancePropertyFilter(SCMOInstance& testInst) const
|
5440 thilo.boehm 1.2.2.4 {
5441 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5442 char* instbase = testInst.inst.base;
5443
5444 if (!insthdr->flags.isFiltered)
5445 {
|
5446 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nNo propterty filter!\n\n");
|
5447 thilo.boehm 1.2.2.4 return;
5448 }
5449
|
5450 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nInstance Property Filter :");
5451 fprintf(_out,"\n==========================");
5452 fprintf(_out,"\n\nNumber of properties in the filter : %u\n"
|
5453 thilo.boehm 1.2.2.4 ,insthdr->filterProperties);
5454
5455 dumpPropertyFilter(testInst);
5456
5457 dumpPropertyFilterIndexMap(testInst);
5458
5459 }
5460
|
5461 thilo.boehm 1.2.2.40 void SCMODump::dumpInstanceProperties(
5462 SCMOInstance& testInst,
5463 Boolean verbose) const
|
5464 thilo.boehm 1.2.2.4 {
5465 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5466 char* instbase = testInst.inst.base;
5467
|
5468 thilo.boehm 1.2.2.13 SCMBValue* val =
|
5469 thilo.boehm 1.2.2.4 (SCMBValue*)_resolveDataPtr(insthdr->propertyArray,instbase);
5470
|
5471 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nInstance Properties :");
5472 fprintf(_out,"\n=====================");
5473 fprintf(_out,"\n\nNumber of properties in instance : %u",
|
5474 thilo.boehm 1.2.2.4 insthdr->numberProperties);
5475
|
5476 thilo.boehm 1.2.2.13 for (Uint32 i = 0, k = insthdr->numberProperties; i < k; i++)
|
5477 thilo.boehm 1.2.2.4 {
|
5478 thilo.boehm 1.2.2.10 fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,
5479 NULLSTR(insthdr->theClass->_getPropertyNameAtNode(i)));
|
5480 thilo.boehm 1.2.2.4 if(insthdr->flags.isFiltered && !testInst._isPropertyInFilter(i))
5481 {
|
5482 thilo.boehm 1.2.2.6 fprintf(_out,"\nProperty is filtered out!");
|
5483 thilo.boehm 1.2.2.4 }
5484 else
5485 {
|
5486 thilo.boehm 1.2.2.40 printSCMOValue(val[i],instbase,verbose);
|
5487 thilo.boehm 1.2.2.4 }
5488 }
5489
5490 }
5491
5492 void SCMODump::dumpPropertyFilterIndexMap(SCMOInstance& testInst) const
5493 {
5494
5495 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5496 char* instbase = testInst.inst.base;
5497
5498 if (!insthdr->flags.isFiltered)
5499 {
|
5500 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nNo propterty filter!\n\n");
|
5501 thilo.boehm 1.2.2.4 return;
5502 }
5503
|
5504 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nProperty Filter Index Max:");
5505 fprintf(_out,"\n==========================\n");
|
5506 thilo.boehm 1.2.2.4
5507 // Get absolut pointer to key index list of the class
|
5508 thilo.boehm 1.2.2.13 Uint32* keyIndex =
|
5509 thilo.boehm 1.2.2.4 (Uint32*)&(instbase)[insthdr->propertyFilterIndexMap.start];
|
5510 thilo.boehm 1.2.2.13
5511 Uint32 line,j,i,k = insthdr->filterProperties;
5512
5513 for (j = 0; j < k; j = j + line)
|
5514 thilo.boehm 1.2.2.4 {
5515 if ((insthdr->filterProperties-j)/16)
5516 {
5517 line = 16 ;
5518 }
5519 else
5520 {
5521 line = insthdr->filterProperties%16;
5522 }
5523
5524
|
5525 thilo.boehm 1.2.2.6 fprintf(_out,"Index :");
|
5526 thilo.boehm 1.2.2.4 for (i = 0; i < line; i++)
5527 {
|
5528 thilo.boehm 1.2.2.6 fprintf(_out," %3u",j+i);
|
5529 thilo.boehm 1.2.2.4 }
5530
|
5531 thilo.boehm 1.2.2.6 fprintf(_out,"\nNode :");
|
5532 thilo.boehm 1.2.2.4 for (i = 0; i < line; i++)
5533 {
|
5534 thilo.boehm 1.2.2.6 fprintf(_out," %3u",keyIndex[j+i]);
|
5535 thilo.boehm 1.2.2.4 }
5536
|
5537 thilo.boehm 1.2.2.6 fprintf(_out,"\n\n");
|
5538 thilo.boehm 1.2.2.4
5539 }
5540
5541 }
5542
5543 void SCMODump::dumpPropertyFilter(SCMOInstance& testInst) const
5544 {
5545
5546 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5547 char* instbase = testInst.inst.base;
5548
5549 if (!insthdr->flags.isFiltered)
5550 {
|
5551 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nNo propterty filter!");
|
5552 thilo.boehm 1.2.2.4 return;
5553 }
5554
|
5555 thilo.boehm 1.2.2.13 Uint64 *thePropertyFilter =
|
5556 thilo.boehm 1.2.2.4 (Uint64*)&(instbase[insthdr->propertyFilter.start]);
|
5557 thilo.boehm 1.2.2.5 Uint32 end, noProperties = insthdr->numberProperties;
|
5558 thilo.boehm 1.2.2.4 Uint32 noMasks = (noProperties-1)/64;
5559 Uint64 printMask = 1;
5560
5561 for (Uint32 i = 0; i <= noMasks; i++ )
5562 {
5563 printMask = 1;
5564 if (i < noMasks)
5565 {
5566 end = 64;
5567 }
5568 else
5569 {
5570 end = noProperties%64;
5571 }
5572
|
5573 thilo.boehm 1.2.2.6 fprintf(_out,"\npropertyFilter[%02u]= ",i);
|
5574 thilo.boehm 1.2.2.4
5575 for (Uint32 j = 0; j < end; j++)
5576 {
5577 if (j > 0 && !(j%8))
5578 {
|
5579 thilo.boehm 1.2.2.6 fprintf(_out," ");
|
5580 thilo.boehm 1.2.2.4 }
5581
5582 if (thePropertyFilter[i] & printMask)
5583 {
|
5584 thilo.boehm 1.2.2.6 fprintf(_out,"1");
|
5585 thilo.boehm 1.2.2.4 }
5586 else
5587 {
|
5588 thilo.boehm 1.2.2.6 fprintf(_out,"0");
|
5589 thilo.boehm 1.2.2.4 }
5590
5591 printMask = printMask << 1;
5592 }
|
5593 thilo.boehm 1.2.2.6 fprintf(_out,"\n");
|
5594 thilo.boehm 1.2.2.4 }
5595 }
5596
|
5597 thilo.boehm 1.2.2.40 void SCMODump::dumpSCMOInstanceKeyBindings(
5598 SCMOInstance& testInst,
5599 Boolean verbose) const
|
5600 thilo.boehm 1.2.2.4 {
5601 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5602 char* instbase = testInst.inst.base;
5603
|
5604 thilo.boehm 1.2.2.24 // create a pointer to keybinding node array of the class.
5605 Uint64 idx = insthdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
5606 SCMBKeyBindingNode* theClassKeyBindNodeArray =
|
5607 thilo.boehm 1.2.2.29 (SCMBKeyBindingNode*)&((insthdr->theClass->cls.base)[idx]);
|
5608 thilo.boehm 1.2.2.24
5609 SCMBKeyBindingValue* ptr =
5610 (SCMBKeyBindingValue*)
|
5611 thilo.boehm 1.2.2.16 _resolveDataPtr(insthdr->keyBindingArray,instbase);
|
5612 thilo.boehm 1.2.2.4
|
5613 thilo.boehm 1.2.2.7 fprintf(_out,"\n\nInstance Key Bindings :");
|
5614 thilo.boehm 1.2.2.6 fprintf(_out,"\n=======================");
|
5615 thilo.boehm 1.2.2.39 fprintf(_out,"\n\nNumber of Key Bindings defined in the Class: %u",
5616 insthdr->numberKeyBindings);
|
5617 thilo.boehm 1.2.2.4
|
5618 thilo.boehm 1.2.2.13 for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++)
|
5619 thilo.boehm 1.2.2.4 {
|
5620 thilo.boehm 1.2.2.16 if (ptr[i].isSet)
5621 {
|
5622 thilo.boehm 1.2.2.40 fprintf(_out,"\n\nName: '%s'\nType: '%s'",
|
5623 thilo.boehm 1.2.2.39 NULLSTR(_getCharString(
5624 theClassKeyBindNodeArray[i].name,
5625 insthdr->theClass->cls.base)),
|
5626 thilo.boehm 1.2.2.40 cimTypeToString(theClassKeyBindNodeArray[i].type));
5627 printUnionValue(
5628 theClassKeyBindNodeArray[i].type,
5629 ptr[i].data,
5630 instbase,
5631 verbose);
|
5632 thilo.boehm 1.2.2.16 }
5633 else
5634 {
|
5635 thilo.boehm 1.2.2.40 fprintf(_out,"\n\nName: '%s': Not Set",
|
5636 thilo.boehm 1.2.2.39 NULLSTR(_getCharString(
5637 theClassKeyBindNodeArray[i].name,
5638 insthdr->theClass->cls.base)));
|
5639 thilo.boehm 1.2.2.16 }
|
5640 thilo.boehm 1.2.2.4 }
|
5641 thilo.boehm 1.2.2.39
5642 fprintf(_out,"\n\nNumber of User Defined Key Bindings: %u",
5643 insthdr->numberUserKeyBindings);
5644
5645
5646 SCMBUserKeyBindingElement* theUserDefKBElement;
5647
5648 Uint64 start = insthdr->userKeyBindingElement.start;
5649 while (start != 0)
5650 {
5651 theUserDefKBElement = (SCMBUserKeyBindingElement*)&(instbase[start]);
5652
5653 if (theUserDefKBElement->value.isSet)
5654 {
|
5655 thilo.boehm 1.2.2.40 fprintf(_out,"\n\nName: '%s'\nType: '%s'",
|
5656 thilo.boehm 1.2.2.39 NULLSTR(_getCharString(theUserDefKBElement->name,instbase)),
|
5657 thilo.boehm 1.2.2.40 cimTypeToString(theUserDefKBElement->type));
5658 printUnionValue(
5659 theUserDefKBElement->type,
5660 theUserDefKBElement->value.data,
5661 instbase,
5662 verbose);
|
5663 thilo.boehm 1.2.2.39 }
5664 else
5665 {
5666 fprintf(_out,"\n\n %s : Not Set",
5667 NULLSTR(_getCharString(theUserDefKBElement->name,instbase)));
5668
5669 }
5670 start = theUserDefKBElement->nextElement.start;
5671 } // for all user def. key bindings.
5672
5673 fprintf(_out,"\n\n");
5674
|
5675 thilo.boehm 1.2.2.4 }
|
5676 thilo.boehm 1.2
5677 void SCMODump::dumpSCMOClass(SCMOClass& testCls) const
5678 {
5679 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5680 thilo.boehm 1.2.2.2 char* clsbase = testCls.cls.base;
|
5681 thilo.boehm 1.1
|
5682 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nDump of SCMOClass\n");
|
5683 thilo.boehm 1.2 // The magic number for SCMO class
|
5684 thilo.boehm 1.2.2.6 fprintf(_out,"\nheader.magic=%08X",clshdr->header.magic);
|
5685 thilo.boehm 1.2 // Total size of the instance memory block( # bytes )
|
5686 thilo.boehm 1.2.2.6 fprintf(_out,"\nheader.totalSize=%llu",clshdr->header.totalSize);
|
5687 thilo.boehm 1.2.2.7 // The reference counter for this c++ class
|
5688 thilo.boehm 1.2.2.6 fprintf(_out,"\nrefCount=%i",clshdr->refCount.get());
|
5689 thilo.boehm 1.1
|
5690 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nsuperClassName: \'%s\'",
|
5691 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(clshdr->superClassName,clsbase)));
|
5692 thilo.boehm 1.2.2.6 fprintf(_out,"\nnameSpace: \'%s\'",
|
5693 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(clshdr->nameSpace,clsbase)));
|
5694 thilo.boehm 1.2.2.6 fprintf(_out,"\nclassName: \'%s\'",
|
5695 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(clshdr->className,clsbase)));
|
5696 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nTheClass qualfiers:");
|
5697 thilo.boehm 1.2 _dumpQualifierArray(
5698 clshdr->qualifierArray.start,
5699 clshdr->numberOfQualifiers,
5700 clsbase);
|
5701 thilo.boehm 1.2.2.6 fprintf(_out,"\n");
|
5702 thilo.boehm 1.2 dumpKeyPropertyMask(testCls);
|
5703 thilo.boehm 1.2.2.6 fprintf(_out,"\n");
|
5704 thilo.boehm 1.2 dumpKeyIndexList(testCls);
|
5705 thilo.boehm 1.2.2.6 fprintf(_out,"\n");
|
5706 thilo.boehm 1.2 dumpClassProperties(testCls);
|
5707 thilo.boehm 1.2.2.6 fprintf(_out,"\n");
|
5708 thilo.boehm 1.2 dumpKeyBindingSet(testCls);
|
5709 thilo.boehm 1.2.2.6 fprintf(_out,"\n");
|
5710 thilo.boehm 1.2 /*
5711 */
|
5712 thilo.boehm 1.2.2.6 fprintf(_out,"\n");
|
5713 thilo.boehm 1.1
|
5714 thilo.boehm 1.2 }
|
5715 thilo.boehm 1.1
|
5716 thilo.boehm 1.2.2.1 void SCMODump::dumpSCMOClassQualifiers(SCMOClass& testCls) const
5717 {
5718 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5719 thilo.boehm 1.2.2.2 char* clsbase = testCls.cls.base;
|
5720 thilo.boehm 1.2.2.1
|
5721 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nTheClass qualfiers:");
|
5722 thilo.boehm 1.2.2.1 _dumpQualifierArray(
5723 clshdr->qualifierArray.start,
5724 clshdr->numberOfQualifiers,
5725 clsbase);
|
5726 thilo.boehm 1.2.2.6 fprintf(_out,"\n\n\n");
|
5727 thilo.boehm 1.2.2.1
5728 }
5729
|
5730 thilo.boehm 1.2 void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const
|
5731 thilo.boehm 1.1 {
|
5732 thilo.boehm 1.2.2.2 char* tmp;
|
5733 thilo.boehm 1.1
|
5734 thilo.boehm 1.2 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5735 thilo.boehm 1.2.2.2 char* clsbase = testCls.cls.base;
|
5736 thilo.boehm 1.1
|
5737 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nHex dump of a SCMBClass:");
5738 fprintf(_out,"\n========================");
|
5739 thilo.boehm 1.2.2.7 fprintf(_out,"\n\n Size of SCMBClass: %llu\n\n",clshdr->header.totalSize);
|
5740 thilo.boehm 1.1
|
5741 thilo.boehm 1.2 _hexDump(clsbase,clshdr->header.totalSize);
|
5742 thilo.boehm 1.1
5743 }
|
5744 thilo.boehm 1.2 void SCMODump::dumpKeyIndexList(SCMOClass& testCls) const
5745 {
5746 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5747 thilo.boehm 1.2.2.2 char* clsbase = testCls.cls.base;
|
5748 thilo.boehm 1.1
|
5749 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nKey Index List:");
5750 fprintf(_out,"\n===============\n");
|
5751 thilo.boehm 1.1
|
5752 thilo.boehm 1.2 // Get absolut pointer to key index list of the class
5753 Uint32* keyIndex = (Uint32*)&(clsbase)[clshdr->keyIndexList.start];
|
5754 thilo.boehm 1.2.2.13 Uint32 line,j,i,k = clshdr->propertySet.number;
5755 for (j = 0; j < k; j = j + line)
|
5756 thilo.boehm 1.1 {
|
5757 thilo.boehm 1.2 if ((clshdr->propertySet.number-j)/16)
|
5758 thilo.boehm 1.1 {
|
5759 thilo.boehm 1.2 line = 16 ;
|
5760 thilo.boehm 1.1 }
|
5761 thilo.boehm 1.2 else
|
5762 thilo.boehm 1.1 {
|
5763 thilo.boehm 1.2 line = clshdr->propertySet.number%16;
|
5764 thilo.boehm 1.1 }
5765
|
5766 thilo.boehm 1.2
|
5767 thilo.boehm 1.2.2.6 fprintf(_out,"Index :");
|
5768 thilo.boehm 1.2 for (i = 0; i < line; i++)
|
5769 thilo.boehm 1.1 {
|
5770 thilo.boehm 1.2.2.6 fprintf(_out," %3u",j+i);
|
5771 thilo.boehm 1.1 }
5772
|
5773 thilo.boehm 1.2.2.6 fprintf(_out,"\nNode :");
|
5774 thilo.boehm 1.2 for (i = 0; i < line; i++)
|
5775 thilo.boehm 1.1 {
|
5776 thilo.boehm 1.2.2.6 fprintf(_out," %3u",keyIndex[j+i]);
|
5777 thilo.boehm 1.1 }
5778
|
5779 thilo.boehm 1.2.2.6 fprintf(_out,"\n\n");
|
5780 thilo.boehm 1.2
5781 }
5782
5783 }
5784
5785 void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const
5786 {
5787 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5788 thilo.boehm 1.2.2.2 char* clsbase = testCls.cls.base;
|
5789 thilo.boehm 1.2
|
5790 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nKey Binding Set:");
5791 fprintf(_out,"\n=================\n");
5792 fprintf(_out,"\nNumber of key bindings: %3u",clshdr->keyBindingSet.number);
|
5793 thilo.boehm 1.2 dumpHashTable(
5794 clshdr->keyBindingSet.hashTable,
5795 PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
|
5796 thilo.boehm 1.1
|
5797 thilo.boehm 1.2 dumpClassKeyBindingNodeArray(testCls);
|
5798 thilo.boehm 1.1
|
5799 thilo.boehm 1.2 }
|
5800 thilo.boehm 1.1
|
5801 thilo.boehm 1.2 void SCMODump::dumpClassKeyBindingNodeArray(SCMOClass& testCls) const
5802 {
5803 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5804 thilo.boehm 1.2.2.2 char* clsbase = testCls.cls.base;
|
5805 thilo.boehm 1.1
|
5806 thilo.boehm 1.2 SCMBKeyBindingNode* nodeArray =
5807 (SCMBKeyBindingNode*)
5808 &(clsbase[clshdr->keyBindingSet.nodeArray.start]);
|
5809 thilo.boehm 1.1
|
5810 thilo.boehm 1.2.2.13 for (Uint32 i = 0, k = clshdr->keyBindingSet.number; i < k; i++)
|
5811 thilo.boehm 1.2 {
|
5812 thilo.boehm 1.2.2.6 fprintf(_out,"\n\n===================");
5813 fprintf(_out,"\nKey Binding #%3u",i);
5814 fprintf(_out,"\n===================");
|
5815 thilo.boehm 1.1
|
5816 thilo.boehm 1.2.2.6 fprintf(_out,"\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));
|
5817 thilo.boehm 1.2 if (nodeArray[i].hasNext)
|
5818 thilo.boehm 1.1 {
|
5819 thilo.boehm 1.2.2.6 fprintf(_out,"\nNext Node: %3u",nodeArray[i].nextNode);
|
5820 thilo.boehm 1.1 }
|
5821 thilo.boehm 1.2 else
|
5822 thilo.boehm 1.1 {
|
5823 thilo.boehm 1.2.2.6 fprintf(_out,"\nNext Node: N/A");
|
5824 thilo.boehm 1.1 }
5825
|
5826 thilo.boehm 1.2.2.6 fprintf(_out,"\nKey Property name: %s",
|
5827 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(nodeArray[i].name,clsbase)));
|
5828 thilo.boehm 1.2
|
5829 thilo.boehm 1.2.2.6 fprintf(_out,"\nHash Tag %3u Hash Index %3u",
|
5830 thilo.boehm 1.2 nodeArray[i].nameHashTag,
5831 nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
5832
|
5833 thilo.boehm 1.2.2.24 fprintf(_out,"\nType: %s",cimTypeToString(nodeArray[i].type));
|
5834 thilo.boehm 1.2
5835 }
5836
5837 }
5838
5839 void SCMODump::dumpClassProperties(SCMOClass& testCls) const
5840 {
5841 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5842 thilo.boehm 1.2.2.2 char* clsbase = testCls.cls.base;
|
5843 thilo.boehm 1.2
|
5844 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nClass Properties:");
5845 fprintf(_out,"\n=================\n");
5846 fprintf(_out,"\nNumber of properties: %3u",clshdr->propertySet.number);
|
5847 thilo.boehm 1.2 dumpHashTable(
5848 clshdr->propertySet.hashTable,
5849 PEGASUS_PROPERTY_SCMB_HASHSIZE);
5850 dumpClassPropertyNodeArray(testCls);
5851
5852 }
5853
5854 void SCMODump::dumpClassPropertyNodeArray(SCMOClass& testCls) const
5855 {
5856 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5857 thilo.boehm 1.2.2.2 char* clsbase = testCls.cls.base;
|
5858 thilo.boehm 1.2
5859 SCMBClassPropertyNode* nodeArray =
5860 (SCMBClassPropertyNode*)
5861 &(clsbase[clshdr->propertySet.nodeArray.start]);
5862
|
5863 thilo.boehm 1.2.2.13 for (Uint32 i = 0, k = clshdr->propertySet.number; i < k; i++)
|
5864 thilo.boehm 1.2 {
|
5865 thilo.boehm 1.1
|
5866 thilo.boehm 1.2.2.6 fprintf(_out,"\nClass property #%3u",i);
5867 fprintf(_out,"\n===================");
|
5868 thilo.boehm 1.1
|
5869 thilo.boehm 1.2.2.6 fprintf(_out,"\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));
|
5870 thilo.boehm 1.2 if (nodeArray[i].hasNext)
5871 {
|
5872 thilo.boehm 1.2.2.6 fprintf(_out,"\nNext Node: %3u",nodeArray[i].nextNode);
|
5873 thilo.boehm 1.1 }
|
5874 thilo.boehm 1.2 else
|
5875 thilo.boehm 1.1 {
|
5876 thilo.boehm 1.2.2.6 fprintf(_out,"\nNext Node: N/A");
|
5877 thilo.boehm 1.1 }
5878
|
5879 thilo.boehm 1.2 _dumpClassProperty(nodeArray[i].theProperty,clsbase);
5880 }
5881 }
5882
5883 void SCMODump::_dumpClassProperty(
5884 const SCMBClassProperty& prop,
|
5885 thilo.boehm 1.2.2.2 char* clsbase) const
|
5886 thilo.boehm 1.2 {
|
5887 thilo.boehm 1.2.2.7 fprintf(_out,"\nProperty name: %s",
|
5888 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(prop.name,clsbase)));
|
5889 thilo.boehm 1.2
|
5890 thilo.boehm 1.2.2.6 fprintf(_out,"\nHash Tag %3u Hash Index %3u",
|
5891 thilo.boehm 1.2 prop.nameHashTag,
5892 prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE);
|
5893 thilo.boehm 1.2.2.6 fprintf(_out,"\nPropagated: %s isKey: %s",
|
5894 thilo.boehm 1.2 (prop.flags.propagated?"TRUE":"FALSE"),
5895 (prop.flags.isKey?"TRUE":"FALSE")
5896 );
|
5897 thilo.boehm 1.1
|
5898 thilo.boehm 1.2.2.6 fprintf(_out,"\nOrigin class name: %s",
|
5899 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(prop.originClassName,clsbase)));
|
5900 thilo.boehm 1.2.2.6 fprintf(_out,"\nReference class name: %s",
|
5901 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(prop.refClassName,clsbase)));
|
5902 thilo.boehm 1.1
|
5903 thilo.boehm 1.2 printSCMOValue(prop.defaultValue,clsbase);
|
5904 thilo.boehm 1.1
|
5905 thilo.boehm 1.2 _dumpQualifierArray(
5906 prop.qualifierArray.start,
5907 prop.numberOfQualifiers,
5908 clsbase);
|
5909 thilo.boehm 1.1
5910 }
5911
|
5912 thilo.boehm 1.2 void SCMODump::dumpHashTable(Uint32* hashTable,Uint32 size) const
|
5913 thilo.boehm 1.1 {
|
5914 thilo.boehm 1.2 Uint32 i,j,line;
|
5915 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nHash table:\n");
|
5916 thilo.boehm 1.1
5917
|
5918 thilo.boehm 1.2 for (j = 0; j < size; j = j + line)
5919 {
5920 if ((size-j)/16)
5921 {
5922 line = 16 ;
5923 }
5924 else
5925 {
5926 line = size%16;
5927 }
|
5928 thilo.boehm 1.1
5929
|
5930 thilo.boehm 1.2.2.6 fprintf(_out,"Index :");
|
5931 thilo.boehm 1.2 for (i = 0; i < line; i++)
|
5932 thilo.boehm 1.1 {
|
5933 thilo.boehm 1.2.2.6 fprintf(_out," %3u",j+i);
|
5934 thilo.boehm 1.1 }
5935
|
5936 thilo.boehm 1.2.2.6 fprintf(_out,"\nHashTable:");
|
5937 thilo.boehm 1.2 for (i = 0; i < line; i++)
|
5938 thilo.boehm 1.1 {
|
5939 thilo.boehm 1.2.2.6 fprintf(_out," %3u",hashTable[j+i]);
|
5940 thilo.boehm 1.1 }
5941
|
5942 thilo.boehm 1.2.2.6 fprintf(_out,"\n\n");
|
5943 thilo.boehm 1.1
5944 }
5945
|
5946 thilo.boehm 1.2
5947 }
5948
5949 void SCMODump::_dumpQualifierArray(
|
5950 thilo.boehm 1.2.2.3 Uint64 start,
|
5951 thilo.boehm 1.2 Uint32 size,
|
5952 thilo.boehm 1.2.2.2 char* clsbase
|
5953 thilo.boehm 1.2 ) const
5954 {
5955
5956 SCMBQualifier *theArray = (SCMBQualifier*)&(clsbase[start]);
5957
5958 for(Uint32 i = 0; i < size; i++)
|
5959 thilo.boehm 1.1 {
|
5960 thilo.boehm 1.2 _dumpQualifier(theArray[i],clsbase);
|
5961 thilo.boehm 1.1 }
|
5962 thilo.boehm 1.2 }
|
5963 thilo.boehm 1.1
|
5964 thilo.boehm 1.2 void SCMODump::_dumpQualifier(
5965 const SCMBQualifier& theQualifier,
|
5966 thilo.boehm 1.2.2.2 char* clsbase
|
5967 thilo.boehm 1.2 ) const
5968 {
5969 if(theQualifier.name == QUALNAME_USERDEFINED)
5970 {
|
5971 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nQualifier user defined name: \'%s\'",
|
5972 thilo.boehm 1.2.2.8 NULLSTR(_getCharString(theQualifier.userDefName,clsbase)));
|
5973 thilo.boehm 1.2 }
5974 else
5975 {
|
5976 thilo.boehm 1.2.2.6 fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'",
|
5977 marek 1.2.2.23 SCMOClass::qualifierNameStrLit(theQualifier.name).str);
|
5978 thilo.boehm 1.2 }
|
5979 thilo.boehm 1.1
|
5980 thilo.boehm 1.2.2.6 fprintf(_out,"\nPropagated : %s",
|
5981 thilo.boehm 1.2 (theQualifier.propagated ? "True" : "False"));
|
5982 thilo.boehm 1.2.2.6 fprintf(_out,"\nFlavor : %s",
|
5983 thilo.boehm 1.2 (const char*)(CIMFlavor(theQualifier.flavor).toString().getCString()));
|
5984 thilo.boehm 1.1
|
5985 thilo.boehm 1.2 printSCMOValue(theQualifier.value,clsbase);
|
5986 thilo.boehm 1.1
|
5987 thilo.boehm 1.2 }
|
5988 thilo.boehm 1.1
|
5989 thilo.boehm 1.2 void SCMODump::printSCMOValue(
5990 const SCMBValue& theValue,
|
5991 thilo.boehm 1.2.2.40 char* base,
5992 Boolean verbose) const
|
5993 thilo.boehm 1.2 {
|
5994 thilo.boehm 1.2.2.6 fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));
|
5995 thilo.boehm 1.2.2.28 fprintf(_out,"\nValue was set: %s",
|
5996 thilo.boehm 1.2 (theValue.flags.isSet ? "True" : "False"));
5997 if (theValue.flags.isNull)
5998 {
|
5999 thilo.boehm 1.2.2.6 fprintf(_out,"\nIt's a NULL value.");
|
6000 thilo.boehm 1.2 return;
6001 }
6002 if (theValue.flags.isArray)
6003 {
|
6004 thilo.boehm 1.2.2.40 fprintf(
6005 _out,
6006 "\nThe value is an Array of size: %u",
6007 theValue.valueArraySize);
6008 printArrayValue(
6009 theValue.valueType,
6010 theValue.valueArraySize,
6011 theValue.value,
6012 base,
6013 verbose);
|
6014 thilo.boehm 1.2 }
6015 else
6016 {
|
6017 thilo.boehm 1.2.2.40 printUnionValue(theValue.valueType,theValue.value,base,verbose);
|
6018 thilo.boehm 1.2 }
|
6019 thilo.boehm 1.1
|
6020 thilo.boehm 1.2 return;
|
6021 thilo.boehm 1.1
6022 }
6023
|
6024 thilo.boehm 1.2.2.10 void SCMODump::dumpKeyPropertyMask(SCMOClass& testCls ) const
6025 {
6026
6027 SCMBClass_Main* clshdr = testCls.cls.hdr;
6028 char* clsbase = testCls.cls.base;
6029
6030 Uint64 *theKeyMask = (Uint64*)&(clsbase[clshdr->keyPropertyMask.start]);
6031 Uint32 end, noProperties = clshdr->propertySet.number;
6032 Uint32 noMasks = (noProperties-1)/64;
6033 Uint64 printMask = 1;
6034
6035 for (Uint32 i = 0; i <= noMasks; i++ )
6036 {
6037 printMask = 1;
6038 if (i < noMasks)
6039 {
6040 end = 64;
6041 }
6042 else
6043 {
6044 end = noProperties%64;
6045 thilo.boehm 1.2.2.10 }
6046
6047 fprintf(_out,"\nkeyPropertyMask[%02u]= ",i);
6048
6049 for (Uint32 j = 0; j < end; j++)
6050 {
6051 if (j > 0 && !(j%8))
6052 {
6053 fprintf(_out," ");
6054 }
6055
6056 if (theKeyMask[i] & printMask)
6057 {
6058 fprintf(_out,"1");
6059 }
6060 else
6061 {
6062 fprintf(_out,"0");
6063 }
6064
6065 printMask = printMask << 1;
6066 thilo.boehm 1.2.2.10 }
6067 fprintf(_out,"\n");
6068 }
6069 }
6070
6071 void SCMODump::_hexDump(char* buffer,int length) const
6072 {
6073
6074 unsigned char printLine[3][80];
6075 int p;
6076 int len;
6077 unsigned char item;
6078
6079 for (int i = 0; i < length;i=i+1)
6080 {
6081 p = i%80;
6082
6083 if ((p == 0 && i > 0) || i == length-1 )
6084 {
6085 for (int y = 0; y < 3; y=y+1)
6086 {
6087 thilo.boehm 1.2.2.10 if (p == 0)
6088 {
6089 len = 80;
6090 } else
6091 {
6092 len = p;
6093 }
6094
6095 for (int x = 0; x < len; x=x+1)
6096 {
6097 if (y == 0)
6098 {
6099 fprintf(_out,"%c",printLine[y][x]);
6100 }
6101 else
6102 {
6103 fprintf(_out,"%1X",printLine[y][x]);
6104 }
6105 }
6106 fprintf(_out,"\n");
6107 }
6108 thilo.boehm 1.2.2.10 fprintf(_out,"\n");
6109 }
6110
6111 item = (unsigned char)buffer[i];
6112
6113 if (item < 32 || item > 125 )
6114 {
6115 printLine[0][p] = '.';
6116 } else
6117 {
6118 printLine[0][p] = item;
6119 }
6120
6121 printLine[1][p] = item/16;
6122 printLine[2][p] = item%16;
6123
6124 }
6125 }
6126
|
6127 thilo.boehm 1.2.2.40 void SCMODump::printArrayValue(
|
6128 thilo.boehm 1.1 CIMType type,
|
6129 thilo.boehm 1.2.2.3 Uint32 size,
|
6130 thilo.boehm 1.2 SCMBUnion u,
|
6131 thilo.boehm 1.2.2.40 char* base,
6132 Boolean verbose) const
|
6133 thilo.boehm 1.1 {
|
6134 thilo.boehm 1.2 Buffer out;
|
6135 thilo.boehm 1.1
|
6136 thilo.boehm 1.2.2.25 SCMBUnion* p;
6137 p = (SCMBUnion*)&(base[u.arrayValue.start]);
6138
|
6139 thilo.boehm 1.1 switch (type)
6140 {
6141 case CIMTYPE_BOOLEAN:
|
6142 thilo.boehm 1.2 {
6143 for (Uint32 i = 0; i < size; i++)
6144 {
|
6145 thilo.boehm 1.2.2.25 out.append('\'');
6146 _toString(out,p[i].simple.val.bin);
6147 out << STRLIT("\'(hasValue=");
6148 out << (p[i].simple.hasValue ?
6149 STRLIT("TRUE)"):
6150 STRLIT("FALSE)"));
6151 out.append(';');
|
6152 thilo.boehm 1.2 }
|
6153 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6154 thilo.boehm 1.2 break;
6155 }
6156
|
6157 thilo.boehm 1.1 case CIMTYPE_UINT8:
|
6158 thilo.boehm 1.2 {
|
6159 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6160 {
6161 out.append('\'');
6162 _toString(out,p[i].simple.val.u8);
6163 out << STRLIT("\'(hasValue=");
6164 out << (p[i].simple.hasValue ?
6165 STRLIT("TRUE)"):
6166 STRLIT("FALSE)"));
6167 out.append(';');
6168 }
|
6169 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6170 thilo.boehm 1.2 break;
6171 }
6172
|
6173 thilo.boehm 1.1 case CIMTYPE_SINT8:
|
6174 thilo.boehm 1.2 {
|
6175 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6176 {
6177 out.append('\'');
6178 _toString(out,p[i].simple.val.s8);
6179 out << STRLIT("\'(hasValue=");
6180 out << (p[i].simple.hasValue ?
6181 STRLIT("TRUE)"):
6182 STRLIT("FALSE)"));
6183 out.append(';');
6184 }
|
6185 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6186 thilo.boehm 1.2 break;
6187 }
6188
|
6189 thilo.boehm 1.1 case CIMTYPE_UINT16:
|
6190 thilo.boehm 1.2 {
|
6191 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6192 {
6193 out.append('\'');
6194 _toString(out,p[i].simple.val.u16);
6195 out << STRLIT("\'(hasValue=");
6196 out << (p[i].simple.hasValue ?
6197 STRLIT("TRUE)"):
6198 STRLIT("FALSE)"));
6199 out.append(';');
6200 }
|
6201 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6202 thilo.boehm 1.2 break;
6203 }
6204
|
6205 thilo.boehm 1.1 case CIMTYPE_SINT16:
|
6206 thilo.boehm 1.2 {
|
6207 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6208 {
6209 out.append('\'');
6210 _toString(out,p[i].simple.val.s16);
6211 out << STRLIT("\'(hasValue=");
6212 out << (p[i].simple.hasValue ?
6213 STRLIT("TRUE)"):
6214 STRLIT("FALSE)"));
6215 out.append(';');
6216 }
|
6217 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6218 thilo.boehm 1.2 break;
6219 }
6220
|
6221 thilo.boehm 1.1 case CIMTYPE_UINT32:
|
6222 thilo.boehm 1.2 {
|
6223 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6224 {
6225 out.append('\'');
6226 _toString(out,p[i].simple.val.u32);
6227 out << STRLIT("\'(hasValue=");
6228 out << (p[i].simple.hasValue ?
6229 STRLIT("TRUE)"):
6230 STRLIT("FALSE)"));
6231 out.append(';');
6232 }
|
6233 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6234 thilo.boehm 1.2 break;
6235 }
6236
|
6237 thilo.boehm 1.1 case CIMTYPE_SINT32:
|
6238 thilo.boehm 1.2 {
|
6239 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6240 {
6241 out.append('\'');
6242 _toString(out,p[i].simple.val.s32);
6243 out << STRLIT("\'(hasValue=");
6244 out << (p[i].simple.hasValue ?
6245 STRLIT("TRUE)"):
6246 STRLIT("FALSE)"));
6247 out.append(';');
6248 }
|
6249 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6250 thilo.boehm 1.2 break;
6251 }
6252
|
6253 thilo.boehm 1.1 case CIMTYPE_UINT64:
|
6254 thilo.boehm 1.2 {
|
6255 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6256 {
6257 out.append('\'');
6258 _toString(out,p[i].simple.val.u64);
6259 out << STRLIT("\'(hasValue=");
6260 out << (p[i].simple.hasValue ?
6261 STRLIT("TRUE)"):
6262 STRLIT("FALSE)"));
6263 out.append(';');
6264 }
|
6265 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6266 thilo.boehm 1.2 break;
6267 }
6268
|
6269 thilo.boehm 1.1 case CIMTYPE_SINT64:
|
6270 thilo.boehm 1.2 {
|
6271 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6272 {
6273 out.append('\'');
6274 _toString(out,p[i].simple.val.s64);
6275 out << STRLIT("\'(hasValue=");
6276 out << (p[i].simple.hasValue ?
6277 STRLIT("TRUE)"):
6278 STRLIT("FALSE)"));
6279 out.append(';');
6280 }
|
6281 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6282 thilo.boehm 1.2 break;
6283 }
6284
|
6285 thilo.boehm 1.1 case CIMTYPE_REAL32:
|
6286 thilo.boehm 1.2 {
|
6287 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6288 {
6289 out.append('\'');
6290 _toString(out,p[i].simple.val.r32);
6291 out << STRLIT("\'(hasValue=");
6292 out << (p[i].simple.hasValue ?
6293 STRLIT("TRUE)"):
6294 STRLIT("FALSE)"));
6295 out.append(';');
6296 }
|
6297 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6298 thilo.boehm 1.2 break;
6299 }
6300
|
6301 thilo.boehm 1.1 case CIMTYPE_REAL64:
|
6302 thilo.boehm 1.2 {
|
6303 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6304 {
6305 out.append('\'');
6306 _toString(out,p[i].simple.val.r64);
6307 out << STRLIT("\'(hasValue=");
6308 out << (p[i].simple.hasValue ?
6309 STRLIT("TRUE)"):
6310 STRLIT("FALSE)"));
6311 out.append(';');
6312 }
|
6313 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6314 thilo.boehm 1.2 break;
6315 }
6316
|
6317 thilo.boehm 1.1 case CIMTYPE_CHAR16:
6318 {
|
6319 thilo.boehm 1.2.2.25 for (Uint32 i = 0; i < size; i++)
6320 {
6321 out.append('\'');
6322 _toString(out,p[i].simple.val.c16);
6323 out << STRLIT("\'(hasValue=");
6324 out << (p[i].simple.hasValue ?
6325 STRLIT("TRUE)"):
6326 STRLIT("FALSE)"));
6327 out.append(';');
6328 }
|
6329 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6330 thilo.boehm 1.1 break;
6331 }
6332
6333 case CIMTYPE_STRING:
6334 {
|
6335 thilo.boehm 1.2.2.25 SCMBDataPtr* p = (SCMBDataPtr*)&(base[u.arrayValue.start]);
|
6336 thilo.boehm 1.2 for (Uint32 i = 0; i < size; i++)
|
6337 thilo.boehm 1.1 {
|
6338 thilo.boehm 1.2.2.57 if ( 0 != p[i].size)
|
6339 thilo.boehm 1.2.2.18 {
|
6340 thilo.boehm 1.2.2.25 out.append('\'');
|
6341 thilo.boehm 1.2.2.18 out.append((const char*)_getCharString(p[i],base),
|
6342 thilo.boehm 1.2.2.57 p[i].size-1);
|
6343 thilo.boehm 1.2.2.25 out.append('\'');
|
6344 thilo.boehm 1.2.2.18 }
6345 else
6346 {
|
6347 thilo.boehm 1.2.2.25 out << STRLIT("NULL;");
|
6348 thilo.boehm 1.2.2.18 }
|
6349 thilo.boehm 1.2.2.25 out.append(';');
|
6350 thilo.boehm 1.2 }
|
6351 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6352 thilo.boehm 1.2 break;
6353 }
|
6354 thilo.boehm 1.1
|
6355 thilo.boehm 1.2 case CIMTYPE_DATETIME:
6356 {
|
6357 thilo.boehm 1.2.2.25 SCMBDateTime* p = (SCMBDateTime*)&(base[u.arrayValue.start]);
|
6358 thilo.boehm 1.2 CIMDateTime x;
6359 for (Uint32 i = 0; i < size; i++)
|
6360 thilo.boehm 1.1 {
|
6361 thilo.boehm 1.2 memcpy(x._rep,&(p[i]),sizeof(SCMBDateTime));
6362 _toString(out,x);
|
6363 thilo.boehm 1.2.2.4 out.append(' ');
|
6364 thilo.boehm 1.1 }
|
6365 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe values are: %s",out.getData());
|
6366 thilo.boehm 1.1 break;
6367 }
6368
6369 case CIMTYPE_REFERENCE:
|
6370 thilo.boehm 1.2.2.30 case CIMTYPE_OBJECT:
|
6371 thilo.boehm 1.1 case CIMTYPE_INSTANCE:
|
6372 thilo.boehm 1.2 {
|
6373 thilo.boehm 1.2.2.40 if (verbose)
|
6374 thilo.boehm 1.2.2.39 {
|
6375 thilo.boehm 1.2.2.40 for (Uint32 i = 0; i < size; i++)
6376 {
6377 fprintf(_out,"\n-----------> "
6378 "Start of embedded external reference [%d]"
6379 " <-----------\n\n",i);
6380 dumpSCMOInstance(*u.extRefPtr);
6381 fprintf(_out,"\n-----------> "
6382 "End of embedded external reference [%d]"
6383 " <-----------\n\n",i);
6384 }
6385
6386 } else
6387 {
6388 fprintf(_out,"\nThe values are: ");
6389
6390 for (Uint32 i = 0; i < size; i++)
6391 {
6392 fprintf(
6393 _out,
6394 "Pointer to external Reference[%d] : \'%p\';",
6395 i,p[i].extRefPtr);
6396 thilo.boehm 1.2.2.40 }
|
6397 thilo.boehm 1.2.2.39 }
|
6398 thilo.boehm 1.2.2.40
|
6399 thilo.boehm 1.2 break;
|
6400 thilo.boehm 1.2.2.39
|
6401 thilo.boehm 1.2 }
|
6402 thilo.boehm 1.1 default:
|
6403 thilo.boehm 1.2 {
|
6404 thilo.boehm 1.2.2.30 PEGASUS_ASSERT(false);
6405 break;
|
6406 thilo.boehm 1.2 }
|
6407 thilo.boehm 1.1 }
6408
|
6409 thilo.boehm 1.2.2.40 return;
|
6410 thilo.boehm 1.1 }
6411
|
6412 thilo.boehm 1.2.2.40 void SCMODump::printUnionValue(
|
6413 thilo.boehm 1.2.2.3 CIMType type,
|
6414 thilo.boehm 1.2 SCMBUnion u,
|
6415 thilo.boehm 1.2.2.40 char* base,
6416 Boolean verbose) const
|
6417 thilo.boehm 1.1 {
|
6418 thilo.boehm 1.2.2.13
|
6419 thilo.boehm 1.2 Buffer out;
|
6420 thilo.boehm 1.1
|
6421 thilo.boehm 1.2 switch (type)
|
6422 thilo.boehm 1.1 {
|
6423 thilo.boehm 1.2 case CIMTYPE_BOOLEAN:
6424 {
|
6425 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.bin);
|
6426 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6427 thilo.boehm 1.2 break;
6428 }
|
6429 thilo.boehm 1.1
|
6430 thilo.boehm 1.2 case CIMTYPE_UINT8:
6431 {
|
6432 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.u8);
|
6433 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6434 thilo.boehm 1.2 break;
6435 }
|
6436 thilo.boehm 1.1
|
6437 thilo.boehm 1.2 case CIMTYPE_SINT8:
6438 {
|
6439 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.s8);
|
6440 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6441 thilo.boehm 1.2 break;
6442 }
|
6443 thilo.boehm 1.1
|
6444 thilo.boehm 1.2 case CIMTYPE_UINT16:
6445 {
|
6446 thilo.boehm 1.2.2.25 _toString(out,(Uint32)u.simple.val.u16);
|
6447 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6448 thilo.boehm 1.2 break;
6449 }
|
6450 thilo.boehm 1.1
|
6451 thilo.boehm 1.2 case CIMTYPE_SINT16:
6452 {
|
6453 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.s16);
|
6454 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6455 thilo.boehm 1.2 break;
6456 }
|
6457 thilo.boehm 1.1
|
6458 thilo.boehm 1.2 case CIMTYPE_UINT32:
6459 {
|
6460 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.u32);
|
6461 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6462 thilo.boehm 1.2 break;
6463 }
|
6464 thilo.boehm 1.1
|
6465 thilo.boehm 1.2 case CIMTYPE_SINT32:
6466 {
|
6467 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.s32);
|
6468 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6469 thilo.boehm 1.2 break;
6470 }
|
6471 thilo.boehm 1.1
|
6472 thilo.boehm 1.2 case CIMTYPE_UINT64:
|
6473 thilo.boehm 1.1 {
|
6474 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.u64);
|
6475 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6476 thilo.boehm 1.2 break;
|
6477 thilo.boehm 1.1 }
6478
|
6479 thilo.boehm 1.2 case CIMTYPE_SINT64:
6480 {
|
6481 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.s64);
|
6482 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6483 thilo.boehm 1.2 break;
6484 }
|
6485 thilo.boehm 1.1
|
6486 thilo.boehm 1.2 case CIMTYPE_REAL32:
6487 {
|
6488 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.r32);
|
6489 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6490 thilo.boehm 1.2 break;
6491 }
|
6492 thilo.boehm 1.1
|
6493 thilo.boehm 1.2 case CIMTYPE_REAL64:
6494 {
|
6495 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.r32);
|
6496 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6497 thilo.boehm 1.2 break;
6498 }
|
6499 thilo.boehm 1.1
|
6500 thilo.boehm 1.2 case CIMTYPE_CHAR16:
6501 {
|
6502 thilo.boehm 1.2.2.25 _toString(out,u.simple.val.c16);
|
6503 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6504 thilo.boehm 1.2 break;
6505 }
|
6506 thilo.boehm 1.1
|
6507 thilo.boehm 1.2 case CIMTYPE_STRING:
6508 {
|
6509 thilo.boehm 1.2.2.57 if ( 0 != u.stringValue.size)
|
6510 thilo.boehm 1.2.2.18 {
|
6511 thilo.boehm 1.2.2.25 out.append((const char*)_getCharString(u.stringValue,base),
|
6512 thilo.boehm 1.2.2.57 u.stringValue.size-1);
|
6513 thilo.boehm 1.2.2.18 }
|
6514 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6515 thilo.boehm 1.2 break;
6516 }
|
6517 thilo.boehm 1.1
|
6518 thilo.boehm 1.2 case CIMTYPE_DATETIME:
6519 {
6520 CIMDateTime x;
|
6521 thilo.boehm 1.2.2.25 memcpy(x._rep,&(u.dateTimeValue),sizeof(SCMBDateTime));
|
6522 thilo.boehm 1.2 _toString(out,x);
|
6523 thilo.boehm 1.2.2.40 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6524 thilo.boehm 1.2 break;
6525 }
|
6526 thilo.boehm 1.1
|
6527 thilo.boehm 1.2 case CIMTYPE_REFERENCE:
|
6528 thilo.boehm 1.2.2.30 case CIMTYPE_OBJECT:
|
6529 thilo.boehm 1.2 case CIMTYPE_INSTANCE:
6530 {
|
6531 thilo.boehm 1.2.2.40 if (verbose)
6532 {
6533 fprintf(_out,"\n-----------> "
6534 "Start of embedded external reference"
6535 " <-----------\n\n");
6536 dumpSCMOInstance(*u.extRefPtr);
6537 fprintf(_out,"\n-----------> "
6538 "End of embedded external reference"
6539 " <-----------\n\n");
6540 } else
6541 {
6542 fprintf(
6543 _out,
6544 "Pointer to external Reference : \'%p\'",
6545 u.extRefPtr);
6546 }
6547
|
6548 thilo.boehm 1.2 break;
6549 }
6550 default:
6551 {
|
6552 thilo.boehm 1.2.2.30 PEGASUS_ASSERT(false);
6553 break;
|
6554 thilo.boehm 1.2 }
6555 }
|
6556 thilo.boehm 1.1
|
6557 thilo.boehm 1.2.2.40 return;
|
6558 thilo.boehm 1.1 }
6559
6560
|
6561 thilo.boehm 1.2 /*****************************************************************************
6562 * The constant functions
6563 *****************************************************************************/
6564
|
6565 thilo.boehm 1.2.2.34 #ifdef PEGASUS_HAS_ICU
|
6566 thilo.boehm 1.2.2.62 Uint32 _utf8ICUncasecmp(
|
6567 thilo.boehm 1.2.2.34 const char* a,
6568 const char* b,
6569 Uint32 len)
6570 {
6571 UErrorCode errorCode=U_ZERO_ERROR;
6572
|
6573 thilo.boehm 1.2.2.38 Uint32 rc, a16len,b16len,utf16BufLen;
6574 utf16BufLen = (len*sizeof(UChar))+2;
|
6575 thilo.boehm 1.2.2.34
6576 UChar* a_UTF16 = (UChar*)malloc(utf16BufLen);
6577 UChar* b_UTF16 = (UChar*)malloc(utf16BufLen);
6578
6579 UConverter *conv = ucnv_open(0, &errorCode);
6580 if(U_FAILURE(errorCode))
6581 {
6582 free(a_UTF16);
|
6583 thilo.boehm 1.2.2.35 free(b_UTF16);
|
6584 thilo.boehm 1.2.2.34 String message("SCMO::_utf8ICUncasecmp() ICUError: ");
6585 message.append(u_errorName(errorCode));
6586 message.append(" Can not open ICU default converter!");
6587 throw CIMException(CIM_ERR_FAILED,message );
6588 }
6589
6590 a16len = ucnv_toUChars(conv,a_UTF16,utf16BufLen,a,len,&errorCode);
6591
6592 if(U_FAILURE(errorCode))
6593 {
6594 free(a_UTF16);
|
6595 thilo.boehm 1.2.2.35 free(b_UTF16);
|
6596 thilo.boehm 1.2.2.34 ucnv_close(conv);
6597 String message("SCMO::_utf8ICUncasecmp() ICUError: ");
6598 message.append(u_errorName(errorCode));
6599 message.append(" Can not convert string a:'");
6600 message.append(String(a,len));
6601 message.append('\'');
6602 throw CIMException(CIM_ERR_FAILED,message );
6603 }
6604
6605 b16len = ucnv_toUChars(conv,b_UTF16,utf16BufLen,b,len,&errorCode);
6606
6607 if(U_FAILURE(errorCode))
6608 {
6609 free(a_UTF16);
|
6610 thilo.boehm 1.2.2.35 free(b_UTF16);
|
6611 thilo.boehm 1.2.2.34 ucnv_close(conv);
6612 String message("SCMO::_utf8ICUncasecmp() ICUError: ");
6613 message.append(u_errorName(errorCode));
6614 message.append(" Can not convert string b:'");
6615 message.append(String(b,len));
6616 message.append('\'');
6617 throw CIMException(CIM_ERR_FAILED,message );
6618 }
6619
6620 rc = u_strCaseCompare(
6621 a_UTF16,a16len,
6622 b_UTF16,b16len,
6623 U_FOLD_CASE_DEFAULT,
6624 &errorCode);
6625
6626 if(U_FAILURE(errorCode))
6627 {
6628 free(a_UTF16);
|
6629 thilo.boehm 1.2.2.35 free(b_UTF16);
|
6630 thilo.boehm 1.2.2.34 ucnv_close(conv);
6631 String message("SCMO::_utf8ICUncasecmp() ICUError: ");
6632 message.append(u_errorName(errorCode));
6633 message.append(" Can not compare string a:'");
6634 message.append(String(a,len));
6635 message.append("' with b: '");
6636 message.append(String(b,len));
6637 message.append('\'');
6638 throw CIMException(CIM_ERR_FAILED,message );
6639 }
6640
6641 free(a_UTF16);
|
6642 thilo.boehm 1.2.2.35 free(b_UTF16);
|
6643 thilo.boehm 1.2.2.34 ucnv_close(conv);
6644
6645 return(rc);
6646 }
6647 #endif
|
6648 thilo.boehm 1.2.2.13
|
6649 thilo.boehm 1.1 /**
6650 * This function calcutates a free memory slot in the single chunk memory block.
|
6651 thilo.boehm 1.2 * Warning: In this routine a reallocation may take place.
|
6652 thilo.boehm 1.1 * @param ptr A reference to a data SCMB data pointer. The values to the free
|
6653 thilo.boehm 1.2 * block is written into this pointer. If the provided ptr is
6654 * located in the single chunk memory block, this pointer may be
6655 * invalid after this call. You have to recalcuate the pointer
|
6656 thilo.boehm 1.1 * after calling this function.
6657 * @parm size The requested free memory slot.
6658 * @parm pmem A reference to the pointer of the single chunk memory block.
6659 * e.g. &cls.mem
6660 * @return The relaive index of the free memory slot.
6661 */
6662
|
6663 thilo.boehm 1.2 static Uint64 _getFreeSpace(
6664 SCMBDataPtr& ptr,
6665 Uint64 size,
|
6666 thilo.boehm 1.2.2.60 SCMBMgmt_Header** pmem)
|
6667 thilo.boehm 1.1 {
6668 Uint64 oldSize, start;
6669
6670 if (size == 0)
6671 {
6672 ptr.start = 0;
|
6673 thilo.boehm 1.2.2.57 ptr.size = 0;
|
6674 thilo.boehm 1.1 return 0;
6675 }
6676
|
6677 thilo.boehm 1.2 // The SCMBDataPtr has to be set before any reallocation.
|
6678 thilo.boehm 1.1 start = (*pmem)->startOfFreeSpace;
6679 ptr.start = start;
|
6680 thilo.boehm 1.2.2.57 ptr.size = size;
|
6681 thilo.boehm 1.1
6682 while ((*pmem)->freeBytes < size)
6683 {
6684 // save old size of buffer
6685 oldSize = (*pmem)->totalSize;
6686 // reallocate the buffer, double the space !
6687 // This is a working approach until a better algorithm is found.
|
6688 r.kieninger 1.2.2.68 void* newBlockPtr = realloc((*pmem),oldSize*2);
6689 if ((newBlockPtr) == 0)
|
6690 thilo.boehm 1.1 {
|
6691 thilo.boehm 1.2 // Not enough memory!
|
6692 thilo.boehm 1.1 throw PEGASUS_STD(bad_alloc)();
6693 }
|
6694 r.kieninger 1.2.2.68 (*pmem) = (SCMBMgmt_Header*)newBlockPtr;
|
6695 thilo.boehm 1.2 // increase the total size and free space
|
6696 marek 1.2.2.23 (*pmem)->freeBytes+=oldSize;
6697 (*pmem)->totalSize+=oldSize;
|
6698 thilo.boehm 1.2 }
|
6699 thilo.boehm 1.1
|
6700 marek 1.2.2.23 (*pmem)->freeBytes -= size;
6701 (*pmem)->startOfFreeSpace += size;
|
6702 thilo.boehm 1.1
|
6703 thilo.boehm 1.2.2.60 // Init memory to 0.
6704 memset(&((char*)(*pmem))[start],0,size);
6705
|
6706 thilo.boehm 1.1 return start;
6707 }
6708
6709 static void _setString(
|
6710 thilo.boehm 1.2 const String& theString,
6711 SCMBDataPtr& ptr,
|
6712 thilo.boehm 1.1 SCMBMgmt_Header** pmem)
6713 {
6714
6715 // Get the UTF8 CString
6716 CString theCString=theString.getCString();
|
6717 thilo.boehm 1.2 // Get the real size of the UTF8 sting + \0.
6718 // It maybe greater then the length in the String due to
|
6719 thilo.boehm 1.1 // 4 byte encoding of non ASCII chars.
6720 Uint64 start,length = strlen((const char*)theCString)+1;
6721
6722 // If the string is not empty.
6723 if (length != 1)
6724 {
6725
6726 // Attention ! In this function a reallocation may take place.
|
6727 thilo.boehm 1.2 // The reference ptr may be unusable after the call to _getFreeSpace
|
6728 thilo.boehm 1.1 // --> use the returned start index.
|
6729 thilo.boehm 1.2 start = _getFreeSpace(ptr , length, pmem);
|
6730 thilo.boehm 1.1 // Copy string including trailing \0
|
6731 thilo.boehm 1.2.2.2 memcpy(&((char*)(*pmem))[start],(const char*)theCString,length);
|
6732 thilo.boehm 1.2 }
|
6733 thilo.boehm 1.1 else
6734 {
6735 ptr.start = 0;
|
6736 thilo.boehm 1.2.2.57 ptr.size = 0;
|
6737 thilo.boehm 1.1 }
6738 }
6739
6740 static void _setBinary(
|
6741 thilo.boehm 1.2 const void* theBuffer,
|
6742 thilo.boehm 1.1 Uint64 bufferSize,
|
6743 thilo.boehm 1.2 SCMBDataPtr& ptr,
|
6744 thilo.boehm 1.1 SCMBMgmt_Header** pmem)
6745 {
6746
6747 // If buffer is not empty.
|
6748 thilo.boehm 1.2.2.63 if (bufferSize != 0 && theBuffer != 0)
|
6749 thilo.boehm 1.1 {
6750
6751 Uint64 start;
6752 // Attention ! In this function a reallocation may take place.
|
6753 thilo.boehm 1.2 // The reference ptr may be unusable after the call to _getFreeSpace
|
6754 thilo.boehm 1.1 // --> use the returned start index.
|
6755 thilo.boehm 1.2 start = _getFreeSpace(ptr , bufferSize, pmem);
|
6756 thilo.boehm 1.1 // Copy buffer into SCMB
6757 memcpy(
|
6758 thilo.boehm 1.2.2.2 &((char*)(*pmem))[start],
|
6759 thilo.boehm 1.1 (const char*)theBuffer,
|
6760 thilo.boehm 1.2 bufferSize);
6761 }
|
6762 thilo.boehm 1.1 else
6763 {
6764 ptr.start = 0;
|
6765 thilo.boehm 1.2.2.57 ptr.size = 0;
|
6766 thilo.boehm 1.1 }
6767 }
6768
|
6769 thilo.boehm 1.2.2.65 static void _destroyExternalReferencesInternal(SCMBMgmt_Header* memHdr)
6770 {
6771
6772 Uint32 number = memHdr->numberExtRef;
6773
6774 if (0 != number)
6775 {
6776 char * base = ((char*)memHdr);
6777 Uint64* array =
6778 (Uint64*)&(base[memHdr->extRefIndexArray.start]);
6779 for (Uint32 i = 0; i < number; i++)
6780 {
6781 delete ((SCMBUnion*)(&(base[array[i]])))->extRefPtr;
6782 }
6783
6784 }
6785 }
6786
|
6787 thilo.boehm 1.1 PEGASUS_NAMESPACE_END
|