1 karl 1.36 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.10 //
|
3 karl 1.36 // 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 mike 1.10 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 mike 1.11 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.10 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
|
14 kumpf 1.28 //
|
15 mike 1.11 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.10 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 mike 1.11 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.10 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Mike Brasher (mbrasher@bmc.com)
27 //
|
28 kumpf 1.29 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
29 // (carolann_graves@hp.com)
|
30 mike 1.10 //
31 //%/////////////////////////////////////////////////////////////////////////////
32
33 #include <cstdio>
34 #include "CIMQualifierDecl.h"
|
35 kumpf 1.19 #include "CIMQualifierDeclRep.h"
|
36 mike 1.10 #include "Indentor.h"
37 #include "CIMName.h"
|
38 kumpf 1.34 #include "InternalException.h"
|
39 mike 1.10 #include "XmlWriter.h"
|
40 kumpf 1.25 #include "MofWriter.h"
|
41 mike 1.10
42 PEGASUS_NAMESPACE_BEGIN
|
43 karl 1.15 PEGASUS_USING_STD;
|
44 mike 1.10 ////////////////////////////////////////////////////////////////////////////////
45 //
46 // CIMQualifierDeclRep
47 //
48 ////////////////////////////////////////////////////////////////////////////////
49
50 CIMQualifierDeclRep::CIMQualifierDeclRep(
|
51 kumpf 1.30 const CIMName& name,
|
52 mike 1.11 const CIMValue& value,
|
53 kumpf 1.33 const CIMScope & scope,
54 const CIMFlavor & flavor,
|
55 mike 1.10 Uint32 arraySize)
|
56 mike 1.11 :
57 _name(name),
58 _value(value),
|
59 mike 1.10 _scope(scope),
60 _flavor(flavor),
61 _arraySize(arraySize)
62 {
|
63 karl 1.17 // Set the flavor defaults. Must actively set them in case input flavor
64 // sets some but not all the defaults. Also Make sure no conflicts. This covers
65 // the fact that we have separate flags for on and off for the toelement
66 // and override functions. Something must be set on creation and the
67 // default in the .h file only covers the case where there is no input.
68 // This also assures that there are no conflicts. Note that it favors
69 // restricted and disable override
70 //ATTN: This should become an exception in case conflicting entities are set.
|
71 kumpf 1.33 if(!(_flavor.hasFlavor (CIMFlavor::RESTRICTED)))
72 _flavor.addFlavor (CIMFlavor::TOSUBCLASS);
73 else
74 _flavor.removeFlavor (CIMFlavor::TOSUBCLASS);
75
76 if(!(_flavor.hasFlavor (CIMFlavor::DISABLEOVERRIDE)))
77 _flavor.addFlavor (CIMFlavor::ENABLEOVERRIDE);
78 else
79 _flavor.removeFlavor (CIMFlavor::ENABLEOVERRIDE);
|
80 karl 1.17
|
81 mike 1.10 }
82
83 CIMQualifierDeclRep::~CIMQualifierDeclRep()
84 {
85
86 }
87
|
88 kumpf 1.30 void CIMQualifierDeclRep::setName(const CIMName& name)
|
89 mike 1.10 {
|
90 mike 1.11 _name = name;
|
91 mike 1.10 }
92
93 static const char* _toString(Boolean x)
94 {
95 return x ? "true" : "false";
96 }
97
98 void CIMQualifierDeclRep::toXml(Array<Sint8>& out) const
99 {
100 out << "<QUALIFIER.DECLARATION";
101 out << " NAME=\"" << _name << "\"";
|
102 kumpf 1.29 out << " TYPE=\"" << cimTypeToString (_value.getType ()) << "\"";
|
103 mike 1.10
104 if (_value.isArray())
105 {
106 out << " ISARRAY=\"true\"";
107
108 if (_arraySize)
109 {
110 char buffer[64];
111 sprintf(buffer, " ARRAYSIZE=\"%d\"", _arraySize);
112 out << buffer;
113 }
114 }
115
|
116 kumpf 1.26 XmlWriter::appendQualifierFlavorEntity(out, _flavor);
|
117 mike 1.10
118 out << ">\n";
119
|
120 kumpf 1.27 XmlWriter::appendScopeElement(out, _scope);
|
121 kumpf 1.23 XmlWriter::appendValueElement(out, _value);
|
122 mike 1.10
123 out << "</QUALIFIER.DECLARATION>\n";
124 }
125
|
126 mike 1.11 /** toMof - Generate the MOF output for the Qualifier Declaration object.
|
127 karl 1.12
|
128 mike 1.11 The BNF for this output is:
|
129 karl 1.12 <pre>
|
130 mike 1.11 qualifierDeclaration = QUALIFIER qualifierName qualifierType scope
131 [ defaultFlavor ] ";"
132
133 qualifierName = IDENTIFIER
134
135 qualifierType = ":" dataType [ array ] [ defaultValue ]
136
137 scope = "," SCOPE "(" metaElement *( "," metaElement )
138 ")"
|
139 karl 1.12 </pre>
|
140 mike 1.11 */
141 void CIMQualifierDeclRep::toMof(Array<Sint8>& out) const
142 {
143 out << "\n";
144
145 // output the "Qualifier" keyword and name
|
146 kumpf 1.25 out << "Qualifier " << _name;
|
147 mike 1.11
148 // output the qualifiertype
|
149 kumpf 1.29 out << " : " << cimTypeToString (_value.getType ());
|
150 mike 1.11
151 // If array put the Array indicator "[]" and possible size after name.
152 if (_value.isArray())
153 {
154 if (_arraySize)
155 {
156 char buffer[32];
157 sprintf(buffer, "[%d]", _arraySize);
158 out << buffer;
159 }
160 else
161 out << "[]";
162 }
163
164 Boolean hasValueField = false;
|
165 karl 1.12 // KS think through the following test
|
166 kumpf 1.29 //if (!_value.isNull() || !(_value.getType() == CIMTYPE_BOOLEAN) )
|
167 karl 1.12 //{
168 // KS With CIM Qualifier, this should be =
|
169 karl 1.13 out << " = ";
|
170 mike 1.11 hasValueField = true;
|
171 kumpf 1.25 MofWriter::appendValueElement(out, _value);
|
172 karl 1.12 //}
|
173 mike 1.11
|
174 karl 1.12 // Output Scope Information
|
175 mike 1.11 String scopeString;
|
176 kumpf 1.27 scopeString = MofWriter::getQualifierScope(_scope);
|
177 karl 1.12 //if (scopeString.size())
178 //{
179 out << ", Scope(" << scopeString << ")";
180 //}
181 // Output Flavor Information
|
182 mike 1.11 String flavorString;
|
183 kumpf 1.26 flavorString = MofWriter::getQualifierFlavor(_flavor);
|
184 mike 1.11 if (flavorString.size())
185 {
|
186 karl 1.12 out << ", Flavor(" << flavorString << ")";
|
187 mike 1.11 }
|
188 karl 1.12 // End each qualifier declaration with newline
|
189 mike 1.11 out << ";\n";
|
190 karl 1.16 }
191
|
192 mike 1.10
193 CIMQualifierDeclRep::CIMQualifierDeclRep()
194 {
195
196 }
197
|
198 mike 1.11 CIMQualifierDeclRep::CIMQualifierDeclRep(const CIMQualifierDeclRep& x) :
|
199 mike 1.10 Sharable(),
200 _name(x._name),
201 _value(x._value),
202 _scope(x._scope),
203 _flavor(x._flavor),
204 _arraySize(x._arraySize)
205 {
206
207 }
208
209 Boolean CIMQualifierDeclRep::identical(const CIMQualifierDeclRep* x) const
210 {
211 return
212 this == x ||
|
213 kumpf 1.30 _name.equal(x->_name) &&
|
214 mike 1.11 _value == x->_value &&
|
215 kumpf 1.32 (_scope.equal (x->_scope)) &&
|
216 kumpf 1.33 (_flavor.equal (x->_flavor)) &&
|
217 mike 1.10 _arraySize == x->_arraySize;
218 }
219
|
220 mike 1.11 void CIMQualifierDeclRep::setValue(const CIMValue& value)
|
221 mike 1.10 {
|
222 mike 1.11 _value = value;
|
223 mike 1.10 }
224
225 PEGASUS_NAMESPACE_END
|
226 mike 1.11
|