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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2