(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                 //%/////////////////////////////////////////////////////////////////////////////
  31                 
  32                 #ifndef _SCMOINSTANCE_H_
  33                 #define _SCMOINSTANCE_H_
  34                 
  35                 
  36                 #include <Pegasus/Common/Config.h>
  37                 #include <Pegasus/Common/Linkage.h>
  38                 #include <Pegasus/Common/SCMO.h>
  39                 #include <Pegasus/Common/SCMOClass.h>
  40                 #include <Pegasus/Common/Union.h>
  41                 
  42                 PEGASUS_NAMESPACE_BEGIN
  43 thilo.boehm 1.2 
  44                 #define PEGASUS_SCMB_INSTANCE_MAGIC 0xD00D1234
  45                 
  46                 class PEGASUS_COMMON_LINKAGE SCMOInstance
  47                 {
  48                 public:
  49                 
  50                     /**
  51                      * A SCMOInstance can only be created by a SCMOClass
  52                      */
  53                     SCMOInstance();
  54                 
  55                     /**
  56                      * Creating a SCMOInstance using a SCMOClass.
  57                      * @param baseClass A SCMOClass.
  58                      */
  59                     SCMOInstance(SCMOClass& baseClass);
  60                 
  61                 
  62                     /**
  63                      * Creating a SCMOInstance using a CIMClass
  64 thilo.boehm 1.2      * using an optional name space name,
  65                      * @param baseClass A SCMOClass.
  66                      * @param nameSpaceName An optional name space name.
  67                      */
  68                     SCMOInstance(CIMClass& theCIMClass, const char* nameSpaceName=0);
  69                 
  70                     /**
  71                      * Copy constructor for the SCMO instance, used to implement refcounting.
  72                      * @param theSCMOClass The instance for which to create a copy
  73                      * @return
  74                      */
  75                     SCMOInstance(const SCMOInstance& theSCMOInstance )
  76                     {
  77                         inst.hdr = theSCMOInstance.inst.hdr;
  78                         Ref();
  79                     }
  80                 
  81                     /**
  82                      * Constructs a SCMOInstance from a memory object of type SCMBInstance_Main.
  83                      * It incremets the referece counter of the memory object.
  84                      * @param hdr A memory object of type SCMBInstance_Main.
  85 thilo.boehm 1.2      **/
  86                     SCMOInstance(SCMBInstance_Main* hdr)
  87                     {
  88                         inst.hdr = hdr;
  89                         Ref();
  90                     }
  91                 
  92                 
  93                     /**
  94                      * Assignment operator for the SCMO instance,
  95                      * @param theSCMOInstance The right hand value
  96                      **/
  97                     SCMOInstance& operator=(const SCMOInstance& theSCMOInstance)
  98                     {
  99                         if (inst.hdr != theSCMOInstance.inst.hdr)
 100                         {
 101                             Unref();
 102                             inst.hdr = theSCMOInstance.inst.hdr;
 103                             Ref();
 104                         }
 105                         return *this;
 106 thilo.boehm 1.2     }
 107                 
 108                     /**
 109                      * Destructor is decrementing the refcount. If refcount is zero, the
 110                      * singele chunk memory object is deallocated.
 111                      */
 112                     ~SCMOInstance()
 113                     {
 114                         Unref();
 115                     }
 116                 
 117                     /**
 118                      * Builds a SCMOInstance based on this SCMOClass.
 119                      * The method arguments determine whether qualifiers are included,
 120                      * the class origin attributes are included,
 121                      * and which properties are included in the new instance.
 122                      * @param baseClass The SCMOClass of this instance.
 123                      * @param includeQualifiers A Boolean indicating whether qualifiers in
 124                      * the class definition (and its properties) are to be added to the
 125                      * instance.  The TOINSTANCE flavor is ignored.
 126                      * @param includeClassOrigin A Boolean indicating whether ClassOrigin
 127 thilo.boehm 1.2      * attributes are to be added to the instance.
 128                      * @param propertyList Is an NULL terminated array of char* to property
 129                      * names defining the properties that are included in the created instance.
 130                      * If the propertyList is NULL, all properties are included to the instance.
 131                      * If the propertyList is empty, no properties are added.
 132                      *
 133                      * Note that this function does NOT generate an error if a property name
 134                      * is supplied that is NOT in the class;
 135                      * it simply does not add that property to the instance.
 136                      *
 137                      */
 138                     SCMOInstance(
 139                         SCMOClass& baseClass,
 140                         Boolean includeQualifiers,
 141                         Boolean includeClassOrigin,
 142                         const char** propertyList);
 143                 
 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 thilo.boehm 1.2      * @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                     /**
 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 thilo.boehm 1.2      * 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                      * 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 thilo.boehm 1.2      * @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                      * 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 thilo.boehm 1.2      */
 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                      * @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 thilo.boehm 1.2 
 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                     /**
 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 thilo.boehm 1.2      *              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                      *                              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 thilo.boehm 1.2      *             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                         Uint32& size ) const;
 291                 
 292                     void getSCMBValuePropertyAt(
 293                         Uint32 pos,
 294                         SCMBValue** value,
 295 thilo.boehm 1.2         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                      *
 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 thilo.boehm 1.2      *                       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                         const char* name,
 333                         CIMType& type,
 334                         const SCMBUnion** pvalue,
 335                         Boolean& isArray,
 336                         Uint32& size ) const;
 337 thilo.boehm 1.2 
 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                      *
 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 thilo.boehm 1.2      *              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                      *             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 thilo.boehm 1.2         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                        //This function is not implemented and now Property filtering is done by
 393                        //the CIMOM infrastructure 
 394 thilo.boehm    1.2     void setPropertyFilter(const char **propertyList);
 395 anusha.kandepu 1.4     
 396 thilo.boehm    1.2     /**
 397                         * Gets the hash index for the named property. Filtering is ignored.
 398                         * @param theName The property name
 399                         * @param pos Returns the hash index.
 400                         * @return     SCMO_OK
 401                         *             SCMO_INVALID_PARAMETER: name was a NULL pointer.
 402                         *             SCMO_NOT_FOUND : Given property name not found.
 403                         */
 404                        SCMO_RC getPropertyNodeIndex(const char* name, Uint32& pos) const;
 405                    
 406                        /**
 407                         * Set/replace a property in the instance at node index.
 408                         * Note: If node is filtered, the property is not set but the return value
 409                         * is still SCMO_OK.
 410                         * @param index The node index.
 411                         * @param type The CIMType of the property
 412                         * @param pInVal A pointer to the value to be set at the named property.
 413                         *               The value has to be in a SCMBUnion.
 414                         *               The value is copied into the instance
 415                         *               If the value == NULL, a null value is assumed.
 416                         *               If the value is an array, the value array has to be
 417 thilo.boehm    1.2      *               stored in continuous memory.
 418                         *               e.g. (SCMBUnion*)value[0 to size-1]
 419                         *
 420                         *              To store an array of size 0, The value pointer has to
 421                         *               not NULL ( value != NULL ) but the size has to be 0
 422                         *                (size == 0).
 423                         *
 424                         *               If the value is type of CIMTYPE_STRING,
 425                         *               the string is referenced by the structure
 426                         *               SCMBUnion.extString:
 427                         *                        pchar contains the absolut pointer to the string
 428                         *                       length contains the size of the string
 429                         *                                without trailing '\0'.
 430                         * @param isArray Indicate that the value is an array. Default false.
 431                         * @param size The size of the array. If not an array this
 432                         *         this parameter is ignorer. Default 0.
 433                         * @return     SCMO_OK
 434                         *             SCMO_INDEX_OUT_OF_BOUND : Given index not found
 435                         *             SCMO_WRONG_TYPE : The property at given node index
 436                         *                               has the wrong type.
 437                         *             SCMO_NOT_AN_ARRAY : The property at given node index
 438 thilo.boehm    1.2      *                                 is not an array.
 439                         *             SCMO_IS_AN_ARRAY  : The property at given node index
 440                         *                                 is an array.
 441                         */
 442                        SCMO_RC setPropertyWithNodeIndex(
 443                            Uint32 node,
 444                            CIMType type,
 445                            const SCMBUnion* pInVal,
 446                            Boolean isArray=false,
 447                            Uint32 size = 0);
 448                    
 449                        /**
 450                         * Set/replace the named key binding using binary data
 451                         * @param name The key binding name.
 452                         * @param type The type as CIMType.
 453                         * @param keyvalue A pointer to the binary key value.
 454                         *         The value is copied into the instance
 455                         *         If the value == NULL, a null value is assumed.
 456                         * @param keyvalue A pointer to the value to be set at the key binding,
 457                         *               The keyvalue has to be in a SCMBUnion.
 458                         *               The keyvalue is copied into the instance.
 459 thilo.boehm    1.2      *               If the keyvalue == NULL, a null value is assumed.
 460                         *
 461                         *               If the keyvalue is type of CIMTYPE_STRING,
 462                         *               the string is referenced by the structure
 463                         *               SCMBUnion.extString:
 464                         *                        pchar contains the absolut pointer to the string
 465                         *                       length contains the size of the string
 466                         *                                without trailing '\0'.
 467                         * @return     SCMO_OK
 468                         *             SCMO_INVALID_PARAMETER : Given name or pvalue
 469                         *                                      is a NULL pointer.
 470                         *             SCMO_TYPE_MISSMATCH : Given type does not
 471                         *                                   match to key binding type
 472                         *             SCMO_NOT_FOUND : Given property name not found.
 473                         */
 474                        SCMO_RC setKeyBinding(
 475                            const char* name,
 476                            CIMType type,
 477                            const SCMBUnion* keyvalue);
 478                    
 479                        /**
 480 thilo.boehm    1.2      * Set/replace the key binding at node
 481                         * @param node The node index of the key.
 482                         * @param type The type as CIMType.
 483                         * @param keyvalue A pointer to the value to be set at the key binding,
 484                         *               The keyvalue has to be in a SCMBUnion.
 485                         *               The keyvalue is copied into the instance.
 486                         *               If the keyvalue == NULL, a null value is assumed.
 487                         *
 488                         *               If the keyvalue is type of CIMTYPE_STRING,
 489                         *               the string is referenced by the structure
 490                         *               SCMBUnion.extString:
 491                         *                        pchar contains the absolut pointer to the string
 492                         *                       length contains the size of the string
 493                         *                                without trailing '\0'.
 494                         * @return     SCMO_OK
 495                         *             SCMO_INVALID_PARAMETER : Given pvalue is a NULL pointer.
 496                         *             SCMO_TYPE_MISSMATCH : Given type does not
 497                         *                                   match to key binding type
 498                         *             SCMO_INDEX_OUT_OF_BOUND : Given index is our of range.
 499                         */
 500                        SCMO_RC setKeyBindingAt(
 501 thilo.boehm    1.2         Uint32 node,
 502                            CIMType type,
 503                            const SCMBUnion* keyvalue);
 504                    
 505                        /**
 506                         * Clears all key bindings in an instance.
 507                         * Warning: External references are freed but only the internal
 508                         * control structures are resetted. No memory is freed and at setting
 509                         * new key bindings the instance will grow in memory usage.
 510                         **/
 511                        void clearKeyBindings();
 512                    
 513                        /**
 514                         * Gets the key binding count.
 515                         * @return the number of key bindings set.
 516                         */
 517                        Uint32 getKeyBindingCount() const;
 518                    
 519                        /**
 520                         * Get the indexed key binding.
 521                         * @parm idx The key bining index
 522 thilo.boehm    1.2      * @parm pname Returns the name.
 523                         *             Has to be copied by caller.
 524                         *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 525                         * @param type Returns the type as CIMType.
 526                         *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 527                         * @param keyvalue A pointer to the binary key value.
 528                         *             Has to be copied by caller.
 529                         *             It is only valid if rc == SCMO_OK.
 530                         * @return     SCMO_OK
 531                         *             SCMO_NULL_VALUE : The key binding is not set.
 532                         *             SCMO_INDEX_OUT_OF_BOUND : Given index not found
 533                         *
 534                         */
 535                        SCMO_RC getKeyBindingAt(
 536                            Uint32 idx,
 537                            const char** pname,
 538                            CIMType& type,
 539                            const SCMBUnion** keyvalue) const;
 540                    
 541                        SCMO_RC getKeyBindingAtUnresolved(
 542                            Uint32 node,
 543 thilo.boehm    1.2         const char** pname,
 544                            Uint32 & pnameLen,
 545                            CIMType& type,
 546                            const SCMBUnion** pdata,
 547                            const char** valueBase) const;
 548                    
 549                        /**
 550                         * Get the named key binding.
 551                         * @parm name The name of the key binding.
 552                         * @param type Returns the type as CIMType.
 553                         *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
 554                         * @param keyvalue Returns a pointer to the value of keybinding.
 555                         *               The value is stored in a SCMBUnion
 556                         *                and has to be copied by the caller !
 557                         *               It returns NULL if rc != SCMO_OK.
 558                         *
 559                         *               If the value is type of CIMTYPE_STRING,
 560                         *               the string is referenced by the structure
 561                         *               SCMBUnion.extString:
 562                         *                       pchar contains the absolut pointer to the string
 563                         *                       length contains the size of the string
 564 thilo.boehm    1.2      *                              without trailing '\0'.
 565                         *               Only for strings the caller has to free pvalue !
 566                         * @param keyvalue A pointer to the binary key value.
 567                         *             Has to be copied by caller.
 568                         *             It is only valid if rc == SCMO_OK.
 569                         * @return     SCMO_OK
 570                         *             SCMO_NULL_VALUE : The key binding is not set.
 571                         *             SCMO_NOT_FOUND : Given property name not found.
 572                         */
 573                        SCMO_RC getKeyBinding(
 574                            const char* name,
 575                            CIMType& ptype,
 576                            const SCMBUnion** keyvalue) const;
 577                    
 578                        /**
 579                         * Determines whether the c++ object has been initialized.
 580                         * @return True if the c++ object has not been initialized, false otherwise.
 581                         */
 582                        Boolean isUninitialized( ) const {return (0 == inst.base); };
 583                    
 584                        /**
 585 thilo.boehm    1.2      * Determines if the SCMOInstance does not contain any property information.
 586                         * Maybe only the class name and/or name space are available.
 587                         * @return True if the SCMOInstacne is empty, false otherwise.
 588                         */
 589                        Boolean isEmpty( ) const {return (inst.hdr->theClass.ptr->isEmpty()); };
 590                    
 591                        /**
 592                         * Determines whether the instance is used as a class container.
 593                         * @return True if the instance is used as a class container only.
 594                         */
 595                        Boolean getIsClassOnly( ) const
 596                        {
 597                            return inst.hdr->flags.isClassOnly;
 598                        }
 599                    
 600                        /**
 601                         * To mark if this instance is a class only container.
 602                         */
 603                        void setIsClassOnly( Boolean b )
 604                        {
 605                            inst.hdr->flags.isClassOnly = b;
 606 thilo.boehm    1.2     }
 607                    
 608                        /**
 609                         * Determies if two objects are referencing to the same instance
 610                         * @return True if the objects are referencing to the some instance.
 611                         */
 612                        Boolean isSame(SCMOInstance& theInstance) const;
 613                    
 614                        /**
 615                         * Sets the provided host name at the instance.
 616                         * @param hostName The host name as UTF8.
 617                         */
 618                        void setHostName(const char* hostName);
 619                    
 620                        /**
 621                         * Get the host name of the instance. The caller has to make a copy !
 622                         * @return The host name as UTF8.
 623                         */
 624                        const char* getHostName() const;
 625                    
 626                        /**
 627 thilo.boehm    1.2      * Get the host name of the instance.
 628                         * @param Return strlen of result string.
 629                         * @return The class name as UTF8.
 630                         */
 631                        const char* getHostName_l(Uint32 & length) const;
 632                    
 633                        /**
 634                         * Sets the provided class name at the instance. By caling this function
 635                         * the instance is in an inconsitacne state and is maked as isCompromised.
 636                         * @param className The class name as UTF8.
 637                         */
 638                        void setClassName(const char* className);
 639                    
 640                        /**
 641                         * Sets the provided class name at the instance. By caling this function
 642                         * the instance is in an inconsitacne state and is maked as isCompromised.
 643                         * @param className The class name as UTF8.
 644                         * @param len The strlen of the name space.
 645                         */
 646                        void setClassName_l(const char* className, Uint32 len);
 647                    
 648 thilo.boehm    1.2     /**
 649                         * Get the class name of the instance. The caller has to make a copy !
 650                         * @return The class name as UTF8.
 651                         */
 652                        const char* getClassName() const;
 653                    
 654                        /**
 655                         * Get the class name of the instance. The caller has to make a copy !
 656                         * @param lenght Return strlen of result string.
 657                         * @return The class name as UTF8.
 658                         */
 659                        const char* getClassName_l(Uint32 & length) const;
 660                    
 661                        /**
 662                         * Sets the provided name space name at the instance.
 663                         * By caling this function the instance is in an inconsitacne state and
 664                         * is maked as isCompromised.
 665                         * @param nameSpaceName The name space name as UTF8.
 666                         */
 667                        void setNameSpace(const char* nameSpace);
 668                    
 669 thilo.boehm    1.2     /**
 670                         * Sets the provided name space name unchecked at the instance.
 671                         * By caling this function the instance is in an inconsitacne state and
 672                         * is maked as isCompromised.
 673                         * @param nameSpaceName The name space name as UTF8.
 674                         * @param len The strlen of the name space.
 675                         */
 676                        void setNameSpace_l(const char* nameSpace, Uint32 len);
 677                    
 678                        /**
 679                         * Get the name space of the instance. The caller has to make a copy !
 680                         * @return The name space as UTF8.
 681                         */
 682                        const char* getNameSpace() const;
 683                    
 684                        /**
 685                         * Get the class name of the instance. The caller has to make a copy !
 686                         * @param Return strlen of result string.
 687                         * @return The class name as UTF8.
 688                         */
 689                        const char* getNameSpace_l(Uint32 & length) const;
 690 thilo.boehm    1.2 
 691                        /**
 692 marek          1.4.2.1      * If hostname or namespace of the SCMOInstance are NULL or empty string,
 693                             * replace them with the given input.
 694                             * @param hn The host name to apply to the SCMOInstance.
 695                             * @param hnLen The length of the hostname in byte without closing zero.
 696                             * @param ns The namespace name to apply to the SCMOInstance.
 697                             * @param nsLen The length of the hostname in byte without closing zero.
 698                             */
 699                            void completeHostNameAndNamespace(
 700                                const char* hn,
 701                                Uint32 hnLen,
 702                                const char* ns,
 703                                Uint32 nsLen);
 704                        
 705                            /**
 706 thilo.boehm    1.2          * Is the name space or class name of the instance the origianl values
 707                             * set by the used SCMOClass.
 708                             * The class name and/or name space may differ with the associated class.
 709                             * @return true if name space or class name was set manually by
 710                             *          setNameSpace() or setClassName()
 711                             */
 712                            Boolean isCompromised() const
 713                            {
 714                                return inst.hdr->flags.isCompromised;
 715                            };
 716                        
 717                        
 718                            /**
 719                             * Mark the instance as a non validated instance.
 720                             */
 721                            void markAsCompromised()
 722                            {
 723                                inst.hdr->flags.isCompromised = true;
 724                            };
 725                        
 726                            /**
 727 thilo.boehm    1.2          *  To indicate the export processing ( eg. XMLWriter )
 728                             *  to include qualifiers for this instance.
 729                             */
 730                            void includeQualifiers()
 731                            {
 732                                inst.hdr->flags.includeQualifiers = true;
 733                            };
 734                        
 735                            /**
 736                             *  To indicate the export processing ( eg. XMLWriter )
 737                             *  to NOT to include (exclude) qualifiers for this instance.
 738                             */
 739                            void excludeQualifiers()
 740                            {
 741                                inst.hdr->flags.includeQualifiers = false;
 742                            }
 743                        
 744                            /**
 745                             *  To indicate the export processing ( eg. XMLWriter )
 746                             *  to include class origins for this instance.
 747                             */
 748 thilo.boehm    1.2         void includeClassOrigins()
 749                            {
 750                                inst.hdr->flags.includeClassOrigin = true;
 751                            };
 752                        
 753                            /**
 754                             *  To indicate the export processing ( eg. XMLWriter )
 755                             *  to NOT to include (exclude) class origins for this instance.
 756                             */
 757                            void excludeClassOrigins()
 758                            {
 759                                inst.hdr->flags.includeClassOrigin = false;
 760                            }
 761                        
 762                        
 763                            /**
 764                             * Returns the number of external references hosted by the instance.
 765                             **/
 766                            Uint32 numberExtRef() const
 767                            {
 768                                return inst.mem->numberExtRef;
 769 thilo.boehm    1.2         }
 770                        
 771                            /**
 772                             * Gets the pointer of an external reference of the instance.
 773                             * Warning: The pointer is purely returned. No management is done.
 774                             * @parm idx The index of the external reference.
 775                             **/
 776                            SCMOInstance* getExtRef(Uint32 idx) const;
 777                        
 778                            /**
 779                             * Sets a pointer of an external reference of the instance.
 780                             * Warning: The pointer is purely returned. No management is done.
 781                             * @parm idx The index of the external reference.
 782                             * @parm ptr The pointer to an SCMOInstance
 783                             **/
 784                            void putExtRef(Uint32 idx,SCMOInstance* ptr);
 785                        
 786                        private:
 787                        
 788                            void Ref()
 789                            {
 790 thilo.boehm    1.2             inst.hdr->refCount++;
 791                            };
 792                        
 793                            void Unref()
 794                            {
 795                                if (inst.hdr->refCount.decAndTestIfZero())
 796                                {
 797                                    // All external references has to be destroyed.
 798                                    _destroyExternalReferences();
 799                                    // The class has also be dereferenced.
 800                                    delete inst.hdr->theClass.ptr;
 801                                    free(inst.base);
 802                                    inst.base=NULL;
 803                                }
 804                        
 805                            };
 806                        
 807                        
 808                            void _copyOnWrite()
 809                            {
 810                                if ( 1 < inst.hdr->refCount.get() )
 811 thilo.boehm    1.2             {
 812                                    SCMBInstance_Main * oldRef = inst.hdr;
 813 thilo.boehm    1.3                 SCMBMgmt_Header* oldMgmt = inst.mem;
 814                        
 815 thilo.boehm    1.2                 _clone();
 816                                    if (oldRef->refCount.decAndTestIfZero())
 817                                    {
 818                                        // All external references has to be destroyed.
 819 thilo.boehm    1.3                     _destroyExternalReferencesInternal(oldMgmt);
 820 thilo.boehm    1.2                     // The class has also be dereferenced.
 821                                        delete oldRef->theClass.ptr;
 822                                        free((void*)oldRef);
 823                                        oldRef=0;
 824                                    }
 825                                }
 826                            };
 827                        
 828                            void _clone();
 829                        
 830                            void _destroyExternalReferences();
 831                        
 832                            void _destroyExternalKeyBindings();
 833                        
 834                            void _copyExternalReferences();
 835                        
 836                            void _setExtRefIndex(Uint64 idx);
 837                        
 838                            void _initSCMOInstance(SCMOClass* pClass);
 839                        
 840                            void _setCIMInstance(const CIMInstance& cimInstance);
 841 thilo.boehm    1.2     
 842                            void _getPropertyAt(
 843                                Uint32 pos,
 844                                SCMBValue** value,
 845                                const char ** valueBase,
 846                                SCMBClassProperty ** propDef) const;
 847                        
 848                            SCMO_RC _getPropertyAtNodeIndex(
 849                                Uint32 pos,
 850                                const char** pname,
 851                                CIMType& type,
 852                                const SCMBUnion** pvalue,
 853                                Boolean& isArray,
 854                                Uint32& size ) const;
 855                        
 856                            void _setPropertyAtNodeIndex(
 857                                Uint32 pos,
 858                                CIMType type,
 859                                const SCMBUnion* pInVal,
 860                                Boolean isArray,
 861                                Uint32 size);
 862 thilo.boehm    1.2     
 863                            void _setCIMValueAtNodeIndex(
 864                                Uint32 node,
 865                                CIMValueRep* valRep,
 866                                CIMType realType);
 867                        
 868                            static void _getCIMValueFromSCMBUnion(
 869                                CIMValue& cimV,
 870                                const CIMType type,
 871                                const Boolean isNull,
 872                                const Boolean isArray,
 873                                const Uint32 arraySize,
 874                                const SCMBUnion& scmbUn,
 875                                const char * base);
 876                        
 877                            static void _getCIMValueFromSCMBValue(
 878                                CIMValue& cimV,
 879                                const SCMBValue& scmbV,
 880                                const char * base);
 881                        
 882                            static SCMOClass _getSCMOClass(
 883 thilo.boehm    1.2             const CIMObjectPath& theCIMObj,
 884                                const char* altNS,
 885                                Uint32 altNSlength);
 886                        
 887                            CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const;
 888                        
 889                            void _setCIMObjectPath(const CIMObjectPath& cimObj);
 890                        
 891                            SCMBUnion* _resolveSCMBUnion(
 892                                CIMType type,
 893                                Boolean isArray,
 894                                Uint32 size,
 895                                Uint64 start,
 896                                char* base) const;
 897                        
 898                            void _setSCMBUnion(
 899                                const SCMBUnion* pInVal,
 900                                CIMType type,
 901                                Boolean isArray,
 902                                Uint32 size,
 903                                SCMBUnion & u);
 904 thilo.boehm    1.2     
 905                            static void _setUnionValue(
 906                                Uint64 start,
 907                                SCMBMgmt_Header** pmem,
 908                                CIMType type,
 909                                Uint64 startNS,
 910                                Uint32 lenNS,
 911                                Union& u);
 912                        
 913                            static void _setUnionArrayValue(
 914                                Uint64 start,
 915                                SCMBMgmt_Header** pmem,
 916                                CIMType type,
 917                                Uint32& n,
 918                                Uint64 startNS,
 919                                Uint32 lenNS,
 920                                Union& u);
 921                        
 922                            static void _setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem);
 923                        
 924                            SCMO_RC _getKeyBindingDataAtNodeIndex(
 925 thilo.boehm    1.2             Uint32 node,
 926                                const char** pname,
 927                                Uint32 & pnameLen,
 928                                CIMType& type,
 929                                const SCMBUnion** pdata) const;
 930                        
 931                            void _copyKeyBindings(SCMOInstance& targetInst) const;
 932                        
 933                            Uint32 _initPropFilterWithKeys();
 934                        
 935                            void _setPropertyInPropertyFilter(Uint32 i);
 936                        
 937                            Boolean _isPropertyInFilter(Uint32 i) const;
 938                        
 939                            void _clearPropertyFilter();
 940                        
 941                            void _setKeyBindingFromSCMBUnion(
 942                                CIMType type,
 943                                const SCMBUnion& u,
 944                                const char * uBase,
 945                                SCMBKeyBindingValue& keyData);
 946 thilo.boehm    1.2     
 947                            SCMO_RC _setKeyBindingFromString(
 948                                const char* name,
 949                                CIMType type,
 950                                String cimKeyBinding);
 951                        
 952                            SCMBUserKeyBindingElement* _getUserDefinedKeyBinding(
 953                                const char* name,
 954                                Uint32 nameLen,
 955                                CIMType type);
 956                        
 957                            void _setUserDefinedKeyBinding(
 958                                SCMBUserKeyBindingElement& theInsertElement,
 959                                char* elementBase);
 960                            /**
 961                             * Set a SCMO user defined key binding using the class CIM type tolerating
 962                             * CIM key binding types converted to CIM types by fuction
 963                             *  _CIMTypeFromKeyBindingType().
 964                             *
 965                             * @parm classType The type of the key binding in the class definition
 966                             * @parm setType The type of the key binding to be set.
 967 thilo.boehm    1.2          * @param keyValue A pointer to the key binding to be set.
 968                             * @param kbValue Out parameter, the SCMO keybinding to be set.
 969                             *
 970                             **/
 971                            SCMO_RC _setKeyBindingTypeTolerate(
 972                                CIMType classType,
 973                                CIMType setType,
 974                                const SCMBUnion* keyValue,
 975                                SCMBKeyBindingValue& kbValue);
 976                        
 977                            CIMType _CIMTypeFromKeyBindingType(
 978                                const char* key,
 979                                CIMKeyBinding::Type t);
 980                        
 981                            SCMO_RC _getUserKeyBindingNodeIndex(Uint32& node, const char* name) const;
 982                        
 983                            SCMBUserKeyBindingElement* _getUserDefinedKeyBindingAt(Uint32 index) const;
 984                        
 985                            Boolean _setCimKeyBindingStringToSCMOKeyBindingValue(
 986                                const String& kbs,
 987                                CIMType type,
 988 thilo.boehm    1.2             SCMBKeyBindingValue& scmoKBV
 989                                );
 990                        
 991                        
 992                            union{
 993                                // To access the instance main structure
 994                                SCMBInstance_Main *hdr;
 995                                // To access the memory management header
 996                                SCMBMgmt_Header     *mem;
 997                                // Generic access pointer
 998                                char *base;
 999                            }inst;
1000                        
1001                            friend class SCMOClass;
1002                            friend class SCMODump;
1003                            friend class SCMOXmlWriter;
1004                            friend class SCMOStreamer;
1005                        };
1006                        
1007                        inline void SCMOInstance::_getPropertyAt(
1008                            Uint32 pos,
1009 thilo.boehm    1.2         SCMBValue** value,
1010                            const char ** valueBase,
1011                            SCMBClassProperty ** propDef) const
1012                        {
1013                            SCMBValue* theInstPropNodeArray =
1014                                (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
1015                        
1016                            // create a pointer to property node array of the class.
1017                            Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start;
1018                            SCMBClassPropertyNode* theClassPropNodeArray =
1019                                (SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx];
1020                        
1021                            // return the absolute pointer to the property definition
1022 anusha.kandepu 1.4         *propDef= &(theClassPropNodeArray[pos].theProperty);
1023 thilo.boehm    1.2     
1024                            // need check if property set or not, if not set use the default value
1025 anusha.kandepu 1.4         if (theInstPropNodeArray[pos].flags.isSet)
1026 thilo.boehm    1.2         {
1027                                // return the absolute pointer to the property value in the instance
1028 anusha.kandepu 1.4             *value = &(theInstPropNodeArray[pos]);
1029 thilo.boehm    1.2             *valueBase = inst.base;
1030                            }
1031                            else
1032                            {
1033                                // return the absolute pointer to
1034 anusha.kandepu 1.4             *value = &(theClassPropNodeArray[pos].theProperty.defaultValue);
1035 thilo.boehm    1.2             *valueBase = inst.hdr->theClass.ptr->cls.base;
1036                            }
1037                        }
1038                        
1039                        inline void SCMOInstance::getSCMBValuePropertyAt(
1040                            Uint32 pos,
1041                            SCMBValue** value,
1042                            const char ** valueBase,
1043                            SCMBClassProperty ** propDef,
1044                            const char ** propDefBase) const
1045                        {
1046                            _getPropertyAt(pos,value,valueBase,propDef);
1047                        
1048                            *propDefBase = inst.hdr->theClass.ptr->cls.base;
1049                        }
1050                        
1051                        inline SCMO_RC SCMOInstance::getKeyBindingAtUnresolved(
1052                                Uint32 node,
1053                                const char** pname,
1054                                Uint32 & pnameLen,
1055                                CIMType& type,
1056 thilo.boehm    1.2             const SCMBUnion** pdata,
1057                                const char** valueBase) const
1058                        {
1059                            SCMO_RC rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,pdata);
1060                            // Adjust size to string length
1061                            if (pnameLen)
1062                            {
1063                                pnameLen--;
1064                            }
1065                            *valueBase = inst.base;
1066                            return rc;
1067                        }
1068                        
1069                        
1070                        
1071                        #define PEGASUS_ARRAY_T SCMOInstance
1072                        # include <Pegasus/Common/ArrayInter.h>
1073                        #undef PEGASUS_ARRAY_T
1074                        
1075                        PEGASUS_NAMESPACE_END
1076                        
1077 thilo.boehm    1.2     
1078                        #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2