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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2