version 1.1.2.30, 2009/10/27 18:38:08
|
version 1.1.2.37, 2009/11/16 10:25:57
|
|
|
| |
#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: |
|
|
* 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. |
|
|
} | } |
| |
/** | /** |
|
* 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 theSCMOClass 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. |
*/ | */ |
|
|
* | * |
*/ | */ |
SCMOInstance( | SCMOInstance( |
SCMOClass baseClass, |
SCMOClass& baseClass, |
Boolean includeQualifiers, | Boolean includeQualifiers, |
Boolean includeClassOrigin, | Boolean includeClassOrigin, |
const char** propertyList); | const char** propertyList); |
|
|
* 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. |
SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj); |
* @exception |
|
* Exception if a key binding is not found as a key property |
/** |
* of the SCMOClass. |
* Builds a SCMOInstance from the given CIMInstance copying all data. |
* @exception Exception if a key binding does not match |
* The SCMOClass is retrieved from SCMOClassCache using |
* the class definition. |
* 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, |
|
Uint64 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, |
|
Uint64 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(SCMOClass baseClass, const CIMObjectPath& cimObj); |
SCMOInstance( |
|
const CIMObject& cimObject, |
|
const char* altNameSpace=0, |
|
Uint64 altNSLen=0); |
| |
/** | /** |
* Converts the SCMOInstance into a CIMInstance. | * Converts the SCMOInstance into a CIMInstance. |
|
|
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. |
*/ | */ |
|
|
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->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. |
*/ | */ |
|
|
* @param hostName The host name as UTF8. | * @param hostName The host name as UTF8. |
* @param len The strlen of the host name. | * @param len The strlen of the host name. |
*/ | */ |
void setHostName_l(const char* hostName, Uint32 len); |
void setHostName_l(const char* hostName, Uint64 len); |
| |
/** | /** |
* Get the host name of the instance. The caller has to make a copy ! | * Get the host 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 ! | * 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(Uint64 & length) const; |
|
|
* @param nameSpaceName The name space name as UTF8. | * @param nameSpaceName The name space name as UTF8. |
* @param len The strlen of the name space. | * @param len The strlen of the name space. |
*/ | */ |
void setNameSpace_l(const char* nameSpace, Uint32 len); |
void setNameSpace_l(const char* nameSpace, Uint64 len); |
| |
/** | /** |
* Get the name space of the instance. The caller has to make a copy ! | * Get the name space of the instance. The caller has to make a copy ! |
|
|
inst.hdr->flags.includeClassOrigin = false; | inst.hdr->flags.includeClassOrigin = false; |
} | } |
| |
|
|
|
/** |
|
* Returns the number of external references hosted by the instance. |
|
**/ |
|
Uint32 numberExtRef() |
|
{ |
|
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); |
|
|
|
/** |
|
* 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() |
|
|
}; | }; |
| |
| |
|
void _copyOnWrite() |
|
{ |
|
if ( 1 < inst.hdr->refCount.get() ) |
|
{ |
|
fprintf(stderr,"!! Copy on Write (%d) !!\n", |
|
inst.hdr->refCount.get() ); |
|
_clone(); |
|
} |
|
}; |
|
|
|
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); |
|
|
const SCMBValue& scmbV, | const SCMBValue& scmbV, |
const char * base); | const char * base); |
| |
|
static SCMOClass _getSCMOClass( |
|
const CIMObjectPath& theCIMObj, |
|
const char* altNS, |
|
Uint64 altNSlength); |
|
|
CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const; | CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const; |
| |
void _setCIMObjectPath(const CIMObjectPath& cimObj); | void _setCIMObjectPath(const CIMObjectPath& cimObj); |
|
|
Uint64 lenNS, | Uint64 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, |