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: CIMMethod.h,v $
26 // Revision 1.2 2001/02/18 03:56:01 mike
27 // Changed more class names (e.g., ConstClassDecl -> CIMConstClass)
28 //
29 // Revision 1.1 2001/02/16 02:07:06 mike
30 // Renamed many classes and headers (using new CIM prefixes).
31 //
32 // Revision 1.5 2001/02/16 00:34:17 mike
33 // added ATTN
34 //
35 // Revision 1.4 2001/02/06 17:04:03 karl
36 // add documentation
37 //
38 // Revision 1.3 2001/01/28 19:07:07 karl
39 // add DOC++ comments
40 //
41 // Revision 1.2 2001/01/15 04:31:44 mike
42 // worked on resolve scheme
43 mike 1.1 //
44 // Revision 1.1.1.1 2001/01/14 19:52:57 mike
45 // Pegasus import
46 //
47 //
48 //END_HISTORY
49
50 /*
51 CIMMethod.h - This header file defines the method class.
52 */
53
54 #ifndef Pegasus_Method_h
55 #define Pegasus_Method_h
56
57 #include <Pegasus/Common/Config.h>
58 #include <Pegasus/Common/CIMMethodRep.h>
59
60 PEGASUS_NAMESPACE_BEGIN
61
62
63 class CIMConstMethod;
64 mike 1.1
65 /** Class CIMMethod - This class defines the operations associated with
66 manipulation of the Pegasus implementation of the CIM CIMMethod. Within this
67 class, methods are provides for creation, deletion, and manipulation of method
68 declarations.
69
70 */
71
72 class PEGASUS_COMMON_LINKAGE CIMMethod
73 {
74 public:
75 /// Creates and instantiates a CIM method.
76 CIMMethod() : _rep(0)
77 {
78
79 }
80 /** Creates and instantiates a CIM method from another method instance
81 @return pointer to the new method instance
82 */
83 CIMMethod(const CIMMethod& x)
84 {
85 mike 1.1 Inc(_rep = x._rep);
86 }
87 ///
88 CIMMethod& operator=(const CIMMethod& x)
89 {
90 if (x._rep != _rep)
91 {
92 Dec(_rep);
93 Inc(_rep = x._rep);
94 }
95 return *this;
96 }
97
98 // ATTN: remove the classOrigin and propagated parameters.
99
100 /** Creates a CIM method with the specified name, type, and classOrigin
101 @param name for the method
102 @param type ATTN
103 @param classOrigin
104 @param propagated
105 @return Throws IllegalName if name argument not legal CIM identifier.
106 mike 1.1 */
107 CIMMethod(
108 const String& name,
109 CIMType type,
110 const String& classOrigin = String(),
111 Boolean propagated = false)
112 {
113 _rep = new CIMMethodRep(name, type, classOrigin, propagated);
114 }
115
116 /// CIMMethod desctructor
117 ~CIMMethod()
118 {
119 Dec(_rep);
120 }
121 /** CIMMethod getName - Gets the name of the method
122 @return String with the name of the method
123 */
124 const String& getName() const
125 {
126 _checkRep();
127 mike 1.1 return _rep->getName();
128 }
129
130 /** CIMMethod setName - Set the method name
131 @parm name ATTN (make reference to name defintion here)
132 @return Throws IllegalName if name argument not legal CIM identifier.
133 */
134 void setName(const String& name)
135 {
136 _checkRep();
137 _rep->setName(name);
138 }
139 /** CIMMethod getType - gets the method type
140 @return The CIM method type for this method.
141 */
142
143 CIMType getType() const
144 {
145 _checkRep();
146 return _rep->getType();
147 }
148 mike 1.1 /** CIMMethod setType - Sets the method type to the specified CIM method
149 type as defined in CIMType /Ref{TYPE}
150 */
151 void setType(CIMType type)
152 {
153 _checkRep();
154 _rep->setType(type);
155 }
156 /** CIMMethod getClassOrigin - Returns the class in which this method
157 was defined.
158 @return ATTN:
159 */
160 const String& getClassOrigin() const
161 {
162 _checkRep();
163 return _rep->getClassOrigin();
164 }
165 /** CIMMethod setClassOrigin - ATTN:
166 */
167 void setClassOrigin(const String& classOrigin)
168 {
169 mike 1.1 _checkRep();
170 _rep->setClassOrigin(classOrigin);
171 }
172 /// method getPropagated - ATTN:
173 Boolean getPropagated() const
174 {
175 _checkRep();
176 return _rep->getPropagated();
177 }
178 /// method setPropagated - ATTN:
179 void setPropagated(Boolean propagated)
180 {
181 _checkRep();
182 _rep->setPropagated(propagated);
183 }
184 /** CIMMethod addQualifier -
185 @parm CIMQualifier to add
186 @param CIMQualifier to be added
187 @return Throws AlreadyExists excetpion if the qualifier already exists in
188 the method
189 @exception AlreadyExists exception of CIMQualifier already exists.
190 mike 1.1 */
191 CIMMethod& addQualifier(const CIMQualifier& x)
192 {
193 _checkRep();
194 _rep->addQualifier(x);
195 return *this;
196 }
197 /** CIMMethod findQualifier - Finds the CIMQualifier named by the input string.
198 @param String defining the name of the parameter to be found
199 @return Index to the parameter found or -1 if not found
200 The -1 must be converted to a Unit32 as follows:
201 <PRE>
202 Uint32 pos = myClass.findProperty("name");
203 if (pos == Uint32(-1))
204 {
205 // Not found!
206 }
207 </PRE>
208 */
209 Uint32 findQualifier(const String& name)
210 {
211 mike 1.1 _checkRep();
212 return _rep->findQualifier(name);
213 }
214 /** CIMMethod findQualifier - Find the qualifier with the name defined on
215 input
216 @param String with the name of the parameter to be found.
217 @return - index to the qualifier found or -1 if no qualifier found.
218 */
219 Uint32 findQualifier(const String& name) const
220 {
221 _checkRep();
222 return _rep->findQualifier(name);
223 }
224 /** CIMMethod getQualifier - Gets the CIMQualifier defined by the index input
225 as a parameter.
226 @param Index of the qualifier requested.
227 @return CIMQualifier object or exception
228 @exception OutOfBounds exception if the index is outside the range of
229 parameters available from the CIMMethod.
230 */
231 CIMQualifier getQualifier(Uint32 pos)
232 mike 1.1 {
233 _checkRep();
234 return _rep->getQualifier(pos);
235 }
236
237 CIMConstQualifier getQualifier(Uint32 pos) const
238 {
239 _checkRep();
240 return _rep->getQualifier(pos);
241 }
242 /** CIMMethod getQualifierCount - Returns count of the number of Qualifiers
243 attached to the CIMMethod
244 @return integer representing number of Qualifiers.
245 */
246 Uint32 getQualifierCount() const
247 {
248 _checkRep();
249 return _rep->getQualifierCount();
250 }
251 /** CIMMethod addParameter - Adds the parameter defined by the input to the
252 CIMMethod
253 mike 1.1 Param - ATTN:
254 */
255 CIMMethod& addParameter(const CIMParameter& x)
256 {
257 _checkRep();
258 _rep->addParameter(x);
259 return *this;
260 }
261 /// CIMMethod findParameter - ATTN:
262 Uint32 findParameter(const String& name)
263 {
264 _checkRep();
265 return _rep->findParameter(name);
266 }
267
268 /** CIMMethod findParameter - Finds the parameter defined by the name input
269 and returns an index to the CIMParameter
270 @param String defining the parameter to be found
271 @return index to the parameter if found. Returns -1 if parameter not
272 found
273 */
274 mike 1.1 Uint32 findParameter(const String& name) const
275 {
276 _checkRep();
277 return _rep->findParameter(name);
278 }
279 /// CIMMethod getParameter - ATTN:
280 CIMParameter getParameter(Uint32 pos)
281 {
282 _checkRep();
283 return _rep->getParameter(pos);
284 }
285
286 /** CIMMethod getParameter - Gets the parameter defined by the index
287 input as a parameter.
288 @param index for the parameter to be returned.
289 @return CIMParameter requested.
290 @Exception OutOfBounds exception is thrown if the index is outside the
291 range of available parameters
292 */
293 CIMConstParameter getParameter(Uint32 pos) const
294 {
295 mike 1.1 _checkRep();
296 return _rep->getParameter(pos);
297 }
298
299 /** CIMMethod getParameterCount - Gets the count of the numbeer of Parameters
300 attached to the CIMMethod.
301 @retrun - count of the number of parameters attached to the CIMMethod.
302 */
303 Uint32 getParameterCount() const
304 {
305 _checkRep();
306 return _rep->getParameterCount();
307 }
308 /// method resolve - ATTN:
309 void resolve(
310 DeclContext* declContext,
311 const String& nameSpace,
312 const CIMConstMethod& method)
313 {
314 _checkRep();
315 _rep->resolve(declContext, nameSpace, method);
316 mike 1.1 }
317 /// CIMMethod resolve
318 void resolve(
319 DeclContext* declContext,
320 const String& nameSpace)
321 {
322 _checkRep();
323 _rep->resolve(declContext, nameSpace);
324 }
325 /// operator
326 operator int() const { return _rep != 0; }
327 /// method toXML - ATTN:
328 void toXml(Array<Sint8>& out) const
329 {
330 _checkRep();
331 _rep->toXml(out);
332 }
333 /// method print - ATTN:
334 void print() const
335 {
336 _checkRep();
337 mike 1.1 _rep->print();
338 }
339 /// CIMMethod identical - ATTN
340 Boolean identical(const CIMConstMethod& x) const;
341 /// CIMMethod clone - ATTN
342 CIMMethod clone() const
343 {
344 return CIMMethod(_rep->clone());
345 }
346
347 private:
348
349 CIMMethod(CIMMethodRep* rep) : _rep(rep)
350 {
351 }
352
353 explicit CIMMethod(const CIMConstMethod& x);
354
355 void _checkRep() const
356 {
357 if (!_rep)
358 mike 1.1 throw UnitializedHandle();
359 }
360
361 CIMMethodRep* _rep;
362 friend class CIMConstMethod;
363 friend class CIMClassRep;
364 };
365
366 ////////////////////////////////////////////////////////////////////////////////
367 //
368 // CIMConstMethod
369 //
370 ////////////////////////////////////////////////////////////////////////////////
371
372 class PEGASUS_COMMON_LINKAGE CIMConstMethod
373 {
374 public:
375
376 CIMConstMethod() : _rep(0)
377 {
378
379 mike 1.1 }
380
381 CIMConstMethod(const CIMConstMethod& x)
382 {
383 Inc(_rep = x._rep);
384 }
385
386 CIMConstMethod(const CIMMethod& x)
387 {
388 Inc(_rep = x._rep);
389 }
390
391 CIMConstMethod& operator=(const CIMConstMethod& x)
392 {
393 if (x._rep != _rep)
394 {
395 Dec(_rep);
396 Inc(_rep = x._rep);
397 }
398 return *this;
399 }
400 mike 1.1
401 CIMConstMethod& operator=(const CIMMethod& x)
402 {
403 if (x._rep != _rep)
404 {
405 Dec(_rep);
406 Inc(_rep = x._rep);
407 }
408 return *this;
409 }
410
411 // Throws IllegalName if name argument not legal CIM identifier.
412
413 CIMConstMethod(
414 const String& name,
415 CIMType type,
416 const String& classOrigin = String(),
417 Boolean propagated = false)
418 {
419 _rep = new CIMMethodRep(name, type, classOrigin, propagated);
420 }
421 mike 1.1
422 ~CIMConstMethod()
423 {
424 Dec(_rep);
425 }
426
427 const String& getName() const
428 {
429 _checkRep();
430 return _rep->getName();
431 }
432
433 CIMType getType() const
434 {
435 _checkRep();
436 return _rep->getType();
437 }
438
439 const String& getClassOrigin() const
440 {
441 _checkRep();
442 mike 1.1 return _rep->getClassOrigin();
443 }
444
445 Boolean getPropagated() const
446 {
447 _checkRep();
448 return _rep->getPropagated();
449 }
450
451 Uint32 findQualifier(const String& name) const
452 {
453 _checkRep();
454 return _rep->findQualifier(name);
455 }
456
457 Uint32 getQualifier(Uint32 pos) const
458 {
459 _checkRep();
460 return _rep->getQualifier(pos);
461 }
462
463 mike 1.1 Uint32 getQualifierCount() const
464 {
465 _checkRep();
466 return _rep->getQualifierCount();
467 }
468
469 Uint32 findParameter(const String& name) const
470 {
471 _checkRep();
472 return _rep->findParameter(name);
473 }
474
475 CIMConstParameter getParameter(Uint32 pos) const
476 {
477 _checkRep();
478 return _rep->getParameter(pos);
479 }
480
481 Uint32 getParameterCount() const
482 {
483 _checkRep();
484 mike 1.1 return _rep->getParameterCount();
485 }
486
487 operator int() const { return _rep != 0; }
488
489 void toXml(Array<Sint8>& out) const
490 {
491 _checkRep();
492 _rep->toXml(out);
493 }
494
495 void print() const
496 {
497 _checkRep();
498 _rep->print();
499 }
500
501 Boolean identical(const CIMConstMethod& x) const
502 {
503 x._checkRep();
504 _checkRep();
505 mike 1.1 return _rep->identical(x._rep);
506 }
507
508 CIMMethod clone() const
509 {
510 return CIMMethod(_rep->clone());
511 }
512
513 private:
514
515 void _checkRep() const
516 {
517 if (!_rep)
518 throw UnitializedHandle();
519 }
520
521 CIMMethodRep* _rep;
522
523 friend class CIMMethod;
524 friend class CIMMethodRep;
525 };
526 mike 1.1
527 PEGASUS_NAMESPACE_END
528
529 #endif /* Pegasus_Method_h */
|