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 #include "SCMO.h"
33 #include <Pegasus/Common/CharSet.h>
34 #include <Pegasus/Common/CIMDateTimeRep.h>
35 #include <Pegasus/Common/CIMPropertyRep.h>
36 #include <Pegasus/Common/CommonUTF.h>
37 #include <Pegasus/Common/StrLit.h>
|
38 thilo.boehm 1.2 #include <Pegasus/Common/XmlWriter.h>
|
39 thilo.boehm 1.1
40
41
42 PEGASUS_USING_STD;
43
44 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096
45
46
47 PEGASUS_NAMESPACE_BEGIN
48
|
49 thilo.boehm 1.2 static StrLit _qualifierNameStrLit[] =
|
50 thilo.boehm 1.1 {
|
51 thilo.boehm 1.2 STRLIT(""),
52 STRLIT("ABSTRACT"),
53 STRLIT("AGGREGATE"),
54 STRLIT("AGGREGATION"),
55 STRLIT("ALIAS"),
56 STRLIT("ARRATYPE"),
57 STRLIT("BITMAP"),
58 STRLIT("BITVALUES"),
59 STRLIT("CLASSCONSTRAINT"),
60 STRLIT("COMPOSITION"),
61 STRLIT("CORRELATABLE"),
|
62 thilo.boehm 1.1 STRLIT("COUNTER"),
63 STRLIT("DELETE"),
|
64 thilo.boehm 1.2 STRLIT("DEPRECATED"),
|
65 thilo.boehm 1.1 STRLIT("DESCRIPTION"),
|
66 thilo.boehm 1.2 STRLIT("DISPLAYDESCRIPTION"),
67 STRLIT("DISPLAYNAME"),
68 STRLIT("DN"),
|
69 thilo.boehm 1.1 STRLIT("EMBEDDEDINSTANCE"),
|
70 thilo.boehm 1.2 STRLIT("EMBEDDEDOBJECT"),
71 STRLIT("EXCEPTION"),
72 STRLIT("EXPENSIVE"),
73 STRLIT("EXPERIMENTAL"),
74 STRLIT("GAUGE"),
75 STRLIT("IFDELETE"),
76 STRLIT("IN"),
77 STRLIT("INVISIBLE"),
|
78 thilo.boehm 1.1 STRLIT("ISPUNIT"),
|
79 thilo.boehm 1.2 STRLIT("KEY"),
|
80 thilo.boehm 1.1 STRLIT("LARGE"),
|
81 thilo.boehm 1.2 STRLIT("MAPPINGSTRINGS"),
82 STRLIT("MAX"),
83 STRLIT("MAXLEN"),
84 STRLIT("MAXVALUE"),
|
85 thilo.boehm 1.1 STRLIT("METHODCONSTRAINT"),
|
86 thilo.boehm 1.2 STRLIT("MIN"),
87 STRLIT("MINLEN"),
88 STRLIT("MINVALUE"),
89 STRLIT("MODELCORRESPONDENCE"),
90 STRLIT("NONLOCAL"),
91 STRLIT("NONLOCALTYPE"),
92 STRLIT("NULLVALUE"),
93 STRLIT("OCTETSTRING"),
94 STRLIT("OUT"),
95 STRLIT("OVERRIDE"),
|
96 thilo.boehm 1.1 STRLIT("PROPAGATED"),
|
97 thilo.boehm 1.2 STRLIT("PROPERTYCONSTRAINT"),
98 STRLIT("PROPERTYUSAGE"),
99 STRLIT("PROVIDER"),
100 STRLIT("PUNIT"),
101 STRLIT("READ"),
102 STRLIT("REQUIRED"),
103 STRLIT("REVISION"),
104 STRLIT("SCHEMA"),
105 STRLIT("SOURCE"),
106 STRLIT("SOURCETYPE"),
107 STRLIT("STATIC"),
108 STRLIT("SYNTAX"),
109 STRLIT("SYNTAXTYPE"),
110 STRLIT("TERMINAL"),
111 STRLIT("TRIGGERTYPE"),
112 STRLIT("UMLPACKAGEPATH"),
|
113 thilo.boehm 1.1 STRLIT("UNITS"),
|
114 thilo.boehm 1.2 STRLIT("UNKNOWNVALUES"),
|
115 thilo.boehm 1.1 STRLIT("UNSUPPORTEDVALUES"),
|
116 thilo.boehm 1.2 STRLIT("VALUEMAP"),
117 STRLIT("VALUES"),
118 STRLIT("VERSION"),
119 STRLIT("WEEK"),
|
120 thilo.boehm 1.1 STRLIT("WRITE")
121 };
122
|
123 thilo.boehm 1.2 #define _NUM_QUALIFIER_NAMES \
124 (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0]))
|
125 thilo.boehm 1.1
126 /*****************************************************************************
127 * The SCMOClass methods
128 *****************************************************************************/
|
129 thilo.boehm 1.2 SCMOClass::SCMOClass()
|
130 thilo.boehm 1.1 {
131 cls.mem = NULL;
132 }
133
134 SCMOClass::SCMOClass(CIMClass& theCIMClass)
135 {
136 PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
137 - sizeof(SCMBClass_Main)>0);
138
139 cls.base = (unsigned char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
140 if (cls.base == NULL)
141 {
|
142 thilo.boehm 1.2 // Not enough memory!
|
143 thilo.boehm 1.1 throw PEGASUS_STD(bad_alloc)();
144 }
145
146 // initalize eye catcher
147 cls.hdr->header.magic=PEGASUS_SCMB_CLASS_MAGIC;
148 cls.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
|
149 thilo.boehm 1.2 // The # of bytes free
|
150 thilo.boehm 1.1 cls.hdr->header.freeBytes=
151 SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBClass_Main);
152
153 // Index to the start of the free space in this instance
154 cls.hdr->header.startOfFreeSpace=sizeof(SCMBClass_Main);
155
156 cls.hdr->refCount=1;
157
158 try
159 {
160 _setString(theCIMClass.getSuperClassName().getString(),
161 cls.hdr->superClassName,
162 &cls.mem );
163 }
164 catch (UninitializedObjectException&)
165 {
166 // there is no Super ClassName
167 cls.hdr->superClassName.start=0;
168 cls.hdr->superClassName.length=0;
169 }
170
171 thilo.boehm 1.1 CIMObjectPath theObjectPath=theCIMClass.getPath();
172
173 //set name space
174 _setString(theObjectPath.getNameSpace().getString(),
175 cls.hdr->nameSpace,
176 &cls.mem );
177
|
178 thilo.boehm 1.2
|
179 thilo.boehm 1.1
180 //set class name
181 _setString(theObjectPath.getClassName().getString(),
182 cls.hdr->className,
183 &cls.mem );
184
185
186 //set class Qualifiers
187 _setClassQualifers(theCIMClass);
188
189 //set properties
190 _setClassProperties(theCIMClass);
191
192 }
193
194 void SCMOClass::getKeyNamesAsString(Array<String>& keyNames) const
195 {
196 SCMBKeyBindingNode* nodeArray =
197 (SCMBKeyBindingNode*)&(cls.base[cls.hdr->keyBindingSet.nodeArray.start]);
198
199 keyNames.clear();
200 thilo.boehm 1.1
201 for (Uint32 i = 0 ; i < cls.hdr->propertySet.number; i++)
202 {
|
203 thilo.boehm 1.2 // Append the key property name.
|
204 thilo.boehm 1.1 // The length has to be reduces by 1 not to copy the trailing '\0'
205 keyNames.append(
206 String((const char*)_getCharString(nodeArray[i].name,cls.base),
207 nodeArray[i].name.length-1));
208
209 }
210 }
211
212 SCMO_RC SCMOClass::_getKeyBindingNodeIndex(Uint32& node, const char* name) const
213 {
214
215 Uint32 tag,len,hashIdx;
216
217 len = strlen(name);
|
218 thilo.boehm 1.2 tag = _generateStringTag((const unsigned char*)name, len);
|
219 thilo.boehm 1.1 // get the node index of the hash table
|
220 thilo.boehm 1.2 hashIdx =
|
221 thilo.boehm 1.1 cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE];
222 // there is no entry in the hash table on this hash table index.
223 if (hashIdx == 0)
224 {
225 // property name not found
226 return SCMO_NOT_FOUND;
227 }
228
229 // get the propterty node array
|
230 thilo.boehm 1.2 SCMBKeyBindingNode* nodeArray =
|
231 thilo.boehm 1.1 (SCMBKeyBindingNode*)
232 &(cls.base[cls.hdr->keyBindingSet.nodeArray.start]);
233
|
234 thilo.boehm 1.2 // set property node array index.
|
235 thilo.boehm 1.1 // The hash table index to the node arra in one larger!
236 node = hashIdx - 1;
237
238 do
239 {
240 // do they have the same hash tag ?
241 if (nodeArray[node].nameHashTag == tag)
242 {
243 // Now it is worth to compare the two names
244 if (_equalUTF8Strings(
245 nodeArray[node].name,cls.base,name,len))
246 {
247 // we found the property !
248 return SCMO_OK;
249 }
250 }
251 // Are we at the end of the chain ?
252 if (!nodeArray[node].hasNext)
253 {
254 // property name not found
255 return SCMO_NOT_FOUND;
256 thilo.boehm 1.1 }
257
258 // get next node index.
259 node = nodeArray[node].nextNode;
260
261 } while ( true );
262
263 // this should never be reached
264 return SCMO_NOT_FOUND;
265
266 }
267
268
269 SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const
270 {
271
272 Uint32 tag,len,hashIdx;
273
274 len = strlen(name);
|
275 thilo.boehm 1.2 tag = _generateStringTag((const unsigned char*)name, len);
|
276 thilo.boehm 1.1 // get the node index of the hash table
|
277 thilo.boehm 1.2 hashIdx =
|
278 thilo.boehm 1.1 cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE];
279 // there is no entry in the hash table on this hash table index.
280 if (hashIdx == 0)
281 {
282 // property name not found
283 return SCMO_NOT_FOUND;
284 }
285
286 // get the propterty node array
|
287 thilo.boehm 1.2 SCMBClassPropertyNode* nodeArray =
|
288 thilo.boehm 1.1 (SCMBClassPropertyNode*)
289 &(cls.base[cls.hdr->propertySet.nodeArray.start]);
290
|
291 thilo.boehm 1.2 // set property node array index.
|
292 thilo.boehm 1.1 // The hash table index to the node arra in one larger!
293 node = hashIdx - 1;
294
295 do
296 {
297 // do they have the same hash tag ?
298 if (nodeArray[node].theProperty.nameHashTag == tag)
299 {
300 // Now it is worth to compare the two names
301 if (_equalUTF8Strings(
302 nodeArray[node].theProperty.name,cls.base,name,len))
303 {
304 // we found the property !
305 return SCMO_OK;
306 }
307 }
308 // Are we at the end of the chain ?
309 if (!nodeArray[node].hasNext)
310 {
311 // property name not found
312 return SCMO_NOT_FOUND;
313 thilo.boehm 1.1 }
314
315 // get next node index.
316 node = nodeArray[node].nextNode;
317
318 } while ( true );
319
320 // this should never be reached
321 return SCMO_NOT_FOUND;
322
323 }
324
325 void SCMOClass::_setClassProperties(CIMClass& theCIMClass)
326 {
327 Uint32 noProps = theCIMClass.getPropertyCount();
328 Uint64 start, startKeyIndexList;
329 Uint32 noKeys = 0;
330 Boolean isKey = false;
331
332 Uint32 keyIndex[noProps];
333
334 thilo.boehm 1.1 cls.hdr->propertySet.number=noProps;
335
336 // allocate the keyIndexList
337 startKeyIndexList = _getFreeSpace(
338 cls.hdr->keyIndexList,
339 noProps*sizeof(Uint32),
340 &cls.mem,
341 true);
|
342 thilo.boehm 1.2
|
343 thilo.boehm 1.1 if(noProps != 0)
344 {
|
345 thilo.boehm 1.2 // Allocate key property mask.
346 // Each property needs a bit in the mask.
|
347 thilo.boehm 1.1 // The number of Uint64 in the key mask is :
|
348 thilo.boehm 1.2 // Decrease the number of properties by 1 since
|
349 thilo.boehm 1.1 // the array is starting at 0!
350 // Divided with the number of bits in a Uint64.
351 // e.g. number of Properties = 68
|
352 thilo.boehm 1.2 // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values.
|
353 thilo.boehm 1.1 _getFreeSpace(cls.hdr->keyPropertyMask,
354 sizeof(Uint64)*(((noProps-1)/64)+1),
355 &cls.mem);
356
357 // allocate property array and save the start index of the array.
358 start = _getFreeSpace(cls.hdr->propertySet.nodeArray,
359 sizeof(SCMBClassPropertyNode)*noProps,
|
360 thilo.boehm 1.2 &cls.mem);
|
361 thilo.boehm 1.1
362 // clear the hash table
363 memset(cls.hdr->propertySet.hashTable,
364 0,
365 PEGASUS_PROPERTY_SCMB_HASHSIZE*sizeof(Uint32));
366
367 _clearKeyPropertyMask();
368
369 for (Uint32 i = 0; i < noProps; i++)
370 {
371
372 _setProperty(start,&isKey ,theCIMClass.getProperty(i));
373 if(isKey)
374 {
|
375 thilo.boehm 1.2 // if the property is a key
|
376 thilo.boehm 1.1 // save the key index
377 keyIndex[noKeys]=i;
378 noKeys++;
379 _setPropertyAsKeyInMask(i);
380 }
381 // Adjust ordered set management structures.
382 _insertPropertyIntoOrderedSet(start,i);
383
384 start = start + sizeof(SCMBClassPropertyNode);
385 }
386
387 cls.hdr->keyBindingSet.number = noKeys;
388
389 if (noKeys != 0)
390 {
391 // allocate key binding array and save the start index of the array.
392 start = _getFreeSpace(cls.hdr->keyBindingSet.nodeArray,
393 sizeof(SCMBKeyBindingNode)*noKeys,
|
394 thilo.boehm 1.2 &cls.mem);
|
395 thilo.boehm 1.1
396 // clear the hash table
397 memset(cls.hdr->keyBindingSet.hashTable,
398 0,
399 PEGASUS_KEYBINDIG_SCMB_HASHSIZE*sizeof(Uint32));
400
401 // fill the key index list
402 memcpy(
403 &(cls.base[startKeyIndexList]),
404 keyIndex,
405 noKeys*sizeof(Uint32));
406
407 for (Uint32 i = 0 ; i < noKeys; i++)
408 {
409
410 _setClassKeyBinding(start,theCIMClass.getProperty(keyIndex[i]));
411 // Adjust ordered set management structures.
412 _insertKeyBindingIntoOrderedSet(start,i);
413
414 start = start + sizeof(SCMBKeyBindingNode);
415 }
416 thilo.boehm 1.1
417 }
418 else
419 {
420 cls.hdr->keyBindingSet.nodeArray.start=0;
421 cls.hdr->keyBindingSet.nodeArray.length=0;
422 }
423 }
424 else
425 {
426 cls.hdr->propertySet.nodeArray.start=0;
427 cls.hdr->propertySet.nodeArray.length=0;
428 cls.hdr->keyPropertyMask.start=0;
429 cls.hdr->keyPropertyMask.length=0;
430 cls.hdr->keyBindingSet.nodeArray.start=0;
431 cls.hdr->keyBindingSet.nodeArray.length=0;
432 }
433 }
434
435 void SCMOClass::_insertKeyBindingIntoOrderedSet(Uint64 start, Uint32 newIndex)
436 {
437 thilo.boehm 1.1
|
438 thilo.boehm 1.2 SCMBKeyBindingNode* newKeyNode =
|
439 thilo.boehm 1.1 (SCMBKeyBindingNode*)&(cls.base[start]);
440
441 SCMBKeyBindingNode* scmoKeyNodeArray =
442 (SCMBKeyBindingNode*)
443 &(cls.base[cls.hdr->keyBindingSet.nodeArray.start]);
444
445 Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable;
446
447 if ( newIndex >= cls.hdr->keyBindingSet.number)
448 {
449 throw IndexOutOfBoundsException();
450 }
451
452 // calculate the new hash index of the new property.
453 Uint32 hash = newKeyNode->nameHashTag % PEGASUS_KEYBINDIG_SCMB_HASHSIZE;
454
455 // 0 is an invalid index in the hash table
456 if (hashTable[hash] == 0)
457 {
458 hashTable[hash] = newIndex + 1;
459 return;
460 thilo.boehm 1.1 }
461
462 // get the first node of the hash chain.
463 Uint32 nodeIndex = hashTable[hash]-1;
464
465 do
466 {
467 // is this the same note ?
468 if (nodeIndex == newIndex)
469 {
470 // The node is already in the ordered set
471 return;
472 }
473
474 // Are we at the end of the chain ?
475 if (!scmoKeyNodeArray[nodeIndex].hasNext)
476 {
477 // link the new element at the end of the chain
478 scmoKeyNodeArray[nodeIndex].nextNode = newIndex;
479 scmoKeyNodeArray[nodeIndex].hasNext = true;
480 return;
481 thilo.boehm 1.1 }
482
483 nodeIndex = scmoKeyNodeArray[nodeIndex].nextNode;
484
485 } while ( true );
486
487 // this should never be reached
488 }
489
490 void SCMOClass::_insertPropertyIntoOrderedSet(Uint64 start, Uint32 newIndex)
491 {
492
493
|
494 thilo.boehm 1.2 SCMBClassPropertyNode* newPropNode =
|
495 thilo.boehm 1.1 (SCMBClassPropertyNode*)&(cls.base[start]);
496
497 SCMBClassPropertyNode* scmoPropNodeArray =
498 (SCMBClassPropertyNode*)
499 &(cls.base[cls.hdr->propertySet.nodeArray.start]);
500
501 Uint32 *hashTable = cls.hdr->propertySet.hashTable;
502
503 if ( newIndex >= cls.hdr->propertySet.number)
504 {
505 throw IndexOutOfBoundsException();
506 }
507
508 // calcuate the new hash index of the new property.
|
509 thilo.boehm 1.2 Uint32 hash = newPropNode->theProperty.nameHashTag %
|
510 thilo.boehm 1.1 PEGASUS_PROPERTY_SCMB_HASHSIZE;
511
512 // 0 is an invalid index in the hash table
513 if (hashTable[hash] == 0)
514 {
515 hashTable[hash] = newIndex + 1;
516 return;
517 }
518
519 // get the first node of the hash chain.
520 Uint32 nodeIndex = hashTable[hash]-1;
521
522 do
523 {
524 // is this the same note ?
525 if (nodeIndex == newIndex)
526 {
527 // The node is already in the ordered set
528 return;
529 }
530
531 thilo.boehm 1.1 // Are we at the end of the chain ?
532 if (!scmoPropNodeArray[nodeIndex].hasNext)
533 {
534 // link the new element at the end of the chain
535 scmoPropNodeArray[nodeIndex].nextNode = newIndex;
536 scmoPropNodeArray[nodeIndex].hasNext = true;
537 return;
538 }
539
540 // get next node index.
541 nodeIndex = scmoPropNodeArray[nodeIndex].nextNode;
542
543 } while ( true );
544
545 // this should never be reached
546 }
547
548 void SCMOClass::_setClassKeyBinding(
|
549 thilo.boehm 1.2 Uint64 start,
|
550 thilo.boehm 1.1 const CIMProperty& theCIMProperty)
551 {
552 CIMPropertyRep* propRep = theCIMProperty._rep;
553 Uint64 valueStart;
554
555 // First do all _setString(). Can cause reallocation.
556 _setString(propRep->_name.getString(),
557 ((SCMBKeyBindingNode*)&(cls.base[start]))->name,
558 &cls.mem);
|
559 thilo.boehm 1.2
560 SCMBKeyBindingNode* scmoKeyBindNode =
|
561 thilo.boehm 1.1 (SCMBKeyBindingNode*)&(cls.base[start]);
562
563 // calculate the new hash tag
|
564 thilo.boehm 1.2 scmoKeyBindNode->nameHashTag =
|
565 thilo.boehm 1.1 _generateSCMOStringTag(scmoKeyBindNode->name,cls.base);
566 scmoKeyBindNode->type = _cimTypeToKeyBindType(propRep->_value.getType());
567 scmoKeyBindNode->hasNext=false;
568 scmoKeyBindNode->nextNode=0;
569
570 }
571
572 void SCMOClass::_clearKeyPropertyMask()
573 {
574
575 Uint64 *keyMask;
576
577 // Calculate the real pointer to the Uint64 array
578 keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];
579
580 // the number of Uint64 in the key mask is :
|
581 thilo.boehm 1.2 // Decrease the number of properties by 1
|
582 thilo.boehm 1.1 // since the array is starting at index 0!
583 // Divide with the number of bits in a Uint64.
584 // e.g. number of Properties = 68
|
585 thilo.boehm 1.2 // (68 - 1) / 64 = 1 --> The mask consists of 2 Uint64
|
586 thilo.boehm 1.1
587 memset(keyMask,0, sizeof(Uint64)*(((cls.hdr->propertySet.number-1)/64)+1));
588
589 }
590
591 void SCMOClass::_setPropertyAsKeyInMask(Uint32 i)
592 {
593 Uint64 *keyMask;
594
595 // In which Uint64 of key mask is the bit for property i ?
596 // Divide with the number of bits in a Uint64.
597 // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].
598 Uint32 idx = i/64 ;
599
600 // Create a filter to set the bit.
601 // Modulo division with 64. Shift left a bit by the remainder.
|
602 thilo.boehm 1.2 Uint64 filter = ( (Uint64)1 << (i%64));
603
|
604 thilo.boehm 1.1 // Calculate the real pointer to the Uint64 array
605 keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];
606
607 keyMask[idx] = keyMask[idx] | filter ;
608 }
609
610 Boolean SCMOClass::_isPropertyKey(Uint32 i)
611 {
612 Uint64 *keyMask;
613
614 // In which Uint64 of key mask is the bit for property i ?
615 // Divide with the number of bits in a Uint64.
616 // e.g. number of Properties = 68
617 // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].
618 Uint32 idx = i/64 ;
619
620 // Create a filter to check if the bit is set:
621 // Modulo division with 64. Shift left a bit by the remainder.
|
622 thilo.boehm 1.2 Uint64 filter = ( (Uint64)1 << (i%64));
|
623 thilo.boehm 1.1
624 // Calculate the real pointer to the Uint64 array
625 keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];
626
627 return keyMask[idx] & filter ;
628
629 }
630
631
632 void SCMOClass::_setProperty(
|
633 thilo.boehm 1.2 Uint64 start,
|
634 thilo.boehm 1.1 Boolean* isKey,
635 const CIMProperty& theCIMProperty)
636 {
637
638 *isKey = false;
639
640 CIMPropertyRep* propRep = theCIMProperty._rep;
641
642 // First do all _setString(). Can cause reallocation.
643
644 _setString(propRep->_name.getString(),
645 ((SCMBClassPropertyNode*)&(cls.base[start]))->theProperty.name,
646 &cls.mem);
647
648 _setString(propRep->_classOrigin.getString(),
649 ((SCMBClassPropertyNode*)
650 &(cls.base[start]))->theProperty.originClassName,
651 &cls.mem);
652
653 _setString(propRep->_referenceClassName.getString(),
654 ((SCMBClassPropertyNode*)&(cls.base[start]))->theProperty.refClassName,
655 thilo.boehm 1.1 &cls.mem);
656
657
|
658 thilo.boehm 1.2 SCMBClassPropertyNode* scmoPropNode =
|
659 thilo.boehm 1.1 (SCMBClassPropertyNode*)&(cls.base[start]);
660
661 // generate new hash tag
|
662 thilo.boehm 1.2 scmoPropNode->theProperty.nameHashTag =
|
663 thilo.boehm 1.1 _generateSCMOStringTag(scmoPropNode->theProperty.name,cls.base);
664
665 scmoPropNode->theProperty.flags.propagated = propRep->_propagated;
666
667 // just for complete intialization.
668 scmoPropNode->hasNext=false;
669 scmoPropNode->nextNode=0;
670
671 // calculate the relative pointer for the default value
|
672 thilo.boehm 1.2 Uint64 valueStart =
|
673 thilo.boehm 1.1 (unsigned char*)&scmoPropNode->theProperty.defaultValue - cls.base;
674
675 _setValue(valueStart,propRep->_value);
676
677 *isKey = _setPropertyQualifiers(start,propRep->_qualifiers);
|
678 thilo.boehm 1.2 // reset property node pointer
|
679 thilo.boehm 1.1 scmoPropNode = (SCMBClassPropertyNode*)&(cls.base[start]);
680 scmoPropNode->theProperty.flags.isKey=*isKey;
681 }
682
683 Boolean SCMOClass::_setPropertyQualifiers(
|
684 thilo.boehm 1.2 Uint64 start,
|
685 thilo.boehm 1.1 const CIMQualifierList& theQualifierList)
686 {
687 Uint32 noQuali = theQualifierList.getCount();
688 Uint64 startArray;
689 QualifierNameEnum propName;
690 Boolean isKey = false;
691
|
692 thilo.boehm 1.2 SCMBClassPropertyNode* scmoPropNode =
|
693 thilo.boehm 1.1 (SCMBClassPropertyNode*)&(cls.base[start]);
694
695 scmoPropNode->theProperty.numberOfQualifiers = noQuali;
696
697
698 if (noQuali != 0)
699 {
700 // allocate qualifier array and save the start of the array.
701 startArray = _getFreeSpace(scmoPropNode->theProperty.qualifierArray,
702 sizeof(SCMBQualifier)*noQuali,
|
703 thilo.boehm 1.2 &cls.mem);
|
704 thilo.boehm 1.1 for (Uint32 i = 0; i < noQuali; i++)
705 {
706 propName = _setQualifier(
707 startArray,
708 theQualifierList.getQualifier(i));
709 // Only set once if the property is identified as key.
710 if(!isKey)
711 {
712 isKey = propName==QUALNAME_KEY;
713 }
|
714 thilo.boehm 1.2
|
715 thilo.boehm 1.1 startArray = startArray + sizeof(SCMBQualifier);
716 }
717 }
718 else
719 {
720 scmoPropNode->theProperty.qualifierArray.start=0;
721 scmoPropNode->theProperty.qualifierArray.length=0;
722 }
723
724 return isKey;
725 }
726 void SCMOClass::_setClassQualifers(CIMClass& theCIMClass)
727 {
728
729 Uint32 noQuali = theCIMClass.getQualifierCount();
730 Uint64 start;
731
732 cls.hdr->numberOfQualifiers = noQuali;
733
734 if (noQuali != 0)
735 {
736 thilo.boehm 1.1 // allocate qualifier array and save the start of the array.
737 start = _getFreeSpace(cls.hdr->qualifierArray,
738 sizeof(SCMBQualifier)*noQuali,
|
739 thilo.boehm 1.2 &cls.mem);
|
740 thilo.boehm 1.1 for (Uint32 i = 0; i < noQuali; i++)
741 {
742 _setQualifier(start,theCIMClass.getQualifier(i));
743 start = start + sizeof(SCMBQualifier);
744
745 }
746
747 }
748 else
749 {
750 cls.hdr->qualifierArray.start=0;
751 cls.hdr->qualifierArray.length=0;
752 }
753
754
755 }
756
757 QualifierNameEnum SCMOClass::_setQualifier(
|
758 thilo.boehm 1.2 Uint64 start,
|
759 thilo.boehm 1.1 const CIMQualifier& theCIMQualifier)
760 {
761 Uint64 valueStart;
762 QualifierNameEnum name;
763
764 SCMBQualifier* scmoQual = (SCMBQualifier*)&(cls.base[start]);
765 name=_getSCMOQualifierNameEnum(theCIMQualifier.getName());
766
767 scmoQual->propagated = theCIMQualifier.getPropagated();
768 scmoQual->name = name;
769 scmoQual->flavor = theCIMQualifier.getFlavor().cimFlavor;
770
771 valueStart = (unsigned char*)&scmoQual->value - cls.base;
772
773 _setValue(valueStart,theCIMQualifier.getValue());
774
775 // reset the pointer, because the base pointer could be reallocated.
776 scmoQual = (SCMBQualifier*)&(cls.base[start]);
777 if (name == QUALNAME_USERDEFINED)
778 {
779 _setString(theCIMQualifier.getName().getString(),
780 thilo.boehm 1.1 scmoQual->userDefName,&cls.mem);
781 }
782
783 return name;
784 }
785
786 void SCMOClass::_setValue(Uint64 start, const CIMValue& theCIMValue)
787 {
788 Uint64 valueStart;
789
790 CIMValueRep* rep = *((CIMValueRep**)&theCIMValue);
791
792 SCMBValue* scmoValue = (SCMBValue*)&(cls.base[start]);
793 scmoValue->valueType = rep->type;
794 scmoValue->valueArraySize = 0;
795 scmoValue->flags.isNull = rep->isNull;
796 scmoValue->flags.isArray = rep->isArray;
|
797 thilo.boehm 1.2 // Only initalized by for completeness.
|
798 thilo.boehm 1.1 scmoValue->flags.isSet = false;
799
800 valueStart = (unsigned char*)&scmoValue->value - cls.base;
801
802 if (rep->isNull)
803 {
804 return;
805 }
806
807 if (scmoValue->flags.isArray)
808 {
809 scmoValue->valueArraySize = theCIMValue.getArraySize();
810 _setArrayValue(valueStart,rep->type, rep->u);
811 }
812 else
|
813 thilo.boehm 1.2 {
|
814 thilo.boehm 1.1 _setUnionValue(valueStart, rep->type, rep->u);
815 }
816 }
817
818 void SCMOClass::_setArrayValue(Uint64 start, CIMType type, Union& u)
819 {
820 SCMBUnion* scmoUnion = (SCMBUnion*)&(cls.base[start]);
821 Uint64 arrayStart;
822 Uint32 n;
823
824 switch (type)
825 {
826 case CIMTYPE_BOOLEAN:
827 {
828 Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u);
829 n = x->size();
830 arrayStart = _getFreeSpace(
831 scmoUnion->_arrayValue,
832 n*sizeof(Boolean),
833 &cls.mem);
834 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Boolean));
835 thilo.boehm 1.1 break;
836 }
837
838 case CIMTYPE_UINT8:
839 {
840 Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u);
841 n = x->size();
842 arrayStart = _getFreeSpace(
843 scmoUnion->_arrayValue,
844 n*sizeof(Uint8),
845 &cls.mem);
846 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Uint8));
847 break;
848 }
849
850 case CIMTYPE_SINT8:
851 {
852 Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u);
853 n = x->size();
854 arrayStart = _getFreeSpace(
855 scmoUnion->_arrayValue,
856 thilo.boehm 1.1 n*sizeof(Sint8),
857 &cls.mem);
858 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Sint8));
859 break;
860 }
861
862 case CIMTYPE_UINT16:
863 {
864 Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u);
865 n = x->size();
866 arrayStart = _getFreeSpace(
867 scmoUnion->_arrayValue,
868 n*sizeof(Uint16),
869 &cls.mem);
870 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Uint16));
871
872 break;
873 }
874
875 case CIMTYPE_SINT16:
876 {
877 thilo.boehm 1.1 Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u);
878 n = x->size();
879 arrayStart = _getFreeSpace(
880 scmoUnion->_arrayValue,
881 n*sizeof(Sint16),
882 &cls.mem);
883 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Sint16));
884 break;
885 }
886
887 case CIMTYPE_UINT32:
888 {
889 Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u);
890 n = x->size();
891 arrayStart = _getFreeSpace(
892 scmoUnion->_arrayValue,
893 n*sizeof(Uint32),
894 &cls.mem);
895 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Uint32));
896 break;
897 }
898 thilo.boehm 1.1
899 case CIMTYPE_SINT32:
900 {
901 Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u);
902 n = x->size();
903 arrayStart = _getFreeSpace(
904 scmoUnion->_arrayValue,
905 n*sizeof(Sint32),
906 &cls.mem);
907 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Sint32));
908 break;
909 }
910
911 case CIMTYPE_UINT64:
912 {
913 Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u);
914 n = x->size();
915 arrayStart = _getFreeSpace(
916 scmoUnion->_arrayValue,
917 n*sizeof(Uint64),
918 &cls.mem);
919 thilo.boehm 1.1 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Uint64));
920 break;
921 }
922
923 case CIMTYPE_SINT64:
924 {
925 Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u);
926 n = x->size();
927 arrayStart = _getFreeSpace(
928 scmoUnion->_arrayValue,
929 n*sizeof(Sint64),
930 &cls.mem);
931 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Sint64));
932 break;
933 }
934
935 case CIMTYPE_REAL32:
936 {
937 Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u);
938 n = x->size();
939 arrayStart = _getFreeSpace(
940 thilo.boehm 1.1 scmoUnion->_arrayValue,
941 n*sizeof(Real32),
942 &cls.mem);
943 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Real32));
944 break;
945 }
946
947 case CIMTYPE_REAL64:
948 {
949 Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u);
950 n = x->size();
951 arrayStart = _getFreeSpace(
952 scmoUnion->_arrayValue,
953 n*sizeof(Real64),
954 &cls.mem);
955 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Real64));
956 break;
957 }
958
959 case CIMTYPE_CHAR16:
960 {
961 thilo.boehm 1.1 Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u);
962 n = x->size();
963 arrayStart = _getFreeSpace(
964 scmoUnion->_arrayValue,
965 n*sizeof(Char16),
966 &cls.mem);
967 memcpy(&cls.base[arrayStart],x->getData(),n * sizeof(Char16));
968 break;
969 }
970
971 case CIMTYPE_STRING:
972 {
973 SCMBDataPtr *ptr;
974
975 Array<String> *x = reinterpret_cast<Array<String>*>(&u);
976
977 n = x->size();
978 arrayStart = _getFreeSpace(
979 scmoUnion->_arrayValue,
980 n*sizeof(SCMBDataPtr),
981 &cls.mem);
982 thilo.boehm 1.1
983 for (Uint32 i = 0; i < n ; i++)
984 {
985 // the pointer has to be set eache loop,
986 // because a reallocation may take place.
987 ptr = (SCMBDataPtr*)(&cls.base[arrayStart]);
988 _setString( (*x)[i],ptr[i], &cls.mem );
989 }
|
990 thilo.boehm 1.2
|
991 thilo.boehm 1.1 break;
992 }
993
994 case CIMTYPE_DATETIME:
995 {
996 SCMBDateTime *ptr;
997 Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u);
998 n = x->size();
999 arrayStart = _getFreeSpace(
1000 scmoUnion->_arrayValue,
1001 n*sizeof(SCMBDateTime),
1002 &cls.mem);
1003
1004 ptr=(SCMBDateTime*)(&cls.base[arrayStart]);
1005
1006 for (Uint32 i = 0; i < n ; i++)
1007 {
1008 memcpy(&(ptr[i]),(*x)[i]._rep,sizeof(SCMBDateTime));
1009 }
1010 break;
1011 }
1012 thilo.boehm 1.1
1013 case CIMTYPE_REFERENCE:
1014
1015 break;
1016
1017 case CIMTYPE_OBJECT:
1018
1019 break;
1020
1021 case CIMTYPE_INSTANCE:
1022
1023 break;
1024 }
1025 }
1026
1027
1028 void SCMOClass::_setUnionValue(Uint64 start, CIMType type, Union& u)
1029 {
1030 SCMBUnion* scmoUnion = (SCMBUnion*)&(cls.base[start]);
1031
1032 switch (type)
1033 thilo.boehm 1.1 {
1034 case CIMTYPE_BOOLEAN:
1035 {
1036 scmoUnion->_booleanValue = u._booleanValue;
1037 break;
1038 }
1039
1040 case CIMTYPE_UINT8:
1041 {
1042 scmoUnion->_uint8Value = u._uint8Value;
1043 break;
1044 }
1045
1046 case CIMTYPE_SINT8:
1047 {
1048 scmoUnion->_sint8Value = u._sint8Value;
1049 break;
1050 }
1051
1052 case CIMTYPE_UINT16:
1053 {
1054 thilo.boehm 1.1 scmoUnion->_uint16Value = u._uint16Value;
1055 break;
1056 }
1057
1058 case CIMTYPE_SINT16:
1059 {
1060 scmoUnion->_sint16Value = u._sint16Value;
1061 break;
1062 }
1063
1064 case CIMTYPE_UINT32:
1065 {
1066 scmoUnion->_uint32Value = u._uint32Value;
1067 break;
1068 }
1069
1070 case CIMTYPE_SINT32:
1071 {
1072 scmoUnion->_sint32Value = u._sint32Value;
1073 break;
1074 }
1075 thilo.boehm 1.1
1076 case CIMTYPE_UINT64:
1077 {
1078 scmoUnion->_uint64Value = u._uint64Value;
1079 break;
1080 }
1081
1082 case CIMTYPE_SINT64:
1083 {
1084 scmoUnion->_sint64Value = u._sint64Value;
1085 break;
1086 }
1087
1088 case CIMTYPE_REAL32:
1089 {
1090 scmoUnion->_real32Value = u._real32Value;
1091 break;
1092 }
1093
1094 case CIMTYPE_REAL64:
1095 {
1096 thilo.boehm 1.1 scmoUnion->_real64Value = u._real64Value;
1097 break;
1098 }
1099
1100 case CIMTYPE_CHAR16:
1101 {
1102 scmoUnion->_char16Value = u._char16Value;
1103 break;
1104 }
1105
1106 case CIMTYPE_STRING:
1107 {
1108 _setString(*((String*)((void*)&u)),
1109 scmoUnion->_stringValue,
1110 &cls.mem );
1111 break;
1112 }
1113
1114 case CIMTYPE_DATETIME:
1115 {
1116 memcpy(
1117 thilo.boehm 1.1 &scmoUnion->_dateTimeValue,
1118 (*((CIMDateTime*)((void*)&u)))._rep,
1119 sizeof(SCMBDateTime));
1120 break;
1121 }
1122
1123 case CIMTYPE_REFERENCE:
|
1124 thilo.boehm 1.2
|
1125 thilo.boehm 1.1 break;
1126
1127 case CIMTYPE_OBJECT:
|
1128 thilo.boehm 1.2
|
1129 thilo.boehm 1.1 break;
1130 case CIMTYPE_INSTANCE:
|
1131 thilo.boehm 1.2
|
1132 thilo.boehm 1.1 break;
1133 }
1134
1135 }
1136
1137 QualifierNameEnum SCMOClass::_getSCMOQualifierNameEnum(
1138 const CIMName& theCIMName)
1139 {
1140 // Get the UTF8 CString
1141 CString theCString=theCIMName.getString().getCString();
1142 // Get the real size of the UTF8 sting.
1143 Uint32 length = strlen((const char*)theCString);
1144
1145
1146 // The start index is 1, because the at index 0 is a place holder for
1147 // the user defined qualifier name which is not part of the qualifier name
1148 // list.
1149 for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++)
1150 {
|
1151 thilo.boehm 1.2 if (_qualifierNameStrLit[i].size == length)
|
1152 thilo.boehm 1.1 {
|
1153 thilo.boehm 1.2 // TBD: Make it more efficent...
|
1154 thilo.boehm 1.1 if(String::equalNoCase(
1155 theCIMName.getString(),
|
1156 thilo.boehm 1.2 _qualifierNameStrLit[i].str))
|
1157 thilo.boehm 1.1 {
1158 return (QualifierNameEnum)i;
1159 }
1160 }
1161 }
1162
1163 return QUALNAME_USERDEFINED;
1164 }
1165
1166 Boolean SCMOClass::_isSamePropOrigin(Uint32 node, const char* origin) const
1167 {
1168 Uint32 len = strlen(origin);
1169
|
1170 thilo.boehm 1.2 SCMBClassPropertyNode* nodeArray =
|
1171 thilo.boehm 1.1 (SCMBClassPropertyNode*)
1172 &(cls.base[cls.hdr->propertySet.nodeArray.start]);
1173
1174 return(_equalUTF8Strings(
1175 nodeArray[node].theProperty.originClassName,
1176 cls.base,
1177 origin,
1178 len));
1179 }
1180
|
1181 thilo.boehm 1.2 /*****************************************************************************
1182 * The SCMOInstance methods
1183 *****************************************************************************/
1184
1185 SCMOInstance::SCMOInstance()
1186 {
1187 inst.base = NULL;
1188 }
1189
1190 SCMOInstance::SCMOInstance(SCMOClass baseClass)
|
1191 thilo.boehm 1.1 {
|
1192 thilo.boehm 1.2 _initSCMOInstance(new SCMOClass(baseClass),false,false);
|
1193 thilo.boehm 1.1 }
1194
|
1195 thilo.boehm 1.2 SCMOInstance::SCMOInstance(
1196 SCMOClass baseClass,
1197 Boolean includeQualifiers,
1198 Boolean includeClassOrigin,
1199 const char** propertyList)
|
1200 thilo.boehm 1.1 {
1201
|
1202 thilo.boehm 1.2 _initSCMOInstance(
1203 new SCMOClass(baseClass),
1204 includeQualifiers,
1205 includeClassOrigin);
|
1206 thilo.boehm 1.1
|
1207 thilo.boehm 1.2 setPropertyFilter(propertyList);
|
1208 thilo.boehm 1.1
|
1209 thilo.boehm 1.2 }
|
1210 thilo.boehm 1.1
|
1211 thilo.boehm 1.2 void SCMOInstance::_initSCMOInstance(
1212 SCMOClass* pClass,
1213 Boolean inclQual,
1214 Boolean inclOrigin)
1215 {
1216 PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
1217 - sizeof(SCMBInstance_Main)>0);
|
1218 thilo.boehm 1.1
1219
|
1220 thilo.boehm 1.2 inst.base = (unsigned char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
1221 if (inst.base == NULL)
1222 {
1223 // Not enough memory!
1224 throw PEGASUS_STD(bad_alloc)();
|
1225 thilo.boehm 1.1 }
1226
|
1227 thilo.boehm 1.2 // initalize eye catcher
1228 inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;
1229 inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
1230 // The # of bytes free
1231 inst.hdr->header.freeBytes=
1232 SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main);
1233 // Index to the start of the free space in this instance
1234 inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main);
|
1235 thilo.boehm 1.1
|
1236 thilo.boehm 1.2 inst.hdr->refCount=1;
|
1237 thilo.boehm 1.1
|
1238 thilo.boehm 1.2 //Assign the SCMBClass structure this instance based on.
1239 inst.hdr->theClass = pClass;
|
1240 thilo.boehm 1.1
|
1241 thilo.boehm 1.2 // Init flags
1242 inst.hdr->flags.includeQualifiers=inclQual;
1243 inst.hdr->flags.includeClassOrigin=inclOrigin;
1244 inst.hdr->flags.isFiltered=false;
|
1245 thilo.boehm 1.1
|
1246 thilo.boehm 1.2 inst.hdr->hostName.start=0;
1247 inst.hdr->hostName.length=0;
|
1248 thilo.boehm 1.1
|
1249 thilo.boehm 1.2 // Number of key bindings
1250 inst.hdr->numberKeyBindings =
1251 inst.hdr->theClass->cls.hdr->keyBindingSet.number;
|
1252 thilo.boehm 1.1
|
1253 thilo.boehm 1.2 // Number of properties
1254 inst.hdr->numberProperties =
1255 inst.hdr->theClass->cls.hdr->propertySet.number;
|
1256 thilo.boehm 1.1
|
1257 thilo.boehm 1.2 // Allocate the SCMOInstanceKeyBindingArray
1258 _getFreeSpace(
1259 inst.hdr->keyBindingArray,
1260 sizeof(SCMBDataPtr)*inst.hdr->numberKeyBindings,
1261 &inst.mem,
1262 true);
|
1263 thilo.boehm 1.1
|
1264 thilo.boehm 1.2 // Allocate the SCMBPropertyFilter
1265 _getFreeSpace(
1266 inst.hdr->propertyFilter,
1267 sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1),
1268 &inst.mem,
1269 true);
|
1270 thilo.boehm 1.1
|
1271 thilo.boehm 1.2 // Allocate the SCMBPropertyFilterIndexMap
1272 _getFreeSpace(
1273 inst.hdr->propertyFilterIndexMap,
1274 sizeof(Uint32)*inst.hdr->numberProperties,
1275 &inst.mem,
1276 true);
|
1277 thilo.boehm 1.1
|
1278 thilo.boehm 1.2 // Allocate the SCMBInstancePropertyArray
1279 _getFreeSpace(
1280 inst.hdr->propertyArray,
1281 sizeof(SCMBValue)*inst.hdr->numberProperties,
1282 &inst.mem,
1283 true);
|
1284 thilo.boehm 1.1
1285 }
1286
|
1287 thilo.boehm 1.2 SCMO_RC SCMOInstance::getProperty(
1288 const char* name,
1289 CIMType& type,
1290 const void** pvalue,
1291 Boolean& isArray,
1292 Uint32& size ) const
|
1293 thilo.boehm 1.1 {
|
1294 thilo.boehm 1.2 Uint32 node;
1295 const unsigned char** pname;
1296 SCMO_RC rc = SCMO_OK;
|
1297 thilo.boehm 1.1
|
1298 thilo.boehm 1.2 *pvalue = NULL;
1299 isArray = false;
1300 size = 0;
|
1301 thilo.boehm 1.1
|
1302 thilo.boehm 1.2 rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
1303 if (rc != SCMO_OK)
1304 {
1305 return rc;
1306 }
|
1307 thilo.boehm 1.1
|
1308 thilo.boehm 1.2 // is filtering on ?
1309 if (inst.hdr->flags.isFiltered)
|
1310 thilo.boehm 1.1 {
|
1311 thilo.boehm 1.2 // Is the property NOT in the property filter ?
1312 if(!_isPropertyInFilter(node))
|
1313 thilo.boehm 1.1 {
|
1314 thilo.boehm 1.2 // The named propery is not part of this instance
1315 // due to filtering.
1316 return SCMO_NOT_FOUND;
|
1317 thilo.boehm 1.1 }
1318 }
1319
|
1320 thilo.boehm 1.2 return _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size);
|
1321 thilo.boehm 1.1 }
1322
|
1323 thilo.boehm 1.2 SCMO_RC SCMOInstance::getPropertyAt(
1324 Uint32 idx,
1325 const unsigned char** pname,
1326 CIMType& type,
1327 const void** pvalue,
1328 Boolean& isArray,
1329 Uint32& size ) const
|
1330 thilo.boehm 1.1 {
|
1331 thilo.boehm 1.2 *pname = NULL;
1332 *pvalue = NULL;
1333 isArray = false;
1334 size = 0;
1335 Uint32 node;
|
1336 thilo.boehm 1.1
|
1337 thilo.boehm 1.2 // is filtering on ?
1338 if (inst.hdr->flags.isFiltered)
|
1339 thilo.boehm 1.1 {
|
1340 thilo.boehm 1.2 // check the number of properties part of the filter
1341 if (idx >= inst.hdr->filterProperties)
|
1342 thilo.boehm 1.1 {
|
1343 thilo.boehm 1.2 return SCMO_INDEX_OUT_OF_BOUND;
|
1344 thilo.boehm 1.1 }
1345
|
1346 thilo.boehm 1.2 // Get absolut pointer to property filter index map of the instance
1347 Uint32* propertyFilterIndexMap =
1348 (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
|
1349 thilo.boehm 1.1
|
1350 thilo.boehm 1.2 // get the real node index of the property.
1351 node = propertyFilterIndexMap[idx];
1352 }
1353 else
1354 {
1355 // the index is used as node index.
1356 node = idx;
1357 if (node >= inst.hdr->numberProperties)
|
1358 thilo.boehm 1.1 {
|
1359 thilo.boehm 1.2 return SCMO_INDEX_OUT_OF_BOUND;
|
1360 thilo.boehm 1.1 }
|
1361 thilo.boehm 1.2 }
|
1362 thilo.boehm 1.1
|
1363 thilo.boehm 1.2 return _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size);
1364 }
|
1365 thilo.boehm 1.1
|
1366 thilo.boehm 1.2 SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const
1367 {
1368 if(name==NULL)
1369 {
1370 return SCMO_INVALID_PARAMETER;
|
1371 thilo.boehm 1.1 }
1372
|
1373 thilo.boehm 1.2 return (inst.hdr->theClass->_getProperyNodeIndex(node,name));
|
1374 thilo.boehm 1.1 }
|
1375 thilo.boehm 1.2 SCMO_RC SCMOInstance::setPropertyWithOrigin(
1376 const char* name,
1377 CIMType type,
1378 void* value,
1379 Boolean isArray,
1380 Uint32 size,
1381 const char* origin)
1382 {
1383 Uint32 node;
1384 SCMO_RC rc;
|
1385 thilo.boehm 1.1
|
1386 thilo.boehm 1.2 rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);
1387 if (rc != SCMO_OK)
1388 {
1389 return rc;
1390 }
|
1391 thilo.boehm 1.1
|
1392 thilo.boehm 1.2 // is filtering on ?
1393 if (inst.hdr->flags.isFiltered)
1394 {
1395 // Is the property NOT in the property filter ?
1396 if(!_isPropertyInFilter(node))
1397 {
1398 // The named propery is not part of this instance
1399 // due to filtering.
1400 return SCMO_NOT_FOUND;
1401 }
1402 }
|
1403 thilo.boehm 1.1
|
1404 thilo.boehm 1.2 // check class origin if set.
1405 if (origin!= NULL)
|
1406 thilo.boehm 1.1 {
|
1407 thilo.boehm 1.2 if(!inst.hdr->theClass->_isSamePropOrigin(node,origin))
1408 {
1409 return SCMO_NOT_SAME_ORIGIN;
1410 }
|
1411 thilo.boehm 1.1 }
|
1412 thilo.boehm 1.2
1413 _setPropertyAtNodeIndex(node,type,value,isArray,size);
1414
1415 return SCMO_OK;
|
1416 thilo.boehm 1.1 }
1417
|
1418 thilo.boehm 1.2 SCMO_RC SCMOInstance::setPropertyWithNodeIndex(
1419 Uint32 node,
1420 CIMType type,
1421 void* value,
1422 Boolean isArray,
1423 Uint32 size)
1424 {
1425 if (node >= inst.hdr->numberProperties)
|
1426 thilo.boehm 1.1 {
|
1427 thilo.boehm 1.2 return SCMO_INDEX_OUT_OF_BOUND;
1428 }
1429
1430 // is filtering on ?
1431 if (inst.hdr->flags.isFiltered)
|
1432 thilo.boehm 1.1 {
|
1433 thilo.boehm 1.2 // Is the property NOT in the property filter ?
1434 if(!_isPropertyInFilter(node))
1435 {
1436 // The named propery is not part of this instance
1437 // due to filtering.
1438 return SCMO_NOT_FOUND;
1439 }
|
1440 thilo.boehm 1.1 }
1441
|
1442 thilo.boehm 1.2 _setPropertyAtNodeIndex(node,type,value,isArray,size);
1443
1444 return SCMO_OK;
1445 }
|
1446 thilo.boehm 1.1
|
1447 thilo.boehm 1.2 void SCMOInstance::_setPropertyAtNodeIndex(
1448 Uint32 node,
1449 CIMType type,
1450 void* value,
1451 Boolean isArray,
1452 Uint32 size)
1453 {
1454 SCMBValue* theInstPropNodeArray =
1455 (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
|
1456 thilo.boehm 1.1
1457
|
1458 thilo.boehm 1.2 theInstPropNodeArray[node].flags.isSet=true;
1459 theInstPropNodeArray[node].valueType=type;
1460 theInstPropNodeArray[node].flags.isArray=isArray;
1461 if (isArray)
1462 {
1463 theInstPropNodeArray[node].valueArraySize=size;
1464 }
|
1465 thilo.boehm 1.1
|
1466 thilo.boehm 1.2 if (value==NULL)
1467 {
1468 theInstPropNodeArray[node].flags.isNull=true;
1469 }
1470 else
1471 {
1472 Uint64 start =
1473 (unsigned const char*)&(theInstPropNodeArray[node].value)-inst.base;
|
1474 thilo.boehm 1.1
|
1475 thilo.boehm 1.2 _setSCMBUnion(value,type,isArray,size,start);
1476 }
|
1477 thilo.boehm 1.1 }
1478
|
1479 thilo.boehm 1.2 void SCMOInstance::_setSCMBUnion(
1480 void* value,
1481 CIMType type,
1482 Boolean isArray,
1483 Uint32 size,
1484 Uint64 start)
|
1485 thilo.boehm 1.1 {
|
1486 thilo.boehm 1.2 SCMBUnion* u = (SCMBUnion*)&(inst.base[start]);
|
1487 thilo.boehm 1.1
1488 switch (type)
1489 {
1490 case CIMTYPE_BOOLEAN:
1491 {
|
1492 thilo.boehm 1.2 if (isArray)
1493 {
1494 _setBinary(value,size*sizeof(Boolean),
1495 u->_arrayValue,
1496 &inst.mem );
1497 }
1498 else
|
1499 thilo.boehm 1.1 {
|
1500 thilo.boehm 1.2 u->_booleanValue = *((Boolean*)value);
|
1501 thilo.boehm 1.1 }
1502 break;
1503 }
1504
1505 case CIMTYPE_UINT8:
|
1506 thilo.boehm 1.2 {
1507 if (isArray)
1508 {
1509 _setBinary(value,size*sizeof(Uint8),
1510 u->_arrayValue,
1511 &inst.mem );
1512 }
1513 else
1514 {
1515 u->_uint8Value = *((Uint8*)value);
1516 }
|
1517 thilo.boehm 1.1 break;
1518 }
1519
1520 case CIMTYPE_SINT8:
1521 {
|
1522 thilo.boehm 1.2 if (isArray)
1523 {
1524 _setBinary(value,size*sizeof(Sint8),
1525 u->_arrayValue,
1526 &inst.mem );
1527 }
1528 else
1529 {
1530 u->_sint8Value = *((Sint8*)value);
1531 }
|
1532 thilo.boehm 1.1 break;
1533 }
1534
1535 case CIMTYPE_UINT16:
1536 {
|
1537 thilo.boehm 1.2 if (isArray)
1538 {
1539 _setBinary(value,size*sizeof(Uint16),
1540 u->_arrayValue,
1541 &inst.mem );
1542 }
1543 else
1544 {
1545 u->_uint16Value = *((Uint16*)value);
1546 }
|
1547 thilo.boehm 1.1 break;
1548 }
1549
1550 case CIMTYPE_SINT16:
1551 {
|
1552 thilo.boehm 1.2 if (isArray)
1553 {
1554 _setBinary(value,size*sizeof(Sint16),
1555 u->_arrayValue,
1556 &inst.mem );
1557 }
1558 else
1559 {
1560 u->_sint16Value = *((Sint16*)value);
1561 }
|
1562 thilo.boehm 1.1 break;
1563 }
1564
1565 case CIMTYPE_UINT32:
1566 {
|
1567 thilo.boehm 1.2 if (isArray)
1568 {
1569 _setBinary(value,size*sizeof(Uint32),
1570 u->_arrayValue,
1571 &inst.mem );
1572 }
1573 else
1574 {
1575 u->_uint32Value = *((Uint32*)value);
1576 }
|
1577 thilo.boehm 1.1 break;
1578 }
1579
1580 case CIMTYPE_SINT32:
1581 {
|
1582 thilo.boehm 1.2 if (isArray)
1583 {
1584 _setBinary(value,size*sizeof(Sint32),
1585 u->_arrayValue,
1586 &inst.mem );
1587 }
1588 else
1589 {
1590 u->_sint32Value = *((Sint32*)value);
1591 }
|
1592 thilo.boehm 1.1 break;
1593 }
1594
1595 case CIMTYPE_UINT64:
1596 {
|
1597 thilo.boehm 1.2 if (isArray)
1598 {
1599 _setBinary(value,size*sizeof(Uint64),
1600 u->_arrayValue,
1601 &inst.mem );
1602 }
1603 else
1604 {
1605 u->_uint64Value = *((Uint64*)value);
1606 }
|
1607 thilo.boehm 1.1 break;
1608 }
1609
1610 case CIMTYPE_SINT64:
1611 {
|
1612 thilo.boehm 1.2 if (isArray)
1613 {
1614 _setBinary(value,size*sizeof(Sint64),
1615 u->_arrayValue,
1616 &inst.mem );
1617 }
1618 else
1619 {
1620 u->_sint64Value = *((Sint64*)value);
1621 }
|
1622 thilo.boehm 1.1 break;
1623 }
1624
1625 case CIMTYPE_REAL32:
1626 {
|
1627 thilo.boehm 1.2 if (isArray)
1628 {
1629 _setBinary(value,size*sizeof(Real32),
1630 u->_arrayValue,
1631 &inst.mem );
1632 }
1633 else
1634 {
1635 u->_real32Value = *((Real32*)value);
1636 }
|
1637 thilo.boehm 1.1 break;
1638 }
1639
1640 case CIMTYPE_REAL64:
1641 {
|
1642 thilo.boehm 1.2 if (isArray)
1643 {
1644 _setBinary(value,size*sizeof(Real64),
1645 u->_arrayValue,
1646 &inst.mem );
1647 }
1648 else
1649 {
1650 u->_real64Value = *((Real64*)value);
1651 }
|
1652 thilo.boehm 1.1 break;
1653 }
1654
1655 case CIMTYPE_CHAR16:
1656 {
|
1657 thilo.boehm 1.2 if (isArray)
1658 {
1659 _setBinary(value,size*sizeof(Char16),
1660 u->_arrayValue,
1661 &inst.mem );
1662 }
1663 else
1664 {
1665 u->_char16Value = *((Char16*)value);
1666 }
|
1667 thilo.boehm 1.1 break;
1668 }
1669
1670 case CIMTYPE_STRING:
1671 {
|
1672 thilo.boehm 1.2 if (isArray)
1673 {
1674 SCMBDataPtr* ptr;
1675 char** tmp;
1676 Uint64 startPtr;
1677
1678 startPtr = _getFreeSpace(
1679 u->_arrayValue,
1680 size*sizeof(SCMBDataPtr),
1681 &inst.mem,false);
1682 // the value is pointer to an array of char*
1683 tmp = (char**)value;
1684
1685 for (Uint32 i = 0; i < size; i++)
1686 {
1687 ptr = (SCMBDataPtr*)&(inst.base[startPtr]);
1688 // Copy the sting including the trailing '\0'
1689 _setBinary(tmp[i],strlen(tmp[i])+1,ptr[i],&inst.mem );
1690 }
1691 }
1692 else
|
1693 thilo.boehm 1.1 {
|
1694 thilo.boehm 1.2 // Copy the sting including the trailing '\0'
1695 _setBinary(
1696 value,
1697 strlen((char*)value)+1,
1698 u->_stringValue,
1699 &inst.mem );
|
1700 thilo.boehm 1.1 }
1701 break;
1702 }
1703
1704 case CIMTYPE_DATETIME:
1705 {
|
1706 thilo.boehm 1.2 if (isArray)
1707 {
1708 _setBinary(value,size*sizeof(SCMBDateTime),
1709 u->_arrayValue,
1710 &inst.mem );
1711 }
1712 else
|
1713 thilo.boehm 1.1 {
|
1714 thilo.boehm 1.2 memcpy(&u->_dateTimeValue,value,sizeof(SCMBDateTime));
|
1715 thilo.boehm 1.1 }
1716 break;
1717 }
1718
|
1719 thilo.boehm 1.2 case CIMTYPE_REFERENCE:
1720
1721 break;
1722
1723 case CIMTYPE_OBJECT:
1724
|
1725 thilo.boehm 1.1 break;
|
1726 thilo.boehm 1.2 case CIMTYPE_INSTANCE:
|
1727 thilo.boehm 1.1
1728 break;
|
1729 thilo.boehm 1.2 }
1730 }
1731
1732 SCMO_RC SCMOInstance::_getPropertyAtNodeIndex(
1733 Uint32 node,
1734 const unsigned char** pname,
1735 CIMType& type,
1736 const void** pvalue,
1737 Boolean& isArray,
1738 Uint32& size ) const
1739 {
1740 SCMBValue* theInstPropNodeArray =
1741 (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
1742
1743 // create a pointer to property node array of the class.
1744 Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;
1745 SCMBClassPropertyNode* theClassPropNodeArray =
1746 (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];
1747
1748 // the property name is always from the class.
1749 // return the absolut pointer to the property name,
1750 thilo.boehm 1.2 // the caller has to copy the name!
1751 *pname=_getCharString(
1752 theClassPropNodeArray[node].theProperty.name,
1753 inst.hdr->theClass->cls.base);
1754
1755 // the property was set by the provider.
1756 if (theInstPropNodeArray[node].flags.isSet)
1757 {
|
1758 thilo.boehm 1.1
|
1759 thilo.boehm 1.2 type = theInstPropNodeArray[node].valueType;
1760 isArray = theInstPropNodeArray[node].flags.isArray;
1761 if (isArray)
|
1762 thilo.boehm 1.1 {
|
1763 thilo.boehm 1.2 size = theInstPropNodeArray[node].valueArraySize;
|
1764 thilo.boehm 1.1 }
|
1765 thilo.boehm 1.2
1766 if (theInstPropNodeArray[node].flags.isNull)
|
1767 thilo.boehm 1.1 {
|
1768 thilo.boehm 1.2 return SCMO_NULL_VALUE;
|
1769 thilo.boehm 1.1 }
|
1770 thilo.boehm 1.2
1771 // calculate the relative index for the value.
1772 Uint64 start =
1773 (unsigned const char*)&(theInstPropNodeArray[node].value) -
1774 inst.base;
1775
1776 // the caller has to copy the value !
1777 *pvalue = _getSCMBUnion(type,isArray,size,start,inst.base);
1778
1779 return SCMO_OK;
1780 }
1781
1782 // the get the defaults out of the class.
1783 type = theClassPropNodeArray[node].theProperty.defaultValue.valueType;
1784 isArray =
1785 theClassPropNodeArray[node].theProperty.defaultValue.flags.isArray;
1786 if (isArray)
1787 {
1788 size = theClassPropNodeArray[node].
1789 theProperty.defaultValue.valueArraySize;
1790 }
1791 thilo.boehm 1.2
1792 if (theClassPropNodeArray[node].theProperty.defaultValue.flags.isNull)
1793 {
1794 return SCMO_NULL_VALUE;
1795 }
1796
1797 // calcutate the relativ start address of the value
1798 Uint64 start =
1799 (unsigned const char*)
1800 &(theClassPropNodeArray[node].theProperty.defaultValue.value) -
1801 (inst.hdr->theClass->cls.base);
1802
1803 *pvalue = _getSCMBUnion(
1804 type,
1805 isArray,
1806 size,
1807 start,
1808 (inst.hdr->theClass->cls.base)
1809 );
1810
1811 return SCMO_OK;
1812 thilo.boehm 1.2
1813 }
1814
1815 SCMOInstance SCMOInstance::clone() const
1816 {
1817 SCMOInstance newInst;
1818 newInst.inst.base = (unsigned char*)malloc(this->inst.mem->totalSize);
1819 if (newInst.inst.base == NULL )
1820 {
1821 throw PEGASUS_STD(bad_alloc)();
|
1822 thilo.boehm 1.1 }
1823
|
1824 thilo.boehm 1.2 memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize);
1825 // reset the refcounter of this new instance
1826 newInst.inst.hdr->refCount = 1;
1827 // kepp the ref counter of the class correct !
1828 newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass));
1829
1830 return newInst;
1831 }
1832
1833 Uint32 SCMOInstance::getPropertyCount() const
1834 {
1835 return(inst.hdr->numberProperties);
|
1836 thilo.boehm 1.1 }
1837
|
1838 thilo.boehm 1.2 const void* SCMOInstance::_getSCMBUnion(
1839 CIMType type,
1840 Boolean isArray,
1841 Uint32 size,
1842 Uint64 start,
1843 unsigned char* base) const
|
1844 thilo.boehm 1.1 {
|
1845 thilo.boehm 1.2
1846 SCMBUnion* u = (SCMBUnion*)&(base[start]);
1847
1848 void* av = NULL;
1849 if (isArray)
1850 {
1851 av = (void*)&base[u->_arrayValue.start];
1852 }
1853
|
1854 thilo.boehm 1.1
1855 switch (type)
1856 {
1857 case CIMTYPE_BOOLEAN:
1858 case CIMTYPE_UINT8:
1859 case CIMTYPE_SINT8:
1860 case CIMTYPE_UINT16:
1861 case CIMTYPE_SINT16:
1862 case CIMTYPE_UINT32:
1863 case CIMTYPE_SINT32:
1864 case CIMTYPE_UINT64:
1865 case CIMTYPE_SINT64:
1866 case CIMTYPE_REAL32:
1867 case CIMTYPE_REAL64:
1868 case CIMTYPE_CHAR16:
|
1869 thilo.boehm 1.2 case CIMTYPE_DATETIME:
|
1870 thilo.boehm 1.1 {
|
1871 thilo.boehm 1.2 if(isArray)
1872 {
1873 return ((void*)av);
1874 }
1875 else
1876 {
1877 return((void*)u);
1878 }
|
1879 thilo.boehm 1.1 break;
1880 }
1881
1882 case CIMTYPE_STRING:
1883 {
|
1884 thilo.boehm 1.2 SCMBDataPtr *ptr;
1885 unsigned char** tmp;
|
1886 thilo.boehm 1.1
|
1887 thilo.boehm 1.2 if (isArray)
1888 {
1889 // allocate an array of char* pointers.
1890 *tmp = (unsigned char*)malloc(size*sizeof(unsigned char*));
1891 if (*tmp == NULL )
1892 {
1893 throw PEGASUS_STD(bad_alloc)();
1894 }
1895
1896 // use temporary variables to avoid casting
1897 ptr = (SCMBDataPtr*)av;
1898
1899 for(Uint32 i = 0; i < size; i++)
1900 {
1901 // resolv relative pointer to absolute pointer
1902 tmp[i] = (unsigned char*)_getCharString(ptr[i],base);
1903 }
|
1904 thilo.boehm 1.1
|
1905 thilo.boehm 1.2 return((void*)*tmp);
1906 }
1907 else
1908 {
1909 return(_getCharString(u->_stringValue,base));
1910 }
|
1911 thilo.boehm 1.1
1912
1913 break;
1914 }
1915
|
1916 thilo.boehm 1.2 case CIMTYPE_REFERENCE:
|
1917 thilo.boehm 1.1
|
1918 thilo.boehm 1.2 break;
|
1919 thilo.boehm 1.1
|
1920 thilo.boehm 1.2 case CIMTYPE_OBJECT:
|
1921 thilo.boehm 1.1
|
1922 thilo.boehm 1.2 break;
|
1923 thilo.boehm 1.1
|
1924 thilo.boehm 1.2 case CIMTYPE_INSTANCE:
|
1925 thilo.boehm 1.1
|
1926 thilo.boehm 1.2 break;
|
1927 thilo.boehm 1.1
|
1928 thilo.boehm 1.2 default:
1929 PEGASUS_ASSERT(false);
1930 break;
1931 }
1932 return NULL;
|
1933 thilo.boehm 1.1 }
1934
|
1935 thilo.boehm 1.2 Uint32 SCMOInstance::getKeyBindingCount()
|
1936 thilo.boehm 1.1 {
|
1937 thilo.boehm 1.2 return(inst.hdr->numberKeyBindings);
|
1938 thilo.boehm 1.1 }
1939
1940
|
1941 thilo.boehm 1.2 SCMO_RC SCMOInstance::getKeyBindingAt(
1942 Uint32 node,
1943 const unsigned char** pname,
1944 CIMKeyBinding::Type& type,
1945 const unsigned char** pvalue) const
|
1946 thilo.boehm 1.1 {
|
1947 thilo.boehm 1.2 *pname = NULL;
1948 *pvalue = NULL;
|
1949 thilo.boehm 1.1
|
1950 thilo.boehm 1.2 if (node >= inst.hdr->numberKeyBindings)
1951 {
1952 return SCMO_INDEX_OUT_OF_BOUND;
1953 }
|
1954 thilo.boehm 1.1
|
1955 thilo.boehm 1.2 return _getKeyBindingAtNodeIndex(node,pname,type,pvalue);
|
1956 thilo.boehm 1.1 }
1957
|
1958 thilo.boehm 1.2 SCMO_RC SCMOInstance::getKeyBinding(
1959 const char* name,
1960 CIMKeyBinding::Type& type,
1961 const unsigned char** pvalue) const
|
1962 thilo.boehm 1.1 {
|
1963 thilo.boehm 1.2 pvalue = NULL;
1964 SCMO_RC rc;
1965 Uint32 node;
1966 const unsigned char** pname;
|
1967 thilo.boehm 1.1
|
1968 thilo.boehm 1.2 rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);
1969 if (rc != SCMO_OK)
|
1970 thilo.boehm 1.1 {
|
1971 thilo.boehm 1.2 return rc;
|
1972 thilo.boehm 1.1 }
1973
|
1974 thilo.boehm 1.2 return _getKeyBindingAtNodeIndex(node,pname,type,pvalue);
|
1975 thilo.boehm 1.1
|
1976 thilo.boehm 1.2 }
|
1977 thilo.boehm 1.1
|
1978 thilo.boehm 1.2 SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex(
1979 Uint32 node,
1980 const unsigned char** pname,
1981 CIMKeyBinding::Type& type,
1982 const unsigned char** pvalue) const
1983 {
|
1984 thilo.boehm 1.1
|
1985 thilo.boehm 1.2 SCMBDataPtr* theInstKeyBindNodeArray =
1986 (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];
|
1987 thilo.boehm 1.1
|
1988 thilo.boehm 1.2 // create a pointer to keybinding node array of the class.
1989 Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
1990 SCMBKeyBindingNode* theClassKeyBindNodeArray =
1991 (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx];
|
1992 thilo.boehm 1.1
|
1993 thilo.boehm 1.2 type = theClassKeyBindNodeArray->type;
1994 *pname = _getCharString(
1995 theClassKeyBindNodeArray->name,
1996 inst.hdr->theClass->cls.base);
|
1997 thilo.boehm 1.1
|
1998 thilo.boehm 1.2 // There is no value set in the instance
1999 // if the relative pointer has no start value.
2000 if (theInstKeyBindNodeArray[node].start==0)
2001 {
2002 return SCMO_NULL_VALUE;
2003 }
|
2004 thilo.boehm 1.1
|
2005 thilo.boehm 1.2 // Set the absolut pointer to the key binding value
2006 *pvalue = _getCharString(theInstKeyBindNodeArray[node],inst.base);
|
2007 thilo.boehm 1.1
|
2008 thilo.boehm 1.2 return SCMO_OK;
|
2009 thilo.boehm 1.1
2010 }
2011
|
2012 thilo.boehm 1.2 SCMO_RC SCMOInstance::setKeyBinding(
2013 const char* name,
2014 CIMKeyBinding::Type type,
2015 const char* pvalue)
|
2016 thilo.boehm 1.1 {
|
2017 thilo.boehm 1.2 SCMO_RC rc;
|
2018 thilo.boehm 1.1 Uint32 node;
2019
|
2020 thilo.boehm 1.2 rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);
|
2021 thilo.boehm 1.1 if (rc != SCMO_OK)
2022 {
2023 return rc;
2024 }
2025
|
2026 thilo.boehm 1.2 // create a pointer to keybinding node array of the class.
2027 Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;
2028 SCMBKeyBindingNode* theClassKeyBindNodeArray =
2029 (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx];
2030
2031 if (theClassKeyBindNodeArray[node].type != type)
|
2032 thilo.boehm 1.1 {
|
2033 thilo.boehm 1.2 return SCMO_TYPE_MISSMATCH;
|
2034 thilo.boehm 1.1 }
2035
|
2036 thilo.boehm 1.2 SCMBDataPtr* theInstKeyBindNodeArray =
2037 (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];
2038
2039 // copy the value including trailing '\0'
2040 _setBinary(pvalue,strlen(pvalue)+1,theInstKeyBindNodeArray[node],&inst.mem);
2041
2042 return SCMO_OK;
2043
|
2044 thilo.boehm 1.1 }
2045
|
2046 thilo.boehm 1.2 void SCMOInstance::setPropertyFilter(const char **propertyList)
|
2047 thilo.boehm 1.1 {
|
2048 thilo.boehm 1.2 SCMO_RC rc;
2049 Uint32 node,i = 0;
2050
2051 // Get absolut pointer to property filter index map of the instance
2052 Uint32* propertyFilterIndexMap =
2053 (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
|
2054 thilo.boehm 1.1
|
2055 thilo.boehm 1.2 // All properties are accepted
2056 if (propertyList == NULL)
|
2057 thilo.boehm 1.1 {
|
2058 thilo.boehm 1.2 // Clear filtering:
2059 // Switch filtering off.
2060 inst.hdr->flags.isFiltered = false;
2061
2062 // Clear filter index map
2063 memset(
2064 propertyFilterIndexMap,
2065 0,
2066 sizeof(Uint32)*inst.hdr->filterProperties);
|
2067 thilo.boehm 1.1
|
2068 thilo.boehm 1.2 //reset number filter properties to all
2069 inst.hdr->filterProperties = inst.hdr->numberProperties;
|
2070 thilo.boehm 1.1
|
2071 thilo.boehm 1.2 return;
|
2072 thilo.boehm 1.1 }
|
2073 thilo.boehm 1.2
2074 // Switch filtering on.
2075 inst.hdr->flags.isFiltered = true;
2076
2077 // intit the filter with the key properties
2078 inst.hdr->filterProperties=_initPropFilterWithKeys();
2079
2080 // add the properties to the filter.
2081 while (propertyList[i] != NULL)
|
2082 thilo.boehm 1.1 {
|
2083 thilo.boehm 1.2 // the hash index of the property if the property name is found
2084 rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]);
2085
2086 if (rc == SCMO_OK)
|
2087 thilo.boehm 1.1 {
|
2088 thilo.boehm 1.2 // The property name was found. Otherwise ignore this property name.
2089 // insert the hash index into the filter index map
2090 propertyFilterIndexMap[inst.hdr->filterProperties]=node;
2091 // increase number of properties in filter.
2092 inst.hdr->filterProperties++;
2093 // set bit in the property filter
2094 _setPropertyInPropertyFilter(node);
|
2095 thilo.boehm 1.1 }
|
2096 thilo.boehm 1.2 // Proceed with the next property name.
2097 i++;
|
2098 thilo.boehm 1.1 }
2099
2100 }
2101
|
2102 thilo.boehm 1.2
2103 Uint32 SCMOInstance::_initPropFilterWithKeys()
2104 {
2105
2106 // Get absolut pointer to the key property mask of the class.
2107 Uint64 idx = inst.hdr->theClass->cls.hdr->keyPropertyMask.start;
2108 Uint64* keyMask =(Uint64*)&(inst.hdr->theClass->cls.base)[idx];
2109
2110 // Get absolut pointer to property filter mask
2111 Uint64* propertyFilterMask =
2112 (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);
2113
2114 // copy the key mask to the property filter mask
2115 memcpy(
2116 propertyFilterMask,
2117 keyMask,
2118 sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));
2119
2120 // Get absolut pointer to key index list of the class
2121 idx=inst.hdr->theClass->cls.hdr->keyIndexList.start;
2122 Uint32* keyIndex = (Uint32*)&(inst.hdr->theClass->cls.base)[idx];
2123 thilo.boehm 1.2
2124 // Get absolut pointer to property filter index map of the instance
2125 Uint32* propertyFilterIndexMap =
2126 (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);
2127
2128 Uint32 noKeys = inst.hdr->theClass->cls.hdr->keyBindingSet.number;
2129 memcpy(propertyFilterIndexMap,keyIndex,sizeof(Uint32)*noKeys);
2130
2131 // return the number of properties already in the filter index map
2132 return noKeys;
2133
2134 }
2135
2136 void SCMOInstance::_clearPropertyFilter()
2137 {
2138 Uint64 *propertyFilter;
2139
2140 // Calculate the real pointer to the Uint64 array
2141 propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start];
2142
2143 // the number of Uint64 in the key mask is :
2144 thilo.boehm 1.2 // Decrease the number of properties by 1
2145 // since the array is starting at index 0!
2146 // Divide with the number of bits in a Uint64.
2147 // e.g. number of Properties = 68
2148 // (68 - 1) / 64 = 1 --> The mask consists of 2 Uint64
2149
2150 memset(propertyFilter,
2151 0,
2152 sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));
2153
2154 }
2155 void SCMOInstance::_setPropertyInPropertyFilter(Uint32 i)
|
2156 thilo.boehm 1.1 {
|
2157 thilo.boehm 1.2 Uint64 *propertyFilter;
2158
2159 // In which Uint64 of key mask is the bit for property i ?
2160 // Divide with the number of bits in a Uint64.
2161 // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].
2162 Uint32 idx = i/64 ;
2163
2164 // Create a filter to set the bit.
2165 // Modulo division with 64. Shift left a bit by the remainder.
2166 Uint64 filter = ( (Uint64)1 << (i%64));
2167
2168 // Calculate the real pointer to the Uint64 array
2169 propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);
|
2170 thilo.boehm 1.1
|
2171 thilo.boehm 1.2 propertyFilter[idx] = propertyFilter[idx] | filter ;
|
2172 thilo.boehm 1.1 }
|
2173 thilo.boehm 1.2
2174 Boolean SCMOInstance::_isPropertyInFilter(Uint32 i) const
|
2175 thilo.boehm 1.1 {
|
2176 thilo.boehm 1.2 Uint64 *propertyFilter;
|
2177 thilo.boehm 1.1
|
2178 thilo.boehm 1.2 // In which Uint64 of key mask is the bit for property i ?
2179 // Divide with the number of bits in a Uint64.
2180 // e.g. number of Properties = 68
2181 // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].
2182 Uint32 idx = i/64 ;
|
2183 thilo.boehm 1.1
|
2184 thilo.boehm 1.2 // Create a filter to check if the bit is set:
2185 // Modulo division with 64. Shift left a bit by the remainder.
2186 Uint64 filter = ( (Uint64)1 << (i%64));
|
2187 thilo.boehm 1.1
|
2188 thilo.boehm 1.2 // Calculate the real pointer to the Uint64 array
2189 propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start];
|
2190 thilo.boehm 1.1
|
2191 thilo.boehm 1.2 // If the bit is set the property is NOT filtered.
2192 // So the result has to be negated!
2193 return propertyFilter[idx] & filter ;
|
2194 thilo.boehm 1.1
2195 }
2196
|
2197 thilo.boehm 1.2 /******************************************************************************
2198 * SCMODump Print and Dump functions
2199 *****************************************************************************/
2200
2201 void SCMODump::dumpSCMOClass(SCMOClass& testCls) const
2202 {
2203 SCMBClass_Main* clshdr = testCls.cls.hdr;
2204 unsigned char* clsbase = testCls.cls.base;
|
2205 thilo.boehm 1.1
|
2206 thilo.boehm 1.2 printf("\n\nDump of SCMOClass\n");
2207 // The magic number for SCMO class
2208 printf("\nheader.magic=%08X",clshdr->header.magic);
2209 // Total size of the instance memory block( # bytes )
2210 printf("\nheader.totalSize=%llu",clshdr->header.totalSize);
2211 // The # of bytes free
2212 printf("\nheader.freeBytes=%llu",clshdr->header.freeBytes);
2213 // Index to the start of the free space in this insance
2214 printf("\nheader.StartOfFreeSpace=%llu",clshdr->header.startOfFreeSpace);
2215 // The reference counter for this class
2216 printf("\nrefCount=%i",clshdr->refCount.get());
|
2217 thilo.boehm 1.1
|
2218 thilo.boehm 1.2 printf("\n\nsuperClassName: \'%s\'",
2219 _getCharString(clshdr->superClassName,clsbase));
2220 printf("\nnameSpace: \'%s\'",_getCharString(clshdr->nameSpace,clsbase));
2221 printf("\nclassName: \'%s\'",_getCharString(clshdr->className,clsbase));
2222 printf("\n\nTheClass qualfiers:");
2223 _dumpQualifierArray(
2224 clshdr->qualifierArray.start,
2225 clshdr->numberOfQualifiers,
2226 clsbase);
2227 printf("\n");
2228 dumpKeyPropertyMask(testCls);
2229 printf("\n");
2230 dumpKeyIndexList(testCls);
2231 printf("\n");
2232 dumpClassProperties(testCls);
2233 printf("\n");
2234 dumpKeyBindingSet(testCls);
2235 printf("\n");
2236 /*
2237 */
2238 printf("\n");
|
2239 thilo.boehm 1.1
|
2240 thilo.boehm 1.2 }
|
2241 thilo.boehm 1.1
|
2242 thilo.boehm 1.2 void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const
|
2243 thilo.boehm 1.1 {
|
2244 thilo.boehm 1.2 unsigned char* tmp;
|
2245 thilo.boehm 1.1
|
2246 thilo.boehm 1.2 SCMBClass_Main* clshdr = testCls.cls.hdr;
2247 unsigned char* clsbase = testCls.cls.base;
|
2248 thilo.boehm 1.1
|
2249 thilo.boehm 1.2 printf("\n\nHex dump of a SCMBClass:");
2250 printf("\n========================");
2251 printf("\n\n Size of SCMBClass: %llu",clshdr->header.totalSize);
2252 printf("\n cls.base = %p\n\n",clsbase);
|
2253 thilo.boehm 1.1
|
2254 thilo.boehm 1.2 _hexDump(clsbase,clshdr->header.totalSize);
|
2255 thilo.boehm 1.1
2256 }
|
2257 thilo.boehm 1.2 void SCMODump::dumpKeyIndexList(SCMOClass& testCls) const
2258 {
2259 SCMBClass_Main* clshdr = testCls.cls.hdr;
2260 unsigned char* clsbase = testCls.cls.base;
|
2261 thilo.boehm 1.1
|
2262 thilo.boehm 1.2 printf("\n\nKey Index List:");
2263 printf("\n===============\n");
|
2264 thilo.boehm 1.1
|
2265 thilo.boehm 1.2 // Get absolut pointer to key index list of the class
2266 Uint32* keyIndex = (Uint32*)&(clsbase)[clshdr->keyIndexList.start];
2267 Uint32 line,j,i;
2268 for (j = 0; j < clshdr->propertySet.number; j = j + line)
|
2269 thilo.boehm 1.1 {
|
2270 thilo.boehm 1.2 if ((clshdr->propertySet.number-j)/16)
|
2271 thilo.boehm 1.1 {
|
2272 thilo.boehm 1.2 line = 16 ;
|
2273 thilo.boehm 1.1 }
|
2274 thilo.boehm 1.2 else
|
2275 thilo.boehm 1.1 {
|
2276 thilo.boehm 1.2 line = clshdr->propertySet.number%16;
|
2277 thilo.boehm 1.1 }
2278
|
2279 thilo.boehm 1.2
2280 printf("Index :");
2281 for (i = 0; i < line; i++)
|
2282 thilo.boehm 1.1 {
|
2283 thilo.boehm 1.2 printf(" %3u",j+i);
|
2284 thilo.boehm 1.1 }
2285
|
2286 thilo.boehm 1.2 printf("\nNode :");
2287 for (i = 0; i < line; i++)
|
2288 thilo.boehm 1.1 {
|
2289 thilo.boehm 1.2 printf(" %3u",keyIndex[j+i]);
|
2290 thilo.boehm 1.1 }
2291
|
2292 thilo.boehm 1.2 printf("\n\n");
2293
2294 }
2295
2296 }
2297
2298 void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const
2299 {
2300 SCMBClass_Main* clshdr = testCls.cls.hdr;
2301 unsigned char* clsbase = testCls.cls.base;
2302
2303 printf("\n\nKey Binding Set:");
2304 printf("\n=================\n");
2305 printf("\nNumber of key bindings: %3u",clshdr->keyBindingSet.number);
2306 dumpHashTable(
2307 clshdr->keyBindingSet.hashTable,
2308 PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
|
2309 thilo.boehm 1.1
|
2310 thilo.boehm 1.2 dumpClassKeyBindingNodeArray(testCls);
|
2311 thilo.boehm 1.1
|
2312 thilo.boehm 1.2 }
|
2313 thilo.boehm 1.1
|
2314 thilo.boehm 1.2 void SCMODump::dumpClassKeyBindingNodeArray(SCMOClass& testCls) const
2315 {
2316 SCMBClass_Main* clshdr = testCls.cls.hdr;
2317 unsigned char* clsbase = testCls.cls.base;
|
2318 thilo.boehm 1.1
|
2319 thilo.boehm 1.2 SCMBKeyBindingNode* nodeArray =
2320 (SCMBKeyBindingNode*)
2321 &(clsbase[clshdr->keyBindingSet.nodeArray.start]);
|
2322 thilo.boehm 1.1
|
2323 thilo.boehm 1.2 for (Uint32 i = 0; i < clshdr->keyBindingSet.number; i++)
2324 {
2325 printf("\n\n===================");
2326 printf("\nKey Binding #%3u",i);
2327 printf("\n===================");
|
2328 thilo.boehm 1.1
|
2329 thilo.boehm 1.2 printf("\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));
2330 if (nodeArray[i].hasNext)
|
2331 thilo.boehm 1.1 {
|
2332 thilo.boehm 1.2 printf("\nNext Node: %3u",nodeArray[i].nextNode);
|
2333 thilo.boehm 1.1 }
|
2334 thilo.boehm 1.2 else
|
2335 thilo.boehm 1.1 {
|
2336 thilo.boehm 1.2 printf("\nNext Node: N/A");
|
2337 thilo.boehm 1.1 }
2338
|
2339 thilo.boehm 1.2 printf("\nKey Property name: %s",
2340 _getCharString(nodeArray[i].name,clsbase));
2341
2342 printf("\nHash Tag %3u Hash Index %3u",
2343 nodeArray[i].nameHashTag,
2344 nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);
2345
2346 printf("\nKey binding type: %s",
2347 XmlWriter::keyBindingTypeToString(nodeArray[i].type).str);
2348
2349 }
2350
2351 }
2352
2353 void SCMODump::dumpClassProperties(SCMOClass& testCls) const
2354 {
2355 SCMBClass_Main* clshdr = testCls.cls.hdr;
2356 unsigned char* clsbase = testCls.cls.base;
2357
2358 printf("\n\nClass Properties:");
2359 printf("\n=================\n");
2360 thilo.boehm 1.2 printf("\nNumber of properties: %3u",clshdr->propertySet.number);
2361 dumpHashTable(
2362 clshdr->propertySet.hashTable,
2363 PEGASUS_PROPERTY_SCMB_HASHSIZE);
2364 dumpClassPropertyNodeArray(testCls);
2365
2366 }
2367
2368 void SCMODump::dumpClassPropertyNodeArray(SCMOClass& testCls) const
2369 {
2370 SCMBClass_Main* clshdr = testCls.cls.hdr;
2371 unsigned char* clsbase = testCls.cls.base;
2372
2373 SCMBClassPropertyNode* nodeArray =
2374 (SCMBClassPropertyNode*)
2375 &(clsbase[clshdr->propertySet.nodeArray.start]);
2376
2377 for (Uint32 i = 0; i < clshdr->propertySet.number; i++)
2378 {
|
2379 thilo.boehm 1.1
|
2380 thilo.boehm 1.2 printf("\n\n===================");
2381 printf("\nClass property #%3u",i);
2382 printf("\n===================");
|
2383 thilo.boehm 1.1
|
2384 thilo.boehm 1.2 printf("\nHas next: %s",(nodeArray[i].hasNext?"TRUE":"FALSE"));
2385 if (nodeArray[i].hasNext)
2386 {
2387 printf("\nNext Node: %3u",nodeArray[i].nextNode);
|
2388 thilo.boehm 1.1 }
|
2389 thilo.boehm 1.2 else
|
2390 thilo.boehm 1.1 {
|
2391 thilo.boehm 1.2 printf("\nNext Node: N/A");
|
2392 thilo.boehm 1.1 }
2393
|
2394 thilo.boehm 1.2 _dumpClassProperty(nodeArray[i].theProperty,clsbase);
2395 }
2396 }
2397
2398 void SCMODump::_dumpClassProperty(
2399 const SCMBClassProperty& prop,
2400 unsigned char* clsbase) const
2401 {
2402 printf("\nProperty name: %s",_getCharString(prop.name,clsbase));
2403
2404 printf("\nHash Tag %3u Hash Index %3u",
2405 prop.nameHashTag,
2406 prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE);
2407 printf("\nPropagated: %s isKey: %s",
2408 (prop.flags.propagated?"TRUE":"FALSE"),
2409 (prop.flags.isKey?"TRUE":"FALSE")
2410 );
|
2411 thilo.boehm 1.1
|
2412 thilo.boehm 1.2 printf("\nOrigin class name: %s",
2413 _getCharString(prop.originClassName,clsbase));
2414 printf("\nReference class name: %s",
2415 _getCharString(prop.refClassName,clsbase));
|
2416 thilo.boehm 1.1
|
2417 thilo.boehm 1.2 printSCMOValue(prop.defaultValue,clsbase);
|
2418 thilo.boehm 1.1
|
2419 thilo.boehm 1.2 _dumpQualifierArray(
2420 prop.qualifierArray.start,
2421 prop.numberOfQualifiers,
2422 clsbase);
|
2423 thilo.boehm 1.1
2424 }
2425
|
2426 thilo.boehm 1.2 void SCMODump::dumpHashTable(Uint32* hashTable,Uint32 size) const
|
2427 thilo.boehm 1.1 {
|
2428 thilo.boehm 1.2 Uint32 i,j,line;
2429 printf("\n\nHash table:\n");
|
2430 thilo.boehm 1.1
2431
|
2432 thilo.boehm 1.2 for (j = 0; j < size; j = j + line)
2433 {
2434 if ((size-j)/16)
2435 {
2436 line = 16 ;
2437 }
2438 else
2439 {
2440 line = size%16;
2441 }
|
2442 thilo.boehm 1.1
2443
|
2444 thilo.boehm 1.2 printf("Index :");
2445 for (i = 0; i < line; i++)
|
2446 thilo.boehm 1.1 {
|
2447 thilo.boehm 1.2 printf(" %3u",j+i);
|
2448 thilo.boehm 1.1 }
2449
|
2450 thilo.boehm 1.2 printf("\nHashTable:");
2451 for (i = 0; i < line; i++)
|
2452 thilo.boehm 1.1 {
|
2453 thilo.boehm 1.2 printf(" %3u",hashTable[j+i]);
|
2454 thilo.boehm 1.1 }
2455
|
2456 thilo.boehm 1.2 printf("\n\n");
|
2457 thilo.boehm 1.1
2458 }
2459
|
2460 thilo.boehm 1.2
2461 }
2462
2463 void SCMODump::_dumpQualifierArray(
2464 Uint64 start,
2465 Uint32 size,
2466 unsigned char* clsbase
2467 ) const
2468 {
2469
2470 SCMBQualifier *theArray = (SCMBQualifier*)&(clsbase[start]);
2471
2472 for(Uint32 i = 0; i < size; i++)
|
2473 thilo.boehm 1.1 {
|
2474 thilo.boehm 1.2 _dumpQualifier(theArray[i],clsbase);
|
2475 thilo.boehm 1.1 }
|
2476 thilo.boehm 1.2 }
|
2477 thilo.boehm 1.1
|
2478 thilo.boehm 1.2 void SCMODump::_dumpQualifier(
2479 const SCMBQualifier& theQualifier,
2480 unsigned char* clsbase
2481 ) const
2482 {
2483 if(theQualifier.name == QUALNAME_USERDEFINED)
2484 {
2485 printf("\n\nQualifier user defined name: \'%s\'",
2486 _getCharString(theQualifier.userDefName,clsbase));
2487 }
2488 else
2489 {
2490 printf("\n\nQualifier DMTF defined name: \'%s\'",
2491 _qualifierNameStrLit[theQualifier.name].str);
2492 }
|
2493 thilo.boehm 1.1
|
2494 thilo.boehm 1.2 printf("\nPropagated : %s",
2495 (theQualifier.propagated ? "True" : "False"));
2496 printf("\nFlavor : %s",
2497 (const char*)(CIMFlavor(theQualifier.flavor).toString().getCString()));
|
2498 thilo.boehm 1.1
|
2499 thilo.boehm 1.2 printSCMOValue(theQualifier.value,clsbase);
|
2500 thilo.boehm 1.1
|
2501 thilo.boehm 1.2 }
|
2502 thilo.boehm 1.1
|
2503 thilo.boehm 1.2 void SCMODump::printSCMOValue(
2504 const SCMBValue& theValue,
2505 unsigned char* base) const
2506 {
2507 printf("\nValueType : %s",cimTypeToString(theValue.valueType));
2508 printf("\nValue was set by the provider: %s",
2509 (theValue.flags.isSet ? "True" : "False"));
2510 if (theValue.flags.isNull)
2511 {
2512 printf("\nIt's a NULL value.");
2513 return;
2514 }
2515 if (theValue.flags.isArray)
2516 {
2517 printf("\nThe value is an Array of size: %u",theValue.valueArraySize);
2518 printf("\nThe values are: '%s'",
2519 (const char*)printArrayValue(
2520 theValue.valueType,
2521 theValue.valueArraySize,
2522 theValue.value,
2523 base).getCString());
2524 thilo.boehm 1.2 }
2525 else
2526 {
2527 printf("\nThe Value is: '%s'",
2528 (const char*)
2529 printUnionValue(theValue.valueType,theValue.value,base)
2530 .getCString());
2531 }
|
2532 thilo.boehm 1.1
|
2533 thilo.boehm 1.2 return;
|
2534 thilo.boehm 1.1
2535 }
2536
|
2537 thilo.boehm 1.2 String SCMODump::printArrayValue(
|
2538 thilo.boehm 1.1 CIMType type,
|
2539 thilo.boehm 1.2 Uint32 size,
2540 SCMBUnion u,
|
2541 thilo.boehm 1.1 unsigned char* base) const
2542 {
|
2543 thilo.boehm 1.2 Buffer out;
|
2544 thilo.boehm 1.1
2545 switch (type)
2546 {
2547 case CIMTYPE_BOOLEAN:
|
2548 thilo.boehm 1.2 {
2549 Boolean* p=(Boolean*)&(base[u._arrayValue.start]);
2550 for (Uint32 i = 0; i < size; i++)
2551 {
2552 _toString(out,p[i]);
2553 out.append(' ');
2554 }
2555 break;
2556 }
2557
|
2558 thilo.boehm 1.1 case CIMTYPE_UINT8:
|
2559 thilo.boehm 1.2 {
2560 Uint8* p=(Uint8*)&(base[u._arrayValue.start]);
2561 _toString(out,p,size);
2562 break;
2563 }
2564
|
2565 thilo.boehm 1.1 case CIMTYPE_SINT8:
|
2566 thilo.boehm 1.2 {
2567 Sint8* p=(Sint8*)&(base[u._arrayValue.start]);
2568
2569 break;
2570 }
2571
|
2572 thilo.boehm 1.1 case CIMTYPE_UINT16:
|
2573 thilo.boehm 1.2 {
2574 Uint16* p=(Uint16*)&(base[u._arrayValue.start]);
2575 _toString(out,p,size);
2576 break;
2577 }
2578
|
2579 thilo.boehm 1.1 case CIMTYPE_SINT16:
|
2580 thilo.boehm 1.2 {
2581 Sint16* p=(Sint16*)&(base[u._arrayValue.start]);
2582 _toString(out,p,size);
2583 break;
2584 }
2585
|
2586 thilo.boehm 1.1 case CIMTYPE_UINT32:
|
2587 thilo.boehm 1.2 {
2588 Uint32* p=(Uint32*)&(base[u._arrayValue.start]);
2589 _toString(out,p,size);
2590 break;
2591 }
2592
|
2593 thilo.boehm 1.1 case CIMTYPE_SINT32:
|
2594 thilo.boehm 1.2 {
2595 Sint32* p=(Sint32*)&(base[u._arrayValue.start]);
2596 _toString(out,p,size);
2597 break;
2598 }
2599
|
2600 thilo.boehm 1.1 case CIMTYPE_UINT64:
|
2601 thilo.boehm 1.2 {
2602 Uint64* p=(Uint64*)&(base[u._arrayValue.start]);
2603 _toString(out,p,size);
2604 break;
2605 }
2606
|
2607 thilo.boehm 1.1 case CIMTYPE_SINT64:
|
2608 thilo.boehm 1.2 {
2609 Sint64* p=(Sint64*)&(base[u._arrayValue.start]);
2610 _toString(out,p,size);
2611 break;
2612 }
2613
|
2614 thilo.boehm 1.1 case CIMTYPE_REAL32:
|
2615 thilo.boehm 1.2 {
2616 Real32* p=(Real32*)&(base[u._arrayValue.start]);
2617 _toString(out,p,size);
2618 break;
2619 }
2620
|
2621 thilo.boehm 1.1 case CIMTYPE_REAL64:
|
2622 thilo.boehm 1.2 {
2623 Real64* p=(Real64*)&(base[u._arrayValue.start]);
2624 _toString(out,p,size);
2625 break;
2626 }
2627
|
2628 thilo.boehm 1.1 case CIMTYPE_CHAR16:
2629 {
|
2630 thilo.boehm 1.2 Char16* p=(Char16*)&(base[u._arrayValue.start]);
2631 _toString(out,p,size);
|
2632 thilo.boehm 1.1 break;
2633 }
2634
2635 case CIMTYPE_STRING:
2636 {
|
2637 thilo.boehm 1.2 SCMBDataPtr* p = (SCMBDataPtr*)&(base[u._arrayValue.start]);
2638 for (Uint32 i = 0; i < size; i++)
|
2639 thilo.boehm 1.1 {
|
2640 thilo.boehm 1.2 out.append((const char*)_getCharString(p[i],base),
2641 p[i].length-1);
2642 out.append(' ');
2643 }
2644 break;
2645 }
|
2646 thilo.boehm 1.1
|
2647 thilo.boehm 1.2 case CIMTYPE_DATETIME:
2648 {
2649 SCMBDateTime* p = (SCMBDateTime*)&(base[u._arrayValue.start]);
2650 CIMDateTime x;
2651 for (Uint32 i = 0; i < size; i++)
|
2652 thilo.boehm 1.1 {
|
2653 thilo.boehm 1.2 memcpy(x._rep,&(p[i]),sizeof(SCMBDateTime));
2654 _toString(out,x);
|
2655 thilo.boehm 1.1 }
2656 break;
2657 }
2658
2659 case CIMTYPE_REFERENCE:
|
2660 thilo.boehm 1.2 {
2661 break;
2662 }
|
2663 thilo.boehm 1.1
2664 case CIMTYPE_OBJECT:
|
2665 thilo.boehm 1.2 {
2666 break;
2667 }
|
2668 thilo.boehm 1.1
2669 case CIMTYPE_INSTANCE:
|
2670 thilo.boehm 1.2 {
2671 break;
2672 }
|
2673 thilo.boehm 1.1 default:
|
2674 thilo.boehm 1.2 {
2675 PEGASUS_ASSERT(0);
2676 }
|
2677 thilo.boehm 1.1 }
2678
|
2679 thilo.boehm 1.2 return out.getData();
|
2680 thilo.boehm 1.1 }
2681
|
2682 thilo.boehm 1.2 String SCMODump::printUnionValue(
2683 CIMType type,
2684 SCMBUnion u,
2685 unsigned char* base) const
|
2686 thilo.boehm 1.1 {
|
2687 thilo.boehm 1.2 Buffer out;
|
2688 thilo.boehm 1.1
|
2689 thilo.boehm 1.2 switch (type)
|
2690 thilo.boehm 1.1 {
|
2691 thilo.boehm 1.2 case CIMTYPE_BOOLEAN:
2692 {
2693 _toString(out,u._booleanValue);
2694 break;
2695 }
|
2696 thilo.boehm 1.1
|
2697 thilo.boehm 1.2 case CIMTYPE_UINT8:
2698 {
2699 _toString(out,u._uint8Value);
2700 break;
2701 }
|
2702 thilo.boehm 1.1
|
2703 thilo.boehm 1.2 case CIMTYPE_SINT8:
2704 {
2705 _toString(out,u._sint8Value);
2706 break;
2707 }
|
2708 thilo.boehm 1.1
|
2709 thilo.boehm 1.2 case CIMTYPE_UINT16:
2710 {
2711 _toString(out,(Uint32)u._uint16Value);
2712 break;
2713 }
|
2714 thilo.boehm 1.1
|
2715 thilo.boehm 1.2 case CIMTYPE_SINT16:
2716 {
2717 _toString(out,u._sint16Value);
2718 break;
2719 }
|
2720 thilo.boehm 1.1
|
2721 thilo.boehm 1.2 case CIMTYPE_UINT32:
2722 {
2723 _toString(out,u._uint32Value);
2724 break;
2725 }
|
2726 thilo.boehm 1.1
|
2727 thilo.boehm 1.2 case CIMTYPE_SINT32:
2728 {
2729 _toString(out,u._sint32Value);
2730 break;
2731 }
|
2732 thilo.boehm 1.1
|
2733 thilo.boehm 1.2 case CIMTYPE_UINT64:
|
2734 thilo.boehm 1.1 {
|
2735 thilo.boehm 1.2 _toString(out,u._uint64Value);
2736 break;
|
2737 thilo.boehm 1.1 }
2738
|
2739 thilo.boehm 1.2 case CIMTYPE_SINT64:
2740 {
2741 _toString(out,u._sint64Value);
2742 break;
2743 }
|
2744 thilo.boehm 1.1
|
2745 thilo.boehm 1.2 case CIMTYPE_REAL32:
2746 {
2747 _toString(out,u._real32Value);
2748 break;
2749 }
|
2750 thilo.boehm 1.1
|
2751 thilo.boehm 1.2 case CIMTYPE_REAL64:
2752 {
2753 _toString(out,u._real32Value);
2754 break;
2755 }
|
2756 thilo.boehm 1.1
|
2757 thilo.boehm 1.2 case CIMTYPE_CHAR16:
2758 {
2759 _toString(out,u._char16Value);
2760 break;
2761 }
|
2762 thilo.boehm 1.1
|
2763 thilo.boehm 1.2 case CIMTYPE_STRING:
2764 {
2765 out.append((const char*)_getCharString(u._stringValue,base),
2766 u._stringValue.length-1);
2767 break;
2768 }
|
2769 thilo.boehm 1.1
|
2770 thilo.boehm 1.2 case CIMTYPE_DATETIME:
2771 {
2772 CIMDateTime x;
2773 memcpy(x._rep,&(u._dateTimeValue),sizeof(SCMBDateTime));
2774 _toString(out,x);
2775 break;
2776 }
|
2777 thilo.boehm 1.1
|
2778 thilo.boehm 1.2 case CIMTYPE_REFERENCE:
2779 {
2780 break;
2781 }
|
2782 thilo.boehm 1.1
|
2783 thilo.boehm 1.2 case CIMTYPE_OBJECT:
2784 {
2785 break;
2786 }
|
2787 thilo.boehm 1.1
|
2788 thilo.boehm 1.2 case CIMTYPE_INSTANCE:
2789 {
2790 break;
2791 }
2792 default:
2793 {
2794 PEGASUS_ASSERT(0);
2795 }
2796 }
|
2797 thilo.boehm 1.1
|
2798 thilo.boehm 1.2 return out.getData();
|
2799 thilo.boehm 1.1 }
2800
|
2801 thilo.boehm 1.2 void SCMODump::dumpKeyPropertyMask(SCMOClass& testCls ) const
|
2802 thilo.boehm 1.1 {
2803
|
2804 thilo.boehm 1.2 SCMBClass_Main* clshdr = testCls.cls.hdr;
2805 unsigned char* clsbase = testCls.cls.base;
|
2806 thilo.boehm 1.1
|
2807 thilo.boehm 1.2 Uint64 *theKeyMask = (Uint64*)&(clsbase[clshdr->keyPropertyMask.start]);
2808 Uint32 end, noProperties = clshdr->propertySet.number;
2809 Uint32 noMasks = (noProperties-1)/64;
2810 Uint64 printMask = 1;
|
2811 thilo.boehm 1.1
|
2812 thilo.boehm 1.2 for (Uint32 i = 0; i <= noMasks; i++ )
2813 {
2814 printMask = 1;
2815 if (i < noMasks)
2816 {
2817 end = 64;
2818 }
2819 else
2820 {
2821 end = noProperties%64;
2822 }
|
2823 thilo.boehm 1.1
|
2824 thilo.boehm 1.2 printf("\nkeyPropertyMask[%02u]= ",i);
|
2825 thilo.boehm 1.1
|
2826 thilo.boehm 1.2 for (Uint32 j = 0; j < end; j++)
2827 {
2828 if (j > 0 && !(j%8))
2829 {
2830 printf(" ");
2831 }
|
2832 thilo.boehm 1.1
|
2833 thilo.boehm 1.2 if (theKeyMask[i] & printMask)
2834 {
2835 printf("1");
2836 }
2837 else
2838 {
2839 printf("0");
2840 }
|
2841 thilo.boehm 1.1
|
2842 thilo.boehm 1.2 printMask = printMask << 1;
2843 }
2844 printf("\n");
2845 }
|
2846 thilo.boehm 1.1 }
2847
|
2848 thilo.boehm 1.2 void SCMODump::_hexDump(unsigned char* buffer,int length) const
|
2849 thilo.boehm 1.1 {
2850
2851 unsigned char printLine[3][80];
2852 int p;
2853 int len;
2854 unsigned char item;
2855
2856 for (int i = 0; i < length;i=i+1)
2857 {
2858 p = i%80;
|
2859 thilo.boehm 1.2
|
2860 thilo.boehm 1.1 if ((p == 0 && i > 0) || i == length-1 )
|
2861 thilo.boehm 1.2 {
|
2862 thilo.boehm 1.1 for (int y = 0; y < 3; y=y+1)
2863 {
2864 if (p == 0)
2865 {
2866 len = 80;
2867 } else
2868 {
2869 len = p;
2870 }
2871
2872 for (int x = 0; x < len; x=x+1)
2873 {
2874 if (y == 0)
2875 {
2876 printf("%c",printLine[y][x]);
2877 }
2878 else
2879 {
2880 printf("%1X",printLine[y][x]);
2881 }
2882 }
2883 thilo.boehm 1.1 printf("\n");
2884 }
2885 printf("\n");
2886 }
2887
2888 item = buffer[i];
2889
2890 if (item < 32 || item > 125 )
2891 {
2892 printLine[0][p] = '.';
2893 } else
2894 {
2895 printLine[0][p] = item;
2896 }
2897
2898 printLine[1][p] = item/16;
2899 printLine[2][p] = item%16;
2900
2901 }
2902 }
2903
|
2904 thilo.boehm 1.2 /*****************************************************************************
2905 * The constant functions
2906 *****************************************************************************/
2907
|
2908 thilo.boehm 1.1 static const void* _resolveDataPtr(
2909 const SCMBDataPtr& ptr,
2910 unsigned char* base)
2911 {
2912 return ((ptr.start==(Uint64)0 ? NULL : (void*)&(base[ptr.start])));
2913 }
2914
|
2915 thilo.boehm 1.2 PEGASUS_COMMON_LINKAGE const unsigned char* _getCharString(
2916 const SCMBDataPtr& ptr,
|
2917 thilo.boehm 1.1 unsigned char* base)
2918 {
2919 return ((ptr.start==(Uint64)0 ? NULL : &(base[ptr.start])));
2920 }
2921
2922
2923 static Uint32 _generateSCMOStringTag(
|
2924 thilo.boehm 1.2 const SCMBDataPtr& ptr,
|
2925 thilo.boehm 1.1 unsigned char* base)
2926 {
2927 // The lenght of a SCMBDataPtr to a UTF8 string includs the trailing '\0'.
2928 return _generateStringTag(_getCharString(ptr,base),ptr.length-1);
2929 }
2930
2931 static Uint32 _generateStringTag(const unsigned char* str, Uint32 len)
2932 {
2933 if (len == 0)
2934 {
2935 return 0;
2936 }
2937 return
2938 (Uint32(CharSet::toUpperHash(str[0]) << 1) |
2939 Uint32(CharSet::toUpperHash(str[len-1])));
2940 }
2941
2942 static CIMKeyBinding::Type _cimTypeToKeyBindType(CIMType cimType)
2943 {
2944 switch (cimType)
2945 {
2946 thilo.boehm 1.1 case CIMTYPE_BOOLEAN:
2947 return(CIMKeyBinding::BOOLEAN);
2948 break;
2949 case CIMTYPE_CHAR16:
2950 case CIMTYPE_STRING:
2951 case CIMTYPE_DATETIME:
2952 return(CIMKeyBinding::STRING);
2953 break;
2954 case CIMTYPE_REFERENCE:
2955 return(CIMKeyBinding::REFERENCE);
2956 break;
2957 case CIMTYPE_OBJECT:
2958 case CIMTYPE_INSTANCE:
2959 // From PEP 194: EmbeddedObjects cannot be keys.
2960 throw TypeMismatchException();
2961 break;
2962 default:
2963 return(CIMKeyBinding::NUMERIC);
2964 break;
2965 }
2966 }
2967 thilo.boehm 1.1
2968 static Boolean _equalUTF8Strings(
2969 const SCMBDataPtr& ptr_a,
2970 unsigned char* base,
2971 const char* name,
2972 Uint32 len)
|
2973 thilo.boehm 1.2
|
2974 thilo.boehm 1.1 {
2975 // size without trailing '\0' !!
2976 if (ptr_a.length-1 != len)
2977 {
2978 return false;
2979 }
2980
2981 const char* a = (const char*)_getCharString(ptr_a,base);
2982
2983 // ToDo: Here an UTF8 complinet comparison should take place
2984 return ( strncmp(a,name,len )== 0 );
2985
2986 }
2987
2988 /**
2989 * This function calcutates a free memory slot in the single chunk memory block.
|
2990 thilo.boehm 1.2 * Warning: In this routine a reallocation may take place.
|
2991 thilo.boehm 1.1 * @param ptr A reference to a data SCMB data pointer. The values to the free
|
2992 thilo.boehm 1.2 * block is written into this pointer. If the provided ptr is
2993 * located in the single chunk memory block, this pointer may be
2994 * invalid after this call. You have to recalcuate the pointer
|
2995 thilo.boehm 1.1 * after calling this function.
2996 * @parm size The requested free memory slot.
2997 * @parm pmem A reference to the pointer of the single chunk memory block.
2998 * e.g. &cls.mem
2999 * @return The relaive index of the free memory slot.
3000 */
3001
|
3002 thilo.boehm 1.2 static Uint64 _getFreeSpace(
3003 SCMBDataPtr& ptr,
3004 Uint64 size,
|
3005 thilo.boehm 1.1 SCMBMgmt_Header** pmem,
3006 Boolean clear)
3007 {
3008 Uint64 oldSize, start;
3009
3010 if (size == 0)
3011 {
3012 ptr.start = 0;
3013 ptr.length = 0;
3014 return 0;
3015 }
3016
|
3017 thilo.boehm 1.2 // The SCMBDataPtr has to be set before any reallocation.
|
3018 thilo.boehm 1.1 start = (*pmem)->startOfFreeSpace;
3019 ptr.start = start;
3020 ptr.length = size;
3021
3022 while ((*pmem)->freeBytes < size)
3023 {
3024 // save old size of buffer
3025 oldSize = (*pmem)->totalSize;
3026 // reallocate the buffer, double the space !
3027 // This is a working approach until a better algorithm is found.
3028 (*pmem) = (SCMBMgmt_Header*)realloc((*pmem),oldSize*2);
3029 if ((*pmem) == NULL)
3030 {
|
3031 thilo.boehm 1.2 // Not enough memory!
|
3032 thilo.boehm 1.1 throw PEGASUS_STD(bad_alloc)();
3033 }
|
3034 thilo.boehm 1.2 // increase the total size and free space
|
3035 thilo.boehm 1.1 (*pmem)->freeBytes= (*pmem)->freeBytes + oldSize;
3036 (*pmem)->totalSize= (*pmem)->totalSize + oldSize;
|
3037 thilo.boehm 1.2 }
|
3038 thilo.boehm 1.1
3039 (*pmem)->freeBytes = (*pmem)->freeBytes - size;
3040 (*pmem)->startOfFreeSpace = (*pmem)->startOfFreeSpace + size;
3041
3042 if (clear)
3043 {
3044 // If requested, set memory to 0.
3045 memset(&((unsigned char*)(*pmem))[start],0,size);
3046 }
3047 return start;
3048 }
3049
3050 static void _setString(
|
3051 thilo.boehm 1.2 const String& theString,
3052 SCMBDataPtr& ptr,
|
3053 thilo.boehm 1.1 SCMBMgmt_Header** pmem)
3054 {
3055
3056 // Get the UTF8 CString
3057 CString theCString=theString.getCString();
|
3058 thilo.boehm 1.2 // Get the real size of the UTF8 sting + \0.
3059 // It maybe greater then the length in the String due to
|
3060 thilo.boehm 1.1 // 4 byte encoding of non ASCII chars.
3061 Uint64 start,length = strlen((const char*)theCString)+1;
3062
3063 // If the string is not empty.
3064 if (length != 1)
3065 {
3066
3067 // Attention ! In this function a reallocation may take place.
|
3068 thilo.boehm 1.2 // The reference ptr may be unusable after the call to _getFreeSpace
|
3069 thilo.boehm 1.1 // --> use the returned start index.
|
3070 thilo.boehm 1.2 start = _getFreeSpace(ptr , length, pmem);
|
3071 thilo.boehm 1.1 // Copy string including trailing \0
3072 memcpy(&((unsigned char*)(*pmem))[start],(const char*)theCString,length);
|
3073 thilo.boehm 1.2 }
|
3074 thilo.boehm 1.1 else
3075 {
3076 ptr.start = 0;
3077 ptr.length = 0;
3078 }
3079 }
3080
3081 static void _setBinary(
|
3082 thilo.boehm 1.2 const void* theBuffer,
|
3083 thilo.boehm 1.1 Uint64 bufferSize,
|
3084 thilo.boehm 1.2 SCMBDataPtr& ptr,
|
3085 thilo.boehm 1.1 SCMBMgmt_Header** pmem)
3086 {
3087
3088 // If buffer is not empty.
3089 if (bufferSize != 1)
3090 {
3091
3092 Uint64 start;
3093 // Attention ! In this function a reallocation may take place.
|
3094 thilo.boehm 1.2 // The reference ptr may be unusable after the call to _getFreeSpace
|
3095 thilo.boehm 1.1 // --> use the returned start index.
|
3096 thilo.boehm 1.2 start = _getFreeSpace(ptr , bufferSize, pmem);
|
3097 thilo.boehm 1.1 // Copy buffer into SCMB
3098 memcpy(
3099 &((unsigned char*)(*pmem))[start],
3100 (const char*)theBuffer,
|
3101 thilo.boehm 1.2 bufferSize);
3102 }
|
3103 thilo.boehm 1.1 else
3104 {
3105 ptr.start = 0;
3106 ptr.length = 0;
3107 }
3108 }
3109
3110
3111 PEGASUS_NAMESPACE_END
|