1 mike 1.17 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 //
21 //==============================================================================
22 mike 1.17 //
23 // Author: Mike Brasher (mbrasher@bmc.com)
24 //
25 // Modified By:
26 //
27 //%/////////////////////////////////////////////////////////////////////////////
28
29 #ifndef Pegasus_Method_h
30 #define Pegasus_Method_h
31
32 #include <Pegasus/Common/Config.h>
33 #include <Pegasus/Common/CIMMethodRep.h>
34
35 PEGASUS_NAMESPACE_BEGIN
36
37 class CIMConstMethod;
38
39 /** Class CIMMethod - This class defines the operations associated with
40 manipulation of the Pegasus implementation of the CIM CIMMethod. Within
41 this class, methods are provides for creation, deletion, and manipulation
42 of method declarations.
43 mike 1.17
44 // ATTN: remove the classOrigin and propagated parameters.
45 */
46 class PEGASUS_COMMON_LINKAGE CIMMethod
47 {
48 public:
49
50 /** Creates and instantiates a CIM method. */
51 CIMMethod() : _rep(0)
52 {
53
54 }
55
56 /** Creates and instantiates a CIM method from another method instance
57 @return pointer to the new method instance
58 */
59 CIMMethod(const CIMMethod& x)
60 {
61 Inc(_rep = x._rep);
62 }
63
64 mike 1.17 /** Assignment operator */
65 CIMMethod& operator=(const CIMMethod& x)
66 {
67 if (x._rep != _rep)
68 {
69 Dec(_rep);
70 Inc(_rep = x._rep);
71 }
72 return *this;
73 }
74
|
75 karl 1.17.2.1 /** Creates a CIM method with the specified name, type, and classOrigin
|
76 mike 1.17 @param name for the method
77 @param type ATTN
78 @param classOrigin
79 @param propagated
80 @return Throws IllegalName if name argument not legal CIM identifier.
81 */
82 CIMMethod(
83 const String& name,
84 CIMType type,
85 const String& classOrigin = String(),
86 Boolean propagated = false)
87 {
88 _rep = new CIMMethodRep(name, type, classOrigin, propagated);
89 }
90
91 /** Desctructor. */
92 ~CIMMethod()
93 {
94 Dec(_rep);
95 }
96
|
97 karl 1.17.2.1 /** getName - Gets the name of the method
|
98 mike 1.17 @return String with the name of the method
99 */
100 const String& getName() const
101 {
102 _checkRep();
103 return _rep->getName();
104 }
105
|
106 karl 1.17.2.1 /** setName - Set the method name
|
107 mike 1.17 @param name
108 @exception IllegalName if name argument not legal CIM identifier.
109 */
110 void setName(const String& name)
111 {
112 _checkRep();
113 _rep->setName(name);
114 }
115
|
116 karl 1.17.2.1 /** getType - gets the method type
|
117 mike 1.17 @return The CIM method type for this method.
118 */
119 CIMType getType() const
120 {
121 _checkRep();
122 return _rep->getType();
123 }
124
|
125 karl 1.17.2.1 /** setType - Sets the method type to the specified CIM method
|
126 mike 1.17 type as defined in CIMType /Ref{TYPE}
127 */
128 void setType(CIMType type)
129 {
130 _checkRep();
131 _rep->setType(type);
132 }
133
|
134 karl 1.17.2.1 /** getClassOrigin - Returns the class in which this method
|
135 mike 1.17 was defined.
136 @return ATTN:
137 */
138 const String& getClassOrigin() const
139 {
140 _checkRep();
141 return _rep->getClassOrigin();
142 }
143
|
144 karl 1.17.2.1 /** setClassOrigin - ATTN: */
|
145 mike 1.17 void setClassOrigin(const String& classOrigin)
146 {
147 _checkRep();
148 _rep->setClassOrigin(classOrigin);
149 }
150
|
151 karl 1.17.2.1 /** getPropagated - Tests the propogated qualifier
152 @return - returns True if method is propogated
153 */
|
154 mike 1.17 Boolean getPropagated() const
155 {
156 _checkRep();
157 return _rep->getPropagated();
158 }
159
|
160 karl 1.17.2.1 /** setPropagated - Sets the Propagaged Qualifier */
|
161 mike 1.17 void setPropagated(Boolean propagated)
162 {
163 _checkRep();
164 _rep->setPropagated(propagated);
165 }
166
|
167 karl 1.17.2.1 /** addQualifier - Adds a Qualifier to the method object.
|
168 mike 1.17 @param CIMQualifier to be added
169 @return Throws AlreadyExists excetpion if the qualifier already exists
170 in the method
171 @exception AlreadyExists exception
172 */
173 CIMMethod& addQualifier(const CIMQualifier& x)
174 {
175 _checkRep();
176 _rep->addQualifier(x);
177 return *this;
178 }
179
|
180 karl 1.17.2.1 /** findQualifier - returns the position of the qualifier with
|
181 mike 1.17 the given name.
182 @param name Name of qualifier to be found.
183 @return index of the parameter if found; otherwise PEG_NOT_FOUND.
184 */
185 Uint32 findQualifier(const String& name)
186 {
187 _checkRep();
188 return _rep->findQualifier(name);
189 }
190
191 Uint32 findQualifier(const String& name) const
192 {
193 _checkRep();
194 return _rep->findQualifier(name);
195 }
196
197 /** existsQualifier - returns the position of the qualifier with
198 the given name.
199 @param name Name of qualifier to be found.
200 @return index of the parameter if found; otherwise PEG_NOT_FOUND.
201 */
202 mike 1.17 Boolean existsQualifier(const String& name)
203 {
204 _checkRep();
205 return _rep->existsQualifier(name);
206 }
207
208 Boolean existsQualifier(const String& name) const
209 {
210 _checkRep();
211 return _rep->existsQualifier(name);
212 }
213
214
|
215 karl 1.17.2.1 /** getQualifier - Gets the CIMQualifier defined by the index
|
216 mike 1.17 input as a parameter.
217 @param Index of the qualifier requested.
218 @return CIMQualifier object or exception
219 @exception OutOfBounds exception if the index is outside the range of
220 parameters available from the CIMMethod.
221 */
222 CIMQualifier getQualifier(Uint32 pos)
223 {
224 _checkRep();
225 return _rep->getQualifier(pos);
226 }
227
228 CIMConstQualifier getQualifier(Uint32 pos) const
229 {
230 _checkRep();
231 return _rep->getQualifier(pos);
232 }
233
234 /** removeQualifier - Removes the CIMQualifier defined by the
235 position input as a parameter.
236 @param Position of the qualifier requested.
237 mike 1.17 @return CIMQualifier object or exception
238 @exception OutOfBounds exception if the index is outside the range of
239 parameters available from the CIMMethod.
240 */
241 void removeQualifier(Uint32 pos)
242 {
243 _checkRep();
244 _rep->removeQualifier(pos);
245 }
246
247
|
248 karl 1.17.2.1 /** getQualifierCount - Returns the number of Qualifiers attached
249 to this CIMmethod object.
|
250 mike 1.17 @return integer representing number of Qualifiers.
251 */
252 Uint32 getQualifierCount() const
253 {
254 _checkRep();
255 return _rep->getQualifierCount();
256 }
257
|
258 karl 1.17.2.1 /** addParameter - Adds the parameter defined by the input
|
259 mike 1.17 to the CIMMethod
260 */
261 CIMMethod& addParameter(const CIMParameter& x)
262 {
263 _checkRep();
264 _rep->addParameter(x);
265 return *this;
266 }
267
|
268 karl 1.17.2.1 /** findParameter - Finds the parameter whose name is given
|
269 mike 1.17 by the name parameter.
270 @param name Name of parameter to be found.
271 @return index of the parameter if found; otherwise PEG_NOT_FOUND.
272 */
273 Uint32 findParameter(const String& name)
274 {
275 _checkRep();
276 return _rep->findParameter(name);
277 }
278
279 Uint32 findParameter(const String& name) const
280 {
281 _checkRep();
282 return _rep->findParameter(name);
283 }
284
|
285 karl 1.17.2.1 /** getParameter - ATTN: */
|
286 mike 1.17 CIMParameter getParameter(Uint32 pos)
287 {
288 _checkRep();
289 return _rep->getParameter(pos);
290 }
291
|
292 karl 1.17.2.1 /** getParameter - Gets the parameter defined by the index
|
293 mike 1.17 input as a parameter.
294 @param index for the parameter to be returned.
295 @return CIMParameter requested.
296 @Exception OutOfBounds exception is thrown if the index is outside the
297 range of available parameters
298 */
299 CIMConstParameter getParameter(Uint32 pos) const
300 {
301 _checkRep();
302 return _rep->getParameter(pos);
303 }
304
|
305 karl 1.17.2.1 /** getParameterCount - Gets the count of the numbeer of
|
306 mike 1.17 Parameters attached to the CIMMethod.
307 @retrun - count of the number of parameters attached to the CIMMethod.
308 */
309 Uint32 getParameterCount() const
310 {
311 _checkRep();
312 return _rep->getParameterCount();
313 }
314
|
315 karl 1.17.2.1 /** resolve - resolves and completes the CIMMethod */
|
316 mike 1.17 void resolve(
317 DeclContext* declContext,
318 const String& nameSpace,
319 const CIMConstMethod& method)
320 {
321 _checkRep();
322 _rep->resolve(declContext, nameSpace, method);
323 }
324
|
325 karl 1.17.2.1 /** resolve - Resolves and completes the CIMMethod */
|
326 mike 1.17 void resolve(
327 DeclContext* declContext,
328 const String& nameSpace)
329 {
330 _checkRep();
331 _rep->resolve(declContext, nameSpace);
332 }
333
334 /** Returns zero if CIMMethod refers to a null pointer */
335 operator int() const
336 {
337 return _rep != 0;
338 }
339
|
340 karl 1.17.2.1 /** toXML - puts XML encoding of this CIMMethod object into out
341 arguemnt.
342 */
|
343 mike 1.17 void toXml(Array<Sint8>& out) const
344 {
345 _checkRep();
346 _rep->toXml(out);
347 }
348
|
349 karl 1.17.2.1 /** print - formats and prints this CIMmethod (in CIM XML encoded form).
350 */
|
351 mike 1.17 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
352 {
353 _checkRep();
354 _rep->print(o);
355 }
356
|
357 karl 1.17.2.1 /** toMof - puts MOF encoding of this object into out arguemnt.
358 */
359 void toMof(Array<Sint8>& out) const
360 {
361 _checkRep();
362 _rep->toMof(out);
363 }
364
365 /** identical - Returns true if this method is identical to the
|
366 mike 1.17 one given by the argument x.
367 */
368 Boolean identical(const CIMConstMethod& x) const;
369
370 /** CIMMethod clone - makes a distinct replica of this method */
371 CIMMethod clone() const
372 {
373 return CIMMethod(_rep->clone());
374 }
375
376 private:
377
378 CIMMethod(CIMMethodRep* rep) : _rep(rep)
379 {
380 }
381
382 PEGASUS_EXPLICIT CIMMethod(const CIMConstMethod& x);
383
384 void _checkRep() const
385 {
386 if (!_rep)
387 mike 1.17 ThrowUnitializedHandle();
388 }
389
390 CIMMethodRep* _rep;
391 friend class CIMConstMethod;
392 friend class CIMClassRep;
393 };
394
395 class PEGASUS_COMMON_LINKAGE CIMConstMethod
396 {
397 public:
398
399 CIMConstMethod() : _rep(0)
400 {
401
402 }
403
404 CIMConstMethod(const CIMConstMethod& x)
405 {
406 Inc(_rep = x._rep);
407 }
408 mike 1.17
409 CIMConstMethod(const CIMMethod& x)
410 {
411 Inc(_rep = x._rep);
412 }
413
414 CIMConstMethod& operator=(const CIMConstMethod& x)
415 {
416 if (x._rep != _rep)
417 {
418 Dec(_rep);
419 Inc(_rep = x._rep);
420 }
421 return *this;
422 }
423
424 CIMConstMethod& operator=(const CIMMethod& x)
425 {
426 if (x._rep != _rep)
427 {
428 Dec(_rep);
429 mike 1.17 Inc(_rep = x._rep);
430 }
431 return *this;
432 }
433
434 // Throws IllegalName if name argument not legal CIM identifier.
435
436 CIMConstMethod(
437 const String& name,
438 CIMType type,
439 const String& classOrigin = String(),
440 Boolean propagated = false)
441 {
442 _rep = new CIMMethodRep(name, type, classOrigin, propagated);
443 }
444
445 ~CIMConstMethod()
446 {
447 Dec(_rep);
448 }
449
450 mike 1.17 const String& getName() const
451 {
452 _checkRep();
453 return _rep->getName();
454 }
455
456 CIMType getType() const
457 {
458 _checkRep();
459 return _rep->getType();
460 }
461
462 const String& getClassOrigin() const
463 {
464 _checkRep();
465 return _rep->getClassOrigin();
466 }
467
468 Boolean getPropagated() const
469 {
470 _checkRep();
471 mike 1.17 return _rep->getPropagated();
472 }
473
474 Uint32 findQualifier(const String& name) const
475 {
476 _checkRep();
477 return _rep->findQualifier(name);
478 }
479
480 Uint32 getQualifier(Uint32 pos) const
481 {
482 _checkRep();
483 return _rep->getQualifier(pos);
484 }
485
486 Uint32 getQualifierCount() const
487 {
488 _checkRep();
489 return _rep->getQualifierCount();
490 }
491
492 mike 1.17 Uint32 findParameter(const String& name) const
493 {
494 _checkRep();
495 return _rep->findParameter(name);
496 }
497
498 CIMConstParameter getParameter(Uint32 pos) const
499 {
500 _checkRep();
501 return _rep->getParameter(pos);
502 }
503
504 Uint32 getParameterCount() const
505 {
506 _checkRep();
507 return _rep->getParameterCount();
508 }
509
510 operator int() const { return _rep != 0; }
511
512 void toXml(Array<Sint8>& out) const
513 mike 1.17 {
514 _checkRep();
515 _rep->toXml(out);
516 }
517
518 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
519 {
520 _checkRep();
521 _rep->print(o);
522 }
523
524 Boolean identical(const CIMConstMethod& x) const
525 {
526 x._checkRep();
527 _checkRep();
528 return _rep->identical(x._rep);
529 }
530
531 CIMMethod clone() const
532 {
533 return CIMMethod(_rep->clone());
534 mike 1.17 }
535
536 private:
537
538 void _checkRep() const
539 {
540 if (!_rep)
541 ThrowUnitializedHandle();
542 }
543
544 CIMMethodRep* _rep;
545
546 friend class CIMMethod;
547 friend class CIMMethodRep;
548 };
549
550 #define PEGASUS_ARRAY_T CIMMethod
551 # include "ArrayInter.h"
552 #undef PEGASUS_ARRAY_T
553
554 PEGASUS_NAMESPACE_END
555 mike 1.17
556 #endif /* Pegasus_Method_h */
|