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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2