(file) Return to SCMO.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2