(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.4.2.1 and 1.10

version 1.4.2.1, 2012/05/25 13:04:22 version 1.10, 2014/11/13 01:47:06
Line 27 
Line 27 
 // //
 ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
 // //
   // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
   // (Single Chunk Memory Objects).
   // The design document can be found on the OpenPegasus website openpegasus.org
   // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
   //
   // This file defines the SCMOInstance interfaces. The implementation of
   // these methods is in SCMO.cpp
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #ifndef _SCMOINSTANCE_H_ #ifndef _SCMOINSTANCE_H_
Line 41 
Line 48 
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   PEGASUS_USING_STD;
   
 #define PEGASUS_SCMB_INSTANCE_MAGIC 0xD00D1234 #define PEGASUS_SCMB_INSTANCE_MAGIC 0xD00D1234
  
 class PEGASUS_COMMON_LINKAGE SCMOInstance class PEGASUS_COMMON_LINKAGE SCMOInstance
Line 125 
Line 134 
      * instance.  The TOINSTANCE flavor is ignored.      * instance.  The TOINSTANCE flavor is ignored.
      * @param includeClassOrigin A Boolean indicating whether ClassOrigin      * @param includeClassOrigin A Boolean indicating whether ClassOrigin
      * attributes are to be added to the instance.      * attributes are to be added to the instance.
      * @param propertyList Is an NULL terminated array of char* to property  
      * names defining the properties that are included in the created instance.  
      * If the propertyList is NULL, all properties are included to the instance.  
      * If the propertyList is empty, no properties are added.  
      *      *
      * Note that this function does NOT generate an error if a property name      * Note that this function does NOT generate an error if a property name
      * is supplied that is NOT in the class;      * is supplied that is NOT in the class;
Line 138 
Line 143 
     SCMOInstance(     SCMOInstance(
         SCMOClass& baseClass,         SCMOClass& baseClass,
         Boolean includeQualifiers,         Boolean includeQualifiers,
         Boolean includeClassOrigin,          Boolean includeClassOrigin);
         const char** propertyList);  
  
     /**     /**
      * Builds a SCMOInstance from the given SCMOClass and copies all      * Builds a SCMOInstance from the given SCMOClass and copies all
Line 289 
Line 293 
         Boolean& isArray,         Boolean& isArray,
         Uint32& size ) const;         Uint32& size ) const;
  
     void getSCMBValuePropertyAt(      // KS_FUTURE removed this as not used. Compiles without it
         Uint32 pos,  ////  void getSCMBValuePropertyAt(
         SCMBValue** value,  ////      Uint32 pos,
         const char ** valueBase,  ////      SCMBValue** value,
         SCMBClassProperty ** propDef,  ////      const char ** valueBase,
         const char ** classBase) const;  ////      SCMBClassProperty ** propDef,
   ////      const char ** classBase) const;
  
     /**     /**
      * Gets the type and value of the named property.      * Gets the type and value of the named property.
Line 337 
Line 342 
  
     /**     /**
      * Set/replace a property in the instance.      * Set/replace a property in the instance.
      * If the class origin is specified, it is honored at identifying       * If the class origin is specified, it is honored when the
      * the property within the instance.       * property is identified within the instance.
        *
      * Note: Only properties which are already part of the instance/class can      * Note: Only properties which are already part of the instance/class can
      * be set/replaced.       * be set/replaced except in for special case where the flag
        * lags.noClassForInstance is set when the instance is created.
        * If the class is not found in the repository, the instance is
        * are marked as noClassForInstance and properties are set in
        * the UserDefined properties area.
      * @param name The name of the property to be set.      * @param name The name of the property to be set.
      * @param type The CIMType of the property       * @param theType The CIMType of the property
      * @param value A pointer to the value to be set at the named property.      * @param value A pointer to the value to be set at the named property.
      *              The value has to be in a SCMBUnion.       *              The value must be in a SCMBUnion.
      *              The value is copied into the instance      *              The value is copied into the instance
      *              If the value == NULL, a null value is assumed.      *              If the value == NULL, a null value is assumed.
      *              If the value is an array, the value array has to be      *              If the value is an array, the value array has to be
Line 358 
Line 368 
      *              If the value is type of CIMTYPE_STRING,      *              If the value is type of CIMTYPE_STRING,
      *              the string is referenced by the structure      *              the string is referenced by the structure
      *              SCMBUnion.extString:      *              SCMBUnion.extString:
      *                       pchar contains the absolut pointer to the string       *                       pchar contains the absolute pointer to
      *                       length contains the size of the string       *                       the string length contains the size of
        *                       the string
      *                              without trailing '\0'.      *                              without trailing '\0'.
      * @param isArray Indicate that the value is an array. Default false.      * @param isArray Indicate that the value is an array. Default false.
      * @param size Returns the size of the array. If not an array this      * @param size Returns the size of the array. If not an array this
      *         this parameter is ignorer. Default 0.       *         this parameter is ignored. Default 0.
      * @param origin The class originality of the property.      * @param origin The class originality of the property.
      *               If NULL, then it is ignorred. Default NULL.       *               If NULL, then it is ignored. Default NULL.
      * @return     SCMO_OK      * @return     SCMO_OK
      *             SCMO_NOT_SAME_ORIGIN : The property name was found, but      *             SCMO_NOT_SAME_ORIGIN : The property name was found, but
      *                                    the origin was not the same.      *                                    the origin was not the same.
Line 376 
Line 387 
      */      */
     SCMO_RC setPropertyWithOrigin(     SCMO_RC setPropertyWithOrigin(
         const char* name,         const char* name,
         CIMType type,          CIMType theType,
         const SCMBUnion* value,         const SCMBUnion* value,
         Boolean isArray=false,         Boolean isArray=false,
         Uint32 size = 0,         Uint32 size = 0,
Line 389 
Line 400 
      */      */
     void buildKeyBindingsFromProperties();     void buildKeyBindingsFromProperties();
  
     //This function is not implemented and now Property filtering is done by  
     //the CIMOM infrastructure  
     void setPropertyFilter(const char **propertyList);  
   
     /**     /**
      * Gets the hash index for the named property. Filtering is ignored.      * Gets the hash index for the named property. Filtering is ignored.
      * @param theName The property name      * @param theName The property name
Line 403 
Line 410 
      */      */
     SCMO_RC getPropertyNodeIndex(const char* name, Uint32& pos) const;     SCMO_RC getPropertyNodeIndex(const char* name, Uint32& pos) const;
  
       // KS_FUTURE confirm that the following is used in OpenPegasus
       // Apprently never referenced within any of OpenPegasus code
     /**     /**
      * Set/replace a property in the instance at node index.      * Set/replace a property in the instance at node index.
      * Note: If node is filtered, the property is not set but the return value  
      * is still SCMO_OK.  
      * @param index The node index.      * @param index The node index.
      * @param type The CIMType of the property      * @param type The CIMType of the property
      * @param pInVal A pointer to the value to be set at the named property.      * @param pInVal A pointer to the value to be set at the named property.
Line 584 
Line 591 
     /**     /**
      * Determines if the SCMOInstance does not contain any property information.      * Determines if the SCMOInstance does not contain any property information.
      * Maybe only the class name and/or name space are available.      * Maybe only the class name and/or name space are available.
      * @return True if the SCMOInstacne is empty, false otherwise.       * @return True if the SCMOInstance is empty, false otherwise.
      */      */
     Boolean isEmpty( ) const {return (inst.hdr->theClass.ptr->isEmpty()); };      Boolean isEmpty( ) const;
  
     /**     /**
      * Determines whether the instance is used as a class container.      * Determines whether the instance is used as a class container.
Line 714 
Line 721 
         return inst.hdr->flags.isCompromised;         return inst.hdr->flags.isCompromised;
     };     };
  
       /**
           returns true if there is no class defined for this instance.
           The flag is set when the SCMO instance is created and the
           repository returns no class.
       */
       Boolean noClassForInstance() const
       {
           return inst.hdr->flags.noClassForInstance;
       };
  
     /**     /**
      * Mark the instance as a non validated instance.      * Mark the instance as a non validated instance.
Line 724 
Line 740 
     };     };
  
     /**     /**
           Sets the flag indicating that there is no class for this
           instance. This property is used for Instances that are
           created where there is no class in the repository.
       */
       void markNoClassForInstance(Boolean x)
       {
           inst.hdr->flags.noClassForInstance = x;
       };
   
       /**
      *  To indicate the export processing ( eg. XMLWriter )      *  To indicate the export processing ( eg. XMLWriter )
      *  to include qualifiers for this instance.      *  to include qualifiers for this instance.
      */      */
Line 794 
Line 820 
     {     {
         if (inst.hdr->refCount.decAndTestIfZero())         if (inst.hdr->refCount.decAndTestIfZero())
         {         {
             // All external references has to be destroyed.              // All external references have to be destroyed.
             _destroyExternalReferences();             _destroyExternalReferences();
             // The class has also be dereferenced.             // The class has also be dereferenced.
             delete inst.hdr->theClass.ptr;             delete inst.hdr->theClass.ptr;
Line 815 
Line 841 
             _clone();             _clone();
             if (oldRef->refCount.decAndTestIfZero())             if (oldRef->refCount.decAndTestIfZero())
             {             {
                 // All external references has to be destroyed.                  // All external references have to be destroyed.
                 _destroyExternalReferencesInternal(oldMgmt);                 _destroyExternalReferencesInternal(oldMgmt);
                 // The class has also be dereferenced.                 // The class has also be dereferenced.
                 delete oldRef->theClass.ptr;                 delete oldRef->theClass.ptr;
Line 839 
Line 865 
  
     void _setCIMInstance(const CIMInstance& cimInstance);     void _setCIMInstance(const CIMInstance& cimInstance);
  
       // Internal but used by friend class SCMOXmlWriter.cpp
       // This function accounts for user-defined and class-defined properties
     void _getPropertyAt(     void _getPropertyAt(
         Uint32 pos,         Uint32 pos,
         SCMBValue** value,         SCMBValue** value,
Line 930 
Line 958 
  
     void _copyKeyBindings(SCMOInstance& targetInst) const;     void _copyKeyBindings(SCMOInstance& targetInst) const;
  
     Uint32 _initPropFilterWithKeys();  
   
     void _setPropertyInPropertyFilter(Uint32 i);  
   
     Boolean _isPropertyInFilter(Uint32 i) const;  
   
     void _clearPropertyFilter();  
   
     void _setKeyBindingFromSCMBUnion(     void _setKeyBindingFromSCMBUnion(
         CIMType type,         CIMType type,
         const SCMBUnion& u,         const SCMBUnion& u,
Line 959 
Line 979 
         char* elementBase);         char* elementBase);
     /**     /**
      * Set a SCMO user defined key binding using the class CIM type tolerating      * Set a SCMO user defined key binding using the class CIM type tolerating
      * CIM key binding types converted to CIM types by fuction       * CIM key binding types converted to CIM types by function
      *  _CIMTypeFromKeyBindingType().      *  _CIMTypeFromKeyBindingType().
      *      *
      * @parm classType The type of the key binding in the class definition      * @parm classType The type of the key binding in the class definition
Line 988 
Line 1008 
         SCMBKeyBindingValue& scmoKBV         SCMBKeyBindingValue& scmoKBV
         );         );
  
       // Functions to support the use of user defined properties
       /*
           Get the node for a user defined property.
           @return node of the property and SCMO_OK or an error
           SCMO_NOT_FOUND indicating that the property cannot be
           found as a user-defined property.
       */
       SCMO_RC _getUserPropertyNodeIndex(Uint32& node, const char* name) const;
   
       /*
           get the Instance SCMBUserPropertyElement for the defined node index.
       */
       SCMBUserPropertyElement*
            _getUserDefinedPropertyElementAt(Uint32 index) const;
   
       void _setPropertyInUserDefinedElement(
           SCMBUserPropertyElement* ptrNewElement,
           CIMType theType,
           const SCMBUnion* pinVal,
           Boolean isArray,
           Uint32 size);
       /**
           Creates a new user-defined property element, chains it to
           the existing user-defined property chain, and populate it
           with name, type, isArray. isSet = false.
           @return pointer to new SCMBUserPropertyElement
       */
       SCMBUserPropertyElement* _createNewUserDefinedProperty(
           const char * name,
           Uint32 nameLen,
           CIMType theType);
   
       /*
           Returns true if the Property is in the set of
           properties defined in an including class
       */
       Boolean _isClassDefinedProperty(Uint32 node) const;
   
       SCMBValue& _getSCMBValueForNode(Uint32 node) const;
  
       /* Definition of inst. Pointer to:
               SCMBInstance_Manin
               SCMBMgmt_Header
               or generic base pointer.
       */
     union{     union{
         // To access the instance main structure         // To access the instance main structure
         SCMBInstance_Main *hdr;         SCMBInstance_Main *hdr;
Line 1004 
Line 1068 
     friend class SCMOStreamer;     friend class SCMOStreamer;
 }; };
  
   
   inline SCMBValue& SCMOInstance::_getSCMBValueForNode(Uint32 node) const
   {
       if (_isClassDefinedProperty(node))
       {
           SCMBValue *theInstPropNodeArray =
               (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
   
           return theInstPropNodeArray[node];
       }
   
       SCMBUserPropertyElement* pElement =
          _getUserDefinedPropertyElementAt(node);
   
       return pElement->value;
   }
   
   
   // KS_TODO clarify this test since our rule is more explicit
   // We cannot have both user-defined and class-defined properties so this
   // could be a more concrete tests.
   inline Boolean SCMOInstance::_isClassDefinedProperty(Uint32 node) const
   {
       return (node < inst.hdr->numberProperties);
   }
   
   // This internal function used by SCMOXmlWriter.cpp
   // It is inline because it is called only once in the CIMServer.
 inline void SCMOInstance::_getPropertyAt( inline void SCMOInstance::_getPropertyAt(
     Uint32 pos,     Uint32 pos,
     SCMBValue** value,     SCMBValue** value,
     const char ** valueBase,     const char ** valueBase,
     SCMBClassProperty ** propDef) const      SCMBClassProperty ** propertyDef) const
   {
       if (_isClassDefinedProperty(pos))
 { {
     SCMBValue* theInstPropNodeArray =     SCMBValue* theInstPropNodeArray =
         (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.ptr->cls.hdr->propertySet.nodeArray.start;          Uint64 idx =
               inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start;
     SCMBClassPropertyNode* theClassPropNodeArray =     SCMBClassPropertyNode* theClassPropNodeArray =
         (SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->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[pos].theProperty);          *propertyDef = &(theClassPropNodeArray[pos].theProperty);
  
     // need check if property set or not, if not set use the default value     // need check if property set or not, if not set use the default value
     if (theInstPropNodeArray[pos].flags.isSet)     if (theInstPropNodeArray[pos].flags.isSet)
Line 1035 
Line 1130 
         *valueBase = inst.hdr->theClass.ptr->cls.base;         *valueBase = inst.hdr->theClass.ptr->cls.base;
     }     }
 } }
       else           // User-defined property
 inline void SCMOInstance::getSCMBValuePropertyAt(  
     Uint32 pos,  
     SCMBValue** value,  
     const char ** valueBase,  
     SCMBClassProperty ** propDef,  
     const char ** propDefBase) const  
 { {
     _getPropertyAt(pos,value,valueBase,propDef);          // KS_TODO mostly same code as _getPropertyAtNodeIndex
           SCMBUserPropertyElement* pElement =
               _getUserDefinedPropertyElementAt(pos);
   
           PEGASUS_ASSERT(pElement != 0);
  
     *propDefBase = inst.hdr->theClass.ptr->cls.base;          *value = &(pElement->value);
           // KS_TODO do we have to deal with isSet == false here. Probably
           // no but confirm with Assert.
           *valueBase = inst.base;
       }
 } }
  
   inline Uint32 SCMOInstance::getPropertyCount() const
   {
       return(inst.hdr->numberProperties + inst.hdr->numberUserProperties);
   }
   
   // KS_FUTURE Remove this completely from code since apparently not used.
   ////// Apparently never used.
   ////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( inline SCMO_RC SCMOInstance::getKeyBindingAtUnresolved(
         Uint32 node,         Uint32 node,
         const char** pname,         const char** pname,
Line 1066 
Line 1182 
     return rc;     return rc;
 } }
  
   inline Boolean SCMOInstance::isEmpty( ) const
   {
       if (noClassForInstance())
       {
           // KS_TODO need another test for empty. Number properties
           // != 0 might work but that would disallow an empty embedded
           // instance.
           return false;
       }
       else
       {
           return (inst.hdr->theClass.ptr->isEmpty());
       }
   }
   
  
  
 #define PEGASUS_ARRAY_T SCMOInstance #define PEGASUS_ARRAY_T SCMOInstance


Legend:
Removed from v.1.4.2.1  
changed lines
  Added in v.1.10

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2