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