1 mike 1.16 //%/////////////////////////////////////////////////////////////////////////////
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.16 //
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.16
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.16 /** 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 /** Creates a CIM method with the specified name, type, and classOrigin
76 @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 mike 1.16 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 /** CIMMethod getName - Gets the name of the method
98 @return String with the name of the method
99 */
100 const String& getName() const
101 {
102 _checkRep();
103 return _rep->getName();
104 }
105
106 mike 1.16 /** CIMMethod setName - Set the method name
107 @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 /** CIMMethod getType - gets the method type
117 @return The CIM method type for this method.
118 */
119 CIMType getType() const
120 {
121 _checkRep();
122 return _rep->getType();
123 }
124
125 /** CIMMethod setType - Sets the method type to the specified CIM method
126 type as defined in CIMType /Ref{TYPE}
127 mike 1.16 */
128 void setType(CIMType type)
129 {
130 _checkRep();
131 _rep->setType(type);
132 }
133
134 /** CIMMethod getClassOrigin - Returns the class in which this method
135 was defined.
136 @return ATTN:
137 */
138 const String& getClassOrigin() const
139 {
140 _checkRep();
141 return _rep->getClassOrigin();
142 }
143
144 /** CIMMethod setClassOrigin - ATTN: */
145 void setClassOrigin(const String& classOrigin)
146 {
147 _checkRep();
148 mike 1.16 _rep->setClassOrigin(classOrigin);
149 }
150
151 /** method getPropagated - ATTN: */
152 Boolean getPropagated() const
153 {
154 _checkRep();
155 return _rep->getPropagated();
156 }
157
158 /** method setPropagated - ATTN: */
159 void setPropagated(Boolean propagated)
160 {
161 _checkRep();
162 _rep->setPropagated(propagated);
163 }
164
165 /** CIMMethod addQualifier - Adds a Qualifier to the method object.
166 @param CIMQualifier to be added
167 @return Throws AlreadyExists excetpion if the qualifier already exists
168 in the method
169 mike 1.16 @exception AlreadyExists exception
170 */
171 CIMMethod& addQualifier(const CIMQualifier& x)
172 {
173 _checkRep();
174 _rep->addQualifier(x);
175 return *this;
176 }
177
178 /** CIMMethod findQualifier - returns the position of the qualifier with
179 the given name.
180 @param name Name of qualifier to be found.
181 @return index of the parameter if found; otherwise PEG_NOT_FOUND.
182 */
183 Uint32 findQualifier(const String& name)
184 {
185 _checkRep();
186 return _rep->findQualifier(name);
187 }
188
189 Uint32 findQualifier(const String& name) const
190 mike 1.16 {
191 _checkRep();
192 return _rep->findQualifier(name);
193 }
194
195 /** existsQualifier - returns the position of the qualifier with
196 the given name.
197 @param name Name of qualifier to be found.
198 @return index of the parameter if found; otherwise PEG_NOT_FOUND.
199 */
200 Boolean existsQualifier(const String& name)
201 {
202 _checkRep();
203 return _rep->existsQualifier(name);
204 }
205
206 Boolean existsQualifier(const String& name) const
207 {
208 _checkRep();
209 return _rep->existsQualifier(name);
210 }
211 mike 1.16
212
213 /** CIMMethod getQualifier - Gets the CIMQualifier defined by the index
214 input as a parameter.
215 @param Index of the qualifier requested.
216 @return CIMQualifier object or exception
217 @exception OutOfBounds exception if the index is outside the range of
218 parameters available from the CIMMethod.
219 */
220 CIMQualifier getQualifier(Uint32 pos)
221 {
222 _checkRep();
223 return _rep->getQualifier(pos);
224 }
225
226 CIMConstQualifier getQualifier(Uint32 pos) const
227 {
228 _checkRep();
229 return _rep->getQualifier(pos);
230 }
231
232 mike 1.16 /** removeQualifier - Removes the CIMQualifier defined by the
233 position input as a parameter.
234 @param Position of the qualifier requested.
235 @return CIMQualifier object or exception
236 @exception OutOfBounds exception if the index is outside the range of
237 parameters available from the CIMMethod.
238 */
239 void removeQualifier(Uint32 pos)
240 {
241 _checkRep();
242 _rep->removeQualifier(pos);
243 }
244
245
246 /** CIMMethod getQualifierCount - Returns the number of Qualifiers attached
247 to this method.
248 @return integer representing number of Qualifiers.
249 */
250 Uint32 getQualifierCount() const
251 {
252 _checkRep();
253 mike 1.16 return _rep->getQualifierCount();
254 }
255
256 /** CIMMethod addParameter - Adds the parameter defined by the input
257 to the CIMMethod
258 */
259 CIMMethod& addParameter(const CIMParameter& x)
260 {
261 _checkRep();
262 _rep->addParameter(x);
263 return *this;
264 }
265
266 /** CIMMethod findParameter - Finds the parameter whose name is given
267 by the name parameter.
268 @param name Name of parameter to be found.
269 @return index of the parameter if found; otherwise PEG_NOT_FOUND.
270 */
271 Uint32 findParameter(const String& name)
272 {
273 _checkRep();
274 mike 1.16 return _rep->findParameter(name);
275 }
276
277 Uint32 findParameter(const String& name) const
278 {
279 _checkRep();
280 return _rep->findParameter(name);
281 }
282
283 /** CIMMethod getParameter - ATTN: */
284 CIMParameter getParameter(Uint32 pos)
285 {
286 _checkRep();
287 return _rep->getParameter(pos);
288 }
289
290 /** CIMMethod getParameter - Gets the parameter defined by the index
291 input as a parameter.
292 @param index for the parameter to be returned.
293 @return CIMParameter requested.
294 @Exception OutOfBounds exception is thrown if the index is outside the
295 mike 1.16 range of available parameters
296 */
297 CIMConstParameter getParameter(Uint32 pos) const
298 {
299 _checkRep();
300 return _rep->getParameter(pos);
301 }
302
303 /** CIMMethod getParameterCount - Gets the count of the numbeer of
304 Parameters attached to the CIMMethod.
305 @retrun - count of the number of parameters attached to the CIMMethod.
306 */
307 Uint32 getParameterCount() const
308 {
309 _checkRep();
310 return _rep->getParameterCount();
311 }
312
313 /** method resolve - ATTN: */
314 void resolve(
315 DeclContext* declContext,
316 mike 1.16 const String& nameSpace,
317 const CIMConstMethod& method)
318 {
319 _checkRep();
320 _rep->resolve(declContext, nameSpace, method);
321 }
322
323 /** CIMMethod resolve */
324 void resolve(
325 DeclContext* declContext,
326 const String& nameSpace)
327 {
328 _checkRep();
329 _rep->resolve(declContext, nameSpace);
330 }
331
332 /** Returns zero if CIMMethod refers to a null pointer */
333 operator int() const
334 {
335 return _rep != 0;
336 }
337 mike 1.16
338 /** method toXML - placing XML encoding of this object into out arguemnt. */
339 void toXml(Array<Sint8>& out) const
340 {
341 _checkRep();
342 _rep->toXml(out);
343 }
344
345 /** method print - prints this method (in CIM encoded form). */
346 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
347 {
348 _checkRep();
349 _rep->print(o);
350 }
351
352 /** CIMMethod identical - Returns true if this method is identical to the
353 one given by the argument x.
354 */
355 Boolean identical(const CIMConstMethod& x) const;
356
357 /** CIMMethod clone - makes a distinct replica of this method */
358 mike 1.16 CIMMethod clone() const
359 {
360 return CIMMethod(_rep->clone());
361 }
362
363 private:
364
365 CIMMethod(CIMMethodRep* rep) : _rep(rep)
366 {
367 }
368
369 PEGASUS_EXPLICIT CIMMethod(const CIMConstMethod& x);
370
371 void _checkRep() const
372 {
373 if (!_rep)
374 ThrowUnitializedHandle();
375 }
376
377 CIMMethodRep* _rep;
378 friend class CIMConstMethod;
379 mike 1.16 friend class CIMClassRep;
380 };
381
382 class PEGASUS_COMMON_LINKAGE CIMConstMethod
383 {
384 public:
385
386 CIMConstMethod() : _rep(0)
387 {
388
389 }
390
391 CIMConstMethod(const CIMConstMethod& x)
392 {
393 Inc(_rep = x._rep);
394 }
395
396 CIMConstMethod(const CIMMethod& x)
397 {
398 Inc(_rep = x._rep);
399 }
400 mike 1.16
401 CIMConstMethod& operator=(const CIMConstMethod& x)
402 {
403 if (x._rep != _rep)
404 {
405 Dec(_rep);
406 Inc(_rep = x._rep);
407 }
408 return *this;
409 }
410
411 CIMConstMethod& operator=(const CIMMethod& x)
412 {
413 if (x._rep != _rep)
414 {
415 Dec(_rep);
416 Inc(_rep = x._rep);
417 }
418 return *this;
419 }
420
421 mike 1.16 // Throws IllegalName if name argument not legal CIM identifier.
422
423 CIMConstMethod(
424 const String& name,
425 CIMType type,
426 const String& classOrigin = String(),
427 Boolean propagated = false)
428 {
429 _rep = new CIMMethodRep(name, type, classOrigin, propagated);
430 }
431
432 ~CIMConstMethod()
433 {
434 Dec(_rep);
435 }
436
437 const String& getName() const
438 {
439 _checkRep();
440 return _rep->getName();
441 }
442 mike 1.16
443 CIMType getType() const
444 {
445 _checkRep();
446 return _rep->getType();
447 }
448
449 const String& getClassOrigin() const
450 {
451 _checkRep();
452 return _rep->getClassOrigin();
453 }
454
455 Boolean getPropagated() const
456 {
457 _checkRep();
458 return _rep->getPropagated();
459 }
460
461 Uint32 findQualifier(const String& name) const
462 {
463 mike 1.16 _checkRep();
464 return _rep->findQualifier(name);
465 }
466
467 Uint32 getQualifier(Uint32 pos) const
468 {
469 _checkRep();
470 return _rep->getQualifier(pos);
471 }
472
473 Uint32 getQualifierCount() const
474 {
475 _checkRep();
476 return _rep->getQualifierCount();
477 }
478
479 Uint32 findParameter(const String& name) const
480 {
481 _checkRep();
482 return _rep->findParameter(name);
483 }
484 mike 1.16
485 CIMConstParameter getParameter(Uint32 pos) const
486 {
487 _checkRep();
488 return _rep->getParameter(pos);
489 }
490
491 Uint32 getParameterCount() const
492 {
493 _checkRep();
494 return _rep->getParameterCount();
495 }
496
497 operator int() const { return _rep != 0; }
498
499 void toXml(Array<Sint8>& out) const
500 {
501 _checkRep();
502 _rep->toXml(out);
503 }
504
505 mike 1.16 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
506 {
507 _checkRep();
508 _rep->print(o);
509 }
510
511 Boolean identical(const CIMConstMethod& x) const
512 {
513 x._checkRep();
514 _checkRep();
515 return _rep->identical(x._rep);
516 }
517
518 CIMMethod clone() const
519 {
520 return CIMMethod(_rep->clone());
521 }
522
523 private:
524
525 void _checkRep() const
526 mike 1.16 {
527 if (!_rep)
528 ThrowUnitializedHandle();
529 }
530
531 CIMMethodRep* _rep;
532
533 friend class CIMMethod;
534 friend class CIMMethodRep;
535 };
536
537 #define PEGASUS_ARRAY_T CIMMethod
538 # include "ArrayInter.h"
539 #undef PEGASUS_ARRAY_T
540
541 PEGASUS_NAMESPACE_END
542
543 #endif /* Pegasus_Method_h */
|