version 1.20, 2011/01/25 11:24:24
|
version 1.23, 2013/09/26 16:04:18
|
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
template<class REP> |
|
inline void Ref(REP* rep) |
|
{ |
|
rep->_refCounter++; |
|
} |
|
|
|
template<class REP> |
|
inline void Unref(REP* rep) |
|
{ |
|
if (rep->_refCounter.decAndTestIfZero()) |
|
delete rep; |
|
} |
|
|
CIMPropertyList::CIMPropertyList() | CIMPropertyList::CIMPropertyList() |
{ | { |
_rep = new CIMPropertyListRep(); | _rep = new CIMPropertyListRep(); |
_rep->isNull = true; |
|
} | } |
| |
CIMPropertyList::CIMPropertyList(const CIMPropertyList& x) | CIMPropertyList::CIMPropertyList(const CIMPropertyList& x) |
{ | { |
_rep = new CIMPropertyListRep(); |
_rep = x._rep; |
_rep->propertyNames = x._rep->propertyNames; |
Ref(_rep); |
_rep->isNull = x._rep->isNull; |
|
_rep->cimNameTags = x._rep->cimNameTags; |
|
} | } |
| |
CIMPropertyList::CIMPropertyList(const Array<CIMName>& propertyNames) |
static inline CIMPropertyListRep* _copyOnWriteCIMPropertyListRep( |
|
CIMPropertyListRep* rep) |
{ | { |
_rep = new CIMPropertyListRep(); |
if (rep->_refCounter.get() > 1) |
|
{ |
|
CIMPropertyListRep* tmpRep= new CIMPropertyListRep(*rep); |
|
Unref(rep); |
|
return tmpRep; |
|
} |
|
else |
|
{ |
|
return rep; |
|
} |
|
} |
| |
|
CIMPropertyList::CIMPropertyList(const Array<CIMName>& propertyNames) |
|
{ |
// ATTN: the following code is inefficient and problematic. besides | // ATTN: the following code is inefficient and problematic. besides |
// adding overhead to check for null property names, it has the | // adding overhead to check for null property names, it has the |
// disadvantage of returning an error if only 1 of n properties are null | // disadvantage of returning an error if only 1 of n properties are null |
|
|
throw UninitializedObjectException(); | throw UninitializedObjectException(); |
} | } |
} | } |
|
_rep = new CIMPropertyListRep(); |
_rep->propertyNames = propertyNames; | _rep->propertyNames = propertyNames; |
_rep->isNull = false; | _rep->isNull = false; |
} | } |
| |
CIMPropertyList::~CIMPropertyList() | CIMPropertyList::~CIMPropertyList() |
{ | { |
delete _rep; |
Unref(_rep); |
} | } |
| |
void CIMPropertyList::set(const Array<CIMName>& propertyNames) | void CIMPropertyList::set(const Array<CIMName>& propertyNames) |
|
|
throw UninitializedObjectException(); | throw UninitializedObjectException(); |
} | } |
} | } |
|
_rep = _copyOnWriteCIMPropertyListRep(_rep); |
| |
_rep->propertyNames = propertyNames; | _rep->propertyNames = propertyNames; |
|
_rep->cimNameTags.clear(); |
_rep->isNull = false; | _rep->isNull = false; |
|
_rep->isCimNameTagsUpdated = false; |
} | } |
| |
CIMPropertyList& CIMPropertyList::operator=(const CIMPropertyList& x) | CIMPropertyList& CIMPropertyList::operator=(const CIMPropertyList& x) |
{ | { |
if (&x != this) |
if (x._rep != _rep) |
{ | { |
_rep->propertyNames = x._rep->propertyNames; |
Unref(_rep); |
_rep->isNull = x._rep->isNull; |
_rep = x._rep; |
_rep->cimNameTags = x._rep->cimNameTags; |
Ref(_rep); |
|
|
} | } |
|
|
return *this; | return *this; |
} | } |
| |
void CIMPropertyList::clear() | void CIMPropertyList::clear() |
{ | { |
|
// If there is more than one reference |
|
// remove reference and get a new shiny empty representation |
|
if (_rep->_refCounter.get() > 1) |
|
{ |
|
Unref(_rep); |
|
_rep = new CIMPropertyListRep(); |
|
} |
|
else |
|
{ |
|
// If there is only one reference |
|
// no need to copy the data, we own it |
|
// just clear the fields |
_rep->propertyNames.clear(); | _rep->propertyNames.clear(); |
_rep->isNull = true; | _rep->isNull = true; |
if(_rep->isCimNameTagsUpdated) | if(_rep->isCimNameTagsUpdated) |
|
|
_rep->isCimNameTagsUpdated = false; | _rep->isCimNameTagsUpdated = false; |
} | } |
} | } |
|
} |
| |
Boolean CIMPropertyList::isNull() const | Boolean CIMPropertyList::isNull() const |
{ | { |
|
|
{ | { |
return _rep->propertyNames; | return _rep->propertyNames; |
} | } |
void CIMPropertyList::fillCIMNameTags() |
|
|
Uint32 CIMPropertyList::getCIMNameTag(Uint32 index) const |
|
{ |
|
return _rep->cimNameTags[index]; |
|
} |
|
void CIMPropertyList::append(Array<String> & propertyListArray) |
|
{ |
|
_rep = _copyOnWriteCIMPropertyListRep(_rep); |
|
Array<Uint32> cimNameTags; |
|
Array<CIMName> cimNameArray; |
|
for (Uint32 i = 0; i < propertyListArray.size(); i++) |
|
{ |
|
CIMName name(propertyListArray[i]); |
|
Uint32 tag = generateCIMNameTag(name); |
|
Boolean dupFound=false; |
|
for(Uint32 j=0;j<cimNameTags.size();j++) |
{ | { |
if((!_rep->isNull) && (!_rep->isCimNameTagsUpdated)) |
if ((tag == cimNameTags[j]) && (name == cimNameArray[j])) |
{ | { |
for(Uint32 i=0;i<_rep->propertyNames.size();i++) |
dupFound = true; |
|
break; |
|
} |
|
} |
|
if(!dupFound) |
{ | { |
_rep->cimNameTags.append( |
cimNameTags.append(tag); |
generateCIMNameTag(_rep->propertyNames[i])); |
cimNameArray.append(name); |
} | } |
|
} |
|
if(cimNameTags.size() != 0 ) |
|
{ |
|
_rep->cimNameTags.appendArray(cimNameTags); |
|
_rep->propertyNames = cimNameArray; |
_rep->isCimNameTagsUpdated = true; | _rep->isCimNameTagsUpdated = true; |
} | } |
|
_rep->isNull = false; |
} | } |
Uint32 CIMPropertyList::getCIMNameTag(Uint32 index) const |
|
|
void CIMPropertyList::appendCIMNameTag(Uint32 nameTag) |
{ | { |
return _rep->cimNameTags[index]; |
_rep = _copyOnWriteCIMPropertyListRep(_rep); |
|
_rep->cimNameTags.append(nameTag); |
} | } |
|
|
|
String CIMPropertyList::toString() const |
|
{ |
|
if (_rep->isNull) |
|
{ |
|
return("NULL"); |
|
} |
|
|
|
if (_rep->propertyNames.size() == 0) |
|
{ |
|
return("EMPTY"); |
|
} |
|
|
|
String rtn(_rep->propertyNames[0].getString()); |
|
for (Uint32 i = 1 ; i < _rep->propertyNames.size() ; i++) |
|
{ |
|
rtn.append(", "); |
|
rtn.append(_rep->propertyNames[i].getString()); |
|
} |
|
return(rtn); |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |