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

Diff for /pegasus/src/Pegasus/Common/SCMOInstance.h between version 1.1.2.30 and 1.2

version 1.1.2.30, 2009/10/27 18:38:08 version 1.2, 2009/12/15 11:39:34
Line 43 
Line 43 
  
 #define PEGASUS_SCMB_INSTANCE_MAGIC 0xD00D1234 #define PEGASUS_SCMB_INSTANCE_MAGIC 0xD00D1234
  
 class SCMOClass;  
   
 class PEGASUS_COMMON_LINKAGE SCMOInstance class PEGASUS_COMMON_LINKAGE SCMOInstance
 { {
 public: public:
Line 58 
Line 56 
      * Creating a SCMOInstance using a SCMOClass.      * Creating a SCMOInstance using a SCMOClass.
      * @param baseClass A SCMOClass.      * @param baseClass A SCMOClass.
      */      */
     SCMOInstance(SCMOClass baseClass);      SCMOInstance(SCMOClass& baseClass);
   
   
       /**
        * Creating a SCMOInstance using a CIMClass
        * using an optional name space name,
        * @param baseClass A SCMOClass.
        * @param nameSpaceName An optional name space name.
        */
       SCMOInstance(CIMClass& theCIMClass, const char* nameSpaceName=0);
  
     /**     /**
      * Copy constructor for the SCMO instance, used to implement refcounting.      * Copy constructor for the SCMO instance, used to implement refcounting.
Line 72 
Line 79 
     }     }
  
     /**     /**
        * Constructs a SCMOInstance from a memory object of type SCMBInstance_Main.
        * It incremets the referece counter of the memory object.
        * @param hdr A memory object of type SCMBInstance_Main.
        **/
       SCMOInstance(SCMBInstance_Main* hdr)
       {
           inst.hdr = hdr;
           Ref();
       }
   
   
       /**
        * Assignment operator for the SCMO instance,
        * @param theSCMOInstance The right hand value
        **/
       SCMOInstance& operator=(const SCMOInstance& theSCMOInstance)
       {
           if (inst.hdr != theSCMOInstance.inst.hdr)
           {
               Unref();
               inst.hdr = theSCMOInstance.inst.hdr;
               Ref();
           }
           return *this;
       }
   
       /**
      * Destructor is decrementing the refcount. If refcount is zero, the      * Destructor is decrementing the refcount. If refcount is zero, the
      * singele chunk memory object is deallocated.      * singele chunk memory object is deallocated.
      */      */
Line 102 
Line 136 
      *      *
      */      */
     SCMOInstance(     SCMOInstance(
         SCMOClass baseClass,          SCMOClass& baseClass,
         Boolean includeQualifiers,         Boolean includeQualifiers,
         Boolean includeClassOrigin,         Boolean includeClassOrigin,
         const char** propertyList);         const char** propertyList);
Line 112 
Line 146 
      * CIMInstance data into the new SCMOInstance.      * CIMInstance data into the new SCMOInstance.
      * @param baseClass The SCMOClass of this instance.      * @param baseClass The SCMOClass of this instance.
      * @param cimInstance A CIMInstace of the same class.      * @param cimInstance A CIMInstace of the same class.
      * @exception Exception if class name and name space does not match.       * @exception Exception if class name does not match.
      * @exception  
      *     Exception if CIMInstance has more key bindings then the SCMOClass.  
      * @exception  
      *     Exception if a key binding is not found as a key property  
      *     of the SCMOClass.  
      * @exception Exception if a key binding does not match  
      *     the class definition.  
      * @exception Exception if a property is not part of class definition.      * @exception Exception if a property is not part of class definition.
      * @exception Exception if a property does not match the class definition.      * @exception Exception if a property does not match the class definition.
      */      */
     SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance);      SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance);
  
     /**     /**
      * Builds a SCMOInstance from the given SCMOClass and copies all      * Builds a SCMOInstance from the given SCMOClass and copies all
      * CIMObjectPath data into the new SCMOInstance.      * CIMObjectPath data into the new SCMOInstance.
      * @param baseClass The SCMOClass of this instance.      * @param baseClass The SCMOClass of this instance.
      * @param cimInstance A CIMObjectpath of the same class.      * @param cimInstance A CIMObjectpath of the same class.
      * @exception Exception if class name and name space does not match.       * @exception Exception if class name does not match.
      * @exception  
      *     Exception if CIMInstance has more key bindings then the SCMOClass.  
      * @exception  
      *     Exception if a key binding is not found as a key property  
      *     of the SCMOClass.  
      * @exception Exception if a key binding does not match  
      *     the class definition.  
      */      */
     SCMOInstance(SCMOClass baseClass, const CIMObjectPath& cimObj);      SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj);
   
       /**
        * Builds a SCMOInstance from the given CIMInstance copying all data.
        * The SCMOClass is retrieved from SCMOClassCache using
        * the class and name space of the CIMInstance.
        * If the SCMOClass was not found, an empty SCMOInstance will be returned
        * and the resulting SCMOInstance is compromized.
        * If the CIMInstance does not contain a name space, the optional fall back
        * name space is used.
        * @param cimInstance A CIMInstace with class name and name space.
        * @param altNameSpace An alternative name space name.
        * @exception Exception if a property is not part of class definition.
        * @exception Exception if a property does not match the class definition.
        */
       SCMOInstance(
           const CIMInstance& cimInstance,
           const char* altNameSpace=0,
           Uint32 altNSLen=0);
   
       /**
        * Builds a SCMOInstance from the given CIMObjectPath copying all data.
        * The SCMOClass is retrieved from SCMOClassCache using
        * the class and name space of the CIMObjectPath.
        * If the SCMOClass was not found, an empty SCMOInstance will be returned
        * and the resulting SCMOInstance is compromized.
        * If the CIMObjectPath does not contain a name space,
        * the optional fall back name space is used.
        * @param cimObj A CIMObjectpath with name space and name
        * @param altNameSpace An alternative name space name.
        * @
        */
       SCMOInstance(
           const CIMObjectPath& cimObj,
           const char* altNameSpace=0,
           Uint32 altNSLen=0);
   
       /**
        * Builds a SCMOInstance from the given CIMObject copying all data.
        * The SCMOClass is retrieved from SCMOClassCache using
        * the class and name space of the CIMObject.
        * If the SCMOClass was not found, an empty SCMOInstance will be returned
        * and the resulting SCMOInstance is compromized.
        * If the CIMInstance does not contain a name space, the optional fall back
        * name space is used.
        * @param cimInstance A CIMInstace with class name and name space.
        * @param altNameSpace An alternative name space name.
        * @exception Exception if a property is not part of class definition.
        * @exception Exception if a property does not match the class definition.
        */
       SCMOInstance(
           const CIMObject& cimObject,
           const char* altNameSpace=0,
           Uint32 altNSLen=0);
  
     /**     /**
      * Converts the SCMOInstance into a CIMInstance.      * Converts the SCMOInstance into a CIMInstance.
Line 180 
Line 253 
      *              Has to be copied by caller.      *              Has to be copied by caller.
      *              It is set to NULL if rc != SCMO_OK.      *              It is set to NULL if rc != SCMO_OK.
      * @param pvalue Returns a pointer to the value of property.      * @param pvalue Returns a pointer to the value of property.
      *               The value is strored in a SCMBUnion       *               The value is stored in a SCMBUnion
      *                and has to be copied by the caller !      *                and has to be copied by the caller !
      *               It returns NULL if rc != SCMO_OK.      *               It returns NULL if rc != SCMO_OK.
      *      *
Line 216 
Line 289 
         Boolean& isArray,         Boolean& isArray,
         Uint32& size ) const;         Uint32& size ) const;
  
       void getSCMBValuePropertyAt(
           Uint32 pos,
           SCMBValue** value,
           const char ** valueBase,
           SCMBClassProperty ** propDef,
           const char ** classBase) const;
   
     /**     /**
      * Gets the type and value of the named property.      * Gets the type and value of the named property.
      * The value has to be copied by the caller !      * The value has to be copied by the caller !
      * @param name The property name      * @param name The property name
      * @param pvalue Returns a pointer to the value of property.      * @param pvalue Returns a pointer to the value of property.
      *               The value is strored in a SCMBUnion       *               The value is stored in a SCMBUnion
      *                and has to be copied by the caller !      *                and has to be copied by the caller !
      *               It returns NULL if rc != SCMO_OK.      *               It returns NULL if rc != SCMO_OK.
      *      *
Line 432 
Line 512 
         const SCMBUnion* keyvalue);         const SCMBUnion* keyvalue);
  
     /**     /**
        * Clears all key bindings in an instance.
        * Warning: External references are freed but only the internal
        * control structures are resetted. No memory is freed and at setting
        * new key bindings the instance will grow in memory usage.
        **/
       void clearKeyBindings();
   
       /**
      * Gets the key binding count.      * Gets the key binding count.
      * @return the number of key bindings set.      * @return the number of key bindings set.
      */      */
Line 459 
Line 547 
         CIMType& type,         CIMType& type,
         const SCMBUnion** keyvalue) const;         const SCMBUnion** keyvalue) const;
  
       SCMO_RC getKeyBindingAtUnresolved(
           Uint32 node,
           const char** pname,
           Uint32 & pnameLen,
           CIMType& type,
           const SCMBUnion** pdata,
           const char** valueBase) const;
   
     /**     /**
      * Get the named key binding.      * Get the named key binding.
      * @parm name The name of the key binding.      * @parm name The name of the key binding.
      * @param type Returns the type as CIMType.      * @param type Returns the type as CIMType.
      *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.      *             It is invalid if rc == SCMO_INDEX_OUT_OF_BOUND.
      * @param keyvalue Returns a pointer to the value of keybinding.      * @param keyvalue Returns a pointer to the value of keybinding.
      *               The value is strored in a SCMBUnion       *               The value is stored in a SCMBUnion
      *                and has to be copied by the caller !      *                and has to be copied by the caller !
      *               It returns NULL if rc != SCMO_OK.      *               It returns NULL if rc != SCMO_OK.
      *      *
Line 495 
Line 591 
     Boolean isUninitialized( ) const {return (0 == inst.base); };     Boolean isUninitialized( ) const {return (0 == inst.base); };
  
     /**     /**
        * Determines if the SCMOInstance does not contain any property information.
        * Maybe only the class name and/or name space are available.
        * @return True if the SCMOInstacne is empty, false otherwise.
        */
       Boolean isEmpty( ) const {return (inst.hdr->theClass.ptr->isEmpty()); };
   
       /**
      * Determines whether the instance is used as a class container.      * Determines whether the instance is used as a class container.
      * @return True if the instance is used as a class container only.      * @return True if the instance is used as a class container only.
      */      */
Line 541 
Line 644 
      * @param Return strlen of result string.      * @param Return strlen of result string.
      * @return The class name as UTF8.      * @return The class name as UTF8.
      */      */
     const char* getHostName_l(Uint64 & length) const;      const char* getHostName_l(Uint32 & length) const;
  
     /**     /**
      * Sets the provided class name at the instance. By caling this function      * Sets the provided class name at the instance. By caling this function
Line 556 
Line 659 
      * @param className The class name as UTF8.      * @param className The class name as UTF8.
      * @param len The strlen of the name space.      * @param len The strlen of the name space.
      */      */
     void setClassName_l(const char* className, Uint64 len);      void setClassName_l(const char* className, Uint32 len);
  
     /**     /**
      * Get the class name of the instance. The caller has to make a copy !      * Get the class name of the instance. The caller has to make a copy !
Line 566 
Line 669 
  
     /**     /**
      * Get the class name of the instance. The caller has to make a copy !      * Get the class name of the instance. The caller has to make a copy !
      * @param Return strlen of result string.       * @param lenght Return strlen of result string.
      * @return The class name as UTF8.      * @return The class name as UTF8.
      */      */
     const char* getClassName_l(Uint64 & length) const;      const char* getClassName_l(Uint32 & length) const;
  
     /**     /**
      * Sets the provided name space name at the instance.      * Sets the provided name space name at the instance.
Line 599 
Line 702 
      * @param Return strlen of result string.      * @param Return strlen of result string.
      * @return The class name as UTF8.      * @return The class name as UTF8.
      */      */
     const char* getNameSpace_l(Uint64 & length) const;      const char* getNameSpace_l(Uint32 & length) const;
  
     /**     /**
      * Is the name space or class name of the instance the origianl values      * Is the name space or class name of the instance the origianl values
Line 658 
Line 761 
         inst.hdr->flags.includeClassOrigin = false;         inst.hdr->flags.includeClassOrigin = false;
     }     }
  
   
       /**
        * Returns the number of external references hosted by the instance.
        **/
       Uint32 numberExtRef() const
       {
           return inst.mem->numberExtRef;
       }
   
       /**
        * Gets the pointer of an external reference of the instance.
        * Warning: The pointer is purely returned. No management is done.
        * @parm idx The index of the external reference.
        **/
       SCMOInstance* getExtRef(Uint32 idx) const;
   
       /**
        * Sets a pointer of an external reference of the instance.
        * Warning: The pointer is purely returned. No management is done.
        * @parm idx The index of the external reference.
        * @parm ptr The pointer to an SCMOInstance
        **/
       void putExtRef(Uint32 idx,SCMOInstance* ptr);
   
 private: private:
  
     void Ref()     void Ref()
     {     {
         inst.hdr->refCount++;         inst.hdr->refCount++;
         // printf("\ninst.hdr->refCount=%u\n",inst.hdr->refCount.get());  
     };     };
  
     void Unref()     void Unref()
     {     {
         if (inst.hdr->refCount.decAndTestIfZero())         if (inst.hdr->refCount.decAndTestIfZero())
         {         {
             // printf("\ninst.hdr->refCount=%u\n",inst.hdr->refCount.get());  
             // All external references has to be destroyed.             // All external references has to be destroyed.
             _destroyExternalReferences();             _destroyExternalReferences();
             // The class has also be dereferenced.             // The class has also be dereferenced.
             delete inst.hdr->theClass;              delete inst.hdr->theClass.ptr;
             free(inst.base);             free(inst.base);
             inst.base=NULL;             inst.base=NULL;
         }         }
         else  
       };
   
   
       void _copyOnWrite()
       {
           if ( 1 < inst.hdr->refCount.get() )
         {         {
             // printf("\ninst.hdr->refCount=%u\n",inst.hdr->refCount.get());              SCMBInstance_Main * oldRef = inst.hdr;
               _clone();
               if (oldRef->refCount.decAndTestIfZero())
               {
                   // All external references has to be destroyed.
                   _destroyExternalReferencesInternal((SCMBMgmt_Header*)oldRef);
                   // The class has also be dereferenced.
                   delete oldRef->theClass.ptr;
                   free((void*)oldRef);
                   oldRef=0;
               }
         }         }
   
     };     };
  
       void _clone();
  
     void _destroyExternalReferences();     void _destroyExternalReferences();
  
       void _destroyExternalKeyBindings();
   
     void _copyExternalReferences();     void _copyExternalReferences();
  
       void _setExtRefIndex(Uint64 idx);
   
     void _initSCMOInstance(SCMOClass* pClass);     void _initSCMOInstance(SCMOClass* pClass);
  
     void _setCIMInstance(const CIMInstance& cimInstance);     void _setCIMInstance(const CIMInstance& cimInstance);
Line 734 
Line 879 
         const SCMBValue& scmbV,         const SCMBValue& scmbV,
         const char * base);         const char * base);
  
       static SCMOClass _getSCMOClass(
           const CIMObjectPath& theCIMObj,
           const char* altNS,
           Uint32 altNSlength);
   
     CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const;     CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const;
  
     void _setCIMObjectPath(const CIMObjectPath& cimObj);     void _setCIMObjectPath(const CIMObjectPath& cimObj);
Line 757 
Line 907 
         SCMBMgmt_Header** pmem,         SCMBMgmt_Header** pmem,
         CIMType type,         CIMType type,
         Uint64 startNS,         Uint64 startNS,
         Uint64 lenNS,          Uint32 lenNS,
         Union& u);         Union& u);
  
     static void _setUnionArrayValue(     static void _setUnionArrayValue(
Line 766 
Line 916 
         CIMType type,         CIMType type,
         Uint32& n,         Uint32& n,
         Uint64 startNS,         Uint64 startNS,
         Uint64 lenNS,          Uint32 lenNS,
         Union& u);         Union& u);
  
       static void _setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem);
   
     SCMO_RC _getKeyBindingDataAtNodeIndex(     SCMO_RC _getKeyBindingDataAtNodeIndex(
         Uint32 node,         Uint32 node,
         const char** pname,         const char** pname,
Line 849 
Line 1001 
     friend class SCMOClass;     friend class SCMOClass;
     friend class SCMODump;     friend class SCMODump;
     friend class SCMOXmlWriter;     friend class SCMOXmlWriter;
       friend class SCMOStreamer;
 }; };
  
 inline void SCMOInstance::_getPropertyAt( inline void SCMOInstance::_getPropertyAt(
Line 877 
Line 1030 
         (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);         (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
  
     // create a pointer to property node array of the class.     // create a pointer to property node array of the class.
     Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;      Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start;
     SCMBClassPropertyNode* theClassPropNodeArray =     SCMBClassPropertyNode* theClassPropNodeArray =
         (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];          (SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx];
  
     // return the absolute pointer to the property definition     // return the absolute pointer to the property definition
     *propDef= &(theClassPropNodeArray[node].theProperty);     *propDef= &(theClassPropNodeArray[node].theProperty);
Line 895 
Line 1048 
     {     {
         // return the absolute pointer to         // return the absolute pointer to
         *value = &(theClassPropNodeArray[node].theProperty.defaultValue);         *value = &(theClassPropNodeArray[node].theProperty.defaultValue);
         *valueBase = inst.hdr->theClass->cls.base;          *valueBase = inst.hdr->theClass.ptr->cls.base;
       }
     }     }
   
   inline void SCMOInstance::getSCMBValuePropertyAt(
       Uint32 pos,
       SCMBValue** value,
       const char ** valueBase,
       SCMBClassProperty ** propDef,
       const char ** propDefBase) const
   {
       _getPropertyAt(pos,value,valueBase,propDef);
   
       *propDefBase = inst.hdr->theClass.ptr->cls.base;
 } }
  
   inline SCMO_RC SCMOInstance::getKeyBindingAtUnresolved(
           Uint32 node,
           const char** pname,
           Uint32 & pnameLen,
           CIMType& type,
           const SCMBUnion** pdata,
           const char** valueBase) const
   {
       SCMO_RC rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,pdata);
       // Adjust size to string length
       if (pnameLen)
       {
           pnameLen--;
       }
       *valueBase = inst.base;
       return rc;
   }
   
   
   
 #define PEGASUS_ARRAY_T SCMOInstance #define PEGASUS_ARRAY_T SCMOInstance
 # include <Pegasus/Common/ArrayInter.h> # include <Pegasus/Common/ArrayInter.h>
 #undef PEGASUS_ARRAY_T #undef PEGASUS_ARRAY_T


Legend:
Removed from v.1.1.2.30  
changed lines
  Added in v.1.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2