1 mike 1.1 //BEGIN_LICENSE
2 //
3 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 // DEALINGS IN THE SOFTWARE.
19 //
20 //END_LICENSE
21 //BEGIN_HISTORY
22 mike 1.1 //
23 // Author:
24 //
25 // $Log: CIMQualifierList.cpp,v $
|
101 mike 1.1 }
102
103 return Uint32(-1);
104 }
105
106 void CIMQualifierList::resolve(
107 DeclContext* declContext,
108 const String& nameSpace,
109 Uint32 scope,
110 Boolean isInstancePart,
111 CIMQualifierList& inheritedQualifiers)
112 {
113 // For each qualifier in the qualifiers array, the following
114 // is checked:
115 //
116 // 1. Whether it is declared (can be obtained from the declContext).
117 //
118 // 2. Whether it has the same type as the declaration.
119 //
120 // 3. Whether the the qualifier is valid for the given scope.
121 //
122 mike 1.1 // 4. Whether the qualifier can be overriden (the flavor is
123 // ENABLEOVERRIDE on the corresponding reference qualifier).
124 //
125 // 5. Whether the qualifier should be propagated to the subclass.
126 //
127 // If the qualifier should be overriden, then it is injected into the
128 // qualifiers array (from the inheritedQualifiers array).
129
130 for (Uint32 i = 0, n = _qualifiers.getSize(); i < n; i++)
131 {
132 CIMQualifier q = _qualifiers[i];
133
134 //----------------------------------------------------------------------
135 // 1. Check to see if it's declared.
136 //----------------------------------------------------------------------
137
138 CIMConstQualifierDecl qd = declContext->lookupQualifierDecl(
139 nameSpace, q.getName());
140
141 if (!qd)
142 throw UndeclaredQualifier(q.getName());
143 mike 1.1
144 //----------------------------------------------------------------------
145 // 2. Check the type:
146 //----------------------------------------------------------------------
147
148 if (!(q.getType() == qd.getType() && q.isArray() == qd.isArray()))
149 throw BadQualifierType(q.getName());
150
151 //----------------------------------------------------------------------
152 // 3. Check the scope:
153 //----------------------------------------------------------------------
154 #if 0
155 // ATTN: These lines throw a bogus exception if the qualifier has
156 // a valid scope (such as Scope::ASSOCIATION) which is not Scope::CLASS
157 // grb 1/16/01
158 if (!(qd.getScope() & scope))
159 throw BadQualifierScope(qd.getName(), ScopeToString(scope));
160 #endif
161 //----------------------------------------------------------------------
162 // See if this qualifier is contained in the inheritedQualifiers. If
163 // so then we must handle the OVERRIDABLE flavor.
164 mike 1.1 //----------------------------------------------------------------------
165
166 // ATTN: there seems to be a problem with the CIM schema that marks the
167 // abstract qualifier as non-overridable but then they override it.
168 // For now it is just disabled. This problem exists in both XML and
169 // CIM schema.
170
171 #if 0
172 Uint32 pos = inheritedQualifiers.find(q.getName());
173
174 if (pos != Uint32(-1))
175 {
176 CIMConstQualifier iq = inheritedQualifiers.getQualifier(pos);
177
178 if (!(iq.getFlavor() & CIMFlavor::OVERRIDABLE))
179 throw BadQualifierOverride(q.getName());
180 }
181 #endif
182 }
183
184 //--------------------------------------------------------------------------
185 mike 1.1 // Propagate qualifiers to subclass or to instance that do not have
186 // already have those qualifiers:
187 //--------------------------------------------------------------------------
188
189 for (Uint32 i = 0, n = inheritedQualifiers.getCount(); i < n; i++)
190 {
191 CIMQualifier iq = inheritedQualifiers.getQualifier(i);
192
193 if (isInstancePart)
194 {
195 if (!(iq.getFlavor() & CIMFlavor::TOINSTANCE))
196 continue;
197 }
198 else
199 {
200 if (!(iq.getFlavor() & CIMFlavor::TOSUBCLASS))
201 continue;
202 }
203
204 // If the qualifiers list does not already contain this qualifier,
205 // then propagate it (and set the propagated flag to true).
206 mike 1.1
207 if (find(iq.getName()) != Uint32(-1))
208 continue;
209
210 CIMQualifier q = iq.clone();
211 q.setPropagated(true);
212 _qualifiers.prepend(q);
213 }
214 }
215
216 void CIMQualifierList::toXml(Array<Sint8>& out) const
217 {
218 for (Uint32 i = 0, n = _qualifiers.getSize(); i < n; i++)
219 _qualifiers[i].toXml(out);
220 }
221
|