-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmpimacs.h
6562 lines (5947 loc) · 213 KB
/
cmpimacs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ------------------------------------------------------------------------- */
/* */
/* Copyright (c) 2006-2015 The Open Group */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining a */
/* copy of this software (the "Software"), to deal in the Software without */
/* restriction, including without limitation the rights to use, copy, */
/* modify, merge, publish, distribute, sublicense, and/or sell copies of */
/* the Software, and to permit persons to whom the Software is furnished */
/* to do so, subject to the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be included */
/* in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS */
/* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT */
/* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR */
/* THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/* */
/* ------------------------------------------------------------------------- */
/**
* @file cmpimacs.h
* @brief Defines CMPI convenience functions that ease the use of the various
* function tables.
*
* MIs that intend to use the @ref convenience-func "CMPI convenience functions"
* need to include this header file.
*
* This header file belongs to the Open Group Technical Standard: Systems
* Management: Common Manageability Programming Interface (CMPI Standard),
* Issue 2 Version 1.
*
* This header file is provided as a convenience only. In the case of any
* discrepancy between the header file and the CMPI Standard (incorporating any
* subsequent Technical Corrigenda), the CMPI Standard shall be definitive.
*/
#ifndef _CMPIMACS_H_
#define _CMPIMACS_H_
#include <cmpift.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
@addtogroup convenience-func
@{
The convenience functions in `cmpimacs.h` are a set of macros and inline
functions that ease the use of the various CMPI function tables. They are
provided to help the CMPI developer and are NOT required to be used. They
do, however, make for cleaner and more readable code.
In CMPI 1.0, the CMPI convenience functions were defined as C preprocessor
macros, which coined the term "CMPI macros".
Since CMPI 2.0, they are defined as C inline functions wherever possible.
Only a small number of them is still defined as C preprocessor macros.
Since CMPI 2.1, those convenience functions that are defined as C inline
functions can also be generated as C preprocessor macros, if the CMPI user
defines the symbol @ref sym-inline "CMPI_NO_INLINE".
The convenience functions are NOT documented in the @ref ref-cmpi-standard
"CMPI Standard", just the existence of the `cmpimacs.h` header file.
However, this online documentation documents the convenience functions and
includes hyperlinks between the convenience functions and the underlying MB
functions or other components of CMPI, in both directions.
The convenience functions follow the same rules for backwards compatibility
as the other CMPI functions (see Subclause 1.7 in the @ref
ref-cmpi-standard "CMPI Standard").
The convenience functions can be broken down into the following groups:
@li @parblock
Convenience functions for MB functions in broker function tables.
The use of these convenience functions simplifies the code, largely by
bypassing the added step of getting from the CMPIBroker structure to the
right one of its function tables and to the corresponding MB function.
These convenience functions have the same set of arguments as the
corresponding MB functions. They have a simplified description of their
functionality and arguments. For a full description, the linked
description of the corresponding MB functions and arguments may need to
be consulted.
For example, the following MB function call:
@code
_broker->bft->attachThread(_broker, ctx);
@endcode
is simplified when using a convenience function to:
@code
CBAttachThread(_broker, ctx);
@endcode
For a list of those convenience functions, see @ref convenience-func-broker
"MB Functions in Broker Function Tables".
@endparblock
@li @parblock
Convenience functions for MB functions of encapsulated data type objects.
The use of these convenience functions simplifies the code, largely by
bypassing the added step of getting from the encapsulated data type
object to its function table and to the corresponding MB function.
These convenience functions have the same set of arguments as the
corresponding MB functions. They have a simplified description of their
functionality and arguments. For a full description, the linked
description of the corresponding MB functions and arguments may need to
be consulted.
For example, the following MB function call:
@code
inst->ft->getProperty(inst, name, rc);
@endcode
is simplified when using a convenience function to:
@code
CMGetProperty(inst, name, rc);
@endcode
For a list of those convenience functions, see @ref convenience-func-edt
"MB Functions of Encapsulated Data Types".
@endparblock
@li @parblock
Helper Functions and Macros
The helper functions and macros encapsulate the access to selected
structure members or otherwise provide functionality that is not directly
available through an MB function.
Examples of this are CMReturn() and CMIsNullObject().
For details, see @ref convenience-func-helper
"Helper Functions and Macros".
@endparblock
@li @parblock
MI Factory Stubs
The MI factory stubs are macros that generate the MI factory functions
and function tables.
Examples of this are CMInstanceMIStub() and CMInstanceMIFactory().
For details, see @ref convenience-func-mi-factory-stubs
"MI Factory Stubs".
@endparblock
@}
*/
/**
@addtogroup sym-inline
@{
@brief Symbols controlling the definition of convenience functions.
These symbols control whether the @ref convenience-func
"CMPI convenience functions" are defined as static inline functions (when
CMPI_INLINE is defined) or as preprocessor macros (when CMPI_NO_INLINE is
defined).
A user of the CMPI header files may define either CMPI_INLINE or
CMPI_NO_INLINE. The default assumed by the CMPI header files is
CMPI_INLINE.
@}
*/
#if !defined(CMPI_INLINE) && !defined(CMPI_NO_INLINE)
# define CMPI_INLINE // if none is defined, set the default
#endif
#if defined(CMPI_INLINE) && defined(CMPI_NO_INLINE)
# error "Only one of CMPI_INLINE and CMPI_NO_INLINE may be defined."
#endif
/**
@addtogroup convenience-func-helper
@{
Helper Functions and Macros.
The helper functions and macros encapsulate the access to selected
structure members or otherwise provide functionality that is not directly
available through an MB function.
*/
/**
@brief Initialize a CMPIStatus structure with a return code and no message.
CMSetStatus() initializes a CMPIStatus structure with a return code and no
message.
@param st If not NULL, points to the CMPIStatus structure that is being
intialized.
@param rc A @ref CMPIrc value specifying the return code.
@return Nothing.
@examples
@code (.c)
CMPIStatus st = { CMPI_RC_OK, NULL };
if (....) // something bad happened
{
CMSetStatus(&st, CMPI_RC_ERR_NOT_SUPPORTED);
return st;
}
@endcode
@see CMPIStatus
@statusopenpegasus Not tested
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMSetStatus(st, rc_) \
do \
{ \
if (st) \
{ \
(st)->rc = (rc_); \
(st)->msg = NULL; \
} \
} while (0)
#else
static inline void CMSetStatus(
CMPIStatus *st,
CMPIrc rc)
{
if (st)
{
st->rc = rc;
st->msg = NULL;
}
}
#endif
/** @brief Initializes a CMPIStatus object with CMPIStatus and message.
CMSetStatusWithString() initialized the CMPIStatus object @p st with
CMPIStatus @p rc and message text defined by @p msg
@param st Points to target CMPIStatus object.
@param rc A @ref CMPIrc value specifying the return code.
@param msg CMPIString containing message text to be
inserted into @p st.
@see CMPIStatus
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMSetStatusWithString(st, rc_, msg_) \
do \
{ \
if (st) \
{ \
(st)->rc = (rc_); \
(st)->msg = (msg_); \
} \
} while (0)
#else
static inline void CMSetStatusWithString(
CMPIStatus *st,
CMPIrc rc,
CMPIString *msg)
{
if (st)
{
st->rc = rc;
st->msg = msg;
}
}
#endif
/** @brief Initializes CMPIStatus struct with return code and message text
message.
CMSetStatusWithChars() initializes a CMPIStatus structure with @p rcp and
either a null msg or a new CMPIString object created from @p msg if @p msg
is not NULL.
@param mb CMPIBroker structure.
@param st Points to CMPIStatus object.
@param rc A @ref CMPIrc value specifying the return code.
@param msg C string character string containing the message
text or NULL if no text is to be added to the
CMPIStatus @p st.
@examples
@code (.c)
static CMPIBroker *_broker; // Cany be populated with stub macro
. . .
CMPIStatus rc = { CMPI_RC_OK, NULL };
CMSetStatusWithChars (_broker, &rc,
CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
@endcode
@see CMPIStatus
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMSetStatusWithChars(mb, st, rc_, msg_) \
do \
{ \
if (st) \
{ \
(st)->rc = (rc_); \
if (mb) \
(st)->msg = (mb)->eft->newString((mb), (msg_), NULL); \
else \
(st)->msg = NULL; \
} \
} while (0)
#else
static inline void CMSetStatusWithChars(
const CMPIBroker *mb,
CMPIStatus *st,
CMPIrc rc,
const char *msg)
{
if (st)
{
st->rc = rc;
if (mb)
{
st->msg = mb->eft->newString(mb, msg, NULL);
}
else
{
st->msg = NULL;
}
}
}
#endif
/**
@brief Return the calling function with CMPIStatus specifying a return code
and no message.
The CMReturn() macro builds a CMPIStatus object specifying a return code
and no message and exits the function in which it was called, causing it
to return that CMPIStatus object. CMReturn() can only be used in functions
that return CMPIStatus.
@param rc A @ref CMPIrc value specifying the return code.
@return This macro never returns to its caller; it contains a `return`
statement and therefore exits the function from which it was called.
@examples
Example of enumerateInstanceNames() MI function that returns CMPI_RC_OK to
the MB.
@code (.c)
CMPIStatus testEnumInstanceNames (CMPIInstanceMI *mi,
const CMPIContext *ctx, const CMPIResult *rslt,
const CMPIObjectPath *classPath)
{
// .... code to return instance names
CMReturn(CMPI_RC_OK);
}
@endcode
@statusopenpegasus TBD
@hideinitializer
*/
#define CMReturn(rc) \
do \
{ \
CMPIStatus stat; \
CMSetStatus(&stat, rc); \
return stat; \
} while (0)
/**
@brief Return the calling function with CMPIStatus specifying a return code
and a message (from CMPIString object).
The CMReturnWithString() macro builds a CMPIStatus object specifying a
return code and a message and exits the function in which it was executed,
causing it to return that CMPIStatus object. CMReturnWithString() can only
be used in functions that return CMPIStatus.
@param rc A @ref CMPIrc value specifying the return code.
@param str Points to a CMPIString object specifying the message.
@return This macro never returns to its caller; it contains a `return`
statement and therefore exits the function from which it was called.
@examples
Example of code in an MI function that checks for an optional MB capability
and returns with an error to the MB if the capability is not available.
@code (.c)
static const CMPIBroker * _broker;
// ...
if (_broker->brokerCapabilities & CMPI_MB_PropertyFiltering)
{
// ...
}
else
{
CMReturnWithString(CMPI_RC_ERR_NOT_SUPPORTED,
CMNewString(_broker, "Property Filtering capability not available",
NULL));
}
@endcode
@see CMPIStatus
@statusopenpegasus TBD
@hideinitializer
*/
#define CMReturnWithString(rc, str) \
do \
{ \
CMPIStatus stat; \
CMSetStatusWithString(&stat, rc, str); \
return stat; \
} while (0)
/**
@brief Return the calling function with CMPIStatus specifying a return code
and a message (from C string).
The CMReturnWithChars() macro builds a CMPIStatus object specifying a
return code and a message and exits the function in which it was executed,
causing it to return that CMPIStatus object. CMReturnWithChars() can only
be used in functions that return CMPIStatus.
@param mb CMPIBroker structure.
@param rc A @ref CMPIrc value specifying the return code.
@param chars A C string (`char*`) specifying the message.
@return This macro never returns to its caller; it contains a `return`
statement and therefore exits the function from which it was called.
@examples
Example of code in a modifyInstance() MI function that is not implemented
and returns to the MB with CMPI_RC_ERR_NOT_SUPPORTED and an according error
message.
@code (.c)
static const CMPIBroker * _broker;
// ...
CMPIStatus testModifyInstance (...)
{
CMReturnWithChars(_broker, CMPI_RC_ERR_NOT_SUPPORTED,
"ModifyInstance is not supported");
}
@endcode
@see CMPIStatus
@statusopenpegasus TBD
@hideinitializer
*/
#define CMReturnWithChars(mb, rc, chars) \
do \
{ \
CMPIStatus stat; \
CMSetStatusWithChars(mb, &stat, rc, chars); \
return stat; \
} while (0)
/** @brief Test an encapsulated data type object pointer for NULL.
This test is suitable for checking any pointers to encapsulated data type
objects for NULL, including the pointers returned by their factory
functions.
@param objptr Pointer to the encapsulated data type object to be tested.
This argument is defined as `void*` to encompass any encapsulated data
type object.
@retval true The object is NULL.
@retval false The object is NOT NULL.
@examples
@code (.c)
cop = CMNewObjectPath(_broker, "root/SampleProvider", _ClassName, &rc);
CMAddKey(cop2, "Identifier", (CMPIValue *)&value1, CMPI_uint8);
// test for NULL before creating instance from cop
if (!CMIsNullObject(cop))
{
instance2 = CMNewInstance(_broker, cop2, &rc);
...
}
@endcode
@statusopenpegasus TBD
@hideinitializer
@todo TODO_KS The example seems to be somewhat confused. Why is a test
of cop meaningful when it is not used at all, and cop2 is used
instead?@n
Karl to review the example.
*/
#ifdef CMPI_NO_INLINE
#define CMIsNullObject(objptr) \
((objptr) == NULL)
#else
static inline CMPIBoolean CMIsNullObject(
const void *objptr)
{
return objptr == NULL;
}
#endif
/** @brief Test a CMPIData value for NULL.
CMIsNullValue() tests a CMPIData value for NULL.
This is done based on the @ref CMPI_nullValue flag in its @p state member.
@param data The CMPIData value to be tested.
@retval true The CMPIData value is NULL.
@retval false The CMPIData value is not NULL.
@examples
Process received method call that includes a CIMObject path @p ref for
classname, method name, arguments, argument name and value in the argument
@code (.c)
CMPIStatus *rc;
className = CMGetClassName(ref, &rc);
name = CMGetCharsPtr(className, &rc);
if (!strcmp(name, _ClassName))
{
if (!strcmp ("SayHello", methodName))
{
// gets the number of arguments contained in "in" Args.
if (CMGetArgCount(in, &rc) > 0)
{
// gets Name argument value
data = CMGetArg(in, "MethodName", &rc);
// should we check rc on response.
// check for data type and !null value of
// argument value rcvd
if (data.type == CMPI_string && !(CMIsNullValue(data)))
{
strCat = CMGetCharsPtr(data.value.string, &rc);
strcat(result, strCat);
strcat(result, "!");
// create the new string to return to client
str1 = CMNewString(_broker, result, &rc);
val1.string = str1;
}
. . .
@endcode
@see CMPIData, CMPIValueState
@statusopenpegasus TBD
@hideinitializer
@todo TODO_KS The example is way too complex if it just intends to show
how to use this function.@n
Karl to come up with simpler example.
*/
#ifdef CMPI_NO_INLINE
#define CMIsNullValue(data) \
(((data).state & CMPI_nullValue) != 0)
#else
static inline CMPIBoolean CMIsNullValue(
CMPIData data)
{
return (data.state & CMPI_nullValue) != 0;
}
#endif
/** @brief Test a CMPIData value for being a key.
CMIsKeyValue() tests a CMPIData value for being a key.
This is done based on the @ref CMPI_keyValue flag in its @p state member.
@param data The CMPIData value to be tested.
@retval true The CMPIData value is a key.
@retval false The CMPIData value is not a key.
@see CMPIData, CMPIValueState
@statusopenpegasus Not tested
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMIsKeyValue(data) \
(((data).state & CMPI_keyValue) != 0)
#else
static inline CMPIBoolean CMIsKeyValue(
CMPIData data)
{
return (data.state & CMPI_keyValue) != 0;
}
#endif
/** @brief Test a CMPIData value for having an array type.
CMIsArray() tests a CMPIData value for having an array type.
This is done based on the @ref CMPI_ARRAY flag in its @p type member.
@param data The CMPIData value to be tested.
@retval true The CMPIData value has array type.
@retval false The CMPIData value does not have array type.
@see CMPIData, CMPIType
@statusopenpegasus Not tested
@hideinitializer
@todo TODO_KS This needs an example.
*/
#ifdef CMPI_NO_INLINE
#define CMIsArray(data) \
(((data).type & CMPI_ARRAY) != 0)
#else
static inline CMPIBoolean CMIsArray(
CMPIData data)
{
return (data.type & CMPI_ARRAY) != 0;
}
#endif
/**
@}
@addtogroup convenience-func-edt
@{
MB Functions of Encapsulated Data Types.
The @ref convenience-func "convenience functions" in this group call
functions on encapsulated data type objects.
The factory functions creating encapsulated data type objects are covered
in @ref convenience-func-broker "MB Functions in Broker Function Tables".
They simplify the code by eliminating the references to function tables.
*/
/**
@brief Release an encapsulated data type object.
CMRelease() releases an encapsulated data type object, by calling the
release() function in the function table of the object.
This indicates to the MB that the object (including any objects it
contains) will no longer be used by the MI. The MB may free the resources
associated with the object during the call to this function, or later
during some garbage collection cycle.
@param obj Points to the encapsulated data type object to be released.
@return CMPIStatus structure indicating the function return status.
@errors
The function return status will indicate one of the following @ref CMPIrc
codes:
@li `CMPI_RC_OK` - Function successful.
@li `CMPI_RC_ERR_INVALID_HANDLE` - The @p rslt handle is invalid.
@fulldescription CMPIContextFT.release(),
CMPIResultFT.release(),
CMPIStringFT.release(),
CMPIArrayFT.release(),
CMPIEnumerationFT.release(),
CMPIInstanceFT.release(),
CMPIObjectPathFT.release(),
CMPIArgsFT.release(),
CMPIDateTimeFT.release(),
CMPISelectExpFT.release(),
CMPISelectCondFT.release(),
CMPISubCondFT.release(),
CMPIPredicateFT.release(),
CMPIErrorFT.release(),
CMPIPropertyListFT.release(),
CMPIEnumerationFilterFT.release()
@examples
Code to clean up after attempting to create an instance:
@code (.c)
CMPIStatus rc = { CMPI_RC_OK, NULL };
CMPISelectExp *se_def = NULL;
clone = CMClone(se_def, &rc);
// . . . test @rc for good completion and use clone if
CMRelease(clone);
@endcode
@statusopenpegasus TBD
@hideinitializer
*/
#define CMRelease(obj) \
((obj)->ft->release((obj)))
/** @brief Clone an encapsulated data type object.
CMClone() clones an encapsulated data type object, by calling the
clone() function in the function table of the object.
@param obj Points to the encapsulated data type object to be cloned.
@param [out] rc Function return status (suppressed when NULL).
@return @parblock If successful, returns a pointer to the
copied clone of the object defined by @p obj.
The returned object shall be explicitly released by the MI using its
release() function, or the CMRelease() macro.
If not successful, returns NULL.
@endparblock
@errors
The following @ref CMPIrc codes shall be recognized:
@li `CMPI_RC_OK` Operation successful.
@li `CMPI_RC_ERR_INVALID_HANDLE` The @p ef handle is invalid.
@fulldescription CMPIContextFT.clone(),
CMPIResultFT.clone(),
CMPIStringFT.clone(),
CMPIArrayFT.clone(),
CMPIEnumerationFT.clone(),
CMPIInstanceFT.clone(),
CMPIObjectPathFT.clone(),
CMPIArgsFT.clone(),
CMPIDateTimeFT.clone(),
CMPISelectExpFT.clone(),
CMPISelectCondFT.clone(),
CMPISubCondFT.clone(),
CMPIPredicateFT.clone(),
CMPIErrorFT.clone(),
CMPIPropertyListFT.clone(),
CMPIEnumerationFilterFT.clone()
@examples
Clone an instance to add to an array:
@code (.c)
// preexisting instance CMPIInstance *ci)
{
CMPIStatus rc = { CMPI_RC_OK, NULL };
CMPIInstance *inst;
if (ci)
{
// clone the instance to be added to the array
inst = CMClone(ci, &rc);
. . .
}
@endcode
@statusopenpegasus TBD
@hideinitializer
@todo TBD KS: test if we need brief in this and release doc
*/
#define CMClone(obj, rc) \
((obj)->ft->clone((obj), (rc)))
/**
@}
@addtogroup convenience-func-edt-context
@{
*/
/** @brief Get a context entry in a CMPIContext object by name.
@param ctx CMPIContext object.
@param name Name of the context entry. See @ref
def-context-fieldnames "Names of CMPIContext fields" for defined names.
@param [out] rc Function return status (suppressed when NULL).
@return Context entry value and type.
@fulldescription CMPIContextFT.getEntry()
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMGetContextEntry(ctx, name, rc) \
((ctx)->ft->getEntry((ctx), (name), (rc)))
#else
static inline CMPIData CMGetContextEntry(
const CMPIContext *ctx,
const char *name,
CMPIStatus *rc)
{
return ctx->ft->getEntry(ctx, name, rc);
}
#endif
/** @brief Get a context entry in a CMPIContext object by index.
@param ctx CMPIContext object.
@param index Zero-based position of the context entry in the internal data
array. The order of context entries in the internal data array is
implementation-defined.
@param [out] name Name of the returned context entry (suppressed when NULL).
@param [out] rc Function return status (suppressed when NULL).
@return Context entry value and type.
@fulldescription CMPIContextFT.getEntryAt()
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMGetContextEntryAt(ctx, index, name, rc) \
((ctx)->ft->getEntryAt((ctx), (index), (name), (rc)))
#else
static inline CMPIData CMGetContextEntryAt(
const CMPIContext *ctx,
CMPICount index,
CMPIString **name,
CMPIStatus *rc)
{
return ctx->ft->getEntryAt(ctx, index, name, rc);
}
#endif
/** @brief Get the number of context entries in a CMPIContext object.
@param ctx CMPIContext object.
@param [out] rc Function return status (suppressed when NULL).
@return Number of entries in the CMPIContext object.
@fulldescription CMPIContextFT.getEntryCount()
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMGetContextEntryCount(ctx, rc) \
((ctx)->ft->getEntryCount((ctx), (rc)))
#else
static inline CMPICount CMGetContextEntryCount(
const CMPIContext *ctx,
CMPIStatus *rc)
{
return ctx->ft->getEntryCount(ctx, rc);
}
#endif
/** @brief Add or replace a context entry in a CMPIContext object.
@param ctx CMPIContext object.
@param name Name of the context entry.
See @ref def-context-fieldnames "Names of CMPIContext fields" for
defined names.
@param value CMPIValue structure containing the non-NULL value to be
assigned to the element, or NULL to assign NULL.
@param type Type of the value.
@return Function return status.
@fulldescription CMPIContextFT.addEntry()
@statusopenpegasus Used
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMAddContextEntry(ctx, name, value, type) \
((ctx)->ft->addEntry((ctx), (name), (CMPIValue *)(value), (type)))
#else
static inline CMPIStatus CMAddContextEntry(
const CMPIContext *ctx,
const char *name,
const CMPIValue *value,
const CMPIType type)
{
return ctx->ft->addEntry(ctx, name, value, type);
}
#endif
/**
@}
@addtogroup convenience-func-edt-result
@{
*/
/** @brief Add a value/type pair to a CMPIResult object.
@param rslt CMPIResult object.
@param value CMPIValue structure containing the non-NULL value to be
assigned to the element, or NULL to assign NULL.
@param type Type of the value.
@return Function return status.
@fulldescription CMPIResultFT.returnData()
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMReturnData(rslt, value, type) \
((rslt)->ft->returnData((rslt), (CMPIValue *)(value), (type)))
#else
static inline CMPIStatus CMReturnData(
const CMPIResult *rslt,
const CMPIValue *value,
const CMPIType type)
{
return rslt->ft->returnData(rslt, value, type);
}
#endif
/** @brief Add an instance to a CMPIResult object.
@param rslt CMPIResult object.
@param inst Instance to be returned.
@return Function return status.
@fulldescription CMPIResultFT.returnInstance()
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMReturnInstance(rslt, inst) \
((rslt)->ft->returnInstance((rslt), (inst)))
#else
static inline CMPIStatus CMReturnInstance(
const CMPIResult *rslt,
const CMPIInstance *inst)
{
return rslt->ft->returnInstance(rslt, inst);
}
#endif
/** @brief Add an object path to a CMPIResult object.
@param rslt CMPIResult object.
@param op Object path to be returned.
@return Function return status.
@fulldescription CMPIResultFT.returnObjectPath()
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMReturnObjectPath(rslt, op) \
((rslt)->ft->returnObjectPath((rslt), (op)))
#else
static inline CMPIStatus CMReturnObjectPath(
const CMPIResult *rslt,
const CMPIObjectPath *op)
{
return rslt->ft->returnObjectPath(rslt, op);
}
#endif
/** @brief Indicate that no further items will be added to a CMPIResult object.
@param rslt CMPIResult object.
@return Function return status.
@fulldescription CMPIResultFT.returnDone()
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMReturnDone(rslt) \
((rslt)->ft->returnDone((rslt)))
#else
static inline CMPIStatus CMReturnDone(
const CMPIResult *rslt)
{
return rslt->ft->returnDone(rslt);
}
#endif
#ifdef CMPI_VER_200
/** @brief Add an error to a CMPIResult object.
@param rslt CMPIResult object.
@param er Error to be returned.
@return Function return status.
@fulldescription CMPIResultFT.returnError()
@added200
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMReturnError(rslt, er) \
((rslt)->ft->returnError((rslt), (er)))
#else
static inline CMPIStatus CMReturnError(
const CMPIResult *rslt,
const CMPIError *er)
{
return rslt->ft->returnError(rslt, er);
}
#endif
#endif /* CMPI_VER_200 */
/**
@}
@addtogroup convenience-func-edt-string
@{
*/
/** @brief Get the C-language string representation of a CMPIString object
(**Deprecated**).
@param str CMPIString object.
@return C-language string representation of the CMPIString object.
@fulldescription CMPIStringFT.getCharPtr()
@examples
@code (.c)
myObjPath = CMNewObjectPath(
_broker,
CMGetCharPtr(CMGetNameSpace(ref,0)),
"TestCMPI_KeyReturned",
0);
@endcode
@deprecated This macro is deprecated since CMPI 2.1, because it does not
provide argument checking or a return code. Use CMGetCharsPtr(),
instead.
@see CMGetCharsPtr()
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMGetCharPtr(str) \
((str)->ft->getCharPtr((str), NULL))
#else
static inline const char * CMGetCharPtr(
const CMPIString *str)
{
return str->ft->getCharPtr(str, NULL);
}
#endif
/** @brief Get a C-language string representation of a CMPIString object.
@param str CMPIString object.
@param [out] rc Function return status (suppressed when NULL).
@return C-language string representation of the CMPIString object.
@fulldescription CMPIStringFT.getCharPtr()
@examples
@code (.c)
CMPIObjectPath *op = NULL;
CMPIStatus rc = { CMPI_RC_OK, NULL };
objPath = CMNewObjectPath (_broker,
CMGetCharsPtr(CMGetNameSpace(ref, &rc), NULL),
class,
&rc);
@endcode
@statusopenpegasus TBD
@hideinitializer
*/
#ifdef CMPI_NO_INLINE
#define CMGetCharsPtr(str, rc) \
((str)->ft->getCharPtr((str), (rc)))
#else
static inline const char * CMGetCharsPtr(
const CMPIString *str,
CMPIStatus *rc)
{
return str->ft->getCharPtr(str, rc);
}
#endif