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$
26 //
27 //END_HISTORY
28
29 #ifndef Pegasus_Parameter_h
30 #define Pegasus_Parameter_h
31
32 #include <Pegasus/Common/Config.h>
33 #include <Pegasus/Common/ParameterRep.h>
34
35 PEGASUS_NAMESPACE_BEGIN
36
37 ////////////////////////////////////////////////////////////////////////////////
38 //
39 // Parameter
40 //
41 ////////////////////////////////////////////////////////////////////////////////
42
43 mike 1.1 class ConstParameter;
44
45 class PEGASUS_COMMON_LINKAGE Parameter
46 {
47 public:
48
49 Parameter() : _rep(0)
50 {
51
52 }
53
54 Parameter(const Parameter& x)
55 {
56 Inc(_rep = x._rep);
57 }
58
59 Parameter& operator=(const Parameter& x)
60 {
61 if (x._rep != _rep)
62 {
63 Dec(_rep);
64 mike 1.1 Inc(_rep = x._rep);
65 }
66 return *this;
67 }
68
69 // Throws IllegalName if name argument not legal CIM identifier.
70
71 Parameter(
72 const String& name,
73 Type type,
74 Boolean isArray = false,
75 Uint32 arraySize = 0,
76 const String& referenceClassName = String::EMPTY)
77 {
78 _rep = new ParameterRep(
79 name, type, isArray, arraySize, referenceClassName);
80 }
81
82 ~Parameter()
83 {
84 Dec(_rep);
85 mike 1.1 }
86
87 const String& getName() const
88 {
89 _checkRep();
90 return _rep->getName();
91 }
92
93 // Throws IllegalName if name argument not legal CIM identifier.
94
95 void setName(const String& name)
96 {
97 _checkRep();
98 _rep->setName(name);
99 }
100
101 Boolean isArray() const
102 {
103 _checkRep();
104 return _rep->isArray();
105 }
106 mike 1.1
107 Uint32 getAraySize() const
108 {
109 _checkRep();
110 return _rep->getAraySize();
111 }
112
113 const String& getReferenceClassName() const
114 {
115 _checkRep();
116 return _rep->getReferenceClassName();
117 }
118
119 Type getType() const
120 {
121 _checkRep();
122 return _rep->getType();
123 }
124
125 void setType(Type type);
126
127 mike 1.1 // Throws AlreadyExists.
128
129 Parameter& addQualifier(const Qualifier& x)
130 {
131 _checkRep();
132 _rep->addQualifier(x);
133 return *this;
134 }
135
136 Uint32 findQualifier(const String& name)
137 {
138 _checkRep();
139 return _rep->findQualifier(name);
140 }
141
142 Uint32 findQualifier(const String& name) const
143 {
144 _checkRep();
145 return _rep->findQualifier(name);
146 }
147
148 mike 1.1 Qualifier getQualifier(Uint32 pos)
149 {
150 _checkRep();
151 return _rep->getQualifier(pos);
152 }
153
154 ConstQualifier getQualifier(Uint32 pos) const
155 {
156 _checkRep();
157 return _rep->getQualifier(pos);
158 }
159
160 Uint32 getQualifierCount() const
161 {
162 _checkRep();
163 return _rep->getQualifierCount();
164 }
165
166 void resolve(DeclContext* declContext, const String& nameSpace)
167 {
168 _checkRep();
169 mike 1.1 _rep->resolve(declContext, nameSpace);
170 }
171
172 operator int() const { return _rep != 0; }
173
174 void toXml(Array<Sint8>& out) const
175 {
176 _checkRep();
177 _rep->toXml(out);
178 }
179
180 void print() const
181 {
182 _checkRep();
183 _rep->print();
184 }
185
186 Boolean identical(const ConstParameter& x) const;
187
188 Parameter clone() const
189 {
190 mike 1.1 return Parameter(_rep->clone());
191 }
192
193 private:
194
195 Parameter(ParameterRep* rep) : _rep(rep)
196 {
197 }
198
199 void _checkRep() const
200 {
201 if (!_rep)
202 throw UnitializedHandle();
203 }
204
205 ParameterRep* _rep;
206 friend class ConstParameter;
207 };
208
209 ////////////////////////////////////////////////////////////////////////////////
210 //
211 mike 1.1 // ConstParameter
212 //
213 ////////////////////////////////////////////////////////////////////////////////
214
215 class PEGASUS_COMMON_LINKAGE ConstParameter
216 {
217 public:
218
219 ConstParameter() : _rep(0)
220 {
221
222 }
223
224 ConstParameter(const ConstParameter& x)
225 {
226 Inc(_rep = x._rep);
227 }
228
229 ConstParameter(const Parameter& x)
230 {
231 Inc(_rep = x._rep);
232 mike 1.1 }
233
234 ConstParameter& operator=(const ConstParameter& x)
235 {
236 if (x._rep != _rep)
237 {
238 Dec(_rep);
239 Inc(_rep = x._rep);
240 }
241 return *this;
242 }
243
244 ConstParameter& operator=(const Parameter& x)
245 {
246 if (x._rep != _rep)
247 {
248 Dec(_rep);
249 Inc(_rep = x._rep);
250 }
251 return *this;
252 }
253 mike 1.1
254 // Throws IllegalName if name argument not legal CIM identifier.
255
256 ConstParameter(
257 const String& name,
258 Type type,
259 Boolean isArray = false,
260 Uint32 arraySize = 0,
261 const String& referenceClassName = String::EMPTY)
262 {
263 _rep = new ParameterRep(
264 name, type, isArray, arraySize, referenceClassName);
265 }
266
267 ~ConstParameter()
268 {
269 Dec(_rep);
270 }
271
272 const String& getName() const
273 {
274 mike 1.1 _checkRep();
275 return _rep->getName();
276 }
277
278 Boolean isArray() const
279 {
280 _checkRep();
281 return _rep->isArray();
282 }
283
284 Uint32 getAraySize() const
285 {
286 _checkRep();
287 return _rep->getAraySize();
288 }
289
290 const String& getReferenceClassName() const
291 {
292 _checkRep();
293 return _rep->getReferenceClassName();
294 }
295 mike 1.1
296 Type getType() const
297 {
298 _checkRep();
299 return _rep->getType();
300 }
301
302 Uint32 findQualifier(const String& name) const
303 {
304 _checkRep();
305 return _rep->findQualifier(name);
306 }
307
308 ConstQualifier getQualifier(Uint32 pos) const
309 {
310 _checkRep();
311 return _rep->getQualifier(pos);
312 }
313
314 Uint32 getQualifierCount() const
315 {
316 mike 1.1 _checkRep();
317 return _rep->getQualifierCount();
318 }
319
320 operator int() const { return _rep != 0; }
321
322 void toXml(Array<Sint8>& out) const
323 {
324 _checkRep();
325 _rep->toXml(out);
326 }
327
328 void print() const
329 {
330 _checkRep();
331 _rep->print();
332 }
333
334 Boolean identical(const ConstParameter& x) const
335 {
336 x._checkRep();
337 mike 1.1 _checkRep();
338 return _rep->identical(x._rep);
339 }
340
341 ConstParameter clone() const
342 {
343 return ConstParameter(_rep->clone());
344 }
345
346 private:
347
348 ConstParameter(ParameterRep* rep) : _rep(rep)
349 {
350 }
351
352 void _checkRep() const
353 {
354 if (!_rep)
355 throw UnitializedHandle();
356 }
357
358 mike 1.1 ParameterRep* _rep;
359 friend class Parameter;
360 };
361
362 PEGASUS_NAMESPACE_END
363
364 #endif /* Pegasus_Parameter_h */
|