version 1.6.2.2, 2011/10/11 18:18:08
|
version 1.6.2.5, 2013/06/05 19:14:16
|
|
|
// | // |
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// |
// | // |
|
// Class CIMResponseData encapsulates the possible types of response data |
|
// representations and supplies conversion methods between these types. |
|
// PEP#348 - The CMPI infrastructure using SCMO (Single Chunk Memory Objects) |
|
// describes its usage in the server flow. |
|
// 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 Pegasus_CIMResponseData_h | #ifndef Pegasus_CIMResponseData_h |
|
|
#include <Pegasus/Common/SCMOClass.h> | #include <Pegasus/Common/SCMOClass.h> |
#include <Pegasus/Common/SCMOInstance.h> | #include <Pegasus/Common/SCMOInstance.h> |
#include <Pegasus/Common/SCMODump.h> | #include <Pegasus/Common/SCMODump.h> |
|
#include <Pegasus/Common/Mutex.h> // KS_TODO Remove |
#include <Pegasus/Common/Magic.h> | #include <Pegasus/Common/Magic.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
|
|
|
// The following is a Trace tool that traces ALL cimResponseData calls |
|
// when enabled |
|
// KS_TODO _ Delete this |
|
//#define TRACELINE cout << __FILE__ << ":" << __LINE__ << endl; |
|
#define TRACELINE |
|
|
typedef Array<Sint8> ArraySint8; | typedef Array<Sint8> ArraySint8; |
#define PEGASUS_ARRAY_T ArraySint8 | #define PEGASUS_ARRAY_T ArraySint8 |
# include <Pegasus/Common/ArrayInter.h> | # include <Pegasus/Common/ArrayInter.h> |
#undef PEGASUS_ARRAY_T | #undef PEGASUS_ARRAY_T |
| |
|
//// KS_TODO REMOVE THIS _Temp test for size validity DELETE when done |
|
#define PSVALID PEGASUS_ASSERT(sizeValid()); |
|
/* |
|
#define PSVALID {printf("PSVALID Error line %u\n",__LINE__); \ |
|
PEGASUS_ASSERT(sizeValid());} |
|
#define PSVALID {if(!sizeValid(){printf("PSVALID Error line %u\n",__LINE__); |
|
PEGASUS_ASSERT(false);}} |
|
*/ |
class PEGASUS_COMMON_LINKAGE CIMResponseData | class PEGASUS_COMMON_LINKAGE CIMResponseData |
{ | { |
public: | public: |
|
|
}; | }; |
//includeClassOrigin & _includeQualifiers are set to true by default. | //includeClassOrigin & _includeQualifiers are set to true by default. |
//_propertyList is initialized to an empty propertylist to enable | //_propertyList is initialized to an empty propertylist to enable |
// sending all properties by default. |
// sending all properties by default. _isClassOperation set false and |
|
// only reset by selected operations (ex. associator response builder) |
CIMResponseData(ResponseDataContent content): | CIMResponseData(ResponseDataContent content): |
_encoding(0),_mapObjectsToIntances(false),_dataType(content), _size(0), |
_encoding(0),_dataType(content),_size(0), _includeQualifiers(true), |
_includeQualifiers(true),_includeClassOrigin(true), |
_includeClassOrigin(true), |
|
_isClassOperation(false), |
_propertyList(CIMPropertyList()) | _propertyList(CIMPropertyList()) |
{ | { |
PEGASUS_ASSERT(valid()); // KS_TEMP |
/// KS_TODO the following is all test code. |
|
TRACELINE; |
|
PEGASUS_ASSERT(valid()); // KS_TEMP KS_TODO DELETE THIS |
|
size(); |
} | } |
| |
CIMResponseData(const CIMResponseData & x): | CIMResponseData(const CIMResponseData & x): |
|
|
_scmoInstances(x._scmoInstances), | _scmoInstances(x._scmoInstances), |
_includeQualifiers(x._includeQualifiers), | _includeQualifiers(x._includeQualifiers), |
_includeClassOrigin(x._includeClassOrigin), | _includeClassOrigin(x._includeClassOrigin), |
|
_isClassOperation(x._isClassOperation), |
_propertyList(x._propertyList), | _propertyList(x._propertyList), |
_magic(x._magic) | _magic(x._magic) |
{ | { |
|
TRACELINE; |
/////PEGASUS_ASSERT(x.valid()); // KS_TEMP | /////PEGASUS_ASSERT(x.valid()); // KS_TEMP |
PEGASUS_ASSERT(valid()); // KS_TEMP | PEGASUS_ASSERT(valid()); // KS_TEMP |
|
size(); |
} | } |
| |
// Construct an empty object. Issue here in that we would like to | // Construct an empty object. Issue here in that we would like to |
|
|
_encoding(0),_mapObjectsToIntances(false), _size(0), | _encoding(0),_mapObjectsToIntances(false), _size(0), |
_includeQualifiers(true), _includeClassOrigin(true), | _includeQualifiers(true), _includeClassOrigin(true), |
_propertyList(CIMPropertyList()) | _propertyList(CIMPropertyList()) |
{} |
{ |
|
TRACELINE; |
|
size(); //// TODOD remove temp |
|
} |
| |
/** | /** |
* Move CIM objects from another CIMResponse data object to this | * Move CIM objects from another CIMResponse data object to this |
|
|
{ | { |
} | } |
| |
// This one may be a hack but we have issue with pull and other operations |
// Issue with pull and other operations |
// in that the other assoc operations return objects and objectPaths | // in that the other assoc operations return objects and objectPaths |
// and the pulls return instances and instancePaths). The pull operation |
// and the pulls return instances and instancePaths. The pull operation |
// must be able to handle either so we use this to reset the datatype | // must be able to handle either so we use this to reset the datatype |
// KS_TODO -- This should check size and only allow if nothing in the | // KS_TODO -- This should check size and only allow if nothing in the |
// object. | // object. |
Boolean setDataType(ResponseDataContent content) | Boolean setDataType(ResponseDataContent content) |
{ | { |
|
TRACELINE; |
PEGASUS_ASSERT(valid()); | PEGASUS_ASSERT(valid()); |
PEGASUS_ASSERT(_size == 0); // KS_TODO_TEMP or debug mode. | PEGASUS_ASSERT(_size == 0); // KS_TODO_TEMP or debug mode. |
_dataType = content; | _dataType = content; |
|
|
// get the datatype property | // get the datatype property |
ResponseDataContent getResponseDataContent() | ResponseDataContent getResponseDataContent() |
{ | { |
|
TRACELINE; |
PEGASUS_ASSERT(valid()); // KS_TEMP KS_TODO | PEGASUS_ASSERT(valid()); // KS_TEMP KS_TODO |
return _dataType; | return _dataType; |
} | } |
|
|
| |
void setInstanceNames(const Array<CIMObjectPath>& x) | void setInstanceNames(const Array<CIMObjectPath>& x) |
{ | { |
|
TRACELINE; |
_instanceNames=x; | _instanceNames=x; |
_encoding |= RESP_ENC_CIM; | _encoding |= RESP_ENC_CIM; |
_size += x.size(); | _size += x.size(); |
|
|
| |
void setInstance(const CIMInstance& x) | void setInstance(const CIMInstance& x) |
{ | { |
SVALID(); |
TRACELINE; |
|
PSVALID; |
_instances.clear(); | _instances.clear(); |
_instances.append(x); | _instances.append(x); |
_size++; | _size++; |
_encoding |= RESP_ENC_CIM; | _encoding |= RESP_ENC_CIM; |
| |
SVALID(); |
PSVALID; |
} | } |
| |
// Instances handling | // Instances handling |
|
|
| |
void setInstances(const Array<CIMInstance>& x) | void setInstances(const Array<CIMInstance>& x) |
{ | { |
SVALID(); |
TRACELINE; |
|
PSVALID; |
_instances=x; | _instances=x; |
_encoding |= RESP_ENC_CIM; | _encoding |= RESP_ENC_CIM; |
_size += x.size(); | _size += x.size(); |
SVALID(); |
PSVALID; |
} | } |
| |
void appendInstance(const CIMInstance& x) | void appendInstance(const CIMInstance& x) |
{ | { |
|
TRACELINE; |
PEGASUS_ASSERT(valid()); | PEGASUS_ASSERT(valid()); |
_instances.append(x); | _instances.append(x); |
_encoding |= RESP_ENC_CIM; | _encoding |= RESP_ENC_CIM; |
|
|
| |
void appendInstances(const Array<CIMInstance>& x) | void appendInstances(const Array<CIMInstance>& x) |
{ | { |
|
TRACELINE; |
PEGASUS_ASSERT(valid()); | PEGASUS_ASSERT(valid()); |
_instances.appendArray(x); | _instances.appendArray(x); |
_encoding |= RESP_ENC_CIM; | _encoding |= RESP_ENC_CIM; |
|
|
Array<CIMObject>& getObjects(); | Array<CIMObject>& getObjects(); |
void setObjects(const Array<CIMObject>& x) | void setObjects(const Array<CIMObject>& x) |
{ | { |
|
TRACELINE; |
PEGASUS_ASSERT(valid()); | PEGASUS_ASSERT(valid()); |
_objects=x; | _objects=x; |
_encoding |= RESP_ENC_CIM; | _encoding |= RESP_ENC_CIM; |
|
|
} | } |
void appendObject(const CIMObject& x) | void appendObject(const CIMObject& x) |
{ | { |
|
TRACELINE; |
PEGASUS_ASSERT(valid()); | PEGASUS_ASSERT(valid()); |
_objects.append(x); | _objects.append(x); |
_encoding |= RESP_ENC_CIM; | _encoding |= RESP_ENC_CIM; |
|
|
| |
void appendSCMO(const Array<SCMOInstance>& x) | void appendSCMO(const Array<SCMOInstance>& x) |
{ | { |
|
TRACELINE; |
PEGASUS_ASSERT(valid()); | PEGASUS_ASSERT(valid()); |
_scmoInstances.appendArray(x); | _scmoInstances.appendArray(x); |
_encoding |= RESP_ENC_SCMO; | _encoding |= RESP_ENC_SCMO; |
|
|
const Boolean includeClassOrigin, | const Boolean includeClassOrigin, |
const CIMPropertyList& propertyList); | const CIMPropertyList& propertyList); |
| |
|
// Used with association and reference operations (i.e. operations that |
|
// return CIMObject or CIMObjectPath to set a parameter to define whether |
|
// responseData is for operation on a class or instance. |
|
// Allows building the correct path (classPath or instancePath) and |
|
// object type (Class or Instance) on response. |
|
void setIsClassOperation(Boolean b); |
|
|
void setPropertyList(const CIMPropertyList& propertyList) | void setPropertyList(const CIMPropertyList& propertyList) |
{ | { |
|
TRACELINE; |
_propertyList = propertyList; | _propertyList = propertyList; |
} | } |
CIMPropertyList & getPropertyList() | CIMPropertyList & getPropertyList() |
{ | { |
|
TRACELINE; |
return _propertyList; | return _propertyList; |
} | } |
| |
void SVALID(); //KS_TEMP |
bool sizeValid(); //KS_TEMP KS_TODO REMOVE |
| |
private: | private: |
| |
|
|
SCMOInstance _getSCMOFromCIMObject(const CIMObject& cimObj); | SCMOInstance _getSCMOFromCIMObject(const CIMObject& cimObj); |
SCMOInstance _getSCMOFromCIMObjectPath(const CIMObjectPath& cimPath); | SCMOInstance _getSCMOFromCIMObjectPath(const CIMObjectPath& cimPath); |
SCMOClass* _getSCMOClass(const char* ns,const char* cls); | 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 | // Bitflags in this integer will reflect what data representation types |
// are currently stored in this CIMResponseData object | // are currently stored in this CIMResponseData object |
|
|
| |
// SCMO encoding | // SCMO encoding |
Array<SCMOInstance> _scmoInstances; | Array<SCMOInstance> _scmoInstances; |
|
|
|
// Request characteristics that are carried through operation for |
|
// modification of response generation. |
Boolean _includeQualifiers; | Boolean _includeQualifiers; |
Boolean _includeClassOrigin; | Boolean _includeClassOrigin; |
|
// Defines whether response CIMObjects or ObjectPaths are class or instance. |
|
// because associators, etc. operations provide both class and instance |
|
// responses. Default is false and should only be set to true by |
|
// operation requests such as associators (which could return either |
|
// instances or classes) when the operation is to return class information. |
|
Boolean _isClassOperation; |
CIMPropertyList _propertyList; | CIMPropertyList _propertyList; |
| |
|
Mutex testLock; |
|
|
// magic number to use with valid function to confirm validity | // magic number to use with valid function to confirm validity |
// of response data. | // of response data. |
Magic<0x57D11323> _magic; | Magic<0x57D11323> _magic; |
|
|
}; | }; |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |