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

   1 thilo.boehm 1.2 //%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.2 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23                 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  24                 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25                 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26                 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27                 //
  28                 //////////////////////////////////////////////////////////////////////////
  29                 //
  30 marek       1.8 // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
  31                 // (Single Chunk Memory Objects).
  32                 // The design document can be found on the OpenPegasus website openpegasus.org
  33                 // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
  34                 //
  35 thilo.boehm 1.2 //%/////////////////////////////////////////////////////////////////////////////
  36                 
  37                 #ifndef _SCMOINSTANCE_H_
  38                 #define _SCMOINSTANCE_H_
  39                 
  40                 
  41                 #include <Pegasus/Common/Config.h>
  42                 #include <Pegasus/Common/Linkage.h>
  43                 #include <Pegasus/Common/SCMO.h>
  44                 #include <Pegasus/Common/SCMOClass.h>
  45                 #include <Pegasus/Common/Union.h>
  46                 
  47                 PEGASUS_NAMESPACE_BEGIN
  48                 
  49                 #define PEGASUS_SCMB_INSTANCE_MAGIC 0xD00D1234
  50                 
  51                 class PEGASUS_COMMON_LINKAGE SCMOInstance
  52                 {
  53                 public:
  54                 
  55                     /**
  56 thilo.boehm 1.2      * A SCMOInstance can only be created by a SCMOClass
  57                      */
  58                     SCMOInstance();
  59                 
  60                     /**
  61                      * Creating a SCMOInstance using a SCMOClass.
  62                      * @param baseClass A SCMOClass.
  63                      */
  64                     SCMOInstance(SCMOClass& baseClass);
  65                 
  66                 
  67                     /**
  68                      * Creating a SCMOInstance using a CIMClass
  69                      * using an optional name space name,
  70                      * @param baseClass A SCMOClass.
  71                      * @param nameSpaceName An optional name space name.
  72                      */
  73                     SCMOInstance(CIMClass& theCIMClass, const char* nameSpaceName=0);
  74                 
  75                     /**
  76                      * Copy constructor for the SCMO instance, used to implement refcounting.
  77 thilo.boehm 1.2      * @param theSCMOClass The instance for which to create a copy
  78                      * @return
  79                      */
  80                     SCMOInstance(const SCMOInstance& theSCMOInstance )
  81                     {
  82                         inst.hdr = theSCMOInstance.inst.hdr;
  83                         Ref();
  84                     }
  85                 
  86                     /**
  87                      * Constructs a SCMOInstance from a memory object of type SCMBInstance_Main.
  88                      * It incremets the referece counter of the memory object.
  89                      * @param hdr A memory object of type SCMBInstance_Main.
  90                      **/
  91                     SCMOInstance(SCMBInstance_Main* hdr)
  92                     {
  93                         inst.hdr = hdr;
  94                         Ref();
  95                     }
  96                 
  97                 
  98 thilo.boehm 1.2     /**
  99                      * Assignment operator for the SCMO instance,
 100                      * @param theSCMOInstance The right hand value
 101                      **/
 102                     SCMOInstance& operator=(const SCMOInstance& theSCMOInstance)
 103                     {
 104                         if (inst.hdr != theSCMOInstance.inst.hdr)
 105                         {
 106                             Unref();
 107                             inst.hdr = theSCMOInstance.inst.hdr;
 108                             Ref();
 109                         }
 110                         return *this;
 111                     }
 112                 
 113                     /**
 114                      * Destructor is decrementing the refcount. If refcount is zero, the
 115                      * singele chunk memory object is deallocated.
 116                      */
 117                     ~SCMOInstance()
 118                     {
 119 thilo.boehm 1.2         Unref();
 120                     }
 121                 
 122                     /**
 123                      * Builds a SCMOInstance based on this SCMOClass.
 124                      * The method arguments determine whether qualifiers are included,
 125                      * the class origin attributes are included,
 126                      * and which properties are included in the new instance.
 127                      * @param baseClass The SCMOClass of this instance.
 128                      * @param includeQualifiers A Boolean indicating whether qualifiers in
 129                      * the class definition (and its properties) are to be added to the
 130                      * instance.  The TOINSTANCE flavor is ignored.
 131                      * @param includeClassOrigin A Boolean indicating whether ClassOrigin
 132                      * attributes are to be added to the instance.
 133                      *
 134                      * Note that this function does NOT generate an error if a property name
 135                      * is supplied that is NOT in the class;
 136                      * it simply does not add that property to the instance.
 137                      *
 138                      */
 139                     SCMOInstance(
 140 thilo.boehm 1.2         SCMOClass& baseClass,
 141                         Boolean includeQualifiers,
 142 marek       1.7         Boolean includeClassOrigin);
 143 thilo.boehm 1.2 
 144                     /**
 145                      * Builds a SCMOInstance from the given SCMOClass and copies all
 146                      * CIMInstance data into the new SCMOInstance.
 147                      * @param baseClass The SCMOClass of this instance.
 148                      * @param cimInstance A CIMInstace of the same class.
 149                      * @exception Exception if class name does not match.
 150                      * @exception Exception if a property is not part of class definition.
 151                      * @exception Exception if a property does not match the class definition.
 152                      */
 153                     SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance);
 154                 
 155                     /**
 156                      * Builds a SCMOInstance from the given SCMOClass and copies all
 157                      * CIMObjectPath data into the new SCMOInstance.
 158                      * @param baseClass The SCMOClass of this instance.
 159                      * @param cimInstance A CIMObjectpath of the same class.
 160                      * @exception Exception if class name does not match.
 161                      */
 162                     SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj);
 163                 
 164 thilo.boehm 1.2     /**
 165                      * Builds a SCMOInstance from the given CIMInstance copying all data.
 166                      * The SCMOClass is retrieved from SCMOClassCache using
 167                      * the class and name space of the CIMInstance.
 168                      * If the SCMOClass was not found, an empty SCMOInstance will be returned
 169                      * and the resulting SCMOInstance is compromized.
 170                      * If the CIMInstance does not contain a name space, the optional fall back
 171                      * name space is used.
 172                      * @param cimInstance A CIMInstace with class name and name space.
 173                      * @param altNameSpace An alternative name space name.
 174                      * @exception Exception if a property is not part of class definition.
 175                      * @exception Exception if a property does not match the class definition.
 176                      */
 177                     SCMOInstance(
 178                         const CIMInstance& cimInstance,
 179                         const char* altNameSpace=0,
 180                         Uint32 altNSLen=0);
 181                 
 182                     /**
 183                      * Builds a SCMOInstance from the given CIMObjectPath copying all data.
 184                      * The SCMOClass is retrieved from SCMOClassCache using
 185 thilo.boehm 1.2      * the class and name space of the CIMObjectPath.
 186                      * If the SCMOClass was not found, an empty SCMOInstance will be returned
 187                      * and the resulting SCMOInstance is compromized.
 188                      * If the CIMObjectPath does not contain a name space,
 189                      * the optional fall back name space is used.
 190                      * @param cimObj A CIMObjectpath with name space and name
 191                      * @param altNameSpace An alternative name space name.
 192                      * @
 193                      */
 194                     SCMOInstance(
 195                         const CIMObjectPath& cimObj,
 196                         const char* altNameSpace=0,
 197                         Uint32 altNSLen=0);
 198                 
 199                     /**
 200                      * Builds a SCMOInstance from the given CIMObject copying all data.
 201                      * The SCMOClass is retrieved from SCMOClassCache using
 202                      * the class and name space of the CIMObject.
 203                      * If the SCMOClass was not found, an empty SCMOInstance will be returned
 204                      * and the resulting SCMOInstance is compromized.
 205                      * If the CIMInstance does not contain a name space, the optional fall back
 206 thilo.boehm 1.2      * name space is used.
 207                      * @param cimInstance A CIMInstace with class name and name space.
 208                      * @param altNameSpace An alternative name space name.
 209                      * @exception Exception if a property is not part of class definition.
 210                      * @exception Exception if a property does not match the class definition.
 211                      */
 212                     SCMOInstance(
 213                         const CIMObject& cimObject,
 214                         const char* altNameSpace=0,
 215                         Uint32 altNSLen=0);
 216                 
 217                     /**
 218                      * Converts the SCMOInstance into a CIMInstance.
 219                      * It is a deep copy of the SCMOInstance into the CIMInstance.
 220                      * @param cimInstance An empty CIMInstance.
 221                      */
 222                     SCMO_RC getCIMInstance(CIMInstance& cimInstance) const;
 223                 
 224                     /**
 225                      * Makes a deep copy of the instance.
 226                      * This creates a new copy of the instance.
 227 thilo.boehm 1.2      * @param objectPathOnly If set to true, only the object path relevant parts
 228                      *     host name and key bindings are part of the cloned instance.
 229                      * @return A new copy of the SCMOInstance object.
 230                      */
 231                     SCMOInstance clone(Boolean objectPathOnly = false) const;
 232                 
 233                     /**
 234                      * Retrieves the objectpath part of the SCMOInstance as an instance
 235                      * of class CIMObjectPath.                .
 236                      * @param cimObj Reference to an instantiated CIMObjectPath to be
 237                      *     populated with the data from the SCMOInstance.
 238                      * @return void
 239                      */
 240                     void getCIMObjectPath(CIMObjectPath& cimObj) const;
 241                 
 242                     /**
 243                      * Returns the number of properties of the instance.
 244                      * @param Number of properties
 245                      */
 246                     Uint32 getPropertyCount() const;
 247                 
 248 thilo.boehm 1.2     /**
 249                      * Gets the property name, type, and value addressed by a positional index.
 250                      * The property name and value has to be copied by the caller !
 251                      * @param pos The positional index of the property
 252                      * @param pname Returns the property name as '\0' terminated string.
 253                      *              Has to be copied by caller.
 254                      *              It is set to NULL if rc != SCMO_OK.
 255                      * @param pvalue Returns a pointer to the value of property.
 256                      *               The value is stored in a SCMBUnion
 257                      *                and has to be copied by the caller !
 258                      *               It returns NULL if rc != SCMO_OK.
 259                      *
 260                      *               If the value is an array, the
 261                      *               value array is stored in continuous memory.
 262                      *               e.g. (SCMBUnion*)value[0 to size-1]
 263                      *
 264                      *               If the value is type of CIMTYPE_STRING,
 265                      *               the string is referenced by the structure
 266                      *               SCMBUnion.extString:
 267                      *                       pchar contains the absolut pointer to the string
 268                      *                       length contains the size of the string
 269 thilo.boehm 1.2      *                              without trailing '\0'.
 270                      *               Only for strings the caller has to free pvalue !
 271                      * @param type Returns the CIMType of the property
 272                      *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 273                      * @param isArray Returns if the value is an array.
 274                      *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 275                      * @param size Returns the size of the array.
 276                      *             If it is not an array, 0 is returned.
 277                      *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 278                      *
 279                      * @return     SCMO_OK
 280                      *             SCMO_NULL_VALUE : The value is a null value.
 281                      *             SCMO_INDEX_OUT_OF_BOUND : Given index not found
 282                      *
 283                      */
 284                     SCMO_RC getPropertyAt(
 285                         Uint32 pos,
 286                         const char** pname,
 287                         CIMType& type,
 288                         const SCMBUnion** pvalue,
 289                         Boolean& isArray,
 290 thilo.boehm 1.2         Uint32& size ) const;
 291                 
 292                     void getSCMBValuePropertyAt(
 293                         Uint32 pos,
 294                         SCMBValue** value,
 295                         const char ** valueBase,
 296                         SCMBClassProperty ** propDef,
 297                         const char ** classBase) const;
 298                 
 299                     /**
 300                      * Gets the type and value of the named property.
 301                      * The value has to be copied by the caller !
 302                      * @param name The property name
 303                      * @param pvalue Returns a pointer to the value of property.
 304                      *               The value is stored in a SCMBUnion
 305                      *                and has to be copied by the caller !
 306                      *               It returns NULL if rc != SCMO_OK.
 307                      *
 308                      *               If the value is an array, the
 309                      *               value array is stored in continuous memory.
 310                      *               e.g. (SCMBUnion*)value[0 to size-1]
 311 thilo.boehm 1.2      *
 312                      *               If the value is type of CIMTYPE_STRING,
 313                      *               the string is referenced by the structure
 314                      *               SCMBUnion.extString:
 315                      *                       pchar contains the absolut pointer to the string
 316                      *                       length contains the size of the string
 317                      *                              without trailing '\0'.
 318                      *               Only for strings the caller has to free pvalue !
 319                      * @param type Returns the CIMType of the property
 320                      *             It is invalid if rc == SCMO_NOT_FOUND.
 321                      * @param isArray Returns if the value is an array.
 322                      *             It is invalid if rc == SCMO_NOT_FOUND.
 323                      * @param size Returns the size of the array.
 324                      *             If it is not an array, 0 is returned.
 325                      *             It is invalid if rc == SCMO_NOT_FOUND.
 326                      *
 327                      * @return     SCMO_OK
 328                      *             SCMO_NULL_VALUE : The value is a null value.
 329                      *             SCMO_NOT_FOUND : Given property name not found.
 330                      */
 331                     SCMO_RC getProperty(
 332 thilo.boehm 1.2         const char* name,
 333                         CIMType& type,
 334                         const SCMBUnion** pvalue,
 335                         Boolean& isArray,
 336                         Uint32& size ) const;
 337                 
 338                     /**
 339                      * Set/replace a property in the instance.
 340                      * If the class origin is specified, it is honored at identifying
 341                      * the property within the instance.
 342                      * Note: Only properties which are already part of the instance/class can
 343                      * be set/replaced.
 344                      * @param name The name of the property to be set.
 345                      * @param type The CIMType of the property
 346                      * @param value A pointer to the value to be set at the named property.
 347                      *              The value has to be in a SCMBUnion.
 348                      *              The value is copied into the instance
 349                      *              If the value == NULL, a null value is assumed.
 350                      *              If the value is an array, the value array has to be
 351                      *              stored in continuous memory.
 352                      *              e.g. (SCMBUnion*)value[0 to size-1]
 353 thilo.boehm 1.2      *
 354                      *              To store an array of size 0, The value pointer has to
 355                      *              not NULL ( value != NULL ) but the size has to be 0
 356                      *              (size == 0).
 357                      *
 358                      *              If the value is type of CIMTYPE_STRING,
 359                      *              the string is referenced by the structure
 360                      *              SCMBUnion.extString:
 361                      *                       pchar contains the absolut pointer to the string
 362                      *                       length contains the size of the string
 363                      *                              without trailing '\0'.
 364                      * @param isArray Indicate that the value is an array. Default false.
 365                      * @param size Returns the size of the array. If not an array this
 366                      *         this parameter is ignorer. Default 0.
 367                      * @param origin The class originality of the property.
 368                      *               If NULL, then it is ignorred. Default NULL.
 369                      * @return     SCMO_OK
 370                      *             SCMO_NOT_SAME_ORIGIN : The property name was found, but
 371                      *                                    the origin was not the same.
 372                      *             SCMO_NOT_FOUND : Given property name not found.
 373                      *             SCMO_WRONG_TYPE : Named property has the wrong type.
 374 thilo.boehm 1.2      *             SCMO_NOT_AN_ARRAY : Named property is not an array.
 375                      *             SCMO_IS_AN_ARRAY  : Named property is an array.
 376                      */
 377                     SCMO_RC setPropertyWithOrigin(
 378                         const char* name,
 379                         CIMType type,
 380                         const SCMBUnion* value,
 381                         Boolean isArray=false,
 382                         Uint32 size = 0,
 383                         const char* origin = NULL);
 384                 
 385                     /**
 386                      * Rebuild of the key bindings from the property values
 387                      * if no or incomplete key properties are set on the instance.
 388                      * @exception NoSuchProperty
 389                      */
 390                     void buildKeyBindingsFromProperties();
 391 anusha.kandepu 1.4     
 392 thilo.boehm    1.2     /**
 393                         * Gets the hash index for the named property. Filtering is ignored.
 394                         * @param theName The property name
 395                         * @param pos Returns the hash index.
 396                         * @return     SCMO_OK
 397                         *             SCMO_INVALID_PARAMETER: name was a NULL pointer.
 398                         *             SCMO_NOT_FOUND : Given property name not found.
 399                         */
 400                        SCMO_RC getPropertyNodeIndex(const char* name, Uint32& pos) const;
 401                    
 402                        /**
 403                         * Set/replace a property in the instance at node index.
 404                         * @param index The node index.
 405                         * @param type The CIMType of the property
 406                         * @param pInVal A pointer to the value to be set at the named property.
 407                         *               The value has to be in a SCMBUnion.
 408                         *               The value is copied into the instance
 409                         *               If the value == NULL, a null value is assumed.
 410                         *               If the value is an array, the value array has to be
 411                         *               stored in continuous memory.
 412                         *               e.g. (SCMBUnion*)value[0 to size-1]
 413 thilo.boehm    1.2      *
 414                         *              To store an array of size 0, The value pointer has to
 415                         *               not NULL ( value != NULL ) but the size has to be 0
 416                         *                (size == 0).
 417                         *
 418                         *               If the value is type of CIMTYPE_STRING,
 419                         *               the string is referenced by the structure
 420                         *               SCMBUnion.extString:
 421                         *                        pchar contains the absolut pointer to the string
 422                         *                       length contains the size of the string
 423                         *                                without trailing '\0'.
 424                         * @param isArray Indicate that the value is an array. Default false.
 425                         * @param size The size of the array. If not an array this
 426                         *         this parameter is ignorer. Default 0.
 427                         * @return     SCMO_OK
 428                         *             SCMO_INDEX_OUT_OF_BOUND : Given index not found
 429                         *             SCMO_WRONG_TYPE : The property at given node index
 430                         *                               has the wrong type.
 431                         *             SCMO_NOT_AN_ARRAY : The property at given node index
 432                         *                                 is not an array.
 433                         *             SCMO_IS_AN_ARRAY  : The property at given node index
 434 thilo.boehm    1.2      *                                 is an array.
 435                         */
 436                        SCMO_RC setPropertyWithNodeIndex(
 437                            Uint32 node,
 438                            CIMType type,
 439                            const SCMBUnion* pInVal,
 440                            Boolean isArray=false,
 441                            Uint32 size = 0);
 442                    
 443                        /**
 444                         * Set/replace the named key binding using binary data
 445                         * @param name The key binding name.
 446                         * @param type The type as CIMType.
 447                         * @param keyvalue A pointer to the binary key value.
 448                         *         The value is copied into the instance
 449                         *         If the value == NULL, a null value is assumed.
 450                         * @param keyvalue A pointer to the value to be set at the key binding,
 451                         *               The keyvalue has to be in a SCMBUnion.
 452                         *               The keyvalue is copied into the instance.
 453                         *               If the keyvalue == NULL, a null value is assumed.
 454                         *
 455 thilo.boehm    1.2      *               If the keyvalue is type of CIMTYPE_STRING,
 456                         *               the string is referenced by the structure
 457                         *               SCMBUnion.extString:
 458                         *                        pchar contains the absolut pointer to the string
 459                         *                       length contains the size of the string
 460                         *                                without trailing '\0'.
 461                         * @return     SCMO_OK
 462                         *             SCMO_INVALID_PARAMETER : Given name or pvalue
 463                         *                                      is a NULL pointer.
 464                         *             SCMO_TYPE_MISSMATCH : Given type does not
 465                         *                                   match to key binding type
 466                         *             SCMO_NOT_FOUND : Given property name not found.
 467                         */
 468                        SCMO_RC setKeyBinding(
 469                            const char* name,
 470                            CIMType type,
 471                            const SCMBUnion* keyvalue);
 472                    
 473                        /**
 474                         * Set/replace the key binding at node
 475                         * @param node The node index of the key.
 476 thilo.boehm    1.2      * @param type The type as CIMType.
 477                         * @param keyvalue A pointer to the value to be set at the key binding,
 478                         *               The keyvalue has to be in a SCMBUnion.
 479                         *               The keyvalue is copied into the instance.
 480                         *               If the keyvalue == NULL, a null value is assumed.
 481                         *
 482                         *               If the keyvalue is type of CIMTYPE_STRING,
 483                         *               the string is referenced by the structure
 484                         *               SCMBUnion.extString:
 485                         *                        pchar contains the absolut pointer to the string
 486                         *                       length contains the size of the string
 487                         *                                without trailing '\0'.
 488                         * @return     SCMO_OK
 489                         *             SCMO_INVALID_PARAMETER : Given pvalue is a NULL pointer.
 490                         *             SCMO_TYPE_MISSMATCH : Given type does not
 491                         *                                   match to key binding type
 492                         *             SCMO_INDEX_OUT_OF_BOUND : Given index is our of range.
 493                         */
 494                        SCMO_RC setKeyBindingAt(
 495                            Uint32 node,
 496                            CIMType type,
 497 thilo.boehm    1.2         const SCMBUnion* keyvalue);
 498                    
 499                        /**
 500                         * Clears all key bindings in an instance.
 501                         * Warning: External references are freed but only the internal
 502                         * control structures are resetted. No memory is freed and at setting
 503                         * new key bindings the instance will grow in memory usage.
 504                         **/
 505                        void clearKeyBindings();
 506                    
 507                        /**
 508                         * Gets the key binding count.
 509                         * @return the number of key bindings set.
 510                         */
 511                        Uint32 getKeyBindingCount() const;
 512                    
 513                        /**
 514                         * Get the indexed key binding.
 515                         * @parm idx The key bining index
 516                         * @parm pname Returns the name.
 517                         *             Has to be copied by caller.
 518 thilo.boehm    1.2      *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 519                         * @param type Returns the type as CIMType.
 520                         *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 521                         * @param keyvalue A pointer to the binary key value.
 522                         *             Has to be copied by caller.
 523                         *             It is only valid if rc == SCMO_OK.
 524                         * @return     SCMO_OK
 525                         *             SCMO_NULL_VALUE : The key binding is not set.
 526                         *             SCMO_INDEX_OUT_OF_BOUND : Given index not found
 527                         *
 528                         */
 529                        SCMO_RC getKeyBindingAt(
 530                            Uint32 idx,
 531                            const char** pname,
 532                            CIMType& type,
 533                            const SCMBUnion** keyvalue) const;
 534                    
 535                        SCMO_RC getKeyBindingAtUnresolved(
 536                            Uint32 node,
 537                            const char** pname,
 538                            Uint32 & pnameLen,
 539 thilo.boehm    1.2         CIMType& type,
 540                            const SCMBUnion** pdata,
 541                            const char** valueBase) const;
 542                    
 543                        /**
 544                         * Get the named key binding.
 545                         * @parm name The name of the key binding.
 546                         * @param type Returns the type as CIMType.
 547                         *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 548                         * @param keyvalue Returns a pointer to the value of keybinding.
 549                         *               The value is stored in a SCMBUnion
 550                         *                and has to be copied by the caller !
 551                         *               It returns NULL if rc != SCMO_OK.
 552                         *
 553                         *               If the value is type of CIMTYPE_STRING,
 554                         *               the string is referenced by the structure
 555                         *               SCMBUnion.extString:
 556                         *                       pchar contains the absolut pointer to the string
 557                         *                       length contains the size of the string
 558                         *                              without trailing '\0'.
 559                         *               Only for strings the caller has to free pvalue !
 560 thilo.boehm    1.2      * @param keyvalue A pointer to the binary key value.
 561                         *             Has to be copied by caller.
 562                         *             It is only valid if rc == SCMO_OK.
 563                         * @return     SCMO_OK
 564                         *             SCMO_NULL_VALUE : The key binding is not set.
 565                         *             SCMO_NOT_FOUND : Given property name not found.
 566                         */
 567                        SCMO_RC getKeyBinding(
 568                            const char* name,
 569                            CIMType& ptype,
 570                            const SCMBUnion** keyvalue) const;
 571                    
 572                        /**
 573                         * Determines whether the c++ object has been initialized.
 574                         * @return True if the c++ object has not been initialized, false otherwise.
 575                         */
 576                        Boolean isUninitialized( ) const {return (0 == inst.base); };
 577                    
 578                        /**
 579                         * Determines if the SCMOInstance does not contain any property information.
 580                         * Maybe only the class name and/or name space are available.
 581 thilo.boehm    1.2      * @return True if the SCMOInstacne is empty, false otherwise.
 582                         */
 583                        Boolean isEmpty( ) const {return (inst.hdr->theClass.ptr->isEmpty()); };
 584                    
 585                        /**
 586                         * Determines whether the instance is used as a class container.
 587                         * @return True if the instance is used as a class container only.
 588                         */
 589                        Boolean getIsClassOnly( ) const
 590                        {
 591                            return inst.hdr->flags.isClassOnly;
 592                        }
 593                    
 594                        /**
 595                         * To mark if this instance is a class only container.
 596                         */
 597                        void setIsClassOnly( Boolean b )
 598                        {
 599                            inst.hdr->flags.isClassOnly = b;
 600                        }
 601                    
 602 thilo.boehm    1.2     /**
 603                         * Determies if two objects are referencing to the same instance
 604                         * @return True if the objects are referencing to the some instance.
 605                         */
 606                        Boolean isSame(SCMOInstance& theInstance) const;
 607                    
 608                        /**
 609                         * Sets the provided host name at the instance.
 610                         * @param hostName The host name as UTF8.
 611                         */
 612                        void setHostName(const char* hostName);
 613                    
 614                        /**
 615                         * Get the host name of the instance. The caller has to make a copy !
 616                         * @return The host name as UTF8.
 617                         */
 618                        const char* getHostName() const;
 619                    
 620                        /**
 621                         * Get the host name of the instance.
 622                         * @param Return strlen of result string.
 623 thilo.boehm    1.2      * @return The class name as UTF8.
 624                         */
 625                        const char* getHostName_l(Uint32 & length) const;
 626                    
 627                        /**
 628                         * Sets the provided class name at the instance. By caling this function
 629                         * the instance is in an inconsitacne state and is maked as isCompromised.
 630                         * @param className The class name as UTF8.
 631                         */
 632                        void setClassName(const char* className);
 633                    
 634                        /**
 635                         * Sets the provided class name at the instance. By caling this function
 636                         * the instance is in an inconsitacne state and is maked as isCompromised.
 637                         * @param className The class name as UTF8.
 638                         * @param len The strlen of the name space.
 639                         */
 640                        void setClassName_l(const char* className, Uint32 len);
 641                    
 642                        /**
 643                         * Get the class name of the instance. The caller has to make a copy !
 644 thilo.boehm    1.2      * @return The class name as UTF8.
 645                         */
 646                        const char* getClassName() const;
 647                    
 648                        /**
 649                         * Get the class name of the instance. The caller has to make a copy !
 650                         * @param lenght Return strlen of result string.
 651                         * @return The class name as UTF8.
 652                         */
 653                        const char* getClassName_l(Uint32 & length) const;
 654                    
 655                        /**
 656                         * Sets the provided name space name at the instance.
 657                         * By caling this function the instance is in an inconsitacne state and
 658                         * is maked as isCompromised.
 659                         * @param nameSpaceName The name space name as UTF8.
 660                         */
 661                        void setNameSpace(const char* nameSpace);
 662                    
 663                        /**
 664                         * Sets the provided name space name unchecked at the instance.
 665 thilo.boehm    1.2      * By caling this function the instance is in an inconsitacne state and
 666                         * is maked as isCompromised.
 667                         * @param nameSpaceName The name space name as UTF8.
 668                         * @param len The strlen of the name space.
 669                         */
 670                        void setNameSpace_l(const char* nameSpace, Uint32 len);
 671                    
 672                        /**
 673                         * Get the name space of the instance. The caller has to make a copy !
 674                         * @return The name space as UTF8.
 675                         */
 676                        const char* getNameSpace() const;
 677                    
 678                        /**
 679                         * Get the class name of the instance. The caller has to make a copy !
 680                         * @param Return strlen of result string.
 681                         * @return The class name as UTF8.
 682                         */
 683                        const char* getNameSpace_l(Uint32 & length) const;
 684                    
 685                        /**
 686 marek          1.6      * If hostname or namespace of the SCMOInstance are NULL or empty string,
 687                         * replace them with the given input.
 688                         * @param hn The host name to apply to the SCMOInstance.
 689                         * @param hnLen The length of the hostname in byte without closing zero.
 690                         * @param ns The namespace name to apply to the SCMOInstance.
 691                         * @param nsLen The length of the hostname in byte without closing zero.
 692                         */
 693                        void completeHostNameAndNamespace(
 694                            const char* hn,
 695                            Uint32 hnLen,
 696                            const char* ns,
 697                            Uint32 nsLen);
 698                    
 699                        /**
 700 thilo.boehm    1.2      * Is the name space or class name of the instance the origianl values
 701                         * set by the used SCMOClass.
 702                         * The class name and/or name space may differ with the associated class.
 703                         * @return true if name space or class name was set manually by
 704                         *          setNameSpace() or setClassName()
 705                         */
 706                        Boolean isCompromised() const
 707                        {
 708                            return inst.hdr->flags.isCompromised;
 709                        };
 710                    
 711                    
 712                        /**
 713                         * Mark the instance as a non validated instance.
 714                         */
 715                        void markAsCompromised()
 716                        {
 717                            inst.hdr->flags.isCompromised = true;
 718                        };
 719                    
 720                        /**
 721 thilo.boehm    1.2      *  To indicate the export processing ( eg. XMLWriter )
 722                         *  to include qualifiers for this instance.
 723                         */
 724                        void includeQualifiers()
 725                        {
 726                            inst.hdr->flags.includeQualifiers = true;
 727                        };
 728                    
 729                        /**
 730                         *  To indicate the export processing ( eg. XMLWriter )
 731                         *  to NOT to include (exclude) qualifiers for this instance.
 732                         */
 733                        void excludeQualifiers()
 734                        {
 735                            inst.hdr->flags.includeQualifiers = false;
 736                        }
 737                    
 738                        /**
 739                         *  To indicate the export processing ( eg. XMLWriter )
 740                         *  to include class origins for this instance.
 741                         */
 742 thilo.boehm    1.2     void includeClassOrigins()
 743                        {
 744                            inst.hdr->flags.includeClassOrigin = true;
 745                        };
 746                    
 747                        /**
 748                         *  To indicate the export processing ( eg. XMLWriter )
 749                         *  to NOT to include (exclude) class origins for this instance.
 750                         */
 751                        void excludeClassOrigins()
 752                        {
 753                            inst.hdr->flags.includeClassOrigin = false;
 754                        }
 755                    
 756                    
 757                        /**
 758                         * Returns the number of external references hosted by the instance.
 759                         **/
 760                        Uint32 numberExtRef() const
 761                        {
 762                            return inst.mem->numberExtRef;
 763 thilo.boehm    1.2     }
 764                    
 765                        /**
 766                         * Gets the pointer of an external reference of the instance.
 767                         * Warning: The pointer is purely returned. No management is done.
 768                         * @parm idx The index of the external reference.
 769                         **/
 770                        SCMOInstance* getExtRef(Uint32 idx) const;
 771                    
 772                        /**
 773                         * Sets a pointer of an external reference of the instance.
 774                         * Warning: The pointer is purely returned. No management is done.
 775                         * @parm idx The index of the external reference.
 776                         * @parm ptr The pointer to an SCMOInstance
 777                         **/
 778                        void putExtRef(Uint32 idx,SCMOInstance* ptr);
 779                    
 780                    private:
 781                    
 782                        void Ref()
 783                        {
 784 thilo.boehm    1.2         inst.hdr->refCount++;
 785                        };
 786                    
 787                        void Unref()
 788                        {
 789                            if (inst.hdr->refCount.decAndTestIfZero())
 790                            {
 791                                // All external references has to be destroyed.
 792                                _destroyExternalReferences();
 793                                // The class has also be dereferenced.
 794                                delete inst.hdr->theClass.ptr;
 795                                free(inst.base);
 796                                inst.base=NULL;
 797                            }
 798                    
 799                        };
 800                    
 801                    
 802                        void _copyOnWrite()
 803                        {
 804                            if ( 1 < inst.hdr->refCount.get() )
 805 thilo.boehm    1.2         {
 806                                SCMBInstance_Main * oldRef = inst.hdr;
 807 thilo.boehm    1.3             SCMBMgmt_Header* oldMgmt = inst.mem;
 808                    
 809 thilo.boehm    1.2             _clone();
 810                                if (oldRef->refCount.decAndTestIfZero())
 811                                {
 812                                    // All external references has to be destroyed.
 813 thilo.boehm    1.3                 _destroyExternalReferencesInternal(oldMgmt);
 814 thilo.boehm    1.2                 // The class has also be dereferenced.
 815                                    delete oldRef->theClass.ptr;
 816                                    free((void*)oldRef);
 817                                    oldRef=0;
 818                                }
 819                            }
 820                        };
 821                    
 822                        void _clone();
 823                    
 824                        void _destroyExternalReferences();
 825                    
 826                        void _destroyExternalKeyBindings();
 827                    
 828                        void _copyExternalReferences();
 829                    
 830                        void _setExtRefIndex(Uint64 idx);
 831                    
 832                        void _initSCMOInstance(SCMOClass* pClass);
 833                    
 834                        void _setCIMInstance(const CIMInstance& cimInstance);
 835 thilo.boehm    1.2 
 836                        void _getPropertyAt(
 837                            Uint32 pos,
 838                            SCMBValue** value,
 839                            const char ** valueBase,
 840                            SCMBClassProperty ** propDef) const;
 841                    
 842                        SCMO_RC _getPropertyAtNodeIndex(
 843                            Uint32 pos,
 844                            const char** pname,
 845                            CIMType& type,
 846                            const SCMBUnion** pvalue,
 847                            Boolean& isArray,
 848                            Uint32& size ) const;
 849                    
 850                        void _setPropertyAtNodeIndex(
 851                            Uint32 pos,
 852                            CIMType type,
 853                            const SCMBUnion* pInVal,
 854                            Boolean isArray,
 855                            Uint32 size);
 856 thilo.boehm    1.2 
 857                        void _setCIMValueAtNodeIndex(
 858                            Uint32 node,
 859                            CIMValueRep* valRep,
 860                            CIMType realType);
 861                    
 862                        static void _getCIMValueFromSCMBUnion(
 863                            CIMValue& cimV,
 864                            const CIMType type,
 865                            const Boolean isNull,
 866                            const Boolean isArray,
 867                            const Uint32 arraySize,
 868                            const SCMBUnion& scmbUn,
 869                            const char * base);
 870                    
 871                        static void _getCIMValueFromSCMBValue(
 872                            CIMValue& cimV,
 873                            const SCMBValue& scmbV,
 874                            const char * base);
 875                    
 876                        static SCMOClass _getSCMOClass(
 877 thilo.boehm    1.2         const CIMObjectPath& theCIMObj,
 878                            const char* altNS,
 879                            Uint32 altNSlength);
 880                    
 881                        CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const;
 882                    
 883                        void _setCIMObjectPath(const CIMObjectPath& cimObj);
 884                    
 885                        SCMBUnion* _resolveSCMBUnion(
 886                            CIMType type,
 887                            Boolean isArray,
 888                            Uint32 size,
 889                            Uint64 start,
 890                            char* base) const;
 891                    
 892                        void _setSCMBUnion(
 893                            const SCMBUnion* pInVal,
 894                            CIMType type,
 895                            Boolean isArray,
 896                            Uint32 size,
 897                            SCMBUnion & u);
 898 thilo.boehm    1.2 
 899                        static void _setUnionValue(
 900                            Uint64 start,
 901                            SCMBMgmt_Header** pmem,
 902                            CIMType type,
 903                            Uint64 startNS,
 904                            Uint32 lenNS,
 905                            Union& u);
 906                    
 907                        static void _setUnionArrayValue(
 908                            Uint64 start,
 909                            SCMBMgmt_Header** pmem,
 910                            CIMType type,
 911                            Uint32& n,
 912                            Uint64 startNS,
 913                            Uint32 lenNS,
 914                            Union& u);
 915                    
 916                        static void _setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem);
 917                    
 918                        SCMO_RC _getKeyBindingDataAtNodeIndex(
 919 thilo.boehm    1.2         Uint32 node,
 920                            const char** pname,
 921                            Uint32 & pnameLen,
 922                            CIMType& type,
 923                            const SCMBUnion** pdata) const;
 924                    
 925                        void _copyKeyBindings(SCMOInstance& targetInst) const;
 926                    
 927                        void _setKeyBindingFromSCMBUnion(
 928                            CIMType type,
 929                            const SCMBUnion& u,
 930                            const char * uBase,
 931                            SCMBKeyBindingValue& keyData);
 932                    
 933                        SCMO_RC _setKeyBindingFromString(
 934                            const char* name,
 935                            CIMType type,
 936                            String cimKeyBinding);
 937                    
 938                        SCMBUserKeyBindingElement* _getUserDefinedKeyBinding(
 939                            const char* name,
 940 thilo.boehm    1.2         Uint32 nameLen,
 941                            CIMType type);
 942                    
 943                        void _setUserDefinedKeyBinding(
 944                            SCMBUserKeyBindingElement& theInsertElement,
 945                            char* elementBase);
 946                        /**
 947                         * Set a SCMO user defined key binding using the class CIM type tolerating
 948                         * CIM key binding types converted to CIM types by fuction
 949                         *  _CIMTypeFromKeyBindingType().
 950                         *
 951                         * @parm classType The type of the key binding in the class definition
 952                         * @parm setType The type of the key binding to be set.
 953                         * @param keyValue A pointer to the key binding to be set.
 954                         * @param kbValue Out parameter, the SCMO keybinding to be set.
 955                         *
 956                         **/
 957                        SCMO_RC _setKeyBindingTypeTolerate(
 958                            CIMType classType,
 959                            CIMType setType,
 960                            const SCMBUnion* keyValue,
 961 thilo.boehm    1.2         SCMBKeyBindingValue& kbValue);
 962                    
 963                        CIMType _CIMTypeFromKeyBindingType(
 964                            const char* key,
 965                            CIMKeyBinding::Type t);
 966                    
 967                        SCMO_RC _getUserKeyBindingNodeIndex(Uint32& node, const char* name) const;
 968                    
 969                        SCMBUserKeyBindingElement* _getUserDefinedKeyBindingAt(Uint32 index) const;
 970                    
 971                        Boolean _setCimKeyBindingStringToSCMOKeyBindingValue(
 972                            const String& kbs,
 973                            CIMType type,
 974                            SCMBKeyBindingValue& scmoKBV
 975                            );
 976                    
 977                    
 978                        union{
 979                            // To access the instance main structure
 980                            SCMBInstance_Main *hdr;
 981                            // To access the memory management header
 982 thilo.boehm    1.2         SCMBMgmt_Header     *mem;
 983                            // Generic access pointer
 984                            char *base;
 985                        }inst;
 986                    
 987                        friend class SCMOClass;
 988                        friend class SCMODump;
 989                        friend class SCMOXmlWriter;
 990                        friend class SCMOStreamer;
 991                    };
 992                    
 993                    inline void SCMOInstance::_getPropertyAt(
 994                        Uint32 pos,
 995                        SCMBValue** value,
 996                        const char ** valueBase,
 997                        SCMBClassProperty ** propDef) const
 998                    {
 999                        SCMBValue* theInstPropNodeArray =
1000                            (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
1001                    
1002                        // create a pointer to property node array of the class.
1003 thilo.boehm    1.2     Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start;
1004                        SCMBClassPropertyNode* theClassPropNodeArray =
1005                            (SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx];
1006                    
1007                        // return the absolute pointer to the property definition
1008 anusha.kandepu 1.4     *propDef= &(theClassPropNodeArray[pos].theProperty);
1009 thilo.boehm    1.2 
1010                        // need check if property set or not, if not set use the default value
1011 anusha.kandepu 1.4     if (theInstPropNodeArray[pos].flags.isSet)
1012 thilo.boehm    1.2     {
1013                            // return the absolute pointer to the property value in the instance
1014 anusha.kandepu 1.4         *value = &(theInstPropNodeArray[pos]);
1015 thilo.boehm    1.2         *valueBase = inst.base;
1016                        }
1017                        else
1018                        {
1019                            // return the absolute pointer to
1020 anusha.kandepu 1.4         *value = &(theClassPropNodeArray[pos].theProperty.defaultValue);
1021 thilo.boehm    1.2         *valueBase = inst.hdr->theClass.ptr->cls.base;
1022                        }
1023                    }
1024                    
1025                    inline void SCMOInstance::getSCMBValuePropertyAt(
1026                        Uint32 pos,
1027                        SCMBValue** value,
1028                        const char ** valueBase,
1029                        SCMBClassProperty ** propDef,
1030                        const char ** propDefBase) const
1031                    {
1032                        _getPropertyAt(pos,value,valueBase,propDef);
1033                    
1034                        *propDefBase = inst.hdr->theClass.ptr->cls.base;
1035                    }
1036                    
1037                    inline SCMO_RC SCMOInstance::getKeyBindingAtUnresolved(
1038                            Uint32 node,
1039                            const char** pname,
1040                            Uint32 & pnameLen,
1041                            CIMType& type,
1042 thilo.boehm    1.2         const SCMBUnion** pdata,
1043                            const char** valueBase) const
1044                    {
1045                        SCMO_RC rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,pdata);
1046                        // Adjust size to string length
1047                        if (pnameLen)
1048                        {
1049                            pnameLen--;
1050                        }
1051                        *valueBase = inst.base;
1052                        return rc;
1053                    }
1054                    
1055                    
1056                    
1057                    #define PEGASUS_ARRAY_T SCMOInstance
1058                    # include <Pegasus/Common/ArrayInter.h>
1059                    #undef PEGASUS_ARRAY_T
1060                    
1061                    PEGASUS_NAMESPACE_END
1062                    
1063 thilo.boehm    1.2 
1064                    #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2