version 1.1.2.1, 2009/08/03 11:10:08
|
version 1.2.4.1, 2013/06/03 22:35:13
|
|
|
// | // |
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// |
// | // |
|
// 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 |
|
// |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#ifndef _SCMOCLASS_H_ | #ifndef _SCMOCLASS_H_ |
|
|
#include <Pegasus/Common/Linkage.h> | #include <Pegasus/Common/Linkage.h> |
#include <Pegasus/Common/SCMO.h> | #include <Pegasus/Common/SCMO.h> |
#include <Pegasus/Common/CIMClass.h> | #include <Pegasus/Common/CIMClass.h> |
|
#include <Pegasus/Common/CIMClassRep.h> |
|
#include <Pegasus/Common/CIMObjectRep.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
| |
/** | /** |
* Constructs a SCMOClass out of a CIMClass. | * Constructs a SCMOClass out of a CIMClass. |
* @param theCIMClass The source the SCMOClass is constucted off. |
* @param theCIMClass The source the SCMOClass is constructed off. |
|
* @param nameSpaceName The namespace for the class, optional. |
* @return | * @return |
*/ | */ |
SCMOClass(CIMClass& theCIMClass ); |
SCMOClass(const CIMClass& theCIMClass, const char* altNameSpace=0 ); |
| |
/** | /** |
* Copy constructor for the SCMO class, used to implement refcounting. | * Copy constructor for the SCMO class, used to implement refcounting. |
|
|
} | } |
| |
/** | /** |
|
* Constructs a SCMOClass from a memory object of type SCMBClass_Main. |
|
* It incremets the referece counter of the memory object. |
|
* @param hdr A memory object of type SCMBClass_Main. |
|
**/ |
|
SCMOClass(SCMBClass_Main* hdr) |
|
{ |
|
cls.hdr = hdr; |
|
Ref(); |
|
} |
|
|
|
/** |
|
* Assignment operator for the SCMO class, |
|
* @param theSCMOClass The right hand value |
|
**/ |
|
SCMOClass& operator=(const SCMOClass& theSCMOClass) |
|
{ |
|
if (cls.hdr != theSCMOClass.cls.hdr) |
|
{ |
|
Unref(); |
|
cls.hdr = theSCMOClass.cls.hdr; |
|
Ref(); |
|
} |
|
return *this; |
|
} |
|
|
|
/** |
|
* Constructs an empty SCMOClass only with name space and class name. |
|
* |
|
* If you construct a SCMOInstance using this class, you must mark it as |
|
* compromized using SCMOInstance.markAsCompromised(). |
|
* |
|
* @param className The name for the class. |
|
* @param nameSpaceName The namespace for the class. |
|
*/ |
|
SCMOClass(const char* className, const char* nameSpaceName ); |
|
|
|
|
|
/** |
* 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. |
*/ | */ |
|
|
} | } |
| |
/** | /** |
|
* Converts the SCMOClass into a CIMClass. |
|
* It is a deep copy of the SCMOClass into the CIMClass. |
|
* @param cimClass An empty CIMClass. |
|
*/ |
|
void getCIMClass(CIMClass& cimClass) const; |
|
|
|
/** |
* Gets the key property names as a string array | * Gets the key property names as a string array |
* @return An Array of String objects containing the names of the key | * @return An Array of String objects containing the names of the key |
* properties. | * properties. |
|
|
void getKeyNamesAsString(Array<String>& keyNames) const; | void getKeyNamesAsString(Array<String>& keyNames) const; |
| |
/** | /** |
* Determines whether the object has been initialized. |
* Gets the super class name of the class. |
* @return True if the object has not been initialized, false otherwise. |
* @retuns The super class name. |
|
* If not available a NULL pointer is returned |
|
*/ |
|
const char* getSuperClassName() const; |
|
|
|
/** |
|
* Gets the super class name of the class. |
|
* @param Return strlen of result string. |
|
* @retuns The super class name. |
|
* If not available a NULL pointer is returned |
*/ | */ |
Boolean isUninitialized( ) const {return (cls.base == NULL); }; |
const char* getSuperClassName_l(Uint32 & length) const; |
|
|
|
static StrLit qualifierNameStrLit(Uint32 num) |
|
{ |
|
return _qualifierNameStrLit[num]; |
|
} |
|
|
|
/** |
|
* Determines if the SCMOClass is an empty class. |
|
* A empty class is a class with no information about properties. |
|
* Maybe only the class name and/or name space are available. |
|
* @return True if it an empty class. |
|
**/ |
|
Boolean isEmpty( )const |
|
{ |
|
// The size of one indicates that only an empty string was stored. |
|
return (cls.hdr->flags.isEmpty); |
|
} |
| |
private: | private: |
| |
void Ref() | void Ref() |
{ | { |
cls.hdr->refCount++; | cls.hdr->refCount++; |
// printf("\ncls.hdr->refCount=%u\n",cls.hdr->refCount.get()); |
|
}; | }; |
| |
void Unref() | void Unref() |
{ | { |
if (cls.hdr->refCount.decAndTestIfZero()) | if (cls.hdr->refCount.decAndTestIfZero()) |
{ | { |
// printf("\ncls.hdr->refCount=%u\n",cls.hdr->refCount.get()); |
_destroyExternalReferences(); |
free(cls.base); | free(cls.base); |
cls.base=NULL; |
cls.base=0; |
} |
|
else |
|
{ |
|
// printf("\ncls.hdr->refCount=%u\n",cls.hdr->refCount.get()); |
|
} | } |
| |
}; | }; |
| |
/** | /** |
* Constructs an uninitialized SCMOClass object. |
* Constructs an empty SCMOClass object. |
*/ | */ |
SCMOClass(); | SCMOClass(); |
| |
|
inline void _initSCMOClass(); |
|
|
|
void _destroyExternalReferences(); |
|
|
SCMO_RC _getProperyNodeIndex(Uint32& node, const char* name) const; | SCMO_RC _getProperyNodeIndex(Uint32& node, const char* name) const; |
SCMO_RC _getKeyBindingNodeIndex(Uint32& node, const char* name) const; | SCMO_RC _getKeyBindingNodeIndex(Uint32& node, const char* name) const; |
| |
void _setClassQualifers(CIMClass& theCIMClass); |
void _setClassQualifers(const CIMQualifierList& theQualifierList); |
|
|
QualifierNameEnum _setQualifier( | QualifierNameEnum _setQualifier( |
Uint64 start, | Uint64 start, |
const CIMQualifier& theCIMQualifier); | const CIMQualifier& theCIMQualifier); |
| |
void _setClassProperties(CIMClass& theCIMClass); |
void _setClassProperties(PropertySet& theCIMProperties); |
void _setProperty(Uint64 start, |
|
|
void _setProperty( |
|
Uint64 start, |
Boolean* isKey, | Boolean* isKey, |
const CIMProperty& theCIMProperty); | const CIMProperty& theCIMProperty); |
|
|
Boolean _setPropertyQualifiers( | Boolean _setPropertyQualifiers( |
Uint64 start, | Uint64 start, |
const CIMQualifierList& theQualifierList); | const CIMQualifierList& theQualifierList); |
|
|
void _setClassKeyBinding(Uint64 start, const CIMProperty& theCIMProperty); | void _setClassKeyBinding(Uint64 start, const CIMProperty& theCIMProperty); |
void _insertPropertyIntoOrderedSet(Uint64 start, Uint32 newIndex); | void _insertPropertyIntoOrderedSet(Uint64 start, Uint32 newIndex); |
void _insertKeyBindingIntoOrderedSet(Uint64 start, Uint32 newIndex); | void _insertKeyBindingIntoOrderedSet(Uint64 start, Uint32 newIndex); |
void _clearKeyPropertyMask(); |
|
void _setPropertyAsKeyInMask(Uint32 i); | void _setPropertyAsKeyInMask(Uint32 i); |
Boolean _isPropertyKey(Uint32 i); | Boolean _isPropertyKey(Uint32 i); |
| |
void _setValue(Uint64 start, const CIMValue& theCIMValue); | void _setValue(Uint64 start, const CIMValue& theCIMValue); |
void _setUnionValue(Uint64 start, CIMType type, Union& u); |
|
void _setArrayValue(Uint64 start, CIMType type, Union& u); |
|
QualifierNameEnum _getSCMOQualifierNameEnum(const CIMName& theCIMname); | QualifierNameEnum _getSCMOQualifierNameEnum(const CIMName& theCIMname); |
Boolean _isSamePropOrigin(Uint32 node, const char* origin) const; | Boolean _isSamePropOrigin(Uint32 node, const char* origin) const; |
| |
inline SCMO_RC _isNodeSameType( |
const char* _getPropertyNameAtNode(Uint32 propNode) const; |
|
|
|
SCMO_RC _isNodeSameType( |
Uint32 node, | Uint32 node, |
CIMType type, | CIMType type, |
Boolean isArray) const; |
Boolean isArray, |
|
CIMType& realType) const; |
|
|
|
CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const; |
|
static void _getCIMQualifierFromSCMBQualifier( |
|
CIMQualifier& theCIMQualifier, |
|
const SCMBQualifier& scmbQualifier, |
|
const char* base); |
| |
union{ | union{ |
// To access the class main structure | // To access the class main structure |
|
|
char *base; | char *base; |
}cls; | }cls; |
| |
|
static const StrLit _qualifierNameStrLit[72]; |
|
|
friend class SCMOInstance; | friend class SCMOInstance; |
friend class SCMODump; | friend class SCMODump; |
|
friend class SCMOXmlWriter; |
|
friend class SCMOClassCache; |
|
friend class SCMOStreamer; |
}; | }; |
| |
| |