Konkret array counts
John Dennis
jdennis at redhat.com
Tue Feb 5 21:42:13 UTC 2013
Oddly there doesn't seem to be an interface (API) in Konkret to get the
size of an array. This seems like a very odd omission.
For instance, lets say you define a method that has an IN parameter
which is an array of strings, for example sake let's call this array
"Names", your Konkret generated method will have a parameter like this:
const KStringA *Names
To do anything with the Names array you have to know how many elements
it has, this proved difficult to figure out.
The definition of KStringA looks like this:
typedef struct _KStringA
{
CMPIUint32 exists;
CMPIUint32 null;
const CMPIArray* value;
char __padding1[16 - sizeof(CMPIArray*)];
CMPIUint32 count;
char __padding2[4];
}
KStringA;
Notice it has a count member. If you were thinking there is an accessor
defined as an inline or macro for the count you'd be wrong. If you were
thinking you could access Names->count and get a valid value you would
be wrong. Apparently it's never initialized.
I verified that when my method is invoked via YAWN it's passing an array
of strings, I can see it in the generated XML. I also called the
XXX_Args_Print() function that Konkret generated. It also shows the
expected array elements. I also called KStringA_Get(Names, 0) to
retrieve the first element, and lo and behold got the first element.
But nowhere can I find how many elements are in this array nor a way to
iterate it.
Apparently there is nothing in Konkret to give you this critical
information. I resorted to calling CMPI directly (which seems like an
API violation) by doing this:
count = CMGetArrayCount(OptionNames->value, NULL);
which works.
But this seems wrong, I shouldn't be reaching in to CMPI data structures
that Konkret is supposed to be hiding from me, *plus* what's the point
of the count member of the KStringA struct? BTW all KArray types have a
count field, by looking at the source code it appears none of the count
fields are initialized, unless you create the array yourself via of of
the K*A_Init() functions which calls KArray_Init().
Also, there doesn't seem to be any doc whatsoever in Konkret for working
with arrays. That also seems odd. Are arrays a second thought in Konkret?
Comments? Am I missing something?
John
--
John Dennis <jdennis at redhat.com>
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
More information about the openlmi-devel
mailing list