1 karl 1.25 //%2005////////////////////////////////////////////////////////////////////////
|
2 mike 1.1 //
|
3 karl 1.24 // 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 karl 1.23 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.24 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.25 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mike 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
13 chip 1.2 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
16 mike 1.1 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
|
18 chip 1.26 //
|
19 chip 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
20 mike 1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
22 chip 1.2 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
25 mike 1.1 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Mike Brasher (mbrasher@bmc.com)
31 //
|
32 chip 1.26 // Modified By:
33 // Carol Ann Krug Graves, Hewlett-Packard Company (carolann_graves@hp.com)
34 // Chip Vincent (cvincent@us.ibm.com)
|
35 aruran.ms 1.27 // Aruran, IBM (ashanmug@in.ibm.com) for BUG# 3476
|
36 mike 1.1 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 #include "CIMObjectRep.h"
|
40 chip 1.26
41 #include <Pegasus/Common/CIMName.h>
|
42 humberto 1.22 #include <Pegasus/Common/MessageLoader.h> //l10n
|
43 mike 1.1
|
44 chip 1.26 PEGASUS_NAMESPACE_BEGIN
45
|
46 mike 1.1 PEGASUS_USING_STD;
47
|
48 chip 1.26 CIMObjectRep::CIMObjectRep()
49 {
50 }
51
52 CIMObjectRep::CIMObjectRep(const CIMObjectRep& x)
|
53 aruran.ms 1.27 : Sharable(), _reference(x._reference),
|
54 chip 1.26 _resolved(x._resolved)
55 {
56 x._qualifiers.cloneTo(_qualifiers);
57
58 _properties.reserveCapacity(x._properties.size());
59
60 for (Uint32 i = 0, n = x._properties.size(); i < n; i++)
61 {
62 _properties.append(x._properties[i].clone());
63 }
64 }
|
65 mike 1.1
|
66 kumpf 1.10 CIMObjectRep::CIMObjectRep(const CIMObjectPath& reference)
|
67 chip 1.28 : _resolved(false)
|
68 mike 1.1 {
|
69 chip 1.28 // ensure the class name is not null
70 if(reference.getClassName().isNull())
71 {
72 throw UninitializedObjectException();
73 }
74
75 _reference = reference;
|
76 mike 1.1 }
77
78 CIMObjectRep::~CIMObjectRep()
79 {
80 }
81
82 void CIMObjectRep::addProperty(const CIMProperty& x)
83 {
|
84 kumpf 1.16 if (x.isUninitialized())
|
85 chip 1.26 {
86 throw UninitializedObjectException();
87 }
|
88 mike 1.1
89 // Reject duplicate property names:
90
|
91 chip 1.26 if (findProperty(x.getName()) != PEG_NOT_FOUND)
92 {
93 MessageLoaderParms parms(
94 "Common.CIMObjectRep.PROPERTY",
95 "property \"$0\"",
96 x.getName().getString());
97
|
98 humberto 1.22 throw AlreadyExistsException(parms);
99 }
|
100 mike 1.1
101 // Append property:
102
103 _properties.append(x);
104 }
105
|
106 kumpf 1.15 Uint32 CIMObjectRep::findProperty(const CIMName& name) const
|
107 mike 1.1 {
108 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
109 {
|
110 chip 1.26 if (name.equal(_properties[i].getName()))
111 {
112 return(i);
113 }
|
114 mike 1.1 }
115
|
116 chip 1.26 return(PEG_NOT_FOUND);
|
117 mike 1.1 }
118
|
119 kumpf 1.20 CIMProperty CIMObjectRep::getProperty(Uint32 index)
|
120 mike 1.1 {
|
121 kumpf 1.20 if (index >= _properties.size())
|
122 chip 1.26 {
123 throw IndexOutOfBoundsException();
124 }
|
125 mike 1.1
|
126 chip 1.26 return(_properties[index]);
|
127 mike 1.1 }
128
|
129 kumpf 1.20 void CIMObjectRep::removeProperty(Uint32 index)
|
130 chip 1.26 {
131 if (index >= _properties.size())
|
132 mike 1.1 {
|
133 chip 1.26 throw IndexOutOfBoundsException();
|
134 mike 1.1 }
135
|
136 chip 1.26 _properties.remove(index);
|
137 mike 1.1 }
138
139
|
140 chip 1.26 Uint32 CIMObjectRep::getPropertyCount() const
|
141 mike 1.1 {
|
142 chip 1.26 return(_properties.size());
|
143 mike 1.1 }
144
145
146 Boolean CIMObjectRep::identical(const CIMObjectRep* x) const
147 {
|
148 chip 1.4 if (!_reference.identical(x->_reference))
|
149 chip 1.26 {
150 return(false);
151 }
|
152 mike 1.1
153 if (!_qualifiers.identical(x->_qualifiers))
|
154 chip 1.26 {
155 return(false);
156 }
|
157 mike 1.1
158 // Compare properties:
159
160 {
|
161 chip 1.26 const Array<CIMProperty>& tmp1 = _properties;
162 const Array<CIMProperty>& tmp2 = x->_properties;
|
163 mike 1.1
|
164 chip 1.26 if (tmp1.size() != tmp2.size())
165 {
166 return(false);
167 }
168
169 for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
170 {
171 if (!tmp1[i].identical(tmp2[i]))
172 {
173 return(false);
174 }
175 }
|
176 mike 1.1 }
177
178 if (_resolved != x->_resolved)
|
179 chip 1.26 {
180 return(false);
181 }
|
182 mike 1.1
|
183 chip 1.26 return(true);
|
184 kumpf 1.11 }
185
|
186 chip 1.28 void CIMObjectRep::setPath(const CIMObjectPath& path)
|
187 kumpf 1.11 {
|
188 chip 1.28 // ensure the class name is not null
189 if(path.getClassName().isNull())
190 {
191 throw UninitializedObjectException();
192 }
193
|
194 chip 1.26 // prevent changing the class name (type) in when updating the object path
195 if(!_reference.getClassName().equal(path.getClassName()))
196 {
197 throw TypeMismatchException();
198 }
199
|
200 kumpf 1.11 _reference = path;
|
201 mike 1.1 }
202
203 PEGASUS_NAMESPACE_END
|