1 mike 1.10 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.26 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.10 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 kumpf 1.26 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10 mike 1.10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
|
13 kumpf 1.26 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
14 mike 1.10 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
16 kumpf 1.26 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
19 mike 1.10 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 //==============================================================================
23 //
24 // Author: Mike Brasher (mbrasher@bmc.com)
25 //
|
26 kumpf 1.27 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
27 // (carolann_graves@hp.com)
|
28 mike 1.10 //
29 //%/////////////////////////////////////////////////////////////////////////////
30
31 #include "CIMQualifier.h"
|
32 kumpf 1.19 #include "CIMQualifierRep.h"
|
33 mike 1.10 #include "Indentor.h"
34 #include "CIMName.h"
|
35 kumpf 1.32 #include "InternalException.h"
|
36 mike 1.10 #include "XmlWriter.h"
|
37 kumpf 1.24 #include "MofWriter.h"
|
38 mike 1.10
39 PEGASUS_NAMESPACE_BEGIN
|
40 karl 1.13 PEGASUS_USING_STD;
|
41 kumpf 1.19
|
42 mike 1.10 ////////////////////////////////////////////////////////////////////////////////
43 //
44 // CIMQualifierRep
45 //
46 ////////////////////////////////////////////////////////////////////////////////
47
48 CIMQualifierRep::CIMQualifierRep(
|
49 kumpf 1.28 const CIMName& name,
|
50 mike 1.10 const CIMValue& value,
|
51 kumpf 1.30 const CIMFlavor & flavor,
|
52 mike 1.10 Boolean propagated)
53 :
54 _name(name),
55 _value(value),
56 _flavor(flavor),
57 _propagated(propagated)
58 {
|
59 karl 1.17 //cout << "KSTEST Qualifer create " << name << " Flavor " << flavor << endl;
|
60 kumpf 1.27 if (_value.getType() == CIMTYPE_NONE)
|
61 mike 1.10 throw NullType();
62 }
63
64 CIMQualifierRep::~CIMQualifierRep()
65 {
66
67 }
68
|
69 kumpf 1.28 void CIMQualifierRep::setName(const CIMName& name)
|
70 mike 1.10 {
71 _name = name;
72 }
73
|
74 kumpf 1.30 void CIMQualifierRep::resolveFlavor (
75 const CIMFlavor & inheritedFlavor,
76 Boolean inherited)
77 {
78 // ATTN: KS P3 Needs more tests and expansion so we treate first different
79 // from inheritance
|
80 karl 1.17
|
81 kumpf 1.30 // if the turnoff flags set, reset the flavor bits
82 if (inheritedFlavor.hasFlavor (CIMFlavor::RESTRICTED))
83 {
|
84 kumpf 1.31 _flavor.removeFlavor (CIMFlavor::TOSUBCLASS);
85 _flavor.removeFlavor (CIMFlavor::TOINSTANCE);
|
86 kumpf 1.30 }
87 if (inheritedFlavor.hasFlavor (CIMFlavor::DISABLEOVERRIDE))
88 {
89 _flavor.removeFlavor (CIMFlavor::ENABLEOVERRIDE);
90 }
91
92 _flavor.addFlavor (inheritedFlavor);
93 }
|
94 karl 1.17
|
95 mike 1.10 static const char* _toString(Boolean x)
96 {
97 return x ? "true" : "false";
98 }
99
100 void CIMQualifierRep::toXml(Array<Sint8>& out) const
101 {
102 out << "<QUALIFIER";
103 out << " NAME=\"" << _name << "\"";
|
104 kumpf 1.27 out << " TYPE=\"" << cimTypeToString (_value.getType ()) << "\"";
|
105 mike 1.10
106 if (_propagated != false)
107 out << " PROPAGATED=\"" << _toString(_propagated) << "\"";
108
|
109 kumpf 1.25 XmlWriter::appendQualifierFlavorEntity(out, _flavor);
|
110 mike 1.10
111 out << ">\n";
|
112 karl 1.12
|
113 kumpf 1.22 XmlWriter::appendValueElement(out, _value);
|
114 mike 1.10
115 out << "</QUALIFIER>\n";
116 }
117
|
118 mike 1.11 /** toMof Generates MOF output for a qualifier.
119 The BNF for this is:
120 <pre>
121 qualifier = qualifierName [ qualifierParameter ] [ ":" 1*flavor]
122
123 qualifierParameter = "(" constantValue ")" | arrayInitializer
124
125 arrayInitializer = "{" constantValue*( "," constantValue)"}"
126 </pre>
127 */
|
128 karl 1.14 void CIMQualifierRep::toMof(Array<Sint8>& out) const
|
129 mike 1.11 {
130 // Output Qualifier name
131 out << _name;
132
133 /* If the qualifier is Boolean, we do not put out a value. This is
134 the way MOF is shown. Note that we should really be checking
|
135 karl 1.17 the qualifierdecl to compare with the default.
|
136 mike 1.11 Also if the value is Null, we do not put out a value because
137 no value has been set. Assumes that qualifiers are built
138 with NULL set if no value has been placed in the qualifier.
139 */
140 Boolean hasValueField = false;
|
141 karl 1.17 if (!_value.isNull())
|
142 mike 1.11 {
|
143 kumpf 1.27 if (_value.getType() == CIMTYPE_BOOLEAN)
|
144 karl 1.17 {
145 Boolean b;
146 _value.get(b);
147 if(!b)
148 out << " (false)";
149 }
150 else
151 {
152 out << " (";
153 hasValueField = true;
|
154 kumpf 1.24 MofWriter::appendValueElement(out, _value);
|
155 karl 1.17 out << ")";
156 }
|
157 mike 1.11 }
158
159 // output the flavors
160 String flavorString;
|
161 kumpf 1.25 flavorString = MofWriter::getQualifierFlavor(_flavor);
|
162 mike 1.11 if (flavorString.size())
163 {
|
164 karl 1.17 out << " : ";
165 out << flavorString;
|
166 mike 1.11 }
|
167 karl 1.15 }
168
169
|
170 mike 1.10 CIMQualifierRep::CIMQualifierRep()
171 {
172
173 }
174
175 CIMQualifierRep::CIMQualifierRep(const CIMQualifierRep& x) :
176 Sharable(),
177 _name(x._name),
178 _value(x._value),
179 _flavor(x._flavor),
180 _propagated(x._propagated)
181 {
182
183 }
184
185 Boolean CIMQualifierRep::identical(const CIMQualifierRep* x) const
186 {
187 return
188 this == x ||
|
189 kumpf 1.28 _name.equal(x->_name) &&
|
190 mike 1.10 _value == x->_value &&
|
191 kumpf 1.30 (_flavor.equal (x->_flavor)) &&
|
192 mike 1.10 _propagated == x->_propagated;
193 }
194
195 void CIMQualifierRep::setValue(const CIMValue& value)
196 {
197 _value = value;
198
|
199 kumpf 1.27 if (_value.getType() == CIMTYPE_NONE)
|
200 mike 1.10 throw NullType();
201 }
202
203 PEGASUS_NAMESPACE_END
|