1 karl 1.37 //%2005////////////////////////////////////////////////////////////////////////
|
2 mike 1.10 //
|
3 karl 1.35 // 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.34 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.35 // 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.37 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mike 1.10 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
13 kumpf 1.26 // 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.10 // 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.38 //
|
19 kumpf 1.26 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
20 mike 1.10 // 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 kumpf 1.26 // 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.10 // 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 kumpf 1.27 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
|
33 david.dillard 1.36 // (carolann_graves@hp.com)
34 // David Dillard, VERITAS Software Corp.
35 // (david.dillard@veritas.com)
|
36 mike 1.10 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 #include "CIMQualifier.h"
|
40 kumpf 1.19 #include "CIMQualifierRep.h"
|
41 mike 1.10 #include "Indentor.h"
42 #include "CIMName.h"
|
43 kumpf 1.32 #include "InternalException.h"
|
44 mike 1.10 #include "XmlWriter.h"
|
45 kumpf 1.24 #include "MofWriter.h"
|
46 mike 1.10
47 PEGASUS_NAMESPACE_BEGIN
|
48 karl 1.13 PEGASUS_USING_STD;
|
49 kumpf 1.19
|
50 mike 1.10 ////////////////////////////////////////////////////////////////////////////////
51 //
52 // CIMQualifierRep
53 //
54 ////////////////////////////////////////////////////////////////////////////////
55
|
56 chip 1.38 CIMQualifierRep::CIMQualifierRep()
57 {
58 }
59
60 CIMQualifierRep::CIMQualifierRep(const CIMQualifierRep& x) :
61 Sharable(),
62 _name(x._name),
63 _value(x._value),
64 _flavor(x._flavor),
65 _propagated(x._propagated)
66 {
67 }
68
|
69 mike 1.10 CIMQualifierRep::CIMQualifierRep(
|
70 chip 1.38 const CIMName& name,
71 const CIMValue& value,
|
72 kumpf 1.30 const CIMFlavor & flavor,
|
73 mike 1.10 Boolean propagated)
|
74 chip 1.38 :
75 _name(name),
76 _value(value),
|
77 mike 1.10 _flavor(flavor),
78 _propagated(propagated)
79 {
|
80 chip 1.38 // ensure name is not null
81 if(name.isNull())
82 {
83 throw UninitializedObjectException();
84 }
|
85 mike 1.10 }
86
87 CIMQualifierRep::~CIMQualifierRep()
88 {
89 }
90
|
91 chip 1.38 void CIMQualifierRep::setName(const CIMName& name)
|
92 mike 1.10 {
|
93 chip 1.38 // ensure name is not null
94 if(name.isNull())
95 {
96 throw UninitializedObjectException();
97 }
98
99 _name = name;
|
100 mike 1.10 }
101
|
102 kumpf 1.30 void CIMQualifierRep::resolveFlavor (
|
103 chip 1.38 const CIMFlavor & inheritedFlavor,
|
104 kumpf 1.30 Boolean inherited)
105 {
106 // ATTN: KS P3 Needs more tests and expansion so we treate first different
107 // from inheritance
|
108 karl 1.17
|
109 kumpf 1.30 // if the turnoff flags set, reset the flavor bits
|
110 chip 1.38 if (inheritedFlavor.hasFlavor (CIMFlavor::RESTRICTED))
|
111 kumpf 1.30 {
|
112 kumpf 1.31 _flavor.removeFlavor (CIMFlavor::TOSUBCLASS);
113 _flavor.removeFlavor (CIMFlavor::TOINSTANCE);
|
114 kumpf 1.30 }
|
115 chip 1.38 if (inheritedFlavor.hasFlavor (CIMFlavor::DISABLEOVERRIDE))
|
116 kumpf 1.30 {
117 _flavor.removeFlavor (CIMFlavor::ENABLEOVERRIDE);
118 }
119
120 _flavor.addFlavor (inheritedFlavor);
121 }
|
122 karl 1.17
|
123 mike 1.10 static const char* _toString(Boolean x)
124 {
125 return x ? "true" : "false";
126 }
127
|
128 mike 1.38.2.1 void CIMQualifierRep::toXml(Buffer& out) const
|
129 mike 1.10 {
|
130 mike 1.38.2.2 out << LIT("<QUALIFIER");
131 out << LIT(" NAME=\"") << _name;
132 out.append('"');
133 out << LIT(" TYPE=\"") << cimTypeToString (_value.getType ());
134 out.append('"');
|
135 mike 1.10
136 if (_propagated != false)
|
137 mike 1.38.2.2 {
138 out << LIT(" PROPAGATED=\"") << _toString(_propagated);
139 out.append('"');
140 }
|
141 mike 1.10
|
142 kumpf 1.25 XmlWriter::appendQualifierFlavorEntity(out, _flavor);
|
143 mike 1.10
|
144 mike 1.38.2.2 out << LIT(">\n");
|
145 chip 1.38
|
146 kumpf 1.22 XmlWriter::appendValueElement(out, _value);
|
147 mike 1.10
|
148 mike 1.38.2.2 out << LIT("</QUALIFIER>\n");
|
149 mike 1.10 }
150
|
151 mike 1.11 /** toMof Generates MOF output for a qualifier.
152 The BNF for this is:
153 <pre>
154 qualifier = qualifierName [ qualifierParameter ] [ ":" 1*flavor]
155
156 qualifierParameter = "(" constantValue ")" | arrayInitializer
157
158 arrayInitializer = "{" constantValue*( "," constantValue)"}"
159 </pre>
160 */
|
161 mike 1.38.2.1 void CIMQualifierRep::toMof(Buffer& out) const
|
162 mike 1.11 {
163 // Output Qualifier name
164 out << _name;
165
166 /* If the qualifier is Boolean, we do not put out a value. This is
167 the way MOF is shown. Note that we should really be checking
|
168 karl 1.17 the qualifierdecl to compare with the default.
|
169 mike 1.11 Also if the value is Null, we do not put out a value because
170 no value has been set. Assumes that qualifiers are built
171 with NULL set if no value has been placed in the qualifier.
172 */
173 Boolean hasValueField = false;
|
174 karl 1.17 if (!_value.isNull())
|
175 mike 1.11 {
|
176 kumpf 1.27 if (_value.getType() == CIMTYPE_BOOLEAN)
|
177 karl 1.17 {
178 Boolean b;
179 _value.get(b);
180 if(!b)
|
181 mike 1.38.2.2 out << LIT(" (false)");
|
182 karl 1.17 }
183 else
184 {
|
185 mike 1.38.2.2 out << LIT(" (");
|
186 karl 1.17 hasValueField = true;
|
187 kumpf 1.24 MofWriter::appendValueElement(out, _value);
|
188 mike 1.38.2.2 out.append(')');
|
189 karl 1.17 }
|
190 mike 1.11 }
191
192 // output the flavors
193 String flavorString;
|
194 kumpf 1.25 flavorString = MofWriter::getQualifierFlavor(_flavor);
|
195 mike 1.11 if (flavorString.size())
196 {
|
197 mike 1.38.2.2 out << LIT(" : ");
|
198 karl 1.17 out << flavorString;
|
199 mike 1.11 }
|
200 karl 1.15 }
201
202
|
203 mike 1.10 Boolean CIMQualifierRep::identical(const CIMQualifierRep* x) const
204 {
205 return
206 this == x ||
|
207 chip 1.38 _name.equal(x->_name) &&
208 _value == x->_value &&
|
209 kumpf 1.30 (_flavor.equal (x->_flavor)) &&
|
210 mike 1.10 _propagated == x->_propagated;
211 }
212
|
213 chip 1.38 void CIMQualifierRep::setValue(const CIMValue& value)
|
214 mike 1.10 {
|
215 chip 1.38 _value = value;
|
216 mike 1.10 }
217
218 PEGASUS_NAMESPACE_END
|