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 const char* SCMOInstance::getHostName() const
2349 {
2350 return _getCharString(inst.hdr->hostName,inst.base);
2351 }
|
2352 thilo.boehm 1.2
|
2353 thilo.boehm 1.3 const char* SCMOInstance::getHostName_l(Uint32& length) const
2354 {
2355 length = inst.hdr->hostName.size;
2356 if (0 == length)
2357 {
2358 return 0;
2359 }
2360 else
|
2361 thilo.boehm 1.2 {
|
2362 thilo.boehm 1.3 length--;
|
2363 thilo.boehm 1.2 }
|
2364 thilo.boehm 1.3 return _getCharString(inst.hdr->hostName,inst.base);
2365 }
2366
2367 void SCMOInstance::setClassName(const char* className)
2368 {
2369 Uint32 len=0;
2370
2371 _copyOnWrite();
|
2372 thilo.boehm 1.2
|
2373 thilo.boehm 1.3 // flag the instance as compromized
2374 inst.hdr->flags.isCompromised=true;
2375 if (className!=0)
|
2376 thilo.boehm 1.2 {
|
2377 thilo.boehm 1.3 len = strlen((const char*)className);
|
2378 thilo.boehm 1.2 }
|
2379 thilo.boehm 1.3 // copy including trailing '\0'
2380 // _setBinary also sets the name to 0 if either className==0 or len+1==1
2381 _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem);
2382 }
|
2383 thilo.boehm 1.2
|
2384 thilo.boehm 1.3 void SCMOInstance::setClassName_l(const char* className, Uint32 len)
2385 {
2386 _copyOnWrite();
|
2387 thilo.boehm 1.2
|
2388 thilo.boehm 1.3 // flag the instance as compromised
2389 inst.hdr->flags.isCompromised=true;
2390 // 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 const char* SCMOInstance::getClassName() const
2396 {
2397 return _getCharString(inst.hdr->instClassName,inst.base);
2398 }
|
2399 thilo.boehm 1.2
|
2400 thilo.boehm 1.3 const char* SCMOInstance::getClassName_l(Uint32 & length) const
2401 {
2402 length = inst.hdr->instClassName.size;
2403 if (0 == length)
2404 {
2405 return 0;
2406 }
2407 else
2408 {
2409 length--;
2410 }
2411 return _getCharString(inst.hdr->instClassName,inst.base);
|
2412 thilo.boehm 1.2 }
2413
|
2414 thilo.boehm 1.3 void SCMOInstance::setNameSpace(const char* nameSpace)
|
2415 thilo.boehm 1.2 {
|
2416 thilo.boehm 1.3 Uint32 len = 0;
2417
2418 _copyOnWrite();
2419
2420 // flag the instance as compromized
2421 inst.hdr->flags.isCompromised=true;
2422
2423 if (nameSpace!=0)
|
2424 thilo.boehm 1.2 {
|
2425 thilo.boehm 1.3
2426 len = strlen((const char*)nameSpace);
|
2427 thilo.boehm 1.1 }
|
2428 thilo.boehm 1.3 // copy including trailing '\0'
2429 _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
2430 }
|
2431 thilo.boehm 1.1
|
2432 thilo.boehm 1.3 void SCMOInstance::setNameSpace_l(const char* nameSpace, Uint32 len)
2433 {
2434 // Copy on Write is only necessary if a realloc() becomes necessary
|
2435 marek 1.9 if (inst.mem->freeBytes < ((len+8) & ~7))
|
2436 thilo.boehm 1.3 {
2437 _copyOnWrite();
2438 }
2439 // flag the instance as compromized
2440 inst.hdr->flags.isCompromised=true;
2441 // copy including trailing '\0'
2442 _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
2443 }
|
2444 thilo.boehm 1.2
|
2445 thilo.boehm 1.3 const char* SCMOInstance::getNameSpace() const
2446 {
2447 return _getCharString(inst.hdr->instNameSpace,inst.base);
|
2448 thilo.boehm 1.2 }
2449
|
2450 thilo.boehm 1.3 const char* SCMOInstance::getNameSpace_l(Uint32 & length) const
|
2451 thilo.boehm 1.2 {
|
2452 thilo.boehm 1.3 length = inst.hdr->instNameSpace.size;
2453 if (0 == length)
2454 {
2455 return 0;
2456 }
2457 else
2458 {
2459 length--;
2460 }
2461 return _getCharString(inst.hdr->instNameSpace,inst.base);
|
2462 thilo.boehm 1.1 }
2463
|
2464 marek 1.14.2.4 void SCMOInstance::completeHostNameAndNamespace(
2465 const char* hn,
2466 Uint32 hnLen,
2467 const char* ns,
2468 Uint32 nsLen)
2469 {
2470 // hostName is Null or empty String ?
2471 if (0 == inst.hdr->hostName.size ||
2472 0 == inst.base[inst.hdr->hostName.start])
2473 {
2474 // Copy on Write is only necessary if a realloc() becomes necessary
2475 if (inst.mem->freeBytes < ((hnLen+8) & ~7))
2476 {
2477 _copyOnWrite();
2478 }
2479 // copy including trailing '\0'
2480 _setBinary(hn,hnLen+1,inst.hdr->hostName,&inst.mem);
2481 }
2482 // namespace is Null or empty String ?
2483 if (0 == inst.hdr->instNameSpace.size ||
2484 0 == inst.base[inst.hdr->instNameSpace.start])
2485 marek 1.14.2.4 {
2486 setNameSpace_l(ns,nsLen);
2487 }
2488 }
2489
2490
|
2491 thilo.boehm 1.3 void SCMOInstance::buildKeyBindingsFromProperties()
|
2492 thilo.boehm 1.1 {
|
2493 marek 1.10 Uint32 propNode;
2494 // The theClassKeyPropList pointer will always be valid,
2495 // even after a realloc() caused by copyOnWrite()
2496 // as this is an absolute pointer to the class which does not change
|
2497 thilo.boehm 1.3 Uint32* theClassKeyPropList =
2498 (Uint32*) &((inst.hdr->theClass.ptr->cls.base)
2499 [(inst.hdr->theClass.ptr->cls.hdr->keyIndexList.start)]);
|
2500 thilo.boehm 1.2
|
2501 marek 1.10 SCMBKeyBindingValue* theKeyBindValueArray =
2502 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
2503 SCMBValue* theInstPropNodeArray=
2504 (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
|
2505 thilo.boehm 1.2
|
2506 marek 1.14.2.3 inst.hdr->numberKeyBindings =
2507 inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
2508
|
2509 thilo.boehm 1.3 for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)
|
2510 thilo.boehm 1.2 {
|
2511 thilo.boehm 1.3 // If the keybinding is not set.
2512 if (!theKeyBindValueArray[i].isSet)
2513 {
2514 // get the node index for this key binding form class
2515 propNode = theClassKeyPropList[i];
2516
2517 // if property was set by the provider and it is not null.
2518 if ( theInstPropNodeArray[propNode].flags.isSet &&
2519 !theInstPropNodeArray[propNode].flags.isNull)
2520 {
2521 _copyOnWrite();
|
2522 marek 1.10 // the instance pointers have to be recalculated as copyOnWrite
2523 // might change the absolute address of these pointers
2524 theInstPropNodeArray =
2525 (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
2526 theKeyBindValueArray =
2527 (SCMBKeyBindingValue*)
2528 &(inst.base[inst.hdr->keyBindingArray.start]);
|
2529 thilo.boehm 1.3
2530 _setKeyBindingFromSCMBUnion(
2531 theInstPropNodeArray[propNode].valueType,
2532 theInstPropNodeArray[propNode].value,
2533 inst.base,
2534 theKeyBindValueArray[i]);
|
2535 marek 1.10
2536 // the instance pointers have to be reinitialized each time,
2537 // because a reallocation can take place
2538 // in _setKeyBindingFromSCMBUnion()
2539 theKeyBindValueArray =
2540 (SCMBKeyBindingValue*)
2541 &(inst.base[inst.hdr->keyBindingArray.start]);
2542 theInstPropNodeArray =
2543 (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
2544
|
2545 thilo.boehm 1.3 }
2546 }
|
2547 thilo.boehm 1.2 }
|
2548 thilo.boehm 1.3 }
|
2549 thilo.boehm 1.2
|
2550 thilo.boehm 1.3 void SCMOInstance::_setKeyBindingFromSCMBUnion(
2551 CIMType type,
2552 const SCMBUnion& u,
2553 const char * uBase,
2554 SCMBKeyBindingValue& keyData)
2555 {
|
2556 thilo.boehm 1.1 switch (type)
2557 {
2558 case CIMTYPE_UINT8:
|
2559 thilo.boehm 1.3 case CIMTYPE_UINT16:
2560 case CIMTYPE_UINT32:
2561 case CIMTYPE_UINT64:
|
2562 thilo.boehm 1.1 case CIMTYPE_SINT8:
2563 case CIMTYPE_SINT16:
2564 case CIMTYPE_SINT32:
2565 case CIMTYPE_SINT64:
2566 case CIMTYPE_REAL32:
2567 case CIMTYPE_REAL64:
2568 case CIMTYPE_CHAR16:
|
2569 thilo.boehm 1.3 case CIMTYPE_BOOLEAN:
2570 {
2571 memcpy(&keyData.data,&u,sizeof(SCMBUnion));
2572 keyData.data.simple.hasValue=true;
2573 keyData.isSet=true;
2574 break;
2575 }
|
2576 thilo.boehm 1.2 case CIMTYPE_DATETIME:
|
2577 thilo.boehm 1.1 {
|
2578 thilo.boehm 1.3 memcpy(&keyData.data,&u,sizeof(SCMBUnion));
2579 keyData.isSet=true;
|
2580 thilo.boehm 1.1 break;
2581 }
2582 case CIMTYPE_STRING:
2583 {
|
2584 thilo.boehm 1.3 keyData.isSet=true;
2585 // Check if a key binding is set with in the same instance.
2586 // If this is the case, a reallocation can take place and the
2587 // uBase pointer can be invalid and cause a read in freed memory!
2588 if (uBase == inst.base)
|
2589 thilo.boehm 1.2 {
|
2590 thilo.boehm 1.3 if (0 != u.stringValue.size )
|
2591 thilo.boehm 1.2 {
|
2592 thilo.boehm 1.3 // We are doing a in instance copy of data.
2593 // We can not use the _setBinary() function because
2594 // all real pointer can be in valid after
2595 // the _getFreeSprace() function!
2596 // We have to save all relative pointer on the stack.
2597 Uint64 start;
2598 SCMBDataPtr tmp;
2599 tmp.size = u.stringValue.size;
2600 tmp.start = u.stringValue.start;
2601
2602 // In this function a reallocation may take place!
2603 // The keyData.data.stringValue is set
2604 // before the rallocation.
2605 start = _getFreeSpace(
2606 keyData.data.stringValue,
2607 u.stringValue.size,
2608 &inst.mem);
2609 // Copy the string,
2610 // but using the own base pointer and the saved relative
2611 // string pointer.
2612 memcpy(
2613 thilo.boehm 1.3 &(inst.base[start]),
2614 _getCharString(tmp,inst.base),
2615 tmp.size);
|
2616 thilo.boehm 1.2 }
|
2617 thilo.boehm 1.3 else
|
2618 thilo.boehm 1.2 {
|
2619 thilo.boehm 1.3 keyData.data.stringValue.size=0;
2620 keyData.data.stringValue.start=0;
|
2621 thilo.boehm 1.2 }
|
2622 thilo.boehm 1.1
|
2623 thilo.boehm 1.2 }
2624 else
2625 {
|
2626 thilo.boehm 1.3 _setBinary(
2627 &uBase[u.stringValue.start],
2628 u.stringValue.size,
2629 keyData.data.stringValue,
2630 &inst.mem);
|
2631 thilo.boehm 1.2 }
|
2632 thilo.boehm 1.1
2633 break;
2634 }
|
2635 thilo.boehm 1.2 case CIMTYPE_REFERENCE:
|
2636 thilo.boehm 1.3 {
2637 if(0 != keyData.data.extRefPtr)
2638 {
2639 delete keyData.data.extRefPtr;
2640 }
|
2641 thilo.boehm 1.1
|
2642 thilo.boehm 1.3 if(u.extRefPtr)
2643 {
2644 keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr);
2645 keyData.isSet=true;
2646 // This function can cause a reallocation !
2647 // Pointers can be invalid after the call.
2648 _setExtRefIndex(&(keyData.data),&inst.mem);
2649 }
2650 else
2651 {
2652 keyData.isSet=true;
2653 keyData.data.extRefPtr=0;
2654 }
2655 break;
2656 }
|
2657 thilo.boehm 1.2 case CIMTYPE_OBJECT:
2658 case CIMTYPE_INSTANCE:
|
2659 thilo.boehm 1.3 {
2660 // From PEP 194: EmbeddedObjects cannot be keys.
2661 throw TypeMismatchException();
2662 break;
2663 }
|
2664 thilo.boehm 1.2 default:
|
2665 thilo.boehm 1.3 {
2666 PEGASUS_ASSERT(false);
2667 break;
2668 }
|
2669 thilo.boehm 1.2 }
|
2670 thilo.boehm 1.1 }
2671
|
2672 thilo.boehm 1.3 void SCMOInstance::_initSCMOInstance(SCMOClass* pClass)
|
2673 thilo.boehm 1.1 {
|
2674 thilo.boehm 1.3 PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
2675 - sizeof(SCMBInstance_Main)>0);
|
2676 thilo.boehm 1.1
2677
|
2678 thilo.boehm 1.3 inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
2679 if (inst.base == 0)
2680 {
2681 // Not enough memory!
2682 throw PEGASUS_STD(bad_alloc)();
2683 }
2684
2685 memset(inst.base,0,sizeof(SCMBInstance_Main));
2686
2687 // initalize eye catcher
2688 inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;
2689 inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
2690 // The # of bytes free
2691 inst.hdr->header.freeBytes=
2692 SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main);
2693 // Index to the start of the free space in this instance
2694 inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main);
2695
2696 inst.hdr->refCount=1;
2697
2698 //Assign the SCMBClass structure this instance based on.
2699 thilo.boehm 1.3 inst.hdr->theClass.ptr = pClass;
2700
2701 // Copy name space name and class name of the class
2702 _setBinary(
2703 _getCharString(inst.hdr->theClass.ptr->cls.hdr->className,
2704 inst.hdr->theClass.ptr->cls.base),
2705 inst.hdr->theClass.ptr->cls.hdr->className.size,
2706 inst.hdr->instClassName,
2707 &inst.mem);
2708
2709 _setBinary(
2710 _getCharString(inst.hdr->theClass.ptr->cls.hdr->nameSpace,
2711 inst.hdr->theClass.ptr->cls.base),
2712 inst.hdr->theClass.ptr->cls.hdr->nameSpace.size,
2713 inst.hdr->instNameSpace,
2714 &inst.mem);
2715
2716 // Number of key bindings
2717 inst.hdr->numberKeyBindings =
2718 inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
2719
2720 thilo.boehm 1.3 // Number of properties
2721 inst.hdr->numberProperties =
2722 inst.hdr->theClass.ptr->cls.hdr->propertySet.number;
2723
2724 // Allocate the SCMOInstanceKeyBindingArray
2725 _getFreeSpace(
2726 inst.hdr->keyBindingArray,
2727 sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
2728 &inst.mem);
2729
2730 // Allocate the SCMBInstancePropertyArray
2731 _getFreeSpace(
2732 inst.hdr->propertyArray,
2733 sizeof(SCMBValue)*inst.hdr->numberProperties,
2734 &inst.mem);
2735
2736 }
2737
2738 void SCMOInstance::_setCIMInstance(const CIMInstance& cimInstance)
|
2739 thilo.boehm 1.1 {
|
2740 thilo.boehm 1.3 CIMPropertyRep* propRep;
2741 Uint32 propNode;
2742 SCMO_RC rc;
2743 CIMType realType;
2744
2745 CIMInstanceRep* instRep = cimInstance._rep;
2746
2747 // Test if the instance has qualifiers.
2748 // The instance level qualifiers are stored on the associated SCMOClass.
2749 inst.hdr->flags.includeQualifiers=(instRep->_qualifiers.getCount()>0);
2750
2751 // To ensure that at converting a CIMInstance to a SCMOInstance
2752 // and vice versa do have the same property set.
2753 inst.hdr->flags.exportSetOnly=true;
|
2754 thilo.boehm 1.1
|
2755 thilo.boehm 1.3 _setCIMObjectPath(instRep->_reference);
2756
2757 // Copy all properties
2758 for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++)
|
2759 thilo.boehm 1.2 {
|
2760 thilo.boehm 1.3 propRep = instRep->_properties[i]._rep;
2761 // if not already detected that qualifiers are specified and
2762 // there are qualifers at that property.
2763 if (!inst.hdr->flags.includeQualifiers &&
2764 propRep->getQualifierCount() > 0)
2765 {
2766 includeQualifiers();
2767 }
2768 // if not already detected that class origins are specified and
2769 // there is a class origin specified at that property.
2770 if (!inst.hdr->flags.includeClassOrigin &&
2771 !propRep->_classOrigin.isNull())
2772 {
2773 includeClassOrigins();
2774 }
2775
2776 // get the property node index for the property
2777 rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(
2778 propNode,
2779 (const char*)propRep->_name.getString().getCString());
2780
2781 thilo.boehm 1.3 if (rc == SCMO_OK)
2782 {
2783 // The type stored in the class information is set on realType.
2784 // It must be used in further calls to guaranty consistence.
2785 rc = inst.hdr->theClass.ptr->_isNodeSameType(
2786 propNode,
2787 propRep->_value._rep->type,
2788 propRep->_value._rep->isArray,
2789 realType);
2790 if (rc == SCMO_OK)
2791 {
2792 _setCIMValueAtNodeIndex(
2793 propNode,
2794 propRep->_value._rep,
2795 realType);
2796 }
2797 else
2798 {
2799 PEG_TRACE((TRC_DISCARDED_DATA,Tracer::LEVEL2,
2800 "CIMProperty '%s' with type '%s' "
2801 "can not be set at SCMOInstance."
2802 thilo.boehm 1.3 "It is has not same type '%s' as defined in "
2803 "class '%s' of name space '%s'",
2804 cimTypeToString(propRep->_value._rep->type),
2805 (const char*)propRep->_name.getString().getCString(),
2806 cimTypeToString(realType),
2807 (const char*)instRep->_reference._rep->
2808 _className.getString().getCString(),
2809 (const char*)instRep->_reference._rep->
2810 _nameSpace.getString().getCString()));
2811 }
2812
2813 }
2814 else
2815 {
2816
2817 PEG_TRACE((TRC_DISCARDED_DATA,Tracer::LEVEL2,
2818 "CIMProperty '%s' can not be set at SCMOInstance."
2819 "It is not part of class '%s' of name space '%s'",
2820 (const char*)propRep->_name.getString().getCString(),
2821 (const char*)instRep->_reference._rep->
2822 _className.getString().getCString(),
2823 thilo.boehm 1.3 (const char*)instRep->_reference._rep->
2824 _nameSpace.getString().getCString()));
2825 }
|
2826 thilo.boehm 1.2 }
|
2827 thilo.boehm 1.1 }
2828
|
2829 thilo.boehm 1.3 SCMO_RC SCMOInstance::getProperty(
|
2830 thilo.boehm 1.2 const char* name,
|
2831 thilo.boehm 1.3 CIMType& type,
2832 const SCMBUnion** pOutVal,
2833 Boolean& isArray,
2834 Uint32& size ) const
|
2835 thilo.boehm 1.1 {
|
2836 thilo.boehm 1.2 Uint32 node;
|
2837 thilo.boehm 1.3 const char* pname;
2838 SCMO_RC rc = SCMO_OK;
2839
2840 *pOutVal = 0;
2841 isArray = false;
2842 size = 0;
|
2843 thilo.boehm 1.1
|
2844 thilo.boehm 1.3 rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
|
2845 thilo.boehm 1.2 if (rc != SCMO_OK)
|
2846 thilo.boehm 1.1 {
|
2847 thilo.boehm 1.2 return rc;
|
2848 thilo.boehm 1.1 }
2849
|
2850 thilo.boehm 1.3 return _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size);
|
2851 thilo.boehm 1.2 }
|
2852 thilo.boehm 1.1
|
2853 thilo.boehm 1.3 SCMO_RC SCMOInstance::getPropertyAt(
2854 Uint32 idx,
2855 const char** pname,
2856 CIMType& type,
2857 const SCMBUnion** pOutVal,
2858 Boolean& isArray,
2859 Uint32& size ) const
|
2860 thilo.boehm 1.2 {
|
2861 thilo.boehm 1.3 *pname = 0;
2862 *pOutVal = 0;
2863 isArray = false;
2864 size = 0;
2865
|
2866 anusha.kandepu 1.14 if (idx >= inst.hdr->numberProperties)
|
2867 thilo.boehm 1.3 {
|
2868 anusha.kandepu 1.14 return SCMO_INDEX_OUT_OF_BOUND;
|
2869 thilo.boehm 1.3 }
|
2870 thilo.boehm 1.1
|
2871 anusha.kandepu 1.14 return _getPropertyAtNodeIndex(idx,pname,type,pOutVal,isArray,size);
|
2872 thilo.boehm 1.3 }
|
2873 thilo.boehm 1.1
|
2874 thilo.boehm 1.3 SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const
2875 {
2876 SCMO_RC rc;
2877 if(name==0)
|
2878 thilo.boehm 1.2 {
|
2879 thilo.boehm 1.3 return SCMO_INVALID_PARAMETER;
|
2880 thilo.boehm 1.2 }
|
2881 thilo.boehm 1.1
|
2882 thilo.boehm 1.3 rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
|
2883 thilo.boehm 1.1
|
2884 thilo.boehm 1.3 return rc;
|
2885 thilo.boehm 1.1
2886 }
2887
|
2888 thilo.boehm 1.3 SCMO_RC SCMOInstance::setPropertyWithOrigin(
|
2889 thilo.boehm 1.2 const char* name,
|
2890 thilo.boehm 1.3 CIMType type,
2891 const SCMBUnion* pInVal,
2892 Boolean isArray,
2893 Uint32 size,
2894 const char* origin)
|
2895 thilo.boehm 1.1 {
|
2896 thilo.boehm 1.3 // In this function no _copyOnWrite(), it does not change the instance.
2897
2898 Uint32 node;
|
2899 thilo.boehm 1.2 SCMO_RC rc;
|
2900 thilo.boehm 1.3 CIMType realType;
2901
2902 rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
2903 if (rc != SCMO_OK)
2904 {
2905 return rc;
2906 }
|
2907 thilo.boehm 1.1
|
2908 thilo.boehm 1.3 // Is the traget type OK ?
2909 // The type stored in the class information is set on realType.
2910 // It must be used in further calls to guaranty consistence.
2911 rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType);
|
2912 thilo.boehm 1.1 if (rc != SCMO_OK)
2913 {
2914 return rc;
2915 }
2916
|
2917 thilo.boehm 1.3 // check class origin if set.
2918 if (origin!= 0)
|
2919 thilo.boehm 1.1 {
|
2920 thilo.boehm 1.3 if(!inst.hdr->theClass.ptr->_isSamePropOrigin(node,origin))
2921 {
2922 return SCMO_NOT_SAME_ORIGIN;
2923 }
|
2924 thilo.boehm 1.1 }
2925
|
2926 thilo.boehm 1.2
|
2927 thilo.boehm 1.3 _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
|
2928 thilo.boehm 1.2
2929 return SCMO_OK;
|
2930 thilo.boehm 1.3 }
2931
2932 SCMO_RC SCMOInstance::setPropertyWithNodeIndex(
2933 Uint32 node,
2934 CIMType type,
2935 const SCMBUnion* pInVal,
2936 Boolean isArray,
2937 Uint32 size)
2938 {
2939 // In this function no _copyOnWrite(), it does not change the instance.
2940
2941 SCMO_RC rc;
2942 CIMType realType;
2943
2944 if (node >= inst.hdr->numberProperties)
2945 {
2946 return SCMO_INDEX_OUT_OF_BOUND;
2947 }
2948
2949 // Is the traget type OK ?
2950 // The type stored in the class information is set on realType.
2951 thilo.boehm 1.3 // It must be used in further calls to guaranty consistence.
2952 rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType);
2953 if (rc != SCMO_OK)
2954 {
2955 return rc;
2956 }
2957
2958 _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
|
2959 thilo.boehm 1.2
|
2960 thilo.boehm 1.3 return SCMO_OK;
|
2961 thilo.boehm 1.1 }
2962
|
2963 thilo.boehm 1.3 void SCMOInstance::_setPropertyAtNodeIndex(
2964 Uint32 node,
2965 CIMType type,
2966 const SCMBUnion* pInVal,
2967 Boolean isArray,
2968 Uint32 size)
|
2969 thilo.boehm 1.1 {
|
2970 thilo.boehm 1.2
|
2971 thilo.boehm 1.3 _copyOnWrite();
2972
2973 SCMBValue* theInstPropNodeArray =
2974 (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
2975
2976
2977 theInstPropNodeArray[node].flags.isSet=true;
2978 theInstPropNodeArray[node].valueType=type;
2979 theInstPropNodeArray[node].flags.isArray=isArray;
2980 if (isArray)
2981 {
2982 theInstPropNodeArray[node].valueArraySize=size;
2983 }
|
2984 thilo.boehm 1.1
|
2985 thilo.boehm 1.3 if (pInVal==0)
2986 {
2987 theInstPropNodeArray[node].flags.isNull=true;
2988 }
2989 else
|
2990 thilo.boehm 1.1 {
|
2991 thilo.boehm 1.3 theInstPropNodeArray[node].flags.isNull=false;
2992 _setSCMBUnion(
2993 pInVal,
2994 type,
2995 isArray,
2996 size,
2997 theInstPropNodeArray[node].value);
2998 }
2999 }
|
3000 thilo.boehm 1.2
|
3001 thilo.boehm 1.3 void SCMOInstance::_setSCMBUnion(
3002 const SCMBUnion* pInVal,
3003 CIMType type,
3004 Boolean isArray,
3005 Uint32 size,
3006 SCMBUnion & u)
3007 {
3008
3009 switch (type)
3010 {
3011 case CIMTYPE_BOOLEAN:
3012 case CIMTYPE_UINT8:
3013 case CIMTYPE_SINT8:
3014 case CIMTYPE_UINT16:
3015 case CIMTYPE_SINT16:
3016 case CIMTYPE_UINT32:
3017 case CIMTYPE_SINT32:
3018 case CIMTYPE_UINT64:
3019 case CIMTYPE_SINT64:
3020 case CIMTYPE_REAL32:
3021 case CIMTYPE_REAL64:
3022 thilo.boehm 1.3 case CIMTYPE_CHAR16:
3023 {
3024 if (isArray)
3025 {
3026 _setBinary(pInVal,size*sizeof(SCMBUnion),
3027 u.arrayValue,
3028 &inst.mem );
3029 }
3030 else
3031 {
3032 memcpy(&u,pInVal,sizeof(SCMBUnion));
3033 u.simple.hasValue=true;
3034 }
3035 break;
3036 }
3037 case CIMTYPE_DATETIME:
3038 {
3039 if (isArray)
3040 {
3041 _setBinary(pInVal,size*sizeof(SCMBUnion),
3042 u.arrayValue,
3043 thilo.boehm 1.3 &inst.mem );
3044 }
3045 else
3046 {
3047 memcpy(&u,pInVal,sizeof(SCMBUnion));
3048
3049 }
3050 break;
3051 }
3052 case CIMTYPE_STRING:
3053 {
3054 if (isArray)
3055 {
3056 SCMBUnion* ptr;
3057 Uint64 startPtr;
3058
3059 startPtr = _getFreeSpace(
3060 u.arrayValue,
3061 size*sizeof(SCMBUnion),
3062 &inst.mem);
3063
3064 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
3065 {
3066 ptr = (SCMBUnion*)&(inst.base[startPtr]);
3067 // Copy the sting including the trailing '\0'
3068 _setBinary(
3069 pInVal[i].extString.pchar,
3070 pInVal[i].extString.length+1,
3071 ptr[i].stringValue,
3072 &inst.mem );
3073 }
3074 }
3075 else
3076 {
3077 // Copy the sting including the trailing '\0'
3078 _setBinary(
3079 pInVal->extString.pchar,
3080 pInVal->extString.length+1,
3081 u.stringValue,
3082 &inst.mem );
3083 }
3084 break;
3085 thilo.boehm 1.3 }
3086
3087 case CIMTYPE_REFERENCE:
3088 case CIMTYPE_OBJECT:
3089 case CIMTYPE_INSTANCE:
3090 {
3091 if(isArray)
3092 {
3093 SCMBUnion* ptr;
3094 Uint64 startPtr;
3095
3096 // if the array was previously set, delete the references !
3097 _deleteArrayExtReference(u.arrayValue,&inst.mem);
3098
3099 // get new array
3100 startPtr = _getFreeSpace(
3101 u.arrayValue,
3102 size*sizeof(SCMBUnion),
3103 &inst.mem);
3104
3105 ptr = (SCMBUnion*)&(inst.base[startPtr]);
3106 thilo.boehm 1.3
3107 for (Uint32 i = 0 ; i < size ; i++)
3108 {
3109 if(pInVal[i].extRefPtr)
3110 {
3111 ptr[i].extRefPtr=
3112 new SCMOInstance(*(pInVal[i].extRefPtr));
3113
3114 // This function can cause a reallocation !
3115 // Pointers can be invalid after the call.
3116 _setExtRefIndex(&(ptr[i]),&inst.mem);
3117 }
3118 else
3119 {
3120 ptr[i].extRefPtr = 0;
3121 }
3122 }
3123
3124 }
3125 else
3126 {
3127 thilo.boehm 1.3 if(0 != u.extRefPtr)
3128 {
3129 delete u.extRefPtr;
3130 }
3131
3132 if(pInVal->extRefPtr)
3133 {
3134 u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr));
3135 // This function can cause a reallocation !
3136 // Pointers can be invalid after the call.
3137 _setExtRefIndex(&u,&inst.mem);
3138
3139 }
3140 else
3141 {
3142 u.extRefPtr = 0;
3143 }
3144 }
3145 break;
3146 }
3147 default:
3148 thilo.boehm 1.3 {
3149 PEGASUS_ASSERT(false);
3150 break;
3151 }
3152 }
3153 }
3154
3155 void SCMOInstance::_setUnionArrayValue(
3156 Uint64 start,
3157 SCMBMgmt_Header** pmem,
3158 CIMType type,
3159 Uint32& n,
3160 Uint64 startNS,
3161 Uint32 sizeNS,
3162 Union& u)
3163 {
3164 SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
3165 SCMBUnion* ptargetUnion;
3166 Uint64 arrayStart;
3167 Uint32 loop;
3168
3169 thilo.boehm 1.3 switch (type)
3170 {
3171 case CIMTYPE_BOOLEAN:
3172 {
3173 Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u);
3174 // n can be invalid after re-allocation in _getFreeSpace !
3175 loop = n = x->size();
3176 arrayStart = _getFreeSpace(
3177 scmoUnion->arrayValue,
3178 loop*sizeof(SCMBUnion),
3179 pmem);
3180
3181 ConstArrayIterator<Boolean> iterator(*x);
3182
3183 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3184 for (Uint32 i = 0; i < loop; i++)
3185 {
3186 ptargetUnion[i].simple.val.bin = iterator[i];
3187 ptargetUnion[i].simple.hasValue = true;
3188 }
3189 break;
3190 thilo.boehm 1.3 }
3191
3192 case CIMTYPE_UINT8:
3193 {
3194 Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u);
3195 // n can be invalid after re-allocation in _getFreeSpace !
3196 loop = n = x->size();
3197 arrayStart = _getFreeSpace(
3198 scmoUnion->arrayValue,
3199 loop*sizeof(SCMBUnion),
3200 pmem);
3201
3202 ConstArrayIterator<Uint8> iterator(*x);
3203
3204 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3205 for (Uint32 i = 0; i < loop; i++)
3206 {
3207 ptargetUnion[i].simple.val.u8 = iterator[i];
3208 ptargetUnion[i].simple.hasValue = true;
3209 }
3210 break;
3211 thilo.boehm 1.3 }
3212
3213 case CIMTYPE_SINT8:
3214 {
3215 Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u);
3216 // n can be invalid after re-allocation in _getFreeSpace !
3217 loop = n = x->size();
3218 arrayStart = _getFreeSpace(
3219 scmoUnion->arrayValue,
3220 loop*sizeof(SCMBUnion),
3221 pmem);
3222
3223 ConstArrayIterator<Sint8> iterator(*x);
3224
3225 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3226 for (Uint32 i = 0; i < loop; i++)
3227 {
3228 ptargetUnion[i].simple.val.s8 = iterator[i];
3229 ptargetUnion[i].simple.hasValue = true;
3230 }
3231 break;
3232 thilo.boehm 1.3 }
3233
3234 case CIMTYPE_UINT16:
3235 {
3236 Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u);
3237 // n can be invalid after re-allocation in _getFreeSpace !
3238 loop = n = x->size();
3239 arrayStart = _getFreeSpace(
3240 scmoUnion->arrayValue,
3241 loop*sizeof(SCMBUnion),
3242 pmem);
3243
3244 ConstArrayIterator<Uint16> iterator(*x);
3245
3246 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3247 for (Uint32 i = 0; i < loop; i++)
3248 {
3249 ptargetUnion[i].simple.val.u16 = iterator[i];
3250 ptargetUnion[i].simple.hasValue = true;
3251 }
3252 break;
3253 thilo.boehm 1.3 }
3254
3255 case CIMTYPE_SINT16:
3256 {
3257 Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u);
3258 // n can be invalid after re-allocation in _getFreeSpace !
3259 loop = n = x->size();
3260 arrayStart = _getFreeSpace(
3261 scmoUnion->arrayValue,
3262 loop*sizeof(SCMBUnion),
3263 pmem);
3264
3265 ConstArrayIterator<Sint16> iterator(*x);
3266
3267 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3268 for (Uint32 i = 0; i < loop; i++)
3269 {
3270 ptargetUnion[i].simple.val.s16 = iterator[i];
3271 ptargetUnion[i].simple.hasValue = true;
3272 }
3273 break;
3274 thilo.boehm 1.3 }
3275
3276 case CIMTYPE_UINT32:
3277 {
3278 Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u);
3279 // n can be invalid after re-allocation in _getFreeSpace !
3280 loop = n = x->size();
3281 arrayStart = _getFreeSpace(
3282 scmoUnion->arrayValue,
3283 loop*sizeof(SCMBUnion),
3284 pmem);
3285
3286 ConstArrayIterator<Uint32> iterator(*x);
3287
3288 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3289 for (Uint32 i = 0; i < loop; i++)
3290 {
3291 ptargetUnion[i].simple.val.u32 = iterator[i];
3292 ptargetUnion[i].simple.hasValue = true;
3293 }
3294 break;
3295 thilo.boehm 1.3 }
3296
3297 case CIMTYPE_SINT32:
3298 {
3299 Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u);
3300 // n can be invalid after re-allocation in _getFreeSpace !
3301 loop = n = x->size();
3302 arrayStart = _getFreeSpace(
3303 scmoUnion->arrayValue,
3304 loop*sizeof(SCMBUnion),
3305 pmem);
3306
3307 ConstArrayIterator<Sint32> iterator(*x);
3308
3309 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3310 for (Uint32 i = 0; i < loop; i++)
3311 {
3312 ptargetUnion[i].simple.val.s32 = iterator[i];
3313 ptargetUnion[i].simple.hasValue = true;
3314 }
3315 break;
3316 thilo.boehm 1.3 }
3317
3318 case CIMTYPE_UINT64:
3319 {
3320 Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u);
3321 // n can be invalid after re-allocation in _getFreeSpace !
3322 loop = n = x->size();
3323 arrayStart = _getFreeSpace(
3324 scmoUnion->arrayValue,
3325 loop*sizeof(SCMBUnion),
3326 pmem);
3327
3328 ConstArrayIterator<Uint64> iterator(*x);
3329
3330 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3331 for (Uint32 i = 0; i < loop; i++)
3332 {
3333 ptargetUnion[i].simple.val.u64 = iterator[i];
3334 ptargetUnion[i].simple.hasValue = true;
3335 }
3336 break;
3337 thilo.boehm 1.3 }
3338
3339 case CIMTYPE_SINT64:
3340 {
3341 Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u);
3342 // n can be invalid after re-allocation in _getFreeSpace !
3343 loop = n = x->size();
3344 arrayStart = _getFreeSpace(
3345 scmoUnion->arrayValue,
3346 loop*sizeof(SCMBUnion),
3347 pmem);
3348
3349 ConstArrayIterator<Sint64> iterator(*x);
3350
3351 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3352 for (Uint32 i = 0; i < loop; i++)
3353 {
3354 ptargetUnion[i].simple.val.s64 = iterator[i];
3355 ptargetUnion[i].simple.hasValue = true;
3356 }
3357 break;
3358 thilo.boehm 1.3 }
3359
3360 case CIMTYPE_REAL32:
3361 {
3362 Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u);
3363 // n can be invalid after re-allocation in _getFreeSpace !
3364 loop = n = x->size();
3365 arrayStart = _getFreeSpace(
3366 scmoUnion->arrayValue,
3367 loop*sizeof(SCMBUnion),
3368 pmem);
3369
3370 ConstArrayIterator<Real32> iterator(*x);
3371
3372 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3373 for (Uint32 i = 0; i < loop; i++)
3374 {
3375 ptargetUnion[i].simple.val.r32 = iterator[i];
3376 ptargetUnion[i].simple.hasValue = true;
3377 }
3378 break;
3379 thilo.boehm 1.3 }
3380
3381 case CIMTYPE_REAL64:
3382 {
3383 Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u);
3384 // n can be invalid after re-allocation in _getFreeSpace !
3385 loop = n = x->size();
3386 arrayStart = _getFreeSpace(
3387 scmoUnion->arrayValue,
3388 loop*sizeof(SCMBUnion),
3389 pmem);
3390
3391 ConstArrayIterator<Real64> iterator(*x);
3392
3393 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3394 for (Uint32 i = 0; i < loop; i++)
3395 {
3396 ptargetUnion[i].simple.val.r64 = iterator[i];
3397 ptargetUnion[i].simple.hasValue = true;
3398 }
3399 break;
3400 thilo.boehm 1.3 }
3401
3402 case CIMTYPE_CHAR16:
3403 {
3404 Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u);
3405 // n can be invalid after re-allocation in _getFreeSpace !
3406 loop = n = x->size();
3407 arrayStart = _getFreeSpace(
3408 scmoUnion->arrayValue,
3409 loop*sizeof(SCMBUnion),
3410 pmem);
3411
3412 ConstArrayIterator<Char16> iterator(*x);
3413
3414 ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
3415 for (Uint32 i = 0; i < loop; i++)
3416 {
3417 ptargetUnion[i].simple.val.c16 = iterator[i];
3418 ptargetUnion[i].simple.hasValue = true;
3419 }
3420 break;
3421 thilo.boehm 1.3 }
3422
3423 case CIMTYPE_STRING:
3424 {
3425 Array<String> *x = reinterpret_cast<Array<String>*>(&u);
3426 // n can be invalid after re-allocation in _getFreeSpace !
3427 loop = n = x->size();
3428
3429 arrayStart = _getFreeSpace(
3430 scmoUnion->arrayValue,
3431 loop*sizeof(SCMBUnion),
3432 pmem);
3433
3434 ConstArrayIterator<String> iterator(*x);
3435
3436 for (Uint32 i = 0; i < loop ; i++)
3437 {
3438 // the pointer has to be set eache loop,
3439 // because a reallocation may take place.
3440 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3441 _setString( iterator[i],ptargetUnion[i].stringValue, pmem );
3442 thilo.boehm 1.3 }
3443
3444 break;
3445 }
3446
3447 case CIMTYPE_DATETIME:
3448 {
3449 Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u);
3450 // n can be invalid after reallocation in _getFreeSpace !
3451 loop = n = x->size();
3452
3453 arrayStart = _getFreeSpace(
3454 scmoUnion->arrayValue,
3455 loop*sizeof(SCMBUnion),
3456 pmem);
3457
3458 ConstArrayIterator<CIMDateTime> iterator(*x);
3459
3460 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3461
3462 for (Uint32 i = 0; i < loop ; i++)
3463 thilo.boehm 1.3 {
3464 memcpy(
3465 &(ptargetUnion[i].dateTimeValue),
3466 iterator[i]._rep,
3467 sizeof(SCMBDateTime));
3468 }
3469 break;
3470 }
3471
3472 case CIMTYPE_REFERENCE:
3473 {
3474 Array<CIMObjectPath> *x =
3475 reinterpret_cast<Array<CIMObjectPath>*>(&u);
3476
3477 // if the array was previously set, delete the references !
3478 _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
3479
3480 // n can be invalid after reallocation in _getFreeSpace !
3481 loop = n = x->size();
3482
3483 arrayStart = _getFreeSpace(
3484 thilo.boehm 1.3 scmoUnion->arrayValue,
3485 loop*sizeof(SCMBUnion),
3486 pmem);
3487
3488 ConstArrayIterator<CIMObjectPath> iterator(*x);
3489
3490 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3491
3492 for (Uint32 i = 0; i < loop ; i++)
3493 {
3494
3495 ptargetUnion[i].extRefPtr =
3496 new SCMOInstance(
3497 iterator[i],
3498 &(((const char*)*pmem)[startNS]),
3499 sizeNS-1);
3500 // Was the conversion successful?
3501 if (ptargetUnion[i].extRefPtr->isEmpty())
3502 {
3503 // N0, delete the SCMOInstance.
3504 delete ptargetUnion[i].extRefPtr;
3505 thilo.boehm 1.3 ptargetUnion[i].extRefPtr = 0;
3506 }
3507 else
3508 {
3509 _setExtRefIndex(&(ptargetUnion[i]),pmem);
3510 }
3511 }
3512
3513 break;
3514 }
3515 case CIMTYPE_OBJECT:
3516 {
3517 Array<CIMObject> *x =
3518 reinterpret_cast<Array<CIMObject>*>(&u);
3519
3520 // if the array was previously set, delete the references !
3521 _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
3522
3523 // n can be invalid after reallocation in _getFreeSpace !
3524 loop = n = x->size();
3525
3526 thilo.boehm 1.3 arrayStart = _getFreeSpace(
3527 scmoUnion->arrayValue,
3528 loop*sizeof(SCMBUnion),
3529 pmem);
3530
3531 ConstArrayIterator<CIMObject> iterator(*x);
3532
3533 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3534
3535 for (Uint32 i = 0; i < loop ; i++)
3536 {
3537 if (iterator[i].isUninitialized())
3538 {
3539 // the Object was empty.
3540 ptargetUnion[i].extRefPtr = 0;
3541 }
3542 else
3543 {
3544 if (iterator[i].isClass())
3545 {
3546 CIMClass cimClass(iterator[i]);
3547 thilo.boehm 1.3
3548 ptargetUnion[i].extRefPtr =
3549 new SCMOInstance(
3550 cimClass,
3551 (&((const char*)*pmem)[startNS]));
3552 // marke as class only !
3553 ptargetUnion[i].extRefPtr->
3554 inst.hdr->flags.isClassOnly=true;
3555
3556 // This function can cause a reallocation !
3557 // Pointers can be invalid after the call.
3558 _setExtRefIndex(&(ptargetUnion[i]),pmem);
3559 }
3560 else
3561 {
3562 CIMInstance theInst(iterator[i]);
3563
3564 ptargetUnion[i].extRefPtr =
3565 new SCMOInstance(
3566 theInst,
3567 &(((const char*)*pmem)[startNS]),
3568 thilo.boehm 1.3 sizeNS-1);
3569 // Was the conversion successful?
3570 if (ptargetUnion[i].extRefPtr->isEmpty())
3571 {
3572 // N0, delete the SCMOInstance.
3573 delete ptargetUnion[i].extRefPtr;
3574 ptargetUnion[i].extRefPtr = 0;
3575 }
3576 else
3577 {
3578 // This function can cause a reallocation !
3579 // Pointers can be invalid after the call.
3580 _setExtRefIndex(&(ptargetUnion[i]),pmem);
3581 }
3582 }
3583 }
3584 }
3585
3586 break;
3587 }
3588 case CIMTYPE_INSTANCE:
3589 thilo.boehm 1.3 {
3590 Array<CIMInstance> *x =
3591 reinterpret_cast<Array<CIMInstance>*>(&u);
3592
3593 // if the array was previously set, delete the references !
3594 _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
3595
3596 // n can be invalid after reallocation in _getFreeSpace !
3597 loop = n = x->size();
3598
3599 arrayStart = _getFreeSpace(
3600 scmoUnion->arrayValue,
3601 loop*sizeof(SCMBUnion),
3602 pmem);
3603
3604 ConstArrayIterator<CIMInstance> iterator(*x);
3605
3606 ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
3607
3608 for (Uint32 i = 0; i < loop ; i++)
3609 {
3610 thilo.boehm 1.3 if (iterator[i].isUninitialized())
3611 {
3612 // the Instance was empty.
3613 ptargetUnion[i].extRefPtr = 0;
3614 }
3615 else
3616 {
3617 ptargetUnion[i].extRefPtr =
3618 new SCMOInstance(
3619 iterator[i],
3620 &(((const char*)*pmem)[startNS]),
3621 sizeNS-1);
3622 // Was the conversion successful?
3623 if (ptargetUnion[i].extRefPtr->isEmpty())
3624 {
3625 // N0, delete the SCMOInstance.
3626 delete ptargetUnion[i].extRefPtr;
3627 ptargetUnion[i].extRefPtr = 0;
3628 }
3629 else
3630 {
3631 thilo.boehm 1.3 // This function can cause a reallocation !
3632 // Pointers can be invalid after the call.
3633 _setExtRefIndex(&(ptargetUnion[i]),pmem);
3634 }
3635
3636 }
3637 }
3638
3639 break;
3640 }
3641 default:
3642 {
3643 PEGASUS_ASSERT(false);
3644 break;
3645 }
3646 }
3647 }
3648
3649
3650 void SCMOInstance::_setUnionValue(
3651 Uint64 start,
3652 thilo.boehm 1.3 SCMBMgmt_Header** pmem,
3653 CIMType type,
3654 Uint64 startNS,
3655 Uint32 sizeNS,
3656 Union& u)
3657 {
3658 SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
3659
3660 switch (type)
3661 {
3662 case CIMTYPE_BOOLEAN:
3663 {
3664 scmoUnion->simple.val.bin = u._booleanValue;
3665 scmoUnion->simple.hasValue=true;
3666 break;
3667 }
3668
3669 case CIMTYPE_UINT8:
3670 {
3671 scmoUnion->simple.val.u8 = u._uint8Value;
3672 scmoUnion->simple.hasValue=true;
3673 thilo.boehm 1.3 break;
3674 }
3675
3676 case CIMTYPE_SINT8:
3677 {
3678 scmoUnion->simple.val.s8 = u._sint8Value;
3679 scmoUnion->simple.hasValue=true;
3680 break;
3681 }
3682
3683 case CIMTYPE_UINT16:
3684 {
3685 scmoUnion->simple.val.u16 = u._uint16Value;
3686 scmoUnion->simple.hasValue=true;
3687 break;
3688 }
3689
3690 case CIMTYPE_SINT16:
3691 {
3692 scmoUnion->simple.val.s16 = u._sint16Value;
3693 scmoUnion->simple.hasValue=true;
3694 thilo.boehm 1.3 break;
3695 }
3696
3697 case CIMTYPE_UINT32:
3698 {
3699 scmoUnion->simple.val.u32 = u._uint32Value;
3700 scmoUnion->simple.hasValue=true;
3701 break;
3702 }
3703
3704 case CIMTYPE_SINT32:
3705 {
3706 scmoUnion->simple.val.s32 = u._sint32Value;
3707 scmoUnion->simple.hasValue=true;
3708 break;
3709 }
3710
3711 case CIMTYPE_UINT64:
3712 {
3713 scmoUnion->simple.val.u64 = u._uint64Value;
3714 scmoUnion->simple.hasValue=true;
3715 thilo.boehm 1.3 break;
3716 }
3717
3718 case CIMTYPE_SINT64:
3719 {
3720 scmoUnion->simple.val.s64 = u._sint64Value;
3721 scmoUnion->simple.hasValue=true;
3722 break;
3723 }
3724
3725 case CIMTYPE_REAL32:
3726 {
3727 scmoUnion->simple.val.r32 = u._real32Value;
3728 scmoUnion->simple.hasValue=true;
3729 break;
3730 }
3731
3732 case CIMTYPE_REAL64:
3733 {
3734 scmoUnion->simple.val.r64 = u._real64Value;
3735 scmoUnion->simple.hasValue=true;
3736 thilo.boehm 1.3 break;
3737 }
3738
3739 case CIMTYPE_CHAR16:
3740 {
3741 scmoUnion->simple.val.c16 = u._char16Value;
3742 scmoUnion->simple.hasValue=true;
3743 break;
3744 }
3745
3746 case CIMTYPE_STRING:
3747 {
|
3748 venkat.puvvada 1.14.2.2 CString cstr = ((String*)((void*)&u))->getCString();
3749 const char *cptr = (const char*)cstr;
3750 _setBinary(
3751 cptr,
3752 strlen(cptr) + 1,
3753 scmoUnion->stringValue,
3754 pmem );
|
3755 thilo.boehm 1.3 break;
3756 }
3757
3758 case CIMTYPE_DATETIME:
3759 {
3760 memcpy(
3761 &scmoUnion->dateTimeValue,
3762 (*((CIMDateTime*)((void*)&u)))._rep,
3763 sizeof(SCMBDateTime));
3764 break;
3765 }
3766
3767 case CIMTYPE_REFERENCE:
3768 {
3769 if (0 != scmoUnion->extRefPtr)
3770 {
3771 delete scmoUnion->extRefPtr;
3772 scmoUnion->extRefPtr = 0;
3773 }
3774
3775 if (0 == u._referenceValue)
3776 thilo.boehm 1.3 {
3777 scmoUnion->extRefPtr = 0;
3778 return;
3779 }
3780
3781 CIMObjectPath* theCIMObj =
3782 (CIMObjectPath*)((void*)&u._referenceValue);
3783
3784 scmoUnion->extRefPtr =
3785 new SCMOInstance(
3786 *theCIMObj,
3787 &(((const char*)*pmem)[startNS]),
3788 sizeNS-1);
3789
3790 // Was the conversion successful?
3791 if (scmoUnion->extRefPtr->isEmpty())
3792 {
3793 // N0, delete the SCMOInstance.
3794 delete scmoUnion->extRefPtr;
3795 scmoUnion->extRefPtr = 0;
3796 }
3797 thilo.boehm 1.3 else
3798 {
3799 // This function can cause a reallocation !
3800 // Pointers can be invalid after the call.
3801 _setExtRefIndex(scmoUnion,pmem);
3802 }
3803
3804 break;
3805 }
3806 case CIMTYPE_OBJECT:
3807 {
3808 if (0 != scmoUnion->extRefPtr)
3809 {
3810 delete scmoUnion->extRefPtr;
3811 scmoUnion->extRefPtr = 0;
3812 }
3813
3814 if (0 == u._referenceValue)
3815 {
3816 scmoUnion->extRefPtr=0;
3817 return;
3818 thilo.boehm 1.3 }
3819
3820 CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue);
3821
3822 if (theCIMObject->isUninitialized())
3823 {
3824 // the Object was empty.
3825 scmoUnion->extRefPtr = 0;
3826 }
3827 else
3828 {
3829 if (theCIMObject->isClass())
3830 {
3831 CIMClass cimClass(*theCIMObject);
3832
3833 scmoUnion->extRefPtr =
3834 new SCMOInstance(
3835 cimClass,
3836 (&((const char*)*pmem)[startNS]));
3837 // marke as class only !
3838 scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true;
3839 thilo.boehm 1.3
3840 // This function can cause a reallocation !
3841 // Pointers can be invalid after the call.
3842 _setExtRefIndex(scmoUnion,pmem);
3843 }
3844 else
3845 {
3846 CIMInstance theCIMInst(*theCIMObject);
3847
3848 scmoUnion->extRefPtr =
3849 new SCMOInstance(
3850 theCIMInst,
3851 &(((const char*)*pmem)[startNS]),
3852 sizeNS-1);
3853
3854 // Was the conversion successful?
3855 if (scmoUnion->extRefPtr->isEmpty())
3856 {
3857 // N0, delete the SCMOInstance.
3858 delete scmoUnion->extRefPtr;
3859 scmoUnion->extRefPtr = 0;
3860 thilo.boehm 1.3 }
3861 else
3862 {
3863 // This function can cause a reallocation !
3864 // Pointers can be invalid after the call.
3865 _setExtRefIndex(scmoUnion,pmem);
3866 }
3867 }
3868 }
3869 break;
3870 }
3871 case CIMTYPE_INSTANCE:
3872 {
3873 if (0 != scmoUnion->extRefPtr)
3874 {
3875 delete scmoUnion->extRefPtr;
3876 scmoUnion->extRefPtr = 0;
3877 }
3878
3879 if (0 == u._referenceValue)
3880 {
3881 thilo.boehm 1.3 scmoUnion->extRefPtr=0;
3882 return;
3883 }
3884
3885 CIMInstance* theCIMInst =
3886 (CIMInstance*)((void*)&u._instanceValue);
3887
3888 if (theCIMInst->isUninitialized())
3889 {
3890 // the Instance was empty.
3891 scmoUnion->extRefPtr = 0;
3892 }
3893 else
3894 {
3895 scmoUnion->extRefPtr =
3896 new SCMOInstance(
3897 *theCIMInst,
3898 &(((const char*)*pmem)[startNS]),
3899 sizeNS-1);
3900
3901 // Was the conversion successful?
3902 thilo.boehm 1.3 if (scmoUnion->extRefPtr->isEmpty())
3903 {
3904 // N0, delete the SCMOInstance.
3905 delete scmoUnion->extRefPtr;
3906 scmoUnion->extRefPtr = 0;
3907 }
3908 else
3909 {
3910 // This function can cause a reallocation !
3911 // Pointers can be invalid after the call.
3912 _setExtRefIndex(scmoUnion,pmem);
3913 }
3914 }
3915 break;
3916 }
3917 default:
3918 {
3919 PEGASUS_ASSERT(false);
3920 break;
3921 }
3922 }
3923 thilo.boehm 1.3 }
3924
3925 SCMO_RC SCMOInstance::_getPropertyAtNodeIndex(
3926 Uint32 node,
3927 const char** pname,
3928 CIMType& type,
3929 const SCMBUnion** pvalue,
3930 Boolean& isArray,
3931 Uint32& size ) const
3932 {
3933 SCMBValue* theInstPropNodeArray =
3934 (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
3935
3936 // create a pointer to property node array of the class.
3937 Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start;
3938 SCMBClassPropertyNode* theClassPropNodeArray =
3939 (SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx];
3940
3941 // the property name is always from the class.
3942 // return the absolut pointer to the property name,
3943 // the caller has to copy the name!
3944 thilo.boehm 1.3 *pname=_getCharString(
3945 theClassPropNodeArray[node].theProperty.name,
3946 inst.hdr->theClass.ptr->cls.base);
3947
3948 // the property was set by the provider.
3949 if (theInstPropNodeArray[node].flags.isSet)
3950 {
3951
3952 type = theInstPropNodeArray[node].valueType;
3953 isArray = theInstPropNodeArray[node].flags.isArray;
3954 if (isArray)
3955 {
3956 size = theInstPropNodeArray[node].valueArraySize;
3957 }
3958
3959 if (theInstPropNodeArray[node].flags.isNull)
3960 {
3961 return SCMO_NULL_VALUE;
3962 }
3963
3964 // calculate the relative index for the value.
3965 thilo.boehm 1.3 Uint64 start =
3966 (const char*)&(theInstPropNodeArray[node].value) -
3967 inst.base;
3968
3969 // the caller has to copy the value !
3970 *pvalue = _resolveSCMBUnion(type,isArray,size,start,inst.base);
3971
3972 return SCMO_OK;
3973 }
3974
3975 // the get the defaults out of the class.
3976 type = theClassPropNodeArray[node].theProperty.defaultValue.valueType;
3977 isArray =
3978 theClassPropNodeArray[node].theProperty.defaultValue.flags.isArray;
3979 if (isArray)
3980 {
3981 size = theClassPropNodeArray[node].
3982 theProperty.defaultValue.valueArraySize;
3983 }
3984
3985 if (theClassPropNodeArray[node].theProperty.defaultValue.flags.isNull)
3986 thilo.boehm 1.3 {
3987 return SCMO_NULL_VALUE;
3988 }
3989
3990 // calcutate the relativ start address of the value
3991 Uint64 start =
3992 (const char*)
3993 &(theClassPropNodeArray[node].theProperty.defaultValue.value) -
3994 (inst.hdr->theClass.ptr->cls.base);
3995
3996 *pvalue = _resolveSCMBUnion(
3997 type,
3998 isArray,
3999 size,
4000 start,
4001 (inst.hdr->theClass.ptr->cls.base)
4002 );
4003
4004 return SCMO_OK;
4005
4006 }
4007 thilo.boehm 1.3
4008 SCMOInstance SCMOInstance::clone(Boolean objectPathOnly) const
4009 {
4010 if (objectPathOnly)
4011 {
4012 // Create a new, empty SCMOInstance
4013 SCMOInstance newInst(*(this->inst.hdr->theClass.ptr));
4014
4015 // Copy the host name to tha new instance-
4016 _setBinary(
4017 _resolveDataPtr(this->inst.hdr->hostName,this->inst.base),
4018 this->inst.hdr->hostName.size,
4019 newInst.inst.hdr->hostName,
4020 &newInst.inst.mem);
4021
4022 newInst.inst.hdr->flags.isCompromised =
4023 this->inst.hdr->flags.isCompromised;
4024
4025 // If the instance contains a user set class and/or name space name
4026 if (this->inst.hdr->flags.isCompromised)
4027 {
4028 thilo.boehm 1.3 // Copy the class name to tha new instance-
4029 _setBinary(
4030 _resolveDataPtr(this->inst.hdr->instClassName,this->inst.base),
4031 this->inst.hdr->instClassName.size,
4032 newInst.inst.hdr->instClassName,
4033 &newInst.inst.mem);
4034
4035 // Copy the name space name to tha new instance-
4036 _setBinary(
4037 _resolveDataPtr(this->inst.hdr->instNameSpace,this->inst.base),
4038 this->inst.hdr->instNameSpace.size,
4039 newInst.inst.hdr->instNameSpace,
4040 &newInst.inst.mem);
4041 }
4042
4043 // Copy the key bindings to that new instance.
4044 this->_copyKeyBindings(newInst);
4045
4046 return newInst;
4047 }
4048
4049 thilo.boehm 1.3 SCMOInstance newInst;
4050 newInst.inst.base = inst.base;
4051 newInst._clone();
4052
4053 return newInst;
4054 }
4055
4056 void SCMOInstance::_clone()
4057 {
4058 char* newBase;
4059 newBase = (char*)malloc((size_t)inst.mem->totalSize);
4060 if (0 == newBase )
4061 {
4062 throw PEGASUS_STD(bad_alloc)();
4063 }
4064
4065 memcpy( newBase,inst.base,(size_t)inst.mem->totalSize);
4066
4067 // make new new memory block to mine.
4068 inst.base = newBase;
4069 // reset the refcounter of this instance
4070 thilo.boehm 1.3 inst.hdr->refCount = 1;
4071 // keep the ref counter of the class correct !
4072 inst.hdr->theClass.ptr = new SCMOClass(*(inst.hdr->theClass.ptr));
4073 // keep the ref count for external references
4074 _copyExternalReferences();
4075
4076 }
4077
4078 void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const
4079 {
4080 Uint32 noBindings = inst.hdr->numberKeyBindings;
4081
4082 SCMBKeyBindingValue* sourceArray =
4083 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
4084
4085 // Address the class keybinding information
4086 const SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
4087 const char * clsbase = inst.hdr->theClass.ptr->cls.base;
4088 SCMBKeyBindingNode* scmoClassArray =
4089 (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
4090
4091 thilo.boehm 1.3 SCMBKeyBindingValue* targetArray;
4092
4093 for (Uint32 i = 0; i < noBindings; i++)
4094 {
4095 // hast to be set every time, because of reallocation.
4096 targetArray=(SCMBKeyBindingValue*)&(targetInst.inst.base)
4097 [targetInst.inst.hdr->keyBindingArray.start];
4098 if(sourceArray[i].isSet)
4099 {
4100 // this has to be done on the target instance to keep constantness.
4101 targetInst._setKeyBindingFromSCMBUnion(
4102 scmoClassArray[i].type,
4103 sourceArray[i].data,
4104 inst.base,
4105 targetArray[i]);
4106 }
4107 }
4108
4109 // Are there user defined key bindings ?
4110 if (0 != inst.hdr->numberUserKeyBindings)
4111 {
4112 thilo.boehm 1.3 SCMBUserKeyBindingElement* theUserDefKBElement =
4113 (SCMBUserKeyBindingElement*)
4114 &(inst.base[inst.hdr->userKeyBindingElement.start]);
4115
4116 for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
4117 {
4118 if (theUserDefKBElement->value.isSet)
4119 {
4120 targetInst._setUserDefinedKeyBinding(*theUserDefKBElement,
4121 inst.base);
4122 }
4123
4124 theUserDefKBElement =
4125 (SCMBUserKeyBindingElement*)
4126 &(inst.base[theUserDefKBElement->nextElement.start]);
4127 } // for all user def. key bindings.
4128 }
4129 }
4130
4131
4132 void SCMOInstance::_setUserDefinedKeyBinding(
4133 thilo.boehm 1.3 SCMBUserKeyBindingElement& theInsertElement,
4134 char* elementBase)
4135 {
4136
4137 SCMBUserKeyBindingElement* ptrNewElement;
4138
4139 // get an exsiting or new user defined key binding
4140 ptrNewElement = _getUserDefinedKeyBinding(
4141 _getCharString(theInsertElement.name,elementBase),
4142 // lenght is without the trailing '\0'
4143 theInsertElement.name.size-1,
4144 theInsertElement.type);
4145
4146 // Copy the data
4147 _setKeyBindingFromSCMBUnion(
4148 theInsertElement.type,
4149 theInsertElement.value.data,
4150 elementBase,
4151 ptrNewElement->value);
4152
4153 }
4154 thilo.boehm 1.3
4155
4156 SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBindingAt(
4157 Uint32 index ) const
4158 {
4159
4160 // Get the start element
4161 SCMBUserKeyBindingElement *ptrNewElement =
4162 (SCMBUserKeyBindingElement*)
4163 &(inst.base[inst.hdr->userKeyBindingElement.start]);
4164
4165 // calculate the index within the user defined key bindings
4166 index = index - inst.hdr->numberKeyBindings;
4167
4168 // traverse trough the user defindes key binding nodes.
4169 for (Uint32 i = 0; i < index; i ++)
4170 {
4171 PEGASUS_ASSERT(ptrNewElement->nextElement.start != 0);
4172 ptrNewElement = (SCMBUserKeyBindingElement*)
4173 &(inst.base[ptrNewElement->nextElement.start]);
4174 }
4175 thilo.boehm 1.3
4176 return ptrNewElement;
4177 }
4178
4179 SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBinding(
4180 const char* name,
4181 Uint32 nameLen,
4182 CIMType type)
4183 {
4184 SCMBDataPtr newElement;
4185 SCMBUserKeyBindingElement* ptrNewElement;
4186 Uint32 node;
4187
4188 // is the key binding already stored as user defind in the instance ?
4189 if (SCMO_OK == _getUserKeyBindingNodeIndex(node,name))
4190 {
4191 ptrNewElement = _getUserDefinedKeyBindingAt(node);
4192 }
4193 else // Not found, create a new user defined key binding.
4194 {
4195
4196 thilo.boehm 1.3 _getFreeSpace(newElement,
4197 sizeof(SCMBUserKeyBindingElement),
4198 &inst.mem);
4199
4200 ptrNewElement =
4201 (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
4202
4203 // link new first user defined key binding element into chain:
4204 // - Assing the start point of user key binding element chain
4205 // to the next element of the new element.
4206 ptrNewElement->nextElement.start =
4207 inst.hdr->userKeyBindingElement.start;
4208 ptrNewElement->nextElement.size =
4209 inst.hdr->userKeyBindingElement.size;
4210 // - Assing the the new element
4211 // to the start point of user key binding element chain
4212 inst.hdr->userKeyBindingElement.start = newElement.start;
4213 inst.hdr->userKeyBindingElement.size = newElement.size;
4214 // Adjust the couter of user defined key bindings.
4215 inst.hdr->numberUserKeyBindings++;
4216
4217 thilo.boehm 1.3
4218 // Copy the type
4219 ptrNewElement->type = type;
4220 ptrNewElement->value.isSet=false;
4221
4222 // Copy the key binding name including the trailing '\0'
4223 _setBinary(name,nameLen+1,ptrNewElement->name,&inst.mem);
4224
4225 // reset the pointer. May the instance was reallocated.
4226 ptrNewElement =
4227 (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
4228
4229 }
4230
4231
4232 return ptrNewElement;
4233
4234 }
4235
4236 Uint32 SCMOInstance::getPropertyCount() const
4237 {
4238 thilo.boehm 1.3 return(inst.hdr->numberProperties);
4239 }
4240
4241 SCMBUnion * SCMOInstance::_resolveSCMBUnion(
4242 CIMType type,
4243 Boolean isArray,
4244 Uint32 size,
4245 Uint64 start,
4246 char* base) const
4247 {
4248
4249 SCMBUnion* u = (SCMBUnion*)&(base[start]);
4250
4251 SCMBUnion* av = 0;
4252
4253 if (isArray)
4254 {
4255 if (size == 0)
4256 {
4257 return 0;
4258 }
4259 thilo.boehm 1.3 av = (SCMBUnion*)&(base[u->arrayValue.start]);
4260 }
4261
4262 switch (type)
4263 {
4264 case CIMTYPE_BOOLEAN:
4265 case CIMTYPE_UINT8:
4266 case CIMTYPE_SINT8:
4267 case CIMTYPE_UINT16:
4268 case CIMTYPE_SINT16:
4269 case CIMTYPE_UINT32:
4270 case CIMTYPE_SINT32:
4271 case CIMTYPE_UINT64:
4272 case CIMTYPE_SINT64:
4273 case CIMTYPE_REAL32:
4274 case CIMTYPE_REAL64:
4275 case CIMTYPE_CHAR16:
4276 case CIMTYPE_DATETIME:
4277 case CIMTYPE_REFERENCE:
4278 case CIMTYPE_OBJECT:
4279 case CIMTYPE_INSTANCE:
4280 thilo.boehm 1.3 {
4281 if(isArray)
4282 {
4283 return (av);
4284 }
4285 else
4286 {
4287 return(u);
4288 }
4289 break;
4290 }
4291
4292 case CIMTYPE_STRING:
4293 {
4294 SCMBUnion *ptr;
4295
4296 if (isArray)
4297 {
4298
4299 ptr = (SCMBUnion*)malloc(size*sizeof(SCMBUnion));
4300 if (ptr == 0 )
4301 thilo.boehm 1.3 {
4302 throw PEGASUS_STD(bad_alloc)();
4303 }
4304
4305 for(Uint32 i = 0; i < size; i++)
4306 {
4307 // resolv relative pointer to absolute pointer
4308 ptr[i].extString.pchar =
4309 (char*)_getCharString(av[i].stringValue,base);
4310 // lenght with out the trailing /0 !
4311 ptr[i].extString.length = av[i].stringValue.size-1;
4312 }
4313 }
4314 else
4315 {
4316 ptr = (SCMBUnion*)malloc(sizeof(SCMBUnion));
4317 ptr->extString.pchar =
4318 (char*)_getCharString(u->stringValue,base);
4319 // lenght with out the trailing /0 !
4320 ptr->extString.length = u->stringValue.size-1;
4321 }
4322 thilo.boehm 1.3
4323 return(ptr);
4324 break;
4325 }
4326 default:
4327 {
4328 PEGASUS_ASSERT(false);
4329 break;
4330 }
4331 }
4332 return 0;
4333 }
4334
4335 void SCMOInstance::clearKeyBindings()
4336 {
4337 _copyOnWrite();
4338
4339 // First destroy all external references in the key bindings
4340 _destroyExternalKeyBindings();
4341
4342 // reset user keybindings
4343 thilo.boehm 1.3 inst.hdr->numberUserKeyBindings = 0;
4344 inst.hdr->userKeyBindingElement.start = 0;
4345 inst.hdr->userKeyBindingElement.size = 0;
4346
4347 // Allocate a clean the SCMOInstanceKeyBindingArray
4348 _getFreeSpace(
4349 inst.hdr->keyBindingArray,
4350 sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
4351 &inst.mem);
|
4352 venkat.puvvada 1.14.2.1
4353 // Clear the keybindings after the allocation. Setting the keybindings
4354 // later causes this value to be reinitialized.
4355 inst.hdr->numberKeyBindings = 0;
|
4356 marek 1.14.2.3
4357 markAsCompromised();
|
4358 thilo.boehm 1.3 }
4359
4360 Uint32 SCMOInstance::getKeyBindingCount() const
4361 {
4362 // count of class keys + user definded keys
4363 return(inst.hdr->numberKeyBindings+
4364 inst.hdr->numberUserKeyBindings);
4365 }
4366
4367
4368 SCMO_RC SCMOInstance::getKeyBindingAt(
4369 Uint32 node,
4370 const char** pname,
4371 CIMType& type,
4372 const SCMBUnion** pvalue) const
4373 {
4374 SCMO_RC rc;
4375 const SCMBUnion* pdata=0;
4376 Uint32 pnameLen=0;
4377
4378 *pname = 0;
4379 thilo.boehm 1.3 *pvalue = 0;
4380
4381 // count of class keys + user definded keys
4382 if (node >= (inst.hdr->numberKeyBindings+
4383 inst.hdr->numberUserKeyBindings))
4384 {
4385 return SCMO_INDEX_OUT_OF_BOUND;
4386 }
4387
4388 rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,&pdata);
4389 if (rc != SCMO_OK)
4390 {
4391 return rc;
4392 }
4393
4394 *pvalue = _resolveSCMBUnion(
4395 type,
4396 false, // A key binding can never be an array.
4397 0,
4398 (char*)pdata-inst.base,
4399 inst.base);
4400 thilo.boehm 1.3
4401 return SCMO_OK;
4402
4403 }
4404
4405 SCMO_RC SCMOInstance::getKeyBinding(
4406 const char* name,
4407 CIMType& type,
4408 const SCMBUnion** pvalue) const
4409 {
4410 SCMO_RC rc;
4411 Uint32 node;
4412 const char* pname=0;
4413 const SCMBUnion* pdata=0;
4414 Uint32 pnameLen=0;
4415
4416 *pvalue = 0;
4417
4418 rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name);
4419 if (rc != SCMO_OK)
4420 {
4421 thilo.boehm 1.3 // look at the user defined key bindings.
4422 rc = _getUserKeyBindingNodeIndex(node,name);
4423 if (rc != SCMO_OK)
4424 {
4425 return rc;
4426 }
4427 }
4428
4429 rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata);
4430
4431 if (rc != SCMO_OK)
4432 {
4433 return rc;
4434 }
4435
4436 *pvalue = _resolveSCMBUnion(
4437 type,
4438 false, // A key binding can never be an array.
4439 0,
4440 (char*)pdata-inst.base,
4441 inst.base);
4442 thilo.boehm 1.3
4443 return SCMO_OK;
4444 }
4445
4446
4447 SCMO_RC SCMOInstance::_getKeyBindingDataAtNodeIndex(
4448 Uint32 node,
4449 const char** pname,
4450 Uint32 & pnameLen,
4451 CIMType & type,
4452 const SCMBUnion** pdata) const
4453 {
4454 if (node < inst.hdr->numberKeyBindings)
4455 {
4456 SCMBKeyBindingValue* theInstKeyBindValueArray =
4457 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
4458
4459 // create a pointer to key binding node array of the class.
4460 Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
4461 keyBindingSet.nodeArray.start;
4462 SCMBKeyBindingNode* theClassKeyBindNodeArray =
4463 thilo.boehm 1.3 (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
4464
4465 type = theClassKeyBindNodeArray[node].type;
4466
4467 // First resolve pointer to the key binding name
4468 pnameLen = theClassKeyBindNodeArray[node].name.size;
4469 *pname = _getCharString(
4470 theClassKeyBindNodeArray[node].name,
4471 inst.hdr->theClass.ptr->cls.base);
4472
4473 // There is no value set in the instance
4474 if (!theInstKeyBindValueArray[node].isSet)
4475 {
4476 return SCMO_NULL_VALUE;
4477 }
4478
4479 *pdata = &(theInstKeyBindValueArray[node].data);
4480 }
4481 else // look at the user defined key bindings
4482 {
4483
4484 thilo.boehm 1.3 SCMBUserKeyBindingElement* theElem = _getUserDefinedKeyBindingAt(node);
4485
4486 type = theElem->type;
4487
4488 pnameLen = theElem->name.size;
4489 *pname = _getCharString(theElem->name,inst.base);
4490
4491 // There is no value set in the instance
4492 if (!theElem->value.isSet)
4493 {
4494 return SCMO_NULL_VALUE;
4495 }
4496
4497 *pdata = &(theElem->value.data);
4498
4499 }
4500
4501 return SCMO_OK;
4502 }
4503
4504 SCMO_RC SCMOInstance::_getUserKeyBindingNodeIndex(
4505 thilo.boehm 1.3 Uint32& node,
4506 const char* name) const
4507 {
4508
4509 Uint32 len = strlen(name);
4510 node = 0;
4511
4512 Uint64 elementStart = inst.hdr->userKeyBindingElement.start;
4513
4514 while (elementStart != 0)
4515 {
4516 SCMBUserKeyBindingElement* theUserDefKBElement =
4517 (SCMBUserKeyBindingElement*)&(inst.base[elementStart]);
4518
4519 if (_equalNoCaseUTF8Strings(
4520 theUserDefKBElement->name,inst.base,name,len))
4521 {
4522 // the node index of a user defined key binding has an offset
4523 // by the number of key bindings defined in the class
4524 node = node + inst.hdr->numberKeyBindings;
4525 return SCMO_OK;
4526 thilo.boehm 1.3 }
4527 node = node + 1;
4528 elementStart = theUserDefKBElement->nextElement.start;
4529 }
4530
4531 return SCMO_NOT_FOUND;
4532
4533 }
4534
4535 CIMType SCMOInstance::_CIMTypeFromKeyBindingType(
4536 const char* key,
4537 CIMKeyBinding::Type t)
4538 {
4539 switch( t )
4540 {
4541 case CIMKeyBinding::NUMERIC:
4542 {
4543 if( *(key)=='-' )
4544 {
4545 Sint64 x;
4546 // check if it is realy an integer
4547 thilo.boehm 1.3 if (StringConversion::stringToSignedInteger(key, x))
4548 {
4549 return CIMTYPE_SINT64;
4550 }
4551 else
4552 {
4553 return CIMTYPE_REAL64;
4554 }
4555 }
4556 else
4557 {
4558 Uint64 x;
4559 // check if it is realy an integer
4560 if (StringConversion::stringToUnsignedInteger(key, x))
4561 {
4562 return CIMTYPE_UINT64;
4563 }
4564 else
4565 {
4566 return CIMTYPE_REAL64;
4567 }
4568 thilo.boehm 1.3 }
4569 break;
4570 }
4571
4572
4573 case CIMKeyBinding::STRING:
4574 {
4575 return CIMTYPE_STRING;
4576 break;
4577 }
4578
4579 case CIMKeyBinding::BOOLEAN:
4580 {
4581 return CIMTYPE_BOOLEAN;
4582 break;
4583 }
4584
4585 case CIMKeyBinding::REFERENCE:
4586 {
4587 return CIMTYPE_REFERENCE;
4588 break;
4589 thilo.boehm 1.3 }
4590
4591 default:
4592 return CIMTYPE_UINT64;
4593 }
4594 return CIMTYPE_UINT64;
4595 }
4596
4597 Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindingValue(
4598 const String& kbs,
4599 CIMType type,
4600 SCMBKeyBindingValue& scmoKBV
4601 )
4602 {
4603 scmoKBV.isSet=false;
4604 // If it not a simple value, it will be over written.
4605 scmoKBV.data.simple.hasValue=false;
4606
4607 if ( kbs.size() == 0 && type != CIMTYPE_STRING)
4608 {
4609 // The string is empty ! Do nothing.
4610 thilo.boehm 1.3 return false;
4611 }
4612
4613 CString a = kbs.getCString();
4614 const char* v = a;
4615
4616 switch (type)
4617 {
4618 case CIMTYPE_UINT8:
4619 {
4620 Uint64 x;
4621 if (StringConversion::stringToUnsignedInteger(v, x) &&
4622 StringConversion::checkUintBounds(x, type))
4623 {
4624 scmoKBV.data.simple.val.u8 = Uint8(x);
4625 scmoKBV.data.simple.hasValue=true;
4626 scmoKBV.isSet=true;
4627 }
4628 break;
4629 }
4630 case CIMTYPE_UINT16:
4631 thilo.boehm 1.3 {
4632 Uint64 x;
4633 if (StringConversion::stringToUnsignedInteger(v, x) &&
4634 StringConversion::checkUintBounds(x, type))
4635 {
4636 scmoKBV.data.simple.val.u16 = Uint16(x);
4637 scmoKBV.data.simple.hasValue=true;
4638 scmoKBV.isSet=true;
4639 }
4640 break;
4641 }
4642
4643 case CIMTYPE_UINT32:
4644 {
4645 Uint64 x;
4646 if (StringConversion::stringToUnsignedInteger(v, x) &&
4647 StringConversion::checkUintBounds(x, type))
4648 {
4649 scmoKBV.data.simple.val.u32 = Uint32(x);
4650 scmoKBV.data.simple.hasValue=true;
4651 scmoKBV.isSet=true;
4652 thilo.boehm 1.3 }
4653 break;
4654 }
4655
4656 case CIMTYPE_UINT64:
4657 {
4658 Uint64 x;
4659 if (StringConversion::stringToUnsignedInteger(v, x))
4660 {
4661 scmoKBV.data.simple.val.u64 = x;
4662 scmoKBV.data.simple.hasValue=true;
4663 scmoKBV.isSet=true;
4664 }
4665 break;
4666 }
4667
4668 case CIMTYPE_SINT8:
4669 {
4670 Sint64 x;
4671 if (StringConversion::stringToSignedInteger(v, x) &&
4672 StringConversion::checkSintBounds(x, type))
4673 thilo.boehm 1.3 {
4674 scmoKBV.data.simple.val.s8 = Sint8(x);
4675 scmoKBV.data.simple.hasValue=true;
4676 scmoKBV.isSet=true;
4677 }
4678 break;
4679 }
4680
4681 case CIMTYPE_SINT16:
4682 {
4683 Sint64 x;
4684 if (StringConversion::stringToSignedInteger(v, x) &&
4685 StringConversion::checkSintBounds(x, type))
4686 {
4687 scmoKBV.data.simple.val.s16 = Sint16(x);
4688 scmoKBV.data.simple.hasValue=true;
4689 scmoKBV.isSet=true;
4690 }
4691 break;
4692 }
4693
4694 thilo.boehm 1.3 case CIMTYPE_SINT32:
4695 {
4696 Sint64 x;
4697 if (StringConversion::stringToSignedInteger(v, x) &&
4698 StringConversion::checkSintBounds(x, type))
4699 {
4700 scmoKBV.data.simple.val.s32 = Sint32(x);
4701 scmoKBV.data.simple.hasValue=true;
4702 scmoKBV.isSet=true;
4703 }
4704 break;
4705 }
4706
4707 case CIMTYPE_SINT64:
4708 {
4709 Sint64 x;
4710 if (StringConversion::stringToSignedInteger(v, x))
4711 {
4712 scmoKBV.data.simple.val.s64 = x;
4713 scmoKBV.data.simple.hasValue=true;
4714 scmoKBV.isSet=true;
4715 thilo.boehm 1.3 }
4716 break;
4717 }
4718
4719 case CIMTYPE_DATETIME:
4720 {
4721 CIMDateTime tmp;
4722
4723 try
4724 {
4725 tmp.set(v);
4726 }
4727 catch (InvalidDateTimeFormatException&)
4728 {
4729 return false;
4730 }
4731
4732 memcpy(
4733 &(scmoKBV.data.dateTimeValue),
4734 tmp._rep,
4735 sizeof(SCMBDateTime));
4736 thilo.boehm 1.3 scmoKBV.isSet=true;
4737 break;
4738 }
4739
4740 case CIMTYPE_REAL32:
4741 {
4742 Real64 x;
4743
4744 if (StringConversion::stringToReal64(v, x))
4745 {
4746 scmoKBV.data.simple.val.r32 = Real32(x);
4747 scmoKBV.data.simple.hasValue=true;
4748 scmoKBV.isSet=true;
4749 }
4750 break;
4751 }
4752
4753 case CIMTYPE_REAL64:
4754 {
4755 Real64 x;
4756
4757 thilo.boehm 1.3 if (StringConversion::stringToReal64(v, x))
4758 {
4759 scmoKBV.data.simple.val.r64 = x;
4760 scmoKBV.data.simple.hasValue=true;
4761 scmoKBV.isSet=true;
4762 }
4763 break;
4764 }
4765
4766 case CIMTYPE_CHAR16:
4767 {
4768 if (kbs.size() == 1)
4769 {
4770 scmoKBV.data.simple.val.c16 = kbs[0];
4771 scmoKBV.data.simple.hasValue=true;
4772 scmoKBV.isSet=true;
4773 }
4774 break;
4775 }
4776 case CIMTYPE_BOOLEAN:
4777 {
4778 thilo.boehm 1.3 if (String::equalNoCase(kbs,"TRUE"))
4779 {
4780 scmoKBV.data.simple.val.bin = true;
4781 scmoKBV.data.simple.hasValue=true;
4782 scmoKBV.isSet=true;
4783 }
4784 else if (String::equalNoCase(kbs,"FALSE"))
4785 {
4786 scmoKBV.data.simple.val.bin = false;
4787 scmoKBV.data.simple.hasValue=true;
4788 scmoKBV.isSet=true;
4789 }
4790 break;
4791 }
4792
4793 case CIMTYPE_STRING:
4794 {
4795 scmoKBV.isSet=true;
4796 // Can cause reallocation !
4797 _setString(kbs,scmoKBV.data.stringValue,&inst.mem);
4798 return true;
4799 thilo.boehm 1.3 break;
4800 }
4801 case CIMTYPE_REFERENCE:
4802 {
4803 if (0 != scmoKBV.data.extRefPtr)
4804 {
4805 delete scmoKBV.data.extRefPtr;
4806 scmoKBV.data.extRefPtr = 0;
4807 scmoKBV.isSet=false;
4808 }
4809 // TBD: Optimize parsing and SCMOInstance creation.
4810 CIMObjectPath theCIMObj(kbs);
4811
4812 scmoKBV.data.extRefPtr = new SCMOInstance(theCIMObj);
4813 scmoKBV.isSet=true;
4814
4815 // Was the conversion successful?
4816 if (scmoKBV.data.extRefPtr->isEmpty())
4817 {
4818 // N0, delete the SCMOInstance.
4819 delete scmoKBV.data.extRefPtr;
4820 thilo.boehm 1.3 scmoKBV.data.extRefPtr = 0;
4821 scmoKBV.isSet=false;
4822 }
4823 else
4824 {
4825 // This function can cause a reallocation !
4826 // Pointers can be invalid after the call.
4827 _setExtRefIndex(&(scmoKBV.data),&inst.mem);
4828 }
4829 break;
4830 }
4831 case CIMTYPE_OBJECT:
4832 case CIMTYPE_INSTANCE:
4833 {
4834 // From PEP 194: EmbeddedObjects cannot be keys.
4835 throw TypeMismatchException();
4836 break;
4837 }
4838 default:
4839 {
4840 PEGASUS_ASSERT(false);
4841 thilo.boehm 1.3 break;
4842 }
4843 }
4844
4845 return scmoKBV.isSet;
4846 }
4847
4848 SCMO_RC SCMOInstance::_setKeyBindingFromString(
4849 const char* name,
4850 CIMType type,
4851 String cimKeyBinding)
4852 {
4853 Uint32 node;
4854
4855 if (0 == name)
4856 {
4857 return SCMO_INVALID_PARAMETER;
4858 }
4859
4860 if (SCMO_OK == inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name))
4861 {
4862 thilo.boehm 1.3 // create a pointer to keybinding node array of the class.
4863 Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
4864 keyBindingSet.nodeArray.start;
4865 SCMBKeyBindingNode* theClassKeyBindNodeArray =
4866 (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
4867
4868 // create a pointer to instance keybinding values
4869 SCMBKeyBindingValue* theInstKeyBindValueArray =
4870 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
4871
4872 // If the set was not successful, the conversion was not successful
4873 if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
4874 cimKeyBinding,
4875 theClassKeyBindNodeArray[node].type,
4876 theInstKeyBindValueArray[node]))
4877 {
4878 return SCMO_TYPE_MISSMATCH;
4879 }
4880
4881 return SCMO_OK;
4882 }
4883 thilo.boehm 1.3
4884 // the key binig does not belong to the associated class
4885 // add/set it as user defined key binding.
4886 SCMBUserKeyBindingElement* ptrNewElement;
4887
4888 ptrNewElement = _getUserDefinedKeyBinding( name,strlen(name),type);
4889
4890 // Copy the data.
4891 // If the set was not successful, the conversion was not successful
4892 if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
4893 cimKeyBinding,
4894 type,
4895 ptrNewElement->value))
4896 {
4897 return SCMO_TYPE_MISSMATCH;
4898 }
4899
4900 return SCMO_OK;
4901 }
4902
4903 SCMO_RC SCMOInstance::setKeyBinding(
4904 thilo.boehm 1.3 const char* name,
4905 CIMType type,
4906 const SCMBUnion* keyvalue)
4907 {
4908 SCMO_RC rc;
4909 Uint32 node;
4910
4911 if (0 == name)
4912 {
4913 return SCMO_INVALID_PARAMETER;
4914 }
4915
4916 if (0 == keyvalue)
4917 {
4918 return SCMO_INVALID_PARAMETER;
4919 }
4920
4921 _copyOnWrite();
4922
|
4923 venkat.puvvada 1.14.2.1 // If keybindings exists and cleared using the clearKeyBindings()
4924 // method, reset the value to the actual keybindings count exists
4925 // in the class.
4926 if (!inst.hdr->numberKeyBindings)
4927 {
4928 inst.hdr->numberKeyBindings =
4929 inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
4930 }
4931
|
4932 thilo.boehm 1.3 rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name);
4933 if (rc != SCMO_OK)
4934 {
4935 // the key bindig does not belong to the associated class
4936 // add/set it as user defined key binding.
4937 SCMBUserKeyBindingElement *theNode;
4938
4939 theNode = _getUserDefinedKeyBinding( name,strlen(name),type);
4940
4941 // Is this a new node or an existing user key binding?
4942 if (theNode->value.isSet && (theNode->type != type))
4943 {
4944 return SCMO_TYPE_MISSMATCH;
4945
4946 }
4947
4948 theNode->value.isSet=true;
4949
4950 _setSCMBUnion(
4951 keyvalue,
4952 type,
4953 thilo.boehm 1.3 false, // a key binding can never be an array.
4954 0,
4955 theNode->value.data);
4956
4957 return SCMO_OK;
4958 }
4959
4960 return setKeyBindingAt(node, type, keyvalue);
4961 }
4962
4963 SCMO_RC SCMOInstance::setKeyBindingAt(
4964 Uint32 node,
4965 CIMType type,
4966 const SCMBUnion* keyvalue)
4967 {
4968 if (0 == keyvalue)
4969 {
4970 return SCMO_INVALID_PARAMETER;
4971 }
4972
4973 // count of class keys + user definded keys
4974 thilo.boehm 1.3 if (node >= (inst.hdr->numberKeyBindings+
4975 inst.hdr->numberUserKeyBindings))
4976 {
4977 return SCMO_INDEX_OUT_OF_BOUND;
4978 }
4979
4980 _copyOnWrite();
4981
|
4982 venkat.puvvada 1.14.2.1 // If keybindings exists and cleared using the clearKeyBindings()
4983 // method, reset the value to the actual keybindings count exists
4984 // in the class.
4985 if (!inst.hdr->numberKeyBindings)
4986 {
4987 inst.hdr->numberKeyBindings =
4988 inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
4989 }
4990
4991
|
4992 thilo.boehm 1.3 // create a pointer to keybinding node array of the class.
4993 Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
4994 keyBindingSet.nodeArray.start;
4995 SCMBKeyBindingNode* theClassKeyBindNodeArray =
4996 (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
4997
4998 // is the node a user defined key binding ?
4999 if (node >= inst.hdr->numberKeyBindings)
5000 {
5001 SCMBUserKeyBindingElement* theNode = _getUserDefinedKeyBindingAt(node);
5002
5003 // Does the new value for the user defined keybinding match?
5004 if (theNode->type != type)
5005 {
5006 return SCMO_TYPE_MISSMATCH;
5007 }
5008
5009 _setSCMBUnion(
5010 keyvalue,
5011 type,
5012 false, // a key binding can never be an array.
5013 thilo.boehm 1.3 0,
5014 theNode->value.data);
5015
5016 return SCMO_OK;
5017
5018 }
5019
5020 SCMBKeyBindingValue* theInstKeyBindValueArray =
5021 (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
5022
5023
5024 if (theClassKeyBindNodeArray[node].type == type)
5025 {
5026
5027 // Has to be set first,
5028 // because reallocaton can take place in _setSCMBUnion()
5029 theInstKeyBindValueArray[node].isSet=true;
5030
5031 _setSCMBUnion(
5032 keyvalue,
5033 type,
5034 thilo.boehm 1.3 false, // a key binding can never be an array.
5035 0,
5036 theInstKeyBindValueArray[node].data);
5037
5038 return SCMO_OK;
5039
5040 }
5041
5042 // The type does not match.
5043 return _setKeyBindingTypeTolerate(
5044 theClassKeyBindNodeArray[node].type,
5045 type,
5046 keyvalue,
5047 theInstKeyBindValueArray[node]);
5048
5049 }
5050
5051 /**
5052 * Set a SCMO user defined key binding using the class CIM type tolerating
5053 * CIM key binding types converted to CIM types by fuction
5054 * _CIMTypeFromKeyBindingType().
5055 thilo.boehm 1.3 *
5056 * @parm classType The type of the key binding in the class definition
5057 * @parm setType The type of the key binding to be set.
5058 * @param keyValue A pointer to the key binding to be set.
5059 * @param kbValue Out parameter, the SCMO keybinding to be set.
5060 *
5061 **/
5062 SCMO_RC SCMOInstance::_setKeyBindingTypeTolerate(
5063 CIMType classType,
5064 CIMType setType,
5065 const SCMBUnion* keyValue,
5066 SCMBKeyBindingValue& kbValue)
5067 {
5068 if (setType == CIMTYPE_UINT64 )
5069 {
5070 switch (classType)
5071 {
5072
5073 case CIMTYPE_UINT8:
5074 {
5075 kbValue.isSet=true;
5076 thilo.boehm 1.3 kbValue.data.simple.hasValue=true;
5077 kbValue.data.simple.val.u8=Uint8(keyValue->simple.val.u64);
5078 return SCMO_OK;
5079 break;
5080 }
5081 case CIMTYPE_UINT16:
5082 {
5083 kbValue.isSet=true;
5084 kbValue.data.simple.hasValue=true;
5085 kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64);
5086 return SCMO_OK;
5087 break;
5088 }
5089 case CIMTYPE_UINT32:
5090 {
5091 kbValue.isSet=true;
5092 kbValue.data.simple.hasValue=true;
5093 kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64);
5094 return SCMO_OK;
5095 break;
5096 }
5097 thilo.boehm 1.3 case CIMTYPE_UINT64:
5098 {
5099 kbValue.isSet=true;
5100 kbValue.data.simple.hasValue=true;
5101 kbValue.data.simple.val.u64=keyValue->simple.val.u64;
5102 return SCMO_OK;
5103 break;
5104 }
5105 default:
5106 {
5107 return SCMO_TYPE_MISSMATCH;
5108 break;
5109 }
5110 }
5111 }
5112
5113 if (setType == CIMTYPE_SINT64)
5114 {
5115 switch (classType)
5116 {
5117
5118 thilo.boehm 1.3 case CIMTYPE_SINT8:
5119 {
5120 kbValue.isSet=true;
5121 kbValue.data.simple.hasValue=true;
5122 kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64);
5123 return SCMO_OK;
5124 break;
5125 }
5126 case CIMTYPE_SINT16:
5127 {
5128 kbValue.isSet=true;
5129 kbValue.data.simple.hasValue=true;
5130 kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64);
5131 return SCMO_OK;
5132 break;
5133 }
5134 case CIMTYPE_SINT32:
5135 {
5136 kbValue.isSet=true;
5137 kbValue.data.simple.hasValue=true;
5138 kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64);
5139 thilo.boehm 1.3 return SCMO_OK;
5140 break;
5141 }
5142 case CIMTYPE_SINT64:
5143 {
5144 kbValue.isSet=true;
5145 kbValue.data.simple.hasValue=true;
5146 kbValue.data.simple.val.s64=keyValue->simple.val.s64;
5147 return SCMO_OK;
5148 break;
5149 }
5150 default:
5151 {
5152 return SCMO_TYPE_MISSMATCH;
5153 break;
5154 }
5155 }
5156 }
5157
5158 if (setType == CIMTYPE_REAL64)
5159 {
5160 thilo.boehm 1.3 switch (classType)
5161 {
5162 case CIMTYPE_REAL32:
5163 {
5164 kbValue.isSet=true;
5165 kbValue.data.simple.hasValue=true;
5166 kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64);
5167 return SCMO_OK;
5168 break;
5169 }
5170 case CIMTYPE_REAL64:
5171 {
5172 kbValue.isSet=true;
5173 kbValue.data.simple.hasValue=true;
5174 kbValue.data.simple.val.r64=keyValue->simple.val.r64;
5175 return SCMO_OK;
5176 break;
5177 }
5178 default:
5179 {
5180 return SCMO_TYPE_MISSMATCH;
5181 thilo.boehm 1.3 break;
5182 }
5183 }
5184 }
5185 else
5186 {
5187 // If type defined in the class and the provided type does not match
5188 // at this point, no convertaion can be done and the provided type
5189 // is handlend as type missmatch.
5190 if (classType != setType)
5191 {
5192 return SCMO_TYPE_MISSMATCH;
5193 }
5194
5195 switch (classType)
5196 {
5197 case CIMTYPE_DATETIME:
5198 case CIMTYPE_BOOLEAN:
5199 case CIMTYPE_UINT64:
5200 case CIMTYPE_SINT64:
5201 case CIMTYPE_REAL64:
5202 thilo.boehm 1.3 case CIMTYPE_STRING:
5203 case CIMTYPE_REFERENCE:
5204 {
5205 kbValue.isSet=true;
5206 _setSCMBUnion(keyValue,classType,false, 0,kbValue.data);
5207 return SCMO_OK;
5208 break;
5209 }
5210 default:
5211 {
5212 return SCMO_TYPE_MISSMATCH;
5213 break;
5214 }
5215 }
5216 }
5217
5218 return SCMO_TYPE_MISSMATCH;
5219
5220 }
5221
5222 static int _indexComp(const void* left, const void* right)
5223 thilo.boehm 1.3 {
5224 return((*(Uint32 *)left)-(*(Uint32 *)right));
5225 }
5226
5227 void SCMOInstance::setPropertyFilter(const char **propertyList)
5228 {
|
5229 anusha.kandepu 1.14 return;
|
5230 thilo.boehm 1.3 }
5231
5232
5233 /******************************************************************************
5234 * SCMODump Print and Dump functions
5235 *****************************************************************************/
5236 SCMODump::SCMODump()
5237 {
|
5238 r.kieninger 1.7 _out = stderr;
|
5239 thilo.boehm 1.3 _fileOpen = false;
5240
5241 #ifdef PEGASUS_OS_ZOS
5242 setEBCDICEncoding(fileno(_out));
5243 #endif
5244
5245 }
5246
5247 SCMODump::SCMODump(const char* filename)
5248 {
5249 openFile(filename);
5250 }
5251
5252 void SCMODump::openFile(const char* filename)
5253 {
5254 const char* pegasusHomeDir = getenv("PEGASUS_HOME");
5255
5256 if (pegasusHomeDir == 0)
5257 {
5258 pegasusHomeDir = ".";
5259 }
5260 thilo.boehm 1.3
5261 _filename = pegasusHomeDir;
5262 _filename.append("/");
5263 _filename.append(filename);
5264
5265 _out = fopen((const char*)_filename.getCString(),"w+");
5266
5267 _fileOpen = true;
5268
5269 #ifdef PEGASUS_OS_ZOS
5270 setEBCDICEncoding(fileno(_out));
5271 #endif
5272
5273 }
5274
5275 void SCMODump::deleteFile()
5276 {
5277 if(_fileOpen)
5278 {
5279 closeFile();
5280 }
5281 thilo.boehm 1.3
5282 System::removeFile((const char*)_filename.getCString());
5283
5284 }
5285 void SCMODump::closeFile()
5286 {
5287 if (_fileOpen)
5288 {
5289 fclose(_out);
5290 _fileOpen=false;
5291 _out = stdout;
5292 }
5293 }
5294
5295 SCMODump::~SCMODump()
5296 {
5297 if (_fileOpen)
5298 {
5299 fclose(_out);
5300 _fileOpen=false;
5301 }
5302 thilo.boehm 1.3 }
5303
5304 Boolean SCMODump::compareFile(String master)
5305 {
5306 if (!_fileOpen)
5307 {
5308 return false;
5309 }
5310 closeFile();
5311
5312 ifstream isMaster;
5313 ifstream isDumpFile;
5314
5315 Open(isDumpFile, _filename);
5316 Open(isMaster, master);
5317
5318 String aLine;
5319 String bLine;
5320
5321 while (GetLine(isDumpFile, aLine) && GetLine(isMaster, bLine))
5322 {
5323 thilo.boehm 1.3 if (aLine != bLine)
5324 {
5325 cout << "|" << aLine << "|" << endl;
5326 cout << "|" << bLine << "|" << endl;
5327 isDumpFile.close();
5328 isMaster.close();
5329 return false;
5330 }
5331 };
5332 isDumpFile.close();
5333 isMaster.close();
5334 return true;
5335 }
5336
|
5337 r.kieninger 1.7 void SCMODump::dumpSCMOInstance(SCMOInstance& testInst, Boolean inclMemHdr)const
|
5338 thilo.boehm 1.3 {
5339 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5340 char* instbase = testInst.inst.base;
5341
5342 fprintf(_out,"\n\nDump of SCMOInstance\n");
|
5343 r.kieninger 1.7
5344 if (inclMemHdr)
5345 {
5346 _dumpSCMBMgmt_Header(insthdr->header,instbase);
5347 }
5348
|
5349 thilo.boehm 1.3 // The reference counter for this c++ class
5350 fprintf(_out,"\nrefCount=%i",insthdr->refCount.get());
5351 fprintf(_out,"\ntheClass: %p",insthdr->theClass.ptr);
5352 fprintf(_out,"\n\nThe Flags:");
5353 fprintf(_out,"\n includeQualifiers: %s",
5354 (insthdr->flags.includeQualifiers ? "True" : "False"));
5355 fprintf(_out,"\n includeClassOrigin: %s",
5356 (insthdr->flags.includeClassOrigin ? "True" : "False"));
5357 fprintf(_out,"\n isClassOnly: %s",
5358 (insthdr->flags.isClassOnly ? "True" : "False"));
5359 fprintf(_out,"\n isCompromised: %s",
5360 (insthdr->flags.isCompromised ? "True" : "False"));
5361 fprintf(_out,"\n exportSetOnly: %s",
5362 (insthdr->flags.exportSetOnly ? "True" : "False"));
5363 fprintf(_out,"\n\ninstNameSpace: \'%s\'",
5364 NULLSTR(_getCharString(insthdr->instNameSpace,instbase)));
5365 fprintf(_out,"\n\ninstClassName: \'%s\'",
5366 NULLSTR(_getCharString(insthdr->instClassName,instbase)));
5367 fprintf(_out,"\n\nhostName: \'%s\'",
5368 NULLSTR(_getCharString(insthdr->hostName,instbase)));
5369
5370 thilo.boehm 1.3 dumpSCMOInstanceKeyBindings(testInst);
5371
5372 dumpInstanceProperties(testInst);
5373 fprintf(_out,"\n\n");
5374
5375 }
5376
5377 void SCMODump::dumpInstanceProperties(
5378 SCMOInstance& testInst,
5379 Boolean verbose) const
5380 {
5381 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5382 char* instbase = testInst.inst.base;
|
5383 thilo.boehm 1.2
|
5384 thilo.boehm 1.3 SCMBValue* val =
5385 (SCMBValue*)_resolveDataPtr(insthdr->propertyArray,instbase);
|
5386 thilo.boehm 1.2
|
5387 thilo.boehm 1.3 fprintf(_out,"\n\nInstance Properties :");
5388 fprintf(_out,"\n=====================");
5389 fprintf(_out,"\n\nNumber of properties in instance : %u",
5390 insthdr->numberProperties);
|
5391 thilo.boehm 1.2
|
5392 thilo.boehm 1.3 for (Uint32 i = 0, k = insthdr->numberProperties; i < k; i++)
|
5393 thilo.boehm 1.1 {
|
5394 thilo.boehm 1.3 fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,
5395 NULLSTR(insthdr->theClass.ptr->_getPropertyNameAtNode(i)));
|
5396 thilo.boehm 1.2
|
5397 anusha.kandepu 1.14 printSCMOValue(val[i],instbase,verbose);
|
5398 thilo.boehm 1.3 }
|
5399 thilo.boehm 1.2
5400 }
5401
|
5402 thilo.boehm 1.3
5403 void SCMODump::dumpSCMOInstanceKeyBindings(
5404 SCMOInstance& testInst,
5405 Boolean verbose) const
|
5406 thilo.boehm 1.1 {
|
5407 thilo.boehm 1.3 SCMBInstance_Main* insthdr = testInst.inst.hdr;
5408 char* instbase = testInst.inst.base;
|
5409 thilo.boehm 1.2
|
5410 thilo.boehm 1.3 // create a pointer to keybinding node array of the class.
5411 Uint64 idx = insthdr->theClass.ptr->cls.hdr->keyBindingSet.nodeArray.start;
5412 SCMBKeyBindingNode* theClassKeyBindNodeArray =
5413 (SCMBKeyBindingNode*)&((insthdr->theClass.ptr->cls.base)[idx]);
|
5414 thilo.boehm 1.2
|
5415 thilo.boehm 1.3 SCMBKeyBindingValue* ptr =
5416 (SCMBKeyBindingValue*)
5417 _resolveDataPtr(insthdr->keyBindingArray,instbase);
5418
5419 fprintf(_out,"\n\nInstance Key Bindings :");
5420 fprintf(_out,"\n=======================");
5421 fprintf(_out,"\n\nNumber of Key Bindings defined in the Class: %u",
5422 insthdr->numberKeyBindings);
5423
5424 for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++)
5425 {
5426 if (ptr[i].isSet)
5427 {
5428 fprintf(_out,"\n\nName: '%s'\nType: '%s'",
5429 NULLSTR(_getCharString(
5430 theClassKeyBindNodeArray[i].name,
5431 insthdr->theClass.ptr->cls.base)),
5432 cimTypeToString(theClassKeyBindNodeArray[i].type));
5433 printUnionValue(
5434 theClassKeyBindNodeArray[i].type,
5435 ptr[i].data,
5436 thilo.boehm 1.3 instbase,
5437 verbose);
5438 }
5439 else
5440 {
5441 fprintf(_out,"\n\nName: '%s': Not Set",
5442 NULLSTR(_getCharString(
5443 theClassKeyBindNodeArray[i].name,
5444 insthdr->theClass.ptr->cls.base)));
5445 }
5446 }
|
5447 thilo.boehm 1.2
|
5448 thilo.boehm 1.3 fprintf(_out,"\n\nNumber of User Defined Key Bindings: %u",
5449 insthdr->numberUserKeyBindings);
|
5450 thilo.boehm 1.1
|
5451 thilo.boehm 1.2
|
5452 thilo.boehm 1.3 SCMBUserKeyBindingElement* theUserDefKBElement;
|
5453 thilo.boehm 1.1
|
5454 thilo.boehm 1.3 Uint64 start = insthdr->userKeyBindingElement.start;
5455 while (start != 0)
5456 {
5457 theUserDefKBElement = (SCMBUserKeyBindingElement*)&(instbase[start]);
|
5458 thilo.boehm 1.1
|
5459 thilo.boehm 1.3 if (theUserDefKBElement->value.isSet)
5460 {
5461 fprintf(_out,"\n\nName: '%s'\nType: '%s'",
5462 NULLSTR(_getCharString(theUserDefKBElement->name,instbase)),
5463 cimTypeToString(theUserDefKBElement->type));
5464 printUnionValue(
5465 theUserDefKBElement->type,
5466 theUserDefKBElement->value.data,
5467 instbase,
5468 verbose);
5469 }
5470 else
5471 {
5472 fprintf(_out,"\n\n %s : Not Set",
5473 NULLSTR(_getCharString(theUserDefKBElement->name,instbase)));
|
5474 thilo.boehm 1.1
|
5475 thilo.boehm 1.3 }
5476 start = theUserDefKBElement->nextElement.start;
5477 } // for all user def. key bindings.
|
5478 thilo.boehm 1.1
|
5479 thilo.boehm 1.3 fprintf(_out,"\n\n");
|
5480 thilo.boehm 1.1
5481 }
5482
|
5483 r.kieninger 1.7 void SCMODump::_dumpSCMBMgmt_Header(SCMBMgmt_Header& header,char* base) const
5484 {
5485 fprintf(_out,"\nThe Management Header:");
5486 // The magic number
5487 fprintf(_out,"\n magic=%08X",header.magic);
5488 // Total size of the memory block( # bytes )
5489 fprintf(_out,"\n totalSize=%llu",header.totalSize);
5490 // Free bytes in the block
5491 fprintf(_out,"\n freeBytes=%llu",header.freeBytes);
5492 // Index to the start of the free space in this SCMB memory block.
5493 fprintf(_out,"\n startOfFreeSpace=%llu",header.startOfFreeSpace);
5494 // Number of external references in this instance.
5495 fprintf(_out,"\n numberExtRef=%u",header.numberExtRef);
5496 // Size of external reference index array;
5497 fprintf(_out,"\n sizeExtRefIndexArray=%u",header.sizeExtRefIndexArray);
5498
5499 if (header.numberExtRef > 0)
5500 {
5501 fprintf(_out,"\n extRefIndexArray=[");
5502 Uint64* extRefIndexArray =
5503 (Uint64*)&(base[header.extRefIndexArray.start]);
5504 r.kieninger 1.7
5505 for (Uint32 i = 0; i < header.numberExtRef;)
5506 {
5507 fprintf(_out,"%llu",extRefIndexArray[i]);
5508 i++;
5509 if (i != header.numberExtRef)
5510 {
5511 fprintf(_out,", ");
5512 }
5513 }
5514 fprintf(_out,"\n");
5515 }
5516 else
5517 {
5518 fprintf(_out,"\n extRefIndexArray=[NO INDEX]\n");
5519 }
5520 }
5521
5522 void SCMODump::dumpSCMOClass(SCMOClass& testCls, Boolean inclMemHdr) const
|
5523 thilo.boehm 1.2 {
5524 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5525 thilo.boehm 1.3 char* clsbase = testCls.cls.base;
|
5526 thilo.boehm 1.1
|
5527 thilo.boehm 1.3 fprintf(_out,"\n\nDump of SCMOClass\n");
|
5528 r.kieninger 1.7
5529 if (inclMemHdr)
5530 {
5531 _dumpSCMBMgmt_Header(clshdr->header,clsbase);
5532 }
5533
|
5534 thilo.boehm 1.3 // The reference counter for this c++ class
5535 fprintf(_out,"\nrefCount=%i",clshdr->refCount.get());
5536 fprintf(_out,"\n\nThe Flags:");
5537 fprintf(_out,"\n isEmpty: %s",
5538 (clshdr->flags.isEmpty ? "True" : "False"));
5539 fprintf(_out,"\n\nsuperClassName: \'%s\'",
5540 NULLSTR(_getCharString(clshdr->superClassName,clsbase)));
5541 fprintf(_out,"\nnameSpace: \'%s\'",
5542 NULLSTR(_getCharString(clshdr->nameSpace,clsbase)));
5543 fprintf(_out,"\nclassName: \'%s\'",
5544 NULLSTR(_getCharString(clshdr->className,clsbase)));
5545 fprintf(_out,"\n\nTheClass qualfiers:");
|
5546 thilo.boehm 1.2 _dumpQualifierArray(
5547 clshdr->qualifierArray.start,
5548 clshdr->numberOfQualifiers,
5549 clsbase);
|
5550 thilo.boehm 1.3 fprintf(_out,"\n");
|
5551 thilo.boehm 1.2 dumpKeyPropertyMask(testCls);
|
5552 thilo.boehm 1.3 fprintf(_out,"\n");
|
5553 thilo.boehm 1.2 dumpKeyIndexList(testCls);
|
5554 thilo.boehm 1.3 fprintf(_out,"\n");
|
5555 thilo.boehm 1.2 dumpClassProperties(testCls);
|
5556 thilo.boehm 1.3 fprintf(_out,"\n");
|
5557 thilo.boehm 1.2 dumpKeyBindingSet(testCls);
|
5558 thilo.boehm 1.3 fprintf(_out,"\n");
|
5559 thilo.boehm 1.2 /*
5560 */
|
5561 thilo.boehm 1.3 fprintf(_out,"\n");
5562
5563 }
5564
5565 void SCMODump::dumpSCMOClassQualifiers(SCMOClass& testCls) const
5566 {
5567 SCMBClass_Main* clshdr = testCls.cls.hdr;
5568 char* clsbase = testCls.cls.base;
5569
5570 fprintf(_out,"\n\nTheClass qualfiers:");
5571 _dumpQualifierArray(
5572 clshdr->qualifierArray.start,
5573 clshdr->numberOfQualifiers,
5574 clsbase);
5575 fprintf(_out,"\n\n\n");
|
5576 thilo.boehm 1.1
|
5577 thilo.boehm 1.2 }
|
5578 thilo.boehm 1.1
|
5579 thilo.boehm 1.2 void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const
|
5580 thilo.boehm 1.1 {
|
5581 thilo.boehm 1.2 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5582 thilo.boehm 1.3 char* clsbase = testCls.cls.base;
|
5583 thilo.boehm 1.1
|
5584 thilo.boehm 1.3 fprintf(_out,"\n\nHex dump of a SCMBClass:");
5585 fprintf(_out,"\n========================");
5586 fprintf(_out,"\n\n Size of SCMBClass: %llu\n\n",clshdr->header.totalSize);
|
5587 thilo.boehm 1.1
|
5588 thilo.boehm 1.2 _hexDump(clsbase,clshdr->header.totalSize);
|
5589 thilo.boehm 1.1
5590 }
|
5591 thilo.boehm 1.2 void SCMODump::dumpKeyIndexList(SCMOClass& testCls) const
5592 {
5593 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5594 thilo.boehm 1.3 char* clsbase = testCls.cls.base;
|
5595 thilo.boehm 1.1
|
5596 thilo.boehm 1.3 fprintf(_out,"\n\nKey Index List:");
5597 fprintf(_out,"\n===============\n");
|
5598 thilo.boehm 1.1
|
5599 thilo.boehm 1.2 // Get absolut pointer to key index list of the class
5600 Uint32* keyIndex = (Uint32*)&(clsbase)[clshdr->keyIndexList.start];
|
5601 thilo.boehm 1.3 Uint32 line,j,i,k = clshdr->propertySet.number;
5602 for (j = 0; j < k; j = j + line)
|
5603 thilo.boehm 1.1 {
|
5604 thilo.boehm 1.2 if ((clshdr->propertySet.number-j)/16)
|
5605 thilo.boehm 1.1 {
|
5606 thilo.boehm 1.2 line = 16 ;
|
5607 thilo.boehm 1.1 }
|
5608 thilo.boehm 1.2 else
|
5609 thilo.boehm 1.1 {
|
5610 thilo.boehm 1.2 line = clshdr->propertySet.number%16;
|
5611 thilo.boehm 1.1 }
5612
|
5613 thilo.boehm 1.2
|
5614 thilo.boehm 1.3 fprintf(_out,"Index :");
|
5615 thilo.boehm 1.2 for (i = 0; i < line; i++)
|
5616 thilo.boehm 1.1 {
|
5617 thilo.boehm 1.3 fprintf(_out," %3u",j+i);
|
5618 thilo.boehm 1.1 }
5619
|
5620 thilo.boehm 1.3 fprintf(_out,"\nNode :");
|
5621 thilo.boehm 1.2 for (i = 0; i < line; i++)
|
5622 thilo.boehm 1.1 {
|
5623 thilo.boehm 1.3 fprintf(_out," %3u",keyIndex[j+i]);
|
5624 thilo.boehm 1.1 }
5625
|
5626 thilo.boehm 1.3 fprintf(_out,"\n\n");
|
5627 thilo.boehm 1.2
5628 }
5629
5630 }
5631
5632 void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const
5633 {
5634 SCMBClass_Main* clshdr = testCls.cls.hdr;
5635
|
5636 thilo.boehm 1.3 fprintf(_out,"\n\nKey Binding Set:");
5637 fprintf(_out,"\n=================\n");
5638 fprintf(_out,"\nNumber of key bindings: %3u",clshdr->keyBindingSet.number);
|
5639 thilo.boehm 1.2 dumpHashTable(
5640 clshdr->keyBindingSet.hashTable,
5641 PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
|
5642 thilo.boehm 1.1
|
5643 thilo.boehm 1.2 dumpClassKeyBindingNodeArray(testCls);
|
5644 thilo.boehm 1.1
|
5645 thilo.boehm 1.2 }
|
5646 thilo.boehm 1.1
|
5647 thilo.boehm 1.2 void SCMODump::dumpClassKeyBindingNodeArray(SCMOClass& testCls) const
5648 {
5649 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5650 thilo.boehm 1.3 char* clsbase = testCls.cls.base;
|
5651 thilo.boehm 1.1
|
5652 thilo.boehm 1.2 SCMBKeyBindingNode* nodeArray =
5653 (SCMBKeyBindingNode*)
5654 &(clsbase[clshdr->keyBindingSet.nodeArray.start]);
|
5655 thilo.boehm 1.1
|
5656 thilo.boehm 1.3 for (Uint32 i = 0, k = clshdr->keyBindingSet.number; i < k; i++)
|
5657 thilo.boehm 1.2 {
|
5658 thilo.boehm 1.3 fprintf(_out,"\n\n===================");
5659 fprintf(_out,"\nKey Binding #%3u",i);
5660 fprintf(_out,"\n===================");
|
5661 thilo.boehm 1.1
|
5662 thilo.boehm 1.3 fprintf(_out,"\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));
|
5663 thilo.boehm 1.2 if (nodeArray[i].hasNext)
|
5664 thilo.boehm 1.1 {
|
5665 thilo.boehm 1.3 fprintf(_out,"\nNext Node: %3u",nodeArray[i].nextNode);
|
5666 thilo.boehm 1.1 }
|
5667 thilo.boehm 1.2 else
|
5668 thilo.boehm 1.1 {
|
5669 thilo.boehm 1.3 fprintf(_out,"\nNext Node: N/A");
|
5670 thilo.boehm 1.1 }
5671
|
5672 thilo.boehm 1.3 fprintf(_out,"\nKey Property name: %s",
5673 NULLSTR(_getCharString(nodeArray[i].name,clsbase)));
|
5674 thilo.boehm 1.2
|
5675 thilo.boehm 1.3 fprintf(_out,"\nHash Tag %3u Hash Index %3u",
|
5676 thilo.boehm 1.2 nodeArray[i].nameHashTag,
5677 nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
5678
|
5679 thilo.boehm 1.3 fprintf(_out,"\nType: %s",cimTypeToString(nodeArray[i].type));
|
5680 thilo.boehm 1.2
5681 }
5682
5683 }
5684
5685 void SCMODump::dumpClassProperties(SCMOClass& testCls) const
5686 {
5687 SCMBClass_Main* clshdr = testCls.cls.hdr;
5688
|
5689 thilo.boehm 1.3 fprintf(_out,"\n\nClass Properties:");
5690 fprintf(_out,"\n=================\n");
5691 fprintf(_out,"\nNumber of properties: %3u",clshdr->propertySet.number);
|
5692 thilo.boehm 1.2 dumpHashTable(
5693 clshdr->propertySet.hashTable,
5694 PEGASUS_PROPERTY_SCMB_HASHSIZE);
5695 dumpClassPropertyNodeArray(testCls);
5696
5697 }
5698
5699 void SCMODump::dumpClassPropertyNodeArray(SCMOClass& testCls) const
5700 {
5701 SCMBClass_Main* clshdr = testCls.cls.hdr;
|
5702 thilo.boehm 1.3 char* clsbase = testCls.cls.base;
|
5703 thilo.boehm 1.2
5704 SCMBClassPropertyNode* nodeArray =
5705 (SCMBClassPropertyNode*)
5706 &(clsbase[clshdr->propertySet.nodeArray.start]);
5707
|
5708 thilo.boehm 1.3 for (Uint32 i = 0, k = clshdr->propertySet.number; i < k; i++)
|
5709 thilo.boehm 1.2 {
|
5710 thilo.boehm 1.1
|
5711 thilo.boehm 1.3 fprintf(_out,"\nClass property #%3u",i);
5712 fprintf(_out,"\n===================");
|
5713 thilo.boehm 1.1
|
5714 thilo.boehm 1.3 fprintf(_out,"\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));
|
5715 thilo.boehm 1.2 if (nodeArray[i].hasNext)
5716 {
|
5717 thilo.boehm 1.3 fprintf(_out,"\nNext Node: %3u",nodeArray[i].nextNode);
|
5718 thilo.boehm 1.1 }
|
5719 thilo.boehm 1.2 else
|
5720 thilo.boehm 1.1 {
|
5721 thilo.boehm 1.3 fprintf(_out,"\nNext Node: N/A");
|
5722 thilo.boehm 1.1 }
5723
|
5724 thilo.boehm 1.2 _dumpClassProperty(nodeArray[i].theProperty,clsbase);
5725 }
5726 }
5727
5728 void SCMODump::_dumpClassProperty(
5729 const SCMBClassProperty& prop,
|
5730 thilo.boehm 1.3 char* clsbase) const
|
5731 thilo.boehm 1.2 {
|
5732 thilo.boehm 1.3 fprintf(_out,"\nProperty name: %s",
5733 NULLSTR(_getCharString(prop.name,clsbase)));
|
5734 thilo.boehm 1.2
|
5735 thilo.boehm 1.3 fprintf(_out,"\nHash Tag %3u Hash Index %3u",
|
5736 thilo.boehm 1.2 prop.nameHashTag,
5737 prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE);
|
5738 thilo.boehm 1.3 fprintf(_out,"\nPropagated: %s isKey: %s",
|
5739 thilo.boehm 1.2 (prop.flags.propagated?"TRUE":"FALSE"),
5740 (prop.flags.isKey?"TRUE":"FALSE")
5741 );
|
5742 thilo.boehm 1.1
|
5743 thilo.boehm 1.3 fprintf(_out,"\nOrigin class name: %s",
5744 NULLSTR(_getCharString(prop.originClassName,clsbase)));
5745 fprintf(_out,"\nReference class name: %s",
5746 NULLSTR(_getCharString(prop.refClassName,clsbase)));
|
5747 thilo.boehm 1.1
|
5748 thilo.boehm 1.2 printSCMOValue(prop.defaultValue,clsbase);
|
5749 thilo.boehm 1.1
|
5750 thilo.boehm 1.2 _dumpQualifierArray(
5751 prop.qualifierArray.start,
5752 prop.numberOfQualifiers,
5753 clsbase);
|
5754 thilo.boehm 1.1
5755 }
5756
|
5757 thilo.boehm 1.2 void SCMODump::dumpHashTable(Uint32* hashTable,Uint32 size) const
|
5758 thilo.boehm 1.1 {
|
5759 thilo.boehm 1.2 Uint32 i,j,line;
|
5760 thilo.boehm 1.3 fprintf(_out,"\n\nHash table:\n");
|
5761 thilo.boehm 1.1
5762
|
5763 thilo.boehm 1.2 for (j = 0; j < size; j = j + line)
5764 {
5765 if ((size-j)/16)
5766 {
5767 line = 16 ;
5768 }
5769 else
5770 {
5771 line = size%16;
5772 }
|
5773 thilo.boehm 1.1
5774
|
5775 thilo.boehm 1.3 fprintf(_out,"Index :");
|
5776 thilo.boehm 1.2 for (i = 0; i < line; i++)
|
5777 thilo.boehm 1.1 {
|
5778 thilo.boehm 1.3 fprintf(_out," %3u",j+i);
|
5779 thilo.boehm 1.1 }
5780
|
5781 thilo.boehm 1.3 fprintf(_out,"\nHashTable:");
|
5782 thilo.boehm 1.2 for (i = 0; i < line; i++)
|
5783 thilo.boehm 1.1 {
|
5784 thilo.boehm 1.3 fprintf(_out," %3u",hashTable[j+i]);
|
5785 thilo.boehm 1.1 }
5786
|
5787 thilo.boehm 1.3 fprintf(_out,"\n\n");
|
5788 thilo.boehm 1.1
5789 }
5790
|
5791 thilo.boehm 1.2
5792 }
5793
5794 void SCMODump::_dumpQualifierArray(
|
5795 thilo.boehm 1.3 Uint64 start,
|
5796 thilo.boehm 1.2 Uint32 size,
|
5797 thilo.boehm 1.3 char* clsbase
|
5798 thilo.boehm 1.2 ) const
5799 {
5800
5801 SCMBQualifier *theArray = (SCMBQualifier*)&(clsbase[start]);
5802
5803 for(Uint32 i = 0; i < size; i++)
|
5804 thilo.boehm 1.1 {
|
5805 thilo.boehm 1.2 _dumpQualifier(theArray[i],clsbase);
|
5806 thilo.boehm 1.1 }
|
5807 thilo.boehm 1.2 }
|
5808 thilo.boehm 1.1
|
5809 thilo.boehm 1.2 void SCMODump::_dumpQualifier(
5810 const SCMBQualifier& theQualifier,
|
5811 thilo.boehm 1.3 char* clsbase
|
5812 thilo.boehm 1.2 ) const
5813 {
5814 if(theQualifier.name == QUALNAME_USERDEFINED)
5815 {
|
5816 thilo.boehm 1.3 fprintf(_out,"\n\nQualifier user defined name: \'%s\'",
5817 NULLSTR(_getCharString(theQualifier.userDefName,clsbase)));
|
5818 thilo.boehm 1.2 }
5819 else
|
5820 thilo.boehm 1.3 {
5821 fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'",
5822 SCMOClass::qualifierNameStrLit(theQualifier.name).str);
5823 }
5824
5825 fprintf(_out,"\nPropagated : %s",
5826 (theQualifier.propagated ? "True" : "False"));
5827 fprintf(_out,"\nFlavor : %s",
5828 (const char*)(CIMFlavor(theQualifier.flavor).toString().getCString()));
5829
5830 printSCMOValue(theQualifier.value,clsbase);
5831
5832 }
5833
5834 void SCMODump::printSCMOValue(
5835 const SCMBValue& theValue,
5836 char* base,
5837 Boolean verbose) const
5838 {
5839 fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));
5840 fprintf(_out,"\nValue was set: %s",
5841 thilo.boehm 1.3 (theValue.flags.isSet ? "True" : "False"));
5842 if (theValue.flags.isNull)
5843 {
5844 fprintf(_out,"\nIt's a NULL value.");
5845 return;
5846 }
5847 if (theValue.flags.isArray)
5848 {
5849 fprintf(
5850 _out,
5851 "\nThe value is an Array of size: %u",
5852 theValue.valueArraySize);
5853 printArrayValue(
5854 theValue.valueType,
5855 theValue.valueArraySize,
5856 theValue.value,
5857 base,
5858 verbose);
5859 }
5860 else
5861 {
5862 thilo.boehm 1.3 printUnionValue(theValue.valueType,theValue.value,base,verbose);
5863 }
5864
5865 return;
5866
5867 }
5868
5869 void SCMODump::dumpKeyPropertyMask(SCMOClass& testCls ) const
5870 {
5871
5872 SCMBClass_Main* clshdr = testCls.cls.hdr;
5873 char* clsbase = testCls.cls.base;
5874
5875 Uint64 *theKeyMask = (Uint64*)&(clsbase[clshdr->keyPropertyMask.start]);
5876 Uint32 end, noProperties = clshdr->propertySet.number;
5877 Uint32 noMasks = (noProperties-1)/64;
5878 Uint64 printMask = 1;
5879
5880 for (Uint32 i = 0; i <= noMasks; i++ )
5881 {
5882 printMask = 1;
5883 thilo.boehm 1.3 if (i < noMasks)
5884 {
5885 end = 64;
5886 }
5887 else
5888 {
5889 end = noProperties%64;
5890 }
5891
5892 fprintf(_out,"\nkeyPropertyMask[%02u]= ",i);
5893
5894 for (Uint32 j = 0; j < end; j++)
5895 {
5896 if (j > 0 && !(j%8))
5897 {
5898 fprintf(_out," ");
5899 }
5900
5901 if (theKeyMask[i] & printMask)
5902 {
5903 fprintf(_out,"1");
5904 thilo.boehm 1.3 }
5905 else
5906 {
5907 fprintf(_out,"0");
5908 }
5909
5910 printMask = printMask << 1;
5911 }
5912 fprintf(_out,"\n");
5913 }
5914 }
5915
5916 void SCMODump::_hexDump(char* buffer,Uint64 length) const
5917 {
5918
5919 unsigned char printLine[3][80];
5920 int p;
5921 int len;
5922 unsigned char item;
5923
5924 for (Uint64 i = 0; i < length;i=i+1)
5925 thilo.boehm 1.3 {
5926 p = (int)i%80;
5927
5928 if ((p == 0 && i > 0) || i == length-1 )
5929 {
5930 for (int y = 0; y < 3; y=y+1)
5931 {
5932 if (p == 0)
5933 {
5934 len = 80;
5935 } else
5936 {
5937 len = p;
5938 }
|
5939 thilo.boehm 1.1
|
5940 thilo.boehm 1.3 for (int x = 0; x < len; x=x+1)
5941 {
5942 if (y == 0)
5943 {
5944 fprintf(_out,"%c",printLine[y][x]);
5945 }
5946 else
5947 {
5948 fprintf(_out,"%1X",printLine[y][x]);
5949 }
5950 }
5951 fprintf(_out,"\n");
5952 }
5953 fprintf(_out,"\n");
5954 }
|
5955 thilo.boehm 1.1
|
5956 thilo.boehm 1.3 item = (unsigned char)buffer[i];
|
5957 thilo.boehm 1.1
|
5958 thilo.boehm 1.3 if (item < 32 || item > 125 )
5959 {
5960 printLine[0][p] = '.';
5961 } else
5962 {
5963 printLine[0][p] = item;
5964 }
|
5965 thilo.boehm 1.1
|
5966 thilo.boehm 1.3 printLine[1][p] = item/16;
5967 printLine[2][p] = item%16;
|
5968 thilo.boehm 1.1
|
5969 thilo.boehm 1.3 }
|
5970 thilo.boehm 1.1 }
5971
|
5972 thilo.boehm 1.3 void SCMODump::printArrayValue(
|
5973 thilo.boehm 1.1 CIMType type,
|
5974 thilo.boehm 1.3 Uint32 size,
|
5975 thilo.boehm 1.2 SCMBUnion u,
|
5976 thilo.boehm 1.3 char* base,
5977 Boolean verbose) const
|
5978 thilo.boehm 1.1 {
|
5979 thilo.boehm 1.2 Buffer out;
|
5980 thilo.boehm 1.1
|
5981 thilo.boehm 1.3 SCMBUnion* p;
5982 p = (SCMBUnion*)&(base[u.arrayValue.start]);
5983
|
5984 thilo.boehm 1.1 switch (type)
5985 {
5986 case CIMTYPE_BOOLEAN:
|
5987 thilo.boehm 1.2 {
5988 for (Uint32 i = 0; i < size; i++)
5989 {
|
5990 thilo.boehm 1.3 out.append('\'');
5991 _toString(out,p[i].simple.val.bin);
5992 out << STRLIT("\'(hasValue=");
5993 out << (p[i].simple.hasValue ?
5994 STRLIT("TRUE)"):
5995 STRLIT("FALSE)"));
5996 out.append(';');
|
5997 thilo.boehm 1.2 }
|
5998 thilo.boehm 1.3 fprintf(_out,"\nThe values are: %s",out.getData());
|
5999 thilo.boehm 1.2 break;
6000 }
6001
|
6002 thilo.boehm 1.1 case CIMTYPE_UINT8:
|
6003 thilo.boehm 1.2 {
|
6004 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6005 {
6006 out.append('\'');
6007 _toString(out,p[i].simple.val.u8);
6008 out << STRLIT("\'(hasValue=");
6009 out << (p[i].simple.hasValue ?
6010 STRLIT("TRUE)"):
6011 STRLIT("FALSE)"));
6012 out.append(';');
6013 }
6014 fprintf(_out,"\nThe values are: %s",out.getData());
|
6015 thilo.boehm 1.2 break;
6016 }
6017
|
6018 thilo.boehm 1.1 case CIMTYPE_SINT8:
|
6019 thilo.boehm 1.2 {
|
6020 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6021 {
6022 out.append('\'');
6023 _toString(out,p[i].simple.val.s8);
6024 out << STRLIT("\'(hasValue=");
6025 out << (p[i].simple.hasValue ?
6026 STRLIT("TRUE)"):
6027 STRLIT("FALSE)"));
6028 out.append(';');
6029 }
6030 fprintf(_out,"\nThe values are: %s",out.getData());
|
6031 thilo.boehm 1.2 break;
6032 }
6033
|
6034 thilo.boehm 1.1 case CIMTYPE_UINT16:
|
6035 thilo.boehm 1.2 {
|
6036 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6037 {
6038 out.append('\'');
6039 _toString(out,p[i].simple.val.u16);
6040 out << STRLIT("\'(hasValue=");
6041 out << (p[i].simple.hasValue ?
6042 STRLIT("TRUE)"):
6043 STRLIT("FALSE)"));
6044 out.append(';');
6045 }
6046 fprintf(_out,"\nThe values are: %s",out.getData());
|
6047 thilo.boehm 1.2 break;
6048 }
6049
|
6050 thilo.boehm 1.1 case CIMTYPE_SINT16:
|
6051 thilo.boehm 1.2 {
|
6052 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6053 {
6054 out.append('\'');
6055 _toString(out,p[i].simple.val.s16);
6056 out << STRLIT("\'(hasValue=");
6057 out << (p[i].simple.hasValue ?
6058 STRLIT("TRUE)"):
6059 STRLIT("FALSE)"));
6060 out.append(';');
6061 }
6062 fprintf(_out,"\nThe values are: %s",out.getData());
|
6063 thilo.boehm 1.2 break;
6064 }
6065
|
6066 thilo.boehm 1.1 case CIMTYPE_UINT32:
|
6067 thilo.boehm 1.2 {
|
6068 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6069 {
6070 out.append('\'');
6071 _toString(out,p[i].simple.val.u32);
6072 out << STRLIT("\'(hasValue=");
6073 out << (p[i].simple.hasValue ?
6074 STRLIT("TRUE)"):
6075 STRLIT("FALSE)"));
6076 out.append(';');
6077 }
6078 fprintf(_out,"\nThe values are: %s",out.getData());
|
6079 thilo.boehm 1.2 break;
6080 }
6081
|
6082 thilo.boehm 1.1 case CIMTYPE_SINT32:
|
6083 thilo.boehm 1.2 {
|
6084 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6085 {
6086 out.append('\'');
6087 _toString(out,p[i].simple.val.s32);
6088 out << STRLIT("\'(hasValue=");
6089 out << (p[i].simple.hasValue ?
6090 STRLIT("TRUE)"):
6091 STRLIT("FALSE)"));
6092 out.append(';');
6093 }
6094 fprintf(_out,"\nThe values are: %s",out.getData());
|
6095 thilo.boehm 1.2 break;
6096 }
6097
|
6098 thilo.boehm 1.1 case CIMTYPE_UINT64:
|
6099 thilo.boehm 1.2 {
|
6100 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6101 {
6102 out.append('\'');
6103 _toString(out,p[i].simple.val.u64);
6104 out << STRLIT("\'(hasValue=");
6105 out << (p[i].simple.hasValue ?
6106 STRLIT("TRUE)"):
6107 STRLIT("FALSE)"));
6108 out.append(';');
6109 }
6110 fprintf(_out,"\nThe values are: %s",out.getData());
|
6111 thilo.boehm 1.2 break;
6112 }
6113
|
6114 thilo.boehm 1.1 case CIMTYPE_SINT64:
|
6115 thilo.boehm 1.2 {
|
6116 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6117 {
6118 out.append('\'');
6119 _toString(out,p[i].simple.val.s64);
6120 out << STRLIT("\'(hasValue=");
6121 out << (p[i].simple.hasValue ?
6122 STRLIT("TRUE)"):
6123 STRLIT("FALSE)"));
6124 out.append(';');
6125 }
6126 fprintf(_out,"\nThe values are: %s",out.getData());
|
6127 thilo.boehm 1.2 break;
6128 }
6129
|
6130 thilo.boehm 1.1 case CIMTYPE_REAL32:
|
6131 thilo.boehm 1.2 {
|
6132 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6133 {
6134 out.append('\'');
6135 _toString(out,p[i].simple.val.r32);
6136 out << STRLIT("\'(hasValue=");
6137 out << (p[i].simple.hasValue ?
6138 STRLIT("TRUE)"):
6139 STRLIT("FALSE)"));
6140 out.append(';');
6141 }
6142 fprintf(_out,"\nThe values are: %s",out.getData());
|
6143 thilo.boehm 1.2 break;
6144 }
6145
|
6146 thilo.boehm 1.1 case CIMTYPE_REAL64:
|
6147 thilo.boehm 1.2 {
|
6148 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6149 {
6150 out.append('\'');
6151 _toString(out,p[i].simple.val.r64);
6152 out << STRLIT("\'(hasValue=");
6153 out << (p[i].simple.hasValue ?
6154 STRLIT("TRUE)"):
6155 STRLIT("FALSE)"));
6156 out.append(';');
6157 }
6158 fprintf(_out,"\nThe values are: %s",out.getData());
|
6159 thilo.boehm 1.2 break;
6160 }
6161
|
6162 thilo.boehm 1.1 case CIMTYPE_CHAR16:
6163 {
|
6164 thilo.boehm 1.3 for (Uint32 i = 0; i < size; i++)
6165 {
6166 out.append('\'');
6167 _toString(out,p[i].simple.val.c16);
6168 out << STRLIT("\'(hasValue=");
6169 out << (p[i].simple.hasValue ?
6170 STRLIT("TRUE)"):
6171 STRLIT("FALSE)"));
6172 out.append(';');
6173 }
6174 fprintf(_out,"\nThe values are: %s",out.getData());
|
6175 thilo.boehm 1.1 break;
6176 }
6177
6178 case CIMTYPE_STRING:
6179 {
|
6180 thilo.boehm 1.2 for (Uint32 i = 0; i < size; i++)
|
6181 thilo.boehm 1.1 {
|
6182 thilo.boehm 1.3 if ( 0 != p[i].stringValue.size)
6183 {
6184 out.append('\'');
6185 out.append(
6186 (const char*)_getCharString(p[i].stringValue,base),
6187 p[i].stringValue.size-1);
6188 out.append('\'');
6189 }
6190 else
6191 {
6192 out << STRLIT("NULL;");
6193 }
6194 out.append(';');
|
6195 thilo.boehm 1.2 }
|
6196 thilo.boehm 1.3 fprintf(_out,"\nThe values are: %s",out.getData());
|
6197 thilo.boehm 1.2 break;
6198 }
|
6199 thilo.boehm 1.1
|
6200 thilo.boehm 1.2 case CIMTYPE_DATETIME:
6201 {
6202 CIMDateTime x;
6203 for (Uint32 i = 0; i < size; i++)
|
6204 thilo.boehm 1.1 {
|
6205 thilo.boehm 1.3 memcpy(x._rep,&(p[i].dateTimeValue),sizeof(SCMBDateTime));
|
6206 thilo.boehm 1.2 _toString(out,x);
|
6207 thilo.boehm 1.3 out.append(' ');
|
6208 thilo.boehm 1.1 }
|
6209 thilo.boehm 1.3 fprintf(_out,"\nThe values are: %s",out.getData());
|
6210 thilo.boehm 1.1 break;
6211 }
6212
6213 case CIMTYPE_REFERENCE:
|
6214 thilo.boehm 1.3 case CIMTYPE_OBJECT:
6215 case CIMTYPE_INSTANCE:
|
6216 thilo.boehm 1.2 {
|
6217 thilo.boehm 1.3 if (verbose)
6218 {
6219 for (Uint32 i = 0; i < size; i++)
6220 {
6221 fprintf(_out,"\n-----------> "
6222 "Start of embedded external reference [%d]"
6223 " <-----------\n\n",i);
6224 dumpSCMOInstance(*(p[i].extRefPtr));
6225 fprintf(_out,"\n-----------> "
6226 "End of embedded external reference [%d]"
6227 " <-----------\n\n",i);
6228 }
6229
6230 } else
6231 {
6232 fprintf(_out,"\nThe values are: ");
6233
6234 for (Uint32 i = 0; i < size; i++)
6235 {
6236 fprintf(
6237 _out,
6238 thilo.boehm 1.3 "Pointer to external Reference[%d] : \'%p\';",
6239 i,p[i].extRefPtr);
6240 }
6241 }
|
6242 thilo.boehm 1.1
|
6243 thilo.boehm 1.2 break;
|
6244 thilo.boehm 1.1
|
6245 thilo.boehm 1.2 }
|
6246 thilo.boehm 1.1 default:
|
6247 thilo.boehm 1.2 {
|
6248 thilo.boehm 1.3 PEGASUS_ASSERT(false);
6249 break;
|
6250 thilo.boehm 1.2 }
|
6251 thilo.boehm 1.1 }
6252
|
6253 thilo.boehm 1.3 return;
|
6254 thilo.boehm 1.1 }
6255
|
6256 thilo.boehm 1.3 void SCMODump::printUnionValue(
6257 CIMType type,
|
6258 thilo.boehm 1.2 SCMBUnion u,
|
6259 thilo.boehm 1.3 char* base,
6260 Boolean verbose) const
|
6261 thilo.boehm 1.1 {
|
6262 thilo.boehm 1.3
|
6263 thilo.boehm 1.2 Buffer out;
|
6264 thilo.boehm 1.1
|
6265 thilo.boehm 1.2 switch (type)
|
6266 thilo.boehm 1.1 {
|
6267 thilo.boehm 1.2 case CIMTYPE_BOOLEAN:
6268 {
|
6269 thilo.boehm 1.3 _toString(out,u.simple.val.bin);
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_UINT8:
6275 {
|
6276 thilo.boehm 1.3 _toString(out,u.simple.val.u8);
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_SINT8:
6282 {
|
6283 thilo.boehm 1.3 _toString(out,u.simple.val.s8);
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_UINT16:
6289 {
|
6290 thilo.boehm 1.3 _toString(out,(Uint32)u.simple.val.u16);
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_SINT16:
6296 {
|
6297 thilo.boehm 1.3 _toString(out,u.simple.val.s16);
6298 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6299 thilo.boehm 1.2 break;
6300 }
|
6301 thilo.boehm 1.1
|
6302 thilo.boehm 1.2 case CIMTYPE_UINT32:
6303 {
|
6304 thilo.boehm 1.3 _toString(out,u.simple.val.u32);
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_SINT32:
6310 {
|
6311 thilo.boehm 1.3 _toString(out,u.simple.val.s32);
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_UINT64:
|
6317 thilo.boehm 1.1 {
|
6318 thilo.boehm 1.3 _toString(out,u.simple.val.u64);
6319 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6320 thilo.boehm 1.2 break;
|
6321 thilo.boehm 1.1 }
6322
|
6323 thilo.boehm 1.2 case CIMTYPE_SINT64:
6324 {
|
6325 thilo.boehm 1.3 _toString(out,u.simple.val.s64);
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_REAL32:
6331 {
|
6332 thilo.boehm 1.3 _toString(out,u.simple.val.r32);
6333 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6334 thilo.boehm 1.2 break;
6335 }
|
6336 thilo.boehm 1.1
|
6337 thilo.boehm 1.2 case CIMTYPE_REAL64:
6338 {
|
6339 thilo.boehm 1.3 _toString(out,u.simple.val.r32);
6340 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6341 thilo.boehm 1.2 break;
6342 }
|
6343 thilo.boehm 1.1
|
6344 thilo.boehm 1.2 case CIMTYPE_CHAR16:
6345 {
|
6346 thilo.boehm 1.3 _toString(out,u.simple.val.c16);
6347 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6348 thilo.boehm 1.2 break;
6349 }
|
6350 thilo.boehm 1.1
|
6351 thilo.boehm 1.2 case CIMTYPE_STRING:
6352 {
|
6353 thilo.boehm 1.3 if ( 0 != u.stringValue.size)
6354 {
6355 out.append((const char*)_getCharString(u.stringValue,base),
6356 u.stringValue.size-1);
6357 }
6358 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6359 thilo.boehm 1.2 break;
6360 }
|
6361 thilo.boehm 1.1
|
6362 thilo.boehm 1.2 case CIMTYPE_DATETIME:
6363 {
6364 CIMDateTime x;
|
6365 thilo.boehm 1.3 memcpy(x._rep,&(u.dateTimeValue),sizeof(SCMBDateTime));
|
6366 thilo.boehm 1.2 _toString(out,x);
|
6367 thilo.boehm 1.3 fprintf(_out,"\nThe Value is: '%s'",out.getData());
|
6368 thilo.boehm 1.2 break;
6369 }
|
6370 thilo.boehm 1.1
|
6371 thilo.boehm 1.2 case CIMTYPE_REFERENCE:
6372 case CIMTYPE_OBJECT:
|
6373 thilo.boehm 1.3 case CIMTYPE_INSTANCE:
|
6374 thilo.boehm 1.2 {
|
6375 thilo.boehm 1.3 if (verbose)
6376 {
6377 fprintf(_out,"\n-----------> "
6378 "Start of embedded external reference"
6379 " <-----------\n\n");
6380 dumpSCMOInstance(*u.extRefPtr);
6381 fprintf(_out,"\n-----------> "
6382 "End of embedded external reference"
6383 " <-----------\n\n");
6384 } else
6385 {
6386 fprintf(
6387 _out,
6388 "Pointer to external Reference : \'%p\'",
6389 u.extRefPtr);
6390 }
|
6391 thilo.boehm 1.1
|
6392 thilo.boehm 1.2 break;
6393 }
6394 default:
6395 {
|
6396 thilo.boehm 1.3 PEGASUS_ASSERT(false);
6397 break;
|
6398 thilo.boehm 1.2 }
6399 }
|
6400 thilo.boehm 1.1
|
6401 thilo.boehm 1.3 return;
|
6402 thilo.boehm 1.1 }
6403
6404
|
6405 thilo.boehm 1.2 /*****************************************************************************
6406 * The constant functions
6407 *****************************************************************************/
6408
|
6409 thilo.boehm 1.3 #ifdef PEGASUS_HAS_ICU
6410 Uint32 _utf8ICUncasecmp(
6411 const char* a,
6412 const char* b,
6413 Uint32 len)
|
6414 thilo.boehm 1.1 {
|
6415 thilo.boehm 1.3 UErrorCode errorCode=U_ZERO_ERROR;
6416
6417 Uint32 rc, a16len,b16len,utf16BufLen;
6418 utf16BufLen = (len*sizeof(UChar))+2;
|
6419 thilo.boehm 1.1
|
6420 thilo.boehm 1.3 UChar* a_UTF16 = (UChar*)malloc(utf16BufLen);
6421 UChar* b_UTF16 = (UChar*)malloc(utf16BufLen);
|
6422 thilo.boehm 1.1
|
6423 thilo.boehm 1.3 UConverter *conv = ucnv_open(0, &errorCode);
6424 if(U_FAILURE(errorCode))
6425 {
6426 free(a_UTF16);
6427 free(b_UTF16);
6428 String message("SCMO::_utf8ICUncasecmp() ICUError: ");
6429 message.append(u_errorName(errorCode));
6430 message.append(" Can not open ICU default converter!");
6431 throw CIMException(CIM_ERR_FAILED,message );
6432 }
|
6433 thilo.boehm 1.1
|
6434 thilo.boehm 1.3 a16len = ucnv_toUChars(conv,a_UTF16,utf16BufLen,a,len,&errorCode);
|
6435 thilo.boehm 1.1
|
6436 thilo.boehm 1.3 if(U_FAILURE(errorCode))
|
6437 thilo.boehm 1.1 {
|
6438 thilo.boehm 1.3 free(a_UTF16);
6439 free(b_UTF16);
6440 ucnv_close(conv);
6441 String message("SCMO::_utf8ICUncasecmp() ICUError: ");
6442 message.append(u_errorName(errorCode));
6443 message.append(" Can not convert string a:'");
6444 message.append(String(a,len));
6445 message.append('\'');
6446 throw CIMException(CIM_ERR_FAILED,message );
|
6447 thilo.boehm 1.1 }
6448
|
6449 thilo.boehm 1.3 b16len = ucnv_toUChars(conv,b_UTF16,utf16BufLen,b,len,&errorCode);
6450
6451 if(U_FAILURE(errorCode))
|
6452 thilo.boehm 1.1 {
|
6453 thilo.boehm 1.3 free(a_UTF16);
6454 free(b_UTF16);
6455 ucnv_close(conv);
6456 String message("SCMO::_utf8ICUncasecmp() ICUError: ");
6457 message.append(u_errorName(errorCode));
6458 message.append(" Can not convert string 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 rc = u_strCaseCompare(
6465 a_UTF16,a16len,
6466 b_UTF16,b16len,
6467 U_FOLD_CASE_DEFAULT,
6468 &errorCode);
|
6469 thilo.boehm 1.2
|
6470 thilo.boehm 1.3 if(U_FAILURE(errorCode))
|
6471 thilo.boehm 1.1 {
|
6472 thilo.boehm 1.3 free(a_UTF16);
6473 free(b_UTF16);
6474 ucnv_close(conv);
6475 String message("SCMO::_utf8ICUncasecmp() ICUError: ");
6476 message.append(u_errorName(errorCode));
6477 message.append(" Can not compare string a:'");
6478 message.append(String(a,len));
6479 message.append("' with b: '");
6480 message.append(String(b,len));
6481 message.append('\'');
6482 throw CIMException(CIM_ERR_FAILED,message );
|
6483 thilo.boehm 1.1 }
6484
|
6485 thilo.boehm 1.3 free(a_UTF16);
6486 free(b_UTF16);
6487 ucnv_close(conv);
|
6488 thilo.boehm 1.1
|
6489 thilo.boehm 1.3 return(rc);
|
6490 thilo.boehm 1.1 }
|
6491 thilo.boehm 1.3 #endif
|
6492 thilo.boehm 1.1
6493 /**
6494 * This function calcutates a free memory slot in the single chunk memory block.
|
6495 thilo.boehm 1.2 * Warning: In this routine a reallocation may take place.
|
6496 thilo.boehm 1.1 * @param ptr A reference to a data SCMB data pointer. The values to the free
|
6497 thilo.boehm 1.2 * block is written into this pointer. If the provided ptr is
6498 * located in the single chunk memory block, this pointer may be
6499 * invalid after this call. You have to recalcuate the pointer
|
6500 thilo.boehm 1.1 * after calling this function.
6501 * @parm size The requested free memory slot.
6502 * @parm pmem A reference to the pointer of the single chunk memory block.
6503 * e.g. &cls.mem
6504 * @return The relaive index of the free memory slot.
6505 */
|
6506 thilo.boehm 1.3 Uint64 _getFreeSpace(
|
6507 thilo.boehm 1.2 SCMBDataPtr& ptr,
|
6508 thilo.boehm 1.3 Uint32 size,
6509 SCMBMgmt_Header** pmem)
|
6510 thilo.boehm 1.1 {
6511 Uint64 oldSize, start;
|
6512 marek 1.4 Uint64 alignedStart, reqAlignSize;
|
6513 thilo.boehm 1.1
6514 if (size == 0)
6515 {
6516 ptr.start = 0;
|
6517 thilo.boehm 1.3 ptr.size = 0;
|
6518 thilo.boehm 1.1 return 0;
6519 }
6520
|
6521 thilo.boehm 1.2 // The SCMBDataPtr has to be set before any reallocation.
|
6522 thilo.boehm 1.1 start = (*pmem)->startOfFreeSpace;
|
6523 marek 1.4
6524 // Need to align the start of freespace to 8 byte
6525 // boundaries to avoid alignment issues on some architectures
6526 // Round up to nearest multiple of 8
6527 alignedStart = (start + 7) & ~7;
6528 // due to the alignment, a little more room is needed in the SCMB
6529 reqAlignSize = (size + alignedStart - start);
6530
6531 ptr.start = alignedStart;
|
6532 thilo.boehm 1.3 ptr.size = size;
|
6533 marek 1.4 // add 8 bytes of size for later alignment on the next pointer
6534 while ((*pmem)->freeBytes < reqAlignSize)
|
6535 thilo.boehm 1.1 {
6536 // save old size of buffer
6537 oldSize = (*pmem)->totalSize;
6538 // reallocate the buffer, double the space !
6539 // This is a working approach until a better algorithm is found.
|
6540 thilo.boehm 1.3 void* newBlockPtr = realloc((*pmem),(size_t)oldSize*2);
6541 if ((newBlockPtr) == 0)
|
6542 thilo.boehm 1.1 {
|
6543 thilo.boehm 1.2 // Not enough memory!
|
6544 thilo.boehm 1.1 throw PEGASUS_STD(bad_alloc)();
6545 }
|
6546 thilo.boehm 1.3 (*pmem) = (SCMBMgmt_Header*)newBlockPtr;
|
6547 thilo.boehm 1.2 // increase the total size and free space
|
6548 thilo.boehm 1.3 (*pmem)->freeBytes+=oldSize;
6549 (*pmem)->totalSize+=oldSize;
|
6550 thilo.boehm 1.2 }
|
6551 thilo.boehm 1.1
|
6552 marek 1.4 (*pmem)->freeBytes -= reqAlignSize;
6553 (*pmem)->startOfFreeSpace = alignedStart + size;
|
6554 thilo.boehm 1.3
|
6555 marek 1.4 // Init memory from unaligned start up to the size required with alignment
6556 // to zero.
6557 memset(&((char*)(*pmem))[start],0,(size_t)reqAlignSize);
|
6558 marek 1.9 PEGASUS_DEBUG_ASSERT(
6559 ((*pmem)->freeBytes+(*pmem)->startOfFreeSpace) == (*pmem)->totalSize);
|
6560 thilo.boehm 1.1
|
6561 marek 1.4 return alignedStart;
|
6562 thilo.boehm 1.1 }
6563
|
6564 thilo.boehm 1.3 void _setString(
|
6565 thilo.boehm 1.2 const String& theString,
6566 SCMBDataPtr& ptr,
|
6567 thilo.boehm 1.1 SCMBMgmt_Header** pmem)
6568 {
6569
6570 // Get the UTF8 CString
6571 CString theCString=theString.getCString();
|
6572 thilo.boehm 1.2 // Get the real size of the UTF8 sting + \0.
6573 // It maybe greater then the length in the String due to
|
6574 thilo.boehm 1.1 // 4 byte encoding of non ASCII chars.
|
6575 thilo.boehm 1.3 Uint64 start;
6576 Uint32 length = strlen((const char*)theCString)+1;
|
6577 thilo.boehm 1.1
6578 // If the string is not empty.
6579 if (length != 1)
6580 {
6581
6582 // Attention ! In this function a reallocation may take place.
|
6583 thilo.boehm 1.2 // The reference ptr may be unusable after the call to _getFreeSpace
|
6584 thilo.boehm 1.1 // --> use the returned start index.
|
6585 thilo.boehm 1.2 start = _getFreeSpace(ptr , length, pmem);
|
6586 thilo.boehm 1.1 // Copy string including trailing \0
|
6587 thilo.boehm 1.3 memcpy(&((char*)(*pmem))[start],(const char*)theCString,length);
|
6588 thilo.boehm 1.2 }
|
6589 thilo.boehm 1.1 else
6590 {
6591 ptr.start = 0;
|
6592 thilo.boehm 1.3 ptr.size = 0;
|
6593 thilo.boehm 1.1 }
6594 }
6595
|
6596 thilo.boehm 1.3 void _setBinary(
|
6597 thilo.boehm 1.2 const void* theBuffer,
|
6598 thilo.boehm 1.3 Uint32 bufferSize,
|
6599 thilo.boehm 1.2 SCMBDataPtr& ptr,
|
6600 thilo.boehm 1.1 SCMBMgmt_Header** pmem)
6601 {
6602
6603 // If buffer is not empty.
|
6604 thilo.boehm 1.3 if (bufferSize != 0 && theBuffer != 0)
|
6605 thilo.boehm 1.1 {
6606
6607 Uint64 start;
6608 // Attention ! In this function a reallocation may take place.
|
6609 thilo.boehm 1.2 // The reference ptr may be unusable after the call to _getFreeSpace
|
6610 thilo.boehm 1.1 // --> use the returned start index.
|
6611 thilo.boehm 1.2 start = _getFreeSpace(ptr , bufferSize, pmem);
|
6612 thilo.boehm 1.1 // Copy buffer into SCMB
6613 memcpy(
|
6614 thilo.boehm 1.3 &((char*)(*pmem))[start],
|
6615 thilo.boehm 1.1 (const char*)theBuffer,
|
6616 thilo.boehm 1.2 bufferSize);
6617 }
|
6618 thilo.boehm 1.1 else
6619 {
6620 ptr.start = 0;
|
6621 thilo.boehm 1.3 ptr.size = 0;
|
6622 thilo.boehm 1.1 }
6623 }
6624
|
6625 thilo.boehm 1.3 void _destroyExternalReferencesInternal(SCMBMgmt_Header* memHdr)
6626 {
6627
6628 Uint32 number = memHdr->numberExtRef;
6629
6630 if (0 != number)
6631 {
6632 char * base = ((char*)memHdr);
6633 Uint64* array =
6634 (Uint64*)&(base[memHdr->extRefIndexArray.start]);
6635 for (Uint32 i = 0; i < number; i++)
6636 {
6637 delete ((SCMBUnion*)(&(base[array[i]])))->extRefPtr;
6638 }
6639
6640 }
6641 }
|
6642 thilo.boehm 1.1
6643 PEGASUS_NAMESPACE_END
|