1 //%2006////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //==============================================================================
32 //%/////////////////////////////////////////////////////////////////////////////
34 #include "CIMObjectRep.h"
36 #include <Pegasus/Common/CIMName.h>
37 #include <Pegasus/Common/MessageLoader.h>
39 PEGASUS_NAMESPACE_BEGIN
43 CIMObjectRep::CIMObjectRep()
47 CIMObjectRep::CIMObjectRep(const CIMObjectRep& x)
48 : Sharable(), _reference(x._reference),
49 _resolved(x._resolved)
51 x._qualifiers.cloneTo(_qualifiers);
53 _properties.reserveCapacity(x._properties.size());
55 for (Uint32 i = 0, n = x._properties.size(); i < n; i++)
57 _properties.append(x._properties[i].clone());
61 CIMObjectRep::CIMObjectRep(const CIMObjectPath& reference)
64 // ensure the class name is not null
65 if (reference.getClassName().isNull())
67 throw UninitializedObjectException();
70 _reference = reference;
73 CIMObjectRep::~CIMObjectRep()
77 void CIMObjectRep::addProperty(const CIMProperty& x)
79 if (x.isUninitialized())
81 throw UninitializedObjectException();
84 // Reject duplicate property names:
86 if (findProperty(x.getName()) != PEG_NOT_FOUND)
88 MessageLoaderParms parms(
89 "Common.CIMObjectRep.PROPERTY",
91 x.getName().getString());
93 throw AlreadyExistsException(parms);
98 _properties.append(x);
101 Uint32 CIMObjectRep::findProperty(const CIMName& name) const
103 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
105 if (name.equal(_properties[i].getName()))
111 return PEG_NOT_FOUND;
114 CIMProperty CIMObjectRep::getProperty(Uint32 index)
116 if (index >= _properties.size())
118 throw IndexOutOfBoundsException();
121 return _properties[index];
124 void CIMObjectRep::removeProperty(Uint32 index)
126 if (index >= _properties.size())
128 throw IndexOutOfBoundsException();
131 _properties.remove(index);
135 Uint32 CIMObjectRep::getPropertyCount() const
137 return _properties.size();
141 Boolean CIMObjectRep::identical(const CIMObjectRep* x) const
143 if (!_reference.identical(x->_reference))
148 if (!_qualifiers.identical(x->_qualifiers))
153 // Compare properties:
156 const Array<CIMProperty>& tmp1 = _properties;
157 const Array<CIMProperty>& tmp2 = x->_properties;
159 if (tmp1.size() != tmp2.size())
164 for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
166 if (!tmp1[i].identical(tmp2[i]))
173 if (_resolved != x->_resolved)
181 void CIMObjectRep::setPath(const CIMObjectPath& path)
183 // ensure the class name is not null
184 if (path.getClassName().isNull())
186 throw UninitializedObjectException();
189 // prevent changing the class name (type) in when updating the object path
190 if (!_reference.getClassName().equal(path.getClassName()))
192 throw TypeMismatchException();
198 PEGASUS_NAMESPACE_END