version 1.3, 2009/07/09 09:19:41
|
version 1.9, 2012/08/08 08:27:59
|
|
|
#include <Pegasus/Common/CIMInstance.h> | #include <Pegasus/Common/CIMInstance.h> |
#include <Pegasus/Common/Linkage.h> | #include <Pegasus/Common/Linkage.h> |
#include <Pegasus/Common/CIMBuffer.h> | #include <Pegasus/Common/CIMBuffer.h> |
|
#include <Pegasus/Common/SCMOClass.h> |
|
#include <Pegasus/Common/SCMOInstance.h> |
|
#include <Pegasus/Common/SCMODump.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
# include <Pegasus/Common/ArrayInter.h> | # include <Pegasus/Common/ArrayInter.h> |
#undef PEGASUS_ARRAY_T | #undef PEGASUS_ARRAY_T |
| |
//----------------------------------------------------------------------------- |
|
// |
|
// CIMInstanceResponseData |
|
// |
|
//----------------------------------------------------------------------------- |
|
| |
class PEGASUS_COMMON_LINKAGE CIMInstanceResponseData |
class PEGASUS_COMMON_LINKAGE CIMResponseData |
{ | { |
public: | public: |
| |
CIMInstanceResponseData(): |
enum ResponseDataEncoding { |
_resolveCallback(0), |
RESP_ENC_CIM = 1, |
_binaryEncoding(false) |
RESP_ENC_BINARY = 2, |
{ |
RESP_ENC_XML = 4, |
} |
RESP_ENC_SCMO = 8 |
|
}; |
CIMInstance& getCimInstance() |
|
{ |
|
_resolve(); |
|
return _cimInstance; |
|
} |
|
| |
const CIMConstInstance& getCimInstance() const |
enum ResponseDataContent { |
|
RESP_INSTNAMES = 1, |
|
RESP_INSTANCES = 2, |
|
RESP_INSTANCE = 3, |
|
RESP_OBJECTS = 4, |
|
RESP_OBJECTPATHS = 5 |
|
}; |
|
//includeClassOrigin & _includeQualifiers are set to true by default. |
|
//_propertyList is initialized to an empty propertylist to enable |
|
// sending all properties by default. |
|
CIMResponseData(ResponseDataContent content): |
|
_encoding(0),_dataType(content),_includeQualifiers(true), |
|
_includeClassOrigin(true),_propertyList(CIMPropertyList()) |
{ | { |
// Resolve the instance before returning it. The resolve step requires |
|
// non-const access, but does not fundamentally change the response |
|
const_cast<CIMInstanceResponseData*>(this)->_resolve(); |
|
|
|
// The CIMInstance is masqueraded as a CIMConstInstance for expedience, |
|
// since the internal representations are the same. |
|
return *((CIMConstInstance*)(void*)&_cimInstance); |
|
} | } |
| |
void setCimInstance(const CIMInstance& x) |
CIMResponseData(const CIMResponseData & x): |
|
_encoding(x._encoding), |
|
_dataType(x._dataType), |
|
_referencesData(x._referencesData), |
|
_instanceData(x._instanceData), |
|
_hostsData(x._hostsData), |
|
_nameSpacesData(x._nameSpacesData), |
|
_binaryData(x._binaryData), |
|
_defaultNamespace(x._defaultNamespace), |
|
_defaultHostname(x._defaultHostname), |
|
_instanceNames(x._instanceNames), |
|
_instances(x._instances), |
|
_objects(x._objects), |
|
_scmoInstances(x._scmoInstances), |
|
_includeQualifiers(x._includeQualifiers), |
|
_includeClassOrigin(x._includeClassOrigin), |
|
_propertyList(x._propertyList) |
{ | { |
_resolveCallback = 0; |
|
_cimInstance = x; |
|
} | } |
| |
Array<Uint8>& getBinaryCimInstance() |
~CIMResponseData() |
{ | { |
return _binaryData; |
|
} | } |
| |
bool setBinaryCimInstance(CIMBuffer& in, bool hasLen=true); |
// C++ objects interface handling |
bool setXmlCimInstance(CIMBuffer& in); |
|
|
|
void encodeBinaryResponse(CIMBuffer& out) const; |
|
void encodeXmlResponse(Buffer& out) const; |
|
|
|
private: |
|
|
|
CIMInstanceResponseData(const CIMInstanceResponseData&); |
|
CIMInstanceResponseData& operator=( |
|
const CIMInstanceResponseData&); |
|
|
|
static Boolean _resolveXMLInstance( |
|
CIMInstanceResponseData* data, |
|
CIMInstance& instance); |
|
|
|
static Boolean _resolveBinaryInstance( |
|
CIMInstanceResponseData* data, |
|
CIMInstance& instance); |
|
| |
Boolean (*_resolveCallback)( |
// Instance Names handling |
CIMInstanceResponseData* msg, |
Array<CIMObjectPath>& getInstanceNames(); |
CIMInstance& cimInstance); |
|
| |
void _resolve() |
void setInstanceNames(const Array<CIMObjectPath>& x) |
{ | { |
if (_resolveCallback) |
_instanceNames=x; |
{ |
_encoding |= RESP_ENC_CIM; |
(*_resolveCallback)(this, _cimInstance); |
|
_resolveCallback = 0; |
|
} |
|
} | } |
| |
Boolean _binaryEncoding; |
// Instance handling |
|
CIMInstance& getInstance(); |
| |
// For XML encoding: |
void setInstance(const CIMInstance& x) |
Array<Sint8> _instanceData; |
|
Array<Sint8> _referenceData; |
|
CIMNamespaceName _nameSpaceData; |
|
String _hostData; |
|
|
|
// For Binary encoding: |
|
Array<Uint8> _binaryData; |
|
|
|
CIMInstance _cimInstance; |
|
|
|
}; |
|
|
|
|
|
//----------------------------------------------------------------------------- |
|
// |
|
// CIMInstancesResponseData |
|
// |
|
//----------------------------------------------------------------------------- |
|
|
|
class PEGASUS_COMMON_LINKAGE CIMInstancesResponseData |
|
{ |
|
public: |
|
|
|
CIMInstancesResponseData(): |
|
_resolveCallback(0), |
|
_binaryEncoding(false) |
|
{ | { |
|
_instances.clear(); |
|
_instances.append(x); |
|
_encoding |= RESP_ENC_CIM; |
} | } |
| |
Array<CIMInstance>& getNamedInstances() |
// Instances handling |
|
Array<CIMInstance>& getInstances(); |
|
|
|
void setInstances(const Array<CIMInstance>& x) |
{ | { |
_resolve(); |
_instances=x; |
return _namedInstances; |
_encoding |= RESP_ENC_CIM; |
} | } |
|
void appendInstance(const CIMInstance& x) |
const Array<CIMConstInstance>& getNamedInstances() const |
|
{ | { |
// Resolve the instances before returning them. The resolve step |
_instances.append(x); |
// requires non-const access, but does not fundamentally change the |
_encoding |= RESP_ENC_CIM; |
// message contents. |
|
const_cast<CIMInstancesResponseData*>(this)->_resolve(); |
|
|
|
// The Array<CIMInstance> is masqueraded as an Array<CIMConstInstance> |
|
// for expedience, since the internal representations are the same. |
|
return *((Array<CIMConstInstance>*)(void*)&_namedInstances); |
|
} | } |
| |
void setNamedInstances(const Array<CIMInstance>& x) |
// Objects handling |
|
Array<CIMObject>& getObjects(); |
|
void setObjects(const Array<CIMObject>& x) |
{ | { |
_resolveCallback = 0; |
_objects=x; |
_namedInstances = x; |
_encoding |= RESP_ENC_CIM; |
} | } |
|
void appendObject(const CIMObject& x) |
Array<Uint8>& getBinaryCimInstances() |
|
{ | { |
return _binaryData; |
_objects.append(x); |
|
_encoding |= RESP_ENC_CIM; |
} | } |
| |
bool setBinaryCimInstances(CIMBuffer& in, bool hasLen=true); |
// SCMO representation, single instance stored as one element array |
bool setXmlCimInstances(CIMBuffer& in); |
// object paths are represented as SCMOInstance |
|
Array<SCMOInstance>& getSCMO(); |
void encodeBinaryResponse(CIMBuffer& out) const; |
|
void encodeXmlResponse(Buffer& out) const; |
|
|
|
private: |
|
|
|
CIMInstancesResponseData(const CIMInstancesResponseData&); |
|
CIMInstancesResponseData& operator=( |
|
const CIMInstancesResponseData&); |
|
|
|
static Boolean _resolveXMLInstances( |
|
CIMInstancesResponseData* data, |
|
Array<CIMInstance>& instances); |
|
| |
static Boolean _resolveBinaryInstances( |
void setSCMO(const Array<SCMOInstance>& x); |
CIMInstancesResponseData* data, |
|
Array<CIMInstance>& instances); |
|
| |
Boolean (*_resolveCallback)( |
void appendSCMO(const Array<SCMOInstance>& x) |
CIMInstancesResponseData* data, |
|
Array<CIMInstance>& cimInstance); |
|
|
|
void _resolve() |
|
{ |
|
if (_resolveCallback) |
|
{ | { |
(*_resolveCallback)(this, _namedInstances); |
_scmoInstances.appendArray(x); |
_resolveCallback = 0; |
_encoding |= RESP_ENC_SCMO; |
} |
|
} | } |
| |
Boolean _binaryEncoding; |
Array<Uint8>& getBinary(); |
| |
// For XML encoding. |
// Set the binary stream in the CIMBuffer into the CIMResponseData |
Array<ArraySint8> _instancesData; |
bool setBinary(CIMBuffer& in); |
Array<ArraySint8> _referencesData; |
|
Array<String> _hostsData; |
|
Array<CIMNamespaceName> _nameSpacesData; |
|
| |
// For binary encoding. |
// Set any data from the CIMBuffer remaining after the current CIMBuffer |
Array<Uint8> _binaryData; |
// position pointer into the CIMResponseData Object. |
|
bool setRemainingBinaryData(CIMBuffer& in); |
| |
Array<CIMInstance> _namedInstances; |
// Xml data is unformatted, no need to differentiate between instance |
}; |
// instances and object paths or objects |
|
bool setXml(CIMBuffer& in); |
| |
|
// function used by OperationAggregator to aggregate response data in a |
|
// single ResponseData object |
|
void appendResponseData(const CIMResponseData & x); |
| |
//----------------------------------------------------------------------------- |
// Function used by CMPI layer to complete the namespace on all data held |
// |
// Input (x) has to have a valid namespace |
// CIMObjectsResponseData |
void completeNamespace(const SCMOInstance * x); |
// |
|
//----------------------------------------------------------------------------- |
|
| |
class PEGASUS_COMMON_LINKAGE CIMObjectsResponseData |
// Function primarily used by CIMOperationRequestDispatcher to complete |
{ |
// namespace and hostname on a,an,r and rn operations in the |
public: |
// OperationAggregator |
|
void completeHostNameAndNamespace( |
|
const String & hn, |
|
const CIMNamespaceName & ns); |
| |
CIMObjectsResponseData(): |
// Encoding responses |
_resolveCallback(0), |
|
_binaryEncoding(false) |
|
{ |
|
} |
|
| |
Array<CIMObject>& getCIMObjects() |
// binary format used with Provider Agents and OP Clients |
{ |
void encodeBinaryResponse(CIMBuffer& out); |
_resolve(); |
// Xml format used with Provider Agents only |
return _cimObjects; |
void encodeInternalXmlResponse(CIMBuffer& out); |
} |
// official Xml format(CIM over Http) used to communicate to clients |
|
void encodeXmlResponse(Buffer& out); |
| |
const Array<CIMConstObject>& getCIMObjects() const |
//This function is called from buildResponce to set CIMResponcedata |
{ |
//with respective values of IncludeQualifiers,IncludeClassOrigin and |
// Resolve the instances before returning them. The resolve step |
//propertyFilter. |
// requires non-const access, but does not fundamentally change the |
void setRequestProperties( |
// message contents. |
const Boolean includeQualifiers, |
const_cast<CIMObjectsResponseData*>(this)->_resolve(); |
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList); |
| |
// The Array<CIMInstance> is masqueraded as an Array<CIMConstInstance> |
void setPropertyList(const CIMPropertyList& propertyList) |
// for expedience, since the internal representations are the same. |
|
return *((Array<CIMConstObject>*)(void*)&_cimObjects); |
|
} |
|
|
|
void setCIMObjects(const Array<CIMObject>& x) |
|
{ | { |
_resolveCallback = 0; |
_propertyList = propertyList; |
_cimObjects = x; |
|
} | } |
|
CIMPropertyList & getPropertyList() |
Array<Uint8>& getBinaryCimObjects() |
|
{ | { |
return _binaryData; |
return _propertyList; |
} | } |
| |
bool setBinaryCimObjects(CIMBuffer& in, bool hasLen=true); |
|
bool setXmlCimObjects(CIMBuffer& in); |
|
|
|
void encodeBinaryResponse(CIMBuffer& out) const; |
|
void encodeXmlResponse(Buffer& out) const; |
|
|
|
private: | private: |
| |
CIMObjectsResponseData(const CIMObjectsResponseData&); |
// helper functions to transform different formats into one-another |
CIMObjectsResponseData& operator=( |
// functions work on the internal data and calling of them should be |
const CIMObjectsResponseData&); |
// avoided |
|
|
static Boolean _resolveXMLObjects( |
void _resolveToCIM(); |
CIMObjectsResponseData* data, |
void _resolveToSCMO(); |
Array<CIMObject>& objects); |
|
|
void _resolveBinary(); |
static Boolean _resolveBinaryObjects( |
|
CIMObjectsResponseData* data, |
void _resolveXmlToSCMO(); |
Array<CIMObject>& objects); |
void _resolveXmlToCIM(); |
|
|
Boolean (*_resolveCallback)( |
void _resolveSCMOToCIM(); |
CIMObjectsResponseData* data, |
void _resolveCIMToSCMO(); |
Array<CIMObject>& cimObjects); |
|
|
// Helper functions for this class only, do NOT externalize |
|
SCMOInstance _getSCMOFromCIMInstance(const CIMInstance& cimInst); |
|
SCMOInstance _getSCMOFromCIMObject(const CIMObject& cimObj); |
|
SCMOInstance _getSCMOFromCIMObjectPath(const CIMObjectPath& cimPath); |
|
SCMOClass* _getSCMOClass(const char* ns,const char* cls); |
|
void _deserializeInstance(Uint32 idx,CIMInstance& cimInstance); |
|
void _deserializeObject(Uint32 idx,CIMObject& cimObject); |
|
Boolean _deserializeReference(Uint32 idx,CIMObjectPath& cimObjectPath); |
|
Boolean _deserializeInstanceName(Uint32 idx,CIMObjectPath& cimObjectPath); |
|
|
|
// Bitflags in this integer will reflect what data representation types |
|
// are currently stored in this CIMResponseData object |
|
Uint32 _encoding; |
|
|
|
// Storing type of data in this enumeration |
|
ResponseDataContent _dataType; |
|
|
|
// unused arrays are represented by ArrayRepBase _empty_rep |
|
// which is a 16 byte large static shared across all of them |
|
// so, even though this object looks large, it holds just |
|
// 2 integer and 9 pointers |
| |
void _resolve() |
|
{ |
|
if (_resolveCallback) |
|
{ |
|
(*_resolveCallback)(this, _cimObjects); |
|
_resolveCallback = 0; |
|
} |
|
} |
|
|
|
Boolean _binaryEncoding; |
|
|
|
// For XML encoding. |
|
// For XML encoding. | // For XML encoding. |
Array<ArraySint8> _cimObjectsData; |
|
Array<ArraySint8> _referencesData; | Array<ArraySint8> _referencesData; |
|
Array<ArraySint8> _instanceData; |
Array<String> _hostsData; | Array<String> _hostsData; |
Array<CIMNamespaceName> _nameSpacesData; | Array<CIMNamespaceName> _nameSpacesData; |
| |
|
|
// For binary encoding. | // For binary encoding. |
Array<Uint8> _binaryData; | Array<Uint8> _binaryData; |
|
CIMNamespaceName _defaultNamespace; |
|
String _defaultHostname; |
|
|
|
// Default C++ encoding |
|
Array<CIMObjectPath> _instanceNames; |
|
Array<CIMInstance> _instances; |
|
Array<CIMObject> _objects; |
|
|
|
// SCMO encoding |
|
Array<SCMOInstance> _scmoInstances; |
|
Boolean _includeQualifiers; |
|
Boolean _includeClassOrigin; |
|
CIMPropertyList _propertyList; |
| |
Array<CIMObject> _cimObjects; |
|
}; | }; |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |