version 1.19, 2002/05/11 21:36:29
|
version 1.36, 2004/05/18 11:03:38
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2003//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
|
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
// Modified By: Karl schopmeyer (k.schopmeyer@opengroup.org) | // Modified By: Karl schopmeyer (k.schopmeyer@opengroup.org) |
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// Amit K Arora, IBM (amita@in.ibm.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include <Pegasus/Common/String.h> | #include <Pegasus/Common/String.h> |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/CIMType.h> | #include <Pegasus/Common/CIMType.h> |
#include <Pegasus/Common/CIMReference.h> |
#include <Pegasus/Common/CIMObjectPath.h> |
#include <Pegasus/Common/CIMDateTime.h> | #include <Pegasus/Common/CIMDateTime.h> |
#include <Pegasus/Common/Exception.h> | #include <Pegasus/Common/Exception.h> |
#include <Pegasus/Common/Array.h> | #include <Pegasus/Common/Array.h> |
|
#include <Pegasus/Common/Linkage.h> |
|
#include <Pegasus/Common/AutoPtr.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
| |
/** | /** |
The CIMValue class represents a value of any of the CIM data types | The CIMValue class represents a value of any of the CIM data types |
(see CIMType.h for a list of valid CIM data types). This class |
(see \Ref{CIMType} for a list of valid CIM data types). This class |
encapsulates a union which holds the current value. The class also | encapsulates a union which holds the current value. The class also |
has a type field indicating the type of that value. | has a type field indicating the type of that value. |
*/ | */ |
class PEGASUS_COMMON_LINKAGE CIMValue | class PEGASUS_COMMON_LINKAGE CIMValue |
{ | { |
public: | public: |
/** Constructor with no value. This constructor creates an NULL CIMValue |
/** Constructor - Creates an NULL CIMValue object set to null and |
object set to null and with type CIMType:none and !arraytype. |
with type CIMType:none and !arraytype. |
*/ | */ |
CIMValue(); | CIMValue(); |
| |
/** Constructor with only the Type. This constructor creates a NULL CIMValue |
/** Constructor - Creates a NULL CIMValue object with the type and |
object with the array indicator set as shown and with the |
array indicator set as specified. |
|
@exception TypeMismatchException If the given type is not valid for a |
|
CIMValue object. |
*/ | */ |
CIMValue(CIMType type, Boolean isArray, Uint32 arraySize = 0); | CIMValue(CIMType type, Boolean isArray, Uint32 arraySize = 0); |
| |
/** Constructor with the Value constructor and a value. This constructs a |
/// Constructor. |
CIMValue object with the type defined by the value constructor and the value |
|
installed |
|
<pre> |
|
ATTN: Add example |
|
</pre> |
|
*/ |
|
CIMValue(Boolean x); | CIMValue(Boolean x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Uint8 x); | CIMValue(Uint8 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Sint8 x); | CIMValue(Sint8 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Uint16 x); | CIMValue(Uint16 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Sint16 x); | CIMValue(Sint16 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Uint32 x); | CIMValue(Uint32 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Sint32 x); | CIMValue(Sint32 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Uint64 x); | CIMValue(Uint64 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Sint64 x); | CIMValue(Sint64 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Real32 x); | CIMValue(Real32 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(Real64 x); | CIMValue(Real64 x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Char16& x); | CIMValue(const Char16& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const String& x); | CIMValue(const String& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const char* x); |
|
|
|
/// Constructor |
|
CIMValue(const CIMDateTime& x); | CIMValue(const CIMDateTime& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const CIMReference& x); |
CIMValue(const CIMObjectPath& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Boolean>& x); | CIMValue(const Array<Boolean>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Uint8>& x); | CIMValue(const Array<Uint8>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Sint8>& x); | CIMValue(const Array<Sint8>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Uint16>& x); | CIMValue(const Array<Uint16>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Sint16>& x); | CIMValue(const Array<Sint16>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Uint32>& x); | CIMValue(const Array<Uint32>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Sint32>& x); | CIMValue(const Array<Sint32>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Uint64>& x); | CIMValue(const Array<Uint64>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Sint64>& x); | CIMValue(const Array<Sint64>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Real32>& x); | CIMValue(const Array<Real32>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Real64>& x); | CIMValue(const Array<Real64>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<Char16>& x); | CIMValue(const Array<Char16>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<String>& x); | CIMValue(const Array<String>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<CIMDateTime>& x); | CIMValue(const Array<CIMDateTime>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const Array<CIMReference>& x); |
CIMValue(const Array<CIMObjectPath>& x); |
| |
/// Constructor |
/// Constructor. |
CIMValue(const CIMValue& x); | CIMValue(const CIMValue& x); |
| |
/// Destructor |
/// Destructor. |
~CIMValue(); | ~CIMValue(); |
| |
/// Operator = | /// Operator = |
CIMValue& operator=(const CIMValue& x); | CIMValue& operator=(const CIMValue& x); |
| |
/** assign - The method to assign one CIMValue object to another CIMValue |
/** Assigns one CIMValue object to another CIMValue object. |
object. |
@param x - CIMValue object to be used for assignment. |
*/ | */ |
void assign(const CIMValue& x); | void assign(const CIMValue& x); |
| |
/** clear - Clears the attributes and value of the CIMValue object. |
/** Clears the attributes and value of the CIMValue object. |
<pre> |
|
ATTNDOC: |
|
</pre> |
|
*/ | */ |
void clear(); | void clear(); |
| |
/** typeCompatible - Compares the types of two CIMvalues. This |
/** Compares the types of two CIMValues. This |
compares the type field and the array indicators. | compares the type field and the array indicators. |
@return true if both are of the same type and both are either arrays | @return true if both are of the same type and both are either arrays |
or not. Else returns false. |
or not, false otherwise. |
<pre> | <pre> |
CIMValue a(Boolean(true); | CIMValue a(Boolean(true); |
CIMValue b = a; | CIMValue b = a; |
|
|
*/ | */ |
Boolean typeCompatible(const CIMValue& x) const; | Boolean typeCompatible(const CIMValue& x) const; |
| |
/** isArray - Determines if the value is an array |
/** Determines if the value is an array. |
@return TRUE if the value is an array |
@return true if the value is an array, false otherwise. |
*/ | */ |
Boolean isArray() const; | Boolean isArray() const; |
| |
/** Returns whether the CIMvalue object is Null. |
/** Determines whether the CIMvalue object is Null. |
Null is the specific condition where no value has | Null is the specific condition where no value has |
yet been set into the value. |
yet been set. If a CIMValue object is Null, any get on that |
If a CIMValue object is Null, any get on that object |
object will create an exception. |
will create an exception. |
@return true if the CIMValue object is Null, false otherwise. |
@return Returns True if the CIMValue object is Null |
|
*/ | */ |
Boolean isNull() const; | Boolean isNull() const; |
| |
/** getArraySize = Returns the size of an Array CIMValue |
/** Gets the size of an Array CIMValue. |
@return The number of entries in the array |
@return The number of entries in the array. |
*/ | */ |
Uint32 getArraySize() const; | Uint32 getArraySize() const; |
| |
/** getType - Gets the CIMType attribute for the CIMValue. |
/** Gets the CIMType attribute for the CIMValue. |
The CIMType is defined in ATTN: |
@return the CIMType value. |
@return Returns the CIMType value |
|
*/ | */ |
CIMType getType() const; | CIMType getType() const; |
| |
/** setNullValue - Sets the CIMType, the Array indicator and if it is |
/** Sets the CIMValue a NULL, but with valid CIMType and array |
the arraytype, the Arraysize of a CIMValue and sets the isNull |
characteristics. |
Attribute. This function is used to set up CIMValues an NULL but |
@param type - CIMType for this CIMValue. |
with valid CIMType and array characteristics (ex. when update from |
@param isArray - Boolean indicating whether this is an array CIMValue. |
XML) |
@param arraySize - Optional parameter indicating the array size. |
@param type - The CIMType for this CIMValue |
|
@param isArray - Boolean indicating whether this is an array CIMValue |
|
@param arraySize (optional) Uint32 parameter indicating the array |
|
size |
|
@return void |
|
<pre> | <pre> |
CIMValue value; // Create a CIMValue object |
CIMValue value; |
value.setNullValue(CIMType::BOOLEAN, false); // Set it |
value.setNullValue(CIMType::BOOLEAN, false); |
</pre> | </pre> |
*/ | */ |
void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0); | void setNullValue(CIMType type, Boolean isArray, Uint32 arraySize = 0); |
| |
/** set - Sets the type, Array attribute and puts the value provided |
/** Sets the type, Array attribute and puts the value provided |
into the value of the target CIMValue. This function sets the |
into the value of the target CIMValue. |
CIMValue to nonNull also. The result is a complete CIMValue object |
|
All of the CIMTypes defined in ATTN: and the Array types defined in |
|
ATTN: may be set. |
|
@param x Typed value (ex. Boolean(true). |
|
@return void |
|
<pre> | <pre> |
CIMValue x; | CIMValue x; |
x.set(Uint16(9)); | x.set(Uint16(9)); |
|
|
*/ | */ |
void set(Boolean x); | void set(Boolean x); |
| |
/// Set |
/// |
void set(Uint8 x); | void set(Uint8 x); |
/// | /// |
void set(Sint8 x); | void set(Sint8 x); |
|
|
/// | /// |
void set(const String& x); | void set(const String& x); |
/// | /// |
void set(const char* x); |
|
/// |
|
void set(const CIMDateTime& x); | void set(const CIMDateTime& x); |
/// | /// |
void set(const CIMReference& x); |
void set(const CIMObjectPath& x); |
/// | /// |
void set(const Array<Boolean>& x); | void set(const Array<Boolean>& x); |
/// | /// |
|
|
/// | /// |
void set(const Array<CIMDateTime>& x); | void set(const Array<CIMDateTime>& x); |
/// | /// |
void set(const Array<CIMReference>& x); |
void set(const Array<CIMObjectPath>& x); |
| |
/** get - Gets the value of a CIMValue |
/** Gets the value of a CIMValue. |
@param Variable in which we return the value: |
Note: Before using get, the caller should use getType () and isNull () |
@return void |
to ensure that the value is not null, and is of the correct type. |
|
|
|
@param Variable in which to return the value. |
|
@exception TypeMismatchException If the CIMValue type is not compatible |
|
with the type of the output parameter. |
<pre> | <pre> |
Uint32 v; | Uint32 v; |
CIMValue value(CIMValue::UINT32, UINT32(99)); | CIMValue value(CIMValue::UINT32, UINT32(99)); |
value.get(v); | value.get(v); |
</pre> | </pre> |
|
|
|
<pre> |
|
Uint32 v; |
|
CIMValue value = property.getValue (); |
|
if ((value.getType () == CIMTYPE_UINT32) && (!value.isNull ())) |
|
value.get (v); |
|
</pre> |
*/ | */ |
void get(Boolean& x) const; | void get(Boolean& x) const; |
/// | /// |
|
|
/// | /// |
void get(CIMDateTime& x) const; | void get(CIMDateTime& x) const; |
/// | /// |
void get(CIMReference& x) const; |
void get(CIMObjectPath& x) const; |
/// | /// |
void get(Array<Boolean>& x) const; | void get(Array<Boolean>& x) const; |
/// | /// |
|
|
/// | /// |
void get(Array<CIMDateTime>& x) const; | void get(Array<CIMDateTime>& x) const; |
/// | /// |
void get(Array<CIMReference>& x) const; |
void get(Array<CIMObjectPath>& x) const; |
|
|
/** toXML - Converts a CIMValue object to XML. The XML is appended |
|
to the Array provided with the call. Returns the result as an |
|
XML element wrapped in the <VALUE>, <VALUE.ARRAY>, <VALUE.REFERENCE>, |
|
or <VALUE.REFARRAY> tags. If the CIMValue is Null, no element is |
|
returned. |
|
@param out Sint8 Array to hold the XML representation |
|
@return Returns the XML representation of the CIMValue |
|
object in the input parameter out. |
|
*/ |
|
void toXml(Array<Sint8>& out) const; |
|
|
|
/** toXML - Converts a CIMValue object to XML. There is no input |
|
parameter and the result is returned as a String rather |
|
than appended to an 8-bit array as above. Returns the |
|
element as value wrapped in the <VALUE>, <VALUE.ARRAY>, |
|
<VALUE.REFERENCE>, or <VALUE.REFARRAY> tags. If the |
|
CIMValue is Null, no element is returned. |
|
@return Returns the XML representation of the CIMValue |
|
object in String form. |
|
*/ |
|
String toXml() const; |
|
|
|
/** CIMMethod print - Format and print the Value as XML to std output |
|
stream |
|
@param o Stream to output to. Defaults to cout. |
|
@return None |
|
<PRE> |
|
Example: |
|
CIMValue value(Boolean(true)); |
|
value.print(); // Prints "true" |
|
</PRE> |
|
*/ |
|
void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const; |
|
| |
/** toMof - Converts a CIMValueObject to Mof. |
/** Compares with another CIMValue object for equality. |
@out Sint8 Array to hold the Mof representation |
@param x - CIMValue to compare with. |
@return Returns the Mof representation of the CIMValue |
@return true if they are identical in type, attribute and value, |
object in the input parameter out. |
false otherwise. |
*/ | */ |
void toMof(Array<Sint8>& out) const; |
Boolean equal(const CIMValue& x) const; |
| |
/** toString - Converts the CIMvalue to a string. Should only be |
/** Converts the CIMvalue to a string. Should only be |
used for output purposes. To get an actual String value, use | used for output purposes. To get an actual String value, use |
get(String &). | get(String &). |
@return - String output for CIMValue. |
@return String output for CIMValue. |
@exception - Throws exception CIMValueInvalidType if the CIMValue |
|
has an invalid type. Normally this is a Pegasus internal error. |
|
<PRE> | <PRE> |
Example: |
|
String test; | String test; |
CIMValue value(Boolean(true)); | CIMValue value(Boolean(true)); |
test = value.toString(); // puts "TRUE" into test | test = value.toString(); // puts "TRUE" into test |
|
|
| |
private: | private: |
| |
CIMValueRep* _rep; |
AutoPtr<CIMValueRep> _rep;//PEP101 |
| |
friend class CIMMethodRep; | friend class CIMMethodRep; |
friend class CIMParameterRep; | friend class CIMParameterRep; |
friend class CIMPropertyRep; | friend class CIMPropertyRep; |
friend class CIMQualifierRep; | friend class CIMQualifierRep; |
friend class CIMQualifierDeclRep; | friend class CIMQualifierDeclRep; |
PEGASUS_COMMON_LINKAGE friend Boolean operator==( |
|
const CIMValue& x, |
|
const CIMValue& y); |
|
}; | }; |
| |
/** operator == compares two CIMValue objects for equality. | /** operator == compares two CIMValue objects for equality. |
@param x - First CIMvalue to compare |
@param x - First CIMValue to compare |
@parm y - Second CIMValue to compare |
@param y - Second CIMValue to compare |
@return True if they are identical in type, attribute and value. |
@return true if they are identical in type, attribute and value, |
|
false otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y); | PEGASUS_COMMON_LINKAGE Boolean operator==(const CIMValue& x, const CIMValue& y); |
| |
/** operator != compares two CIMValue objects for nonequality |
/** operator != compares two CIMValue objects for inequality. |
|
@param x - First CIMValue to compare |
|
@param y - Second CIMValue to compare |
|
@return true if they are NOT identical in type, attribute or value, |
|
false otherwise. |
*/ | */ |
PEGASUS_COMMON_LINKAGE Boolean operator!=(const CIMValue& x, const CIMValue& y); | PEGASUS_COMMON_LINKAGE Boolean operator!=(const CIMValue& x, const CIMValue& y); |
| |
#define PEGASUS_ARRAY_T CIMValue | #define PEGASUS_ARRAY_T CIMValue |
# include "ArrayInter.h" |
# include <Pegasus/Common/ArrayInter.h> |
#undef PEGASUS_ARRAY_T | #undef PEGASUS_ARRAY_T |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |