[PATCH] [CU] Commented some structures in the std_association.h file

# HG changeset patch # User Richard Maciel <richardm@br.ibm.com> # Date 1226511618 7200 # Node ID a0bfb9da65f0ae911dbd7d18936d0a5fdcd63345 # Parent 5fbf96fedcf7df32fccc3f989aa4520af8c9a264 [CU] Commented some structures in the std_association.h file * Commented the assoc_handler_t, make_ref_t types and the std_assoc, std_assoc_info structures to make easier for newbies to learn how to create new associations. Signed-off-by: Richard Maciel <richardm@br.ibm.com> diff -r 5fbf96fedcf7 -r a0bfb9da65f0 std_association.h --- a/std_association.h Wed Oct 08 10:32:18 2008 -0700 +++ b/std_association.h Wed Nov 12 15:40:18 2008 -0200 @@ -27,15 +27,68 @@ struct std_assoc; struct std_assoc_info; +/* + * This type defines the signature of the association handler function. The + * handler function receives the reference of the source class of the + * association and must map it to a list of CMPIInstance objects (targets + * of the association). + * + * In parameters: + * CMPIObjectPath * - Path to the source class + * struct std_assoc_info * - See std_assoc_info comment + * + * Out parameters: + * struct inst_list * - Instances associated to ref + */ typedef CMPIStatus (*assoc_handler_t)(const CMPIObjectPath *ref, struct std_assoc_info *info, struct inst_list *list); +/* + * This type defines the signature of the handler which creates the + * reference. The handler function receives the source object path, + * and the target instance, so it can create the reference which is returned + * by the function. + * + * In parameters: + * CMPIObjectPath * - Path to the source class + * CMPIInstance * - Target instance + * std_assoc_info - Information from the query that called this function. + * See std_assoc_info comment for more information. + * std_assoc - This structure keeps the following necessary info to + * the creation of the association class instance: + * association class name and the names of the attributes + * which will be set into the association class. + * See the std_assoc comment for more info + */ typedef CMPIInstance *(*make_ref_t)(const CMPIObjectPath *, const CMPIInstance *, struct std_assoc_info *info, struct std_assoc *); +/* + * std_assoc is the definition that the developer puts in their source file. + * It must be registered using the macro STDA_AssocMIStub. + * + * source_class - Defines the list of possible classes that can be passed to + * the association for this case + * source_prop - Defines the property of the association class that refers + * to the input (source class) of this case. This must match + * that of the schema, and is used for automatic generation of + * the reference object in the References() or ReferenceNames() + * operation + * target_class - Same as source_class, applied for target + * target_prop - Same as source_prop, applied for target + * assoc_class - Defines the list of association classes which implement this + * association + * handler - Function handler responsible for doing the association and + * returning the list of target instances of the association. + * See assoc_handler_t comment for more info + * make_ref - Function handler responsible for creating an instance of the + * association class as requested by the References() or + * ReferenceNames() operation. See make_ref_t comment for more + * info + */ struct std_assoc { char **source_class; char *source_prop; @@ -49,6 +102,17 @@ make_ref_t make_ref; }; +/* + * The std_assoc_info is used to keep information related to the query done + * + * assoc_class - Name of the association class + * result_class - Name of the class of the target + * role - Name of the property of the source class + * result_role - Name of the property of the target class + * properties - + * context - + * provider_name - Calling provider name + */ struct std_assoc_info { const char *assoc_class; const char *result_class;

Hi Richard, None of the comment blocks added in this patch match the style of our other interface documentation. Please see libcmpiutil.h and make sure your comments are doxygen compliant. RM> +/* RM> + * This type defines the signature of the association handler function. The RM> + * handler function receives the reference of the source class of the RM> + * association and must map it to a list of CMPIInstance objects (targets RM> + * of the association). RM> + * RM> + * In parameters: RM> + * CMPIObjectPath * - Path to the source class RM> + * struct std_assoc_info * - See std_assoc_info comment RM> + * RM> + * Out parameters: RM> + * struct inst_list * - Instances associated to ref RM> + */ RM> typedef CMPIStatus (*assoc_handler_t)(const CMPIObjectPath *ref, RM> struct std_assoc_info *info, RM> struct inst_list *list); Personally, I think it's a little bizarre to document the behavior of a function at the definition of the type. This type could be re-used for functions that perform different tasks. I think the explanation should be at the place where a specific instance is used, which would be in std_assoc. Further, I don't think that the documentation of the parameters adds any clarity over the code itself. All the other CMPI functions take a reference, so the meaning of that is well-known. Further, the meaning of the assoc and assoc_info structures should be easily implied by the documentation of the structures themselves. RM> +/* RM> + * This type defines the signature of the handler which creates the RM> + * reference. The handler function receives the source object path, RM> + * and the target instance, so it can create the reference which is returned RM> + * by the function. RM> + * RM> + * In parameters: RM> + * CMPIObjectPath * - Path to the source class RM> + * CMPIInstance * - Target instance RM> + * std_assoc_info - Information from the query that called this function. RM> + * See std_assoc_info comment for more information. RM> + * std_assoc - This structure keeps the following necessary info to RM> + * the creation of the association class instance: RM> + * association class name and the names of the attributes RM> + * which will be set into the association class. RM> + * See the std_assoc comment for more info RM> + */ RM> typedef CMPIInstance *(*make_ref_t)(const CMPIObjectPath *, RM> const CMPIInstance *, RM> struct std_assoc_info *info, RM> struct std_assoc *); I think the same arguments apply to this as well. I'd rather add parameter names to the typedef to both remain consistent with the above, and to convey meaning. RM> +/* RM> + * std_assoc is the definition that the developer puts in their source file. RM> + * It must be registered using the macro STDA_AssocMIStub. RM> + * RM> + * source_class - Defines the list of possible classes that can be passed to RM> + * the association for this case RM> + * source_prop - Defines the property of the association class that refers RM> + * to the input (source class) of this case. This must match RM> + * that of the schema, and is used for automatic generation of RM> + * the reference object in the References() or ReferenceNames() RM> + * operation RM> + * target_class - Same as source_class, applied for target RM> + * target_prop - Same as source_prop, applied for target RM> + * assoc_class - Defines the list of association classes which implement this RM> + * association I think the wording here is a bit off. Association classes don't implement an association. Perhaps this should be something like "A list of association class names that this handler is able to perform". In general, I think that you could drop a lot of the text out of the explanation of the individual members of this structure and add a few sentences about the semantic meaning of this structure at the top. Specifically, this structure defines an association relationship, between a set of source and target classes, through a named (set of) association classes, and the function handler to do the work. RM> +/* RM> + * The std_assoc_info is used to keep information related to the query done RM> + * RM> + * assoc_class - Name of the association class RM> + * result_class - Name of the class of the target RM> + * role - Name of the property of the source class RM> + * result_role - Name of the property of the target class RM> + * properties - RM> + * context - RM> + * provider_name - Calling provider name RM> + */ These structure members are named after the formal CIM association query components, so I don't think the comments are adding any value here. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

+/* + * This type defines the signature of the association handler function. The + * handler function receives the reference of the source class of the + * association and must map it to a list of CMPIInstance objects (targets + * of the association). + * + * In parameters: + * CMPIObjectPath * - Path to the source class
When someone says "class" in CIM, they usually mean the generic class (or MOF) representation. The CMPIObjectPath is a short (or encapsulated) representation of a specific instance. So "Path to source class" here makes me think that you're passing in the generic class info, but really what's being passed in is info about a specific instance. CMPIObjectPath, CMPIInstance (etc) are part of the CMPI API, so I'm not sure it's meaningful documenting here. But I wanted to point out the distinction between ObjectPath and class just to make sure the meaning is clear.
+/* + * std_assoc is the definition that the developer puts in their source file. + * It must be registered using the macro STDA_AssocMIStub.
STDA_AssocMIStub() registers the provider itself. All providers need to register themselves to expose to the CIMOM what type of provider they are. STDA_AssocMIStub() is used for association providers, but there's all STD_InstanceMIStub() and STDIM_MethodMIStub() macros used for registering providers as instance or method providers respectively. std_assoc is used in the registration process, but I don't think it needs to be mentioned here - mentioning it in the comment for STDA_AssocMIStub() would be more appropriate. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Dan Smith
-
Kaitlin Rupert
-
Richard Maciel