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.39 void CIMQualifierRep::toXml(Buffer& out) const
|
129 mike 1.10 {
130 out << "<QUALIFIER";
131 out << " NAME=\"" << _name << "\"";
|
132 kumpf 1.27 out << " TYPE=\"" << cimTypeToString (_value.getType ()) << "\"";
|
133 mike 1.10
134 if (_propagated != false)
135 out << " PROPAGATED=\"" << _toString(_propagated) << "\"";
136
|
137 kumpf 1.25 XmlWriter::appendQualifierFlavorEntity(out, _flavor);
|
138 mike 1.10
139 out << ">\n";
|
140 chip 1.38
|
141 kumpf 1.22 XmlWriter::appendValueElement(out, _value);
|
142 mike 1.10
143 out << "</QUALIFIER>\n";
144 }
145
|
146 mike 1.11 /** toMof Generates MOF output for a qualifier.
147 The BNF for this is:
148 <pre>
149 qualifier = qualifierName [ qualifierParameter ] [ ":" 1*flavor]
150
151 qualifierParameter = "(" constantValue ")" | arrayInitializer
152
153 arrayInitializer = "{" constantValue*( "," constantValue)"}"
154 </pre>
155 */
|
156 mike 1.39 void CIMQualifierRep::toMof(Buffer& out) const
|
157 mike 1.11 {
158 // Output Qualifier name
159 out << _name;
160
161 /* If the qualifier is Boolean, we do not put out a value. This is
162 the way MOF is shown. Note that we should really be checking
|
163 karl 1.17 the qualifierdecl to compare with the default.
|
164 mike 1.11 Also if the value is Null, we do not put out a value because
165 no value has been set. Assumes that qualifiers are built
166 with NULL set if no value has been placed in the qualifier.
167 */
168 Boolean hasValueField = false;
|
169 karl 1.17 if (!_value.isNull())
|
170 mike 1.11 {
|
171 kumpf 1.27 if (_value.getType() == CIMTYPE_BOOLEAN)
|
172 karl 1.17 {
173 Boolean b;
174 _value.get(b);
175 if(!b)
|
176 chip 1.38 out << " (false)";
|
177 karl 1.17 }
178 else
179 {
180 out << " (";
181 hasValueField = true;
|
182 kumpf 1.24 MofWriter::appendValueElement(out, _value);
|
183 chip 1.38 out << ")";
|
184 karl 1.17 }
|
185 mike 1.11 }
186
187 // output the flavors
188 String flavorString;
|
189 kumpf 1.25 flavorString = MofWriter::getQualifierFlavor(_flavor);
|
190 mike 1.11 if (flavorString.size())
191 {
|
192 karl 1.17 out << " : ";
193 out << flavorString;
|
194 mike 1.11 }
|
195 karl 1.15 }
196
197
|
198 mike 1.10 Boolean CIMQualifierRep::identical(const CIMQualifierRep* x) const
199 {
200 return
201 this == x ||
|
202 chip 1.38 _name.equal(x->_name) &&
203 _value == x->_value &&
|
204 kumpf 1.30 (_flavor.equal (x->_flavor)) &&
|
205 mike 1.10 _propagated == x->_propagated;
206 }
207
|
208 chip 1.38 void CIMQualifierRep::setValue(const CIMValue& value)
|
209 mike 1.10 {
|
210 chip 1.38 _value = value;
|
211 mike 1.10 }
212
213 PEGASUS_NAMESPACE_END
|