1 //%/////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //==============================================================================
23 // Author: Mike Brasher (mbrasher@bmc.com)
27 //%/////////////////////////////////////////////////////////////////////////////
29 #include "CIMObjectRep.h"
33 PEGASUS_NAMESPACE_BEGIN
35 CIMObjectRep::CIMObjectRep(const CIMReference& reference)
36 : _reference(reference), _resolved(false)
40 CIMObjectRep::~CIMObjectRep()
45 void CIMObjectRep::addProperty(const CIMProperty& x)
48 throw UnitializedHandle();
50 // Reject duplicate property names:
52 if (findProperty(x.getName()) != PEG_NOT_FOUND)
53 throw AlreadyExists();
57 _properties.append(x);
60 Uint32 CIMObjectRep::findProperty(const String& name)
62 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
64 if (CIMName::equal(_properties[i].getName(), name))
71 Boolean CIMObjectRep::existsProperty(const String& name)
73 return (findProperty(name) == PEG_NOT_FOUND) ? false : true;
76 CIMProperty CIMObjectRep::getProperty(Uint32 pos)
78 if (pos >= _properties.size())
81 return _properties[pos];
84 void CIMObjectRep::removeProperty(Uint32 pos)
86 if (pos >= _properties.size())
89 _properties.remove(pos);
93 Uint32 CIMObjectRep::getPropertyCount() const
95 return _properties.size();
99 CIMObjectRep::CIMObjectRep()
104 CIMObjectRep::CIMObjectRep(const CIMObjectRep& x) :
106 _reference(x._reference),
107 _resolved(x._resolved)
109 x._qualifiers.cloneTo(_qualifiers);
111 _properties.reserve(x._properties.size());
113 for (Uint32 i = 0, n = x._properties.size(); i < n; i++)
114 _properties.append(x._properties[i].clone(true));
117 Boolean CIMObjectRep::identical(const CIMObjectRep* x) const
119 if (!_reference.identical(x->_reference))
122 if (!_qualifiers.identical(x->_qualifiers))
125 // Compare properties:
128 const Array<CIMProperty>& tmp1 = _properties;
129 const Array<CIMProperty>& tmp2 = x->_properties;
131 if (tmp1.size() != tmp2.size())
134 for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
136 if (!tmp1[i].identical(tmp2[i]))
141 if (_resolved != x->_resolved)
147 PEGASUS_NAMESPACE_END