/* Copyright 2020 Siemens Digital Industries Software
 ==================================================
 Copyright 2016.
 Siemens Product Lifecycle Management Software Inc.
 All Rights Reserved.
 ==================================================
 Copyright 2020 Siemens Digital Industries Software */
 
/** 
    mfg_maturity_rule_interface.hxx

    example for maturity rule registered as a callback function
*/
#ifndef MFG_MFG_MATURITY_RULE_INTERFACE_H
#define MFG_MFG_MATURITY_RULE_INTERFACE_H

#include <vector>
#include <string>
#include <unidefs.h>
#include <mfg/libmfg_exports.h>

/**
   Represents property data containing property name and its corresponding value.
   @note for @p value, only first member of the vector will be considered. 
*/
typedef struct MFG_maturity_property_data_s {
    std::string                 propertyName;   /**< Name of the property, e.g., "status", "statusDisplayValue", "tooltip". Function using this structure documents the valid property names. */
    std::string                 dataType;       /**< Type of the data. valid values can be "boolean", "character", "date", "float", "double", "integer", "string" and "businessObject" */
    std::vector<std::string>      value;        /**< Value of the property. If single valued then vector will have just one entry*/
} MFG_maturity_property_data_t;

/** The function pointer suggests the parameter a custom API must have for the Maturity Report functionality to work in the application Manufcaturing Process Planner (MPP). The custom API must be registered with teamcenter using install_callback utility. Refer to 
    technical documentation on how this utility is used. Once registered, the Maturity Report functionality will invoke the custom API and use the response in the report. The response must be in specific format as describe below.
    <ul>
    <li>Rule status: One of the property data in the response must have property name as "status" with data type as "string". The acceptable values are "pass","fail" and "error" to suggest the rule status. This property data is required.</li>
    <li>Rule display value: One of the property data in the response may have property name as "statusDisplayValue" with corresponding data type specified. Maturity report functionality does the conversion based on the specfied data type. Refer to technical documentation of Custom Maturity Report on how a specific data type is converted to string and vice-versa. This value is used as display value of the rule in the report. This property data is optional.</li>    
    <li>Rule tooltip: One of the property data in the response can may property name as "tooltip" with data type as "string". This value is used as tooltip. This property data is optional.</li>
    </ul>
    @note If any of input parameter is invalid, @p ruleResults should be empty.
    @returns ITK_ok always
*/
typedef int (*maturity_report_callback_fn_t)(
    const int                                             ruleID,               /**< (I) ID of the rule being evaluated.*/
    const tag_t                                           objectScope,          /**< (I) BOMLine tag which is a scope for the maturity report evaluation. All objects in the hierarchy of this scope are evaluated for the maturity check.*/
    const tag_t                                           targetObject,         /**< (I) BOMLine tag in the hierarchy of objectScope against which rule is evaluated*/
    const std::map<std::string, std::string>&             ruleAttributes,       /**< (I) Rule attributes as defined in custom rule definition. Refer to technical documentation on how a custom rule is defined for maturity report.*/
    std::vector<MFG_maturity_property_data_t>&            ruleResults           /**< (O) List of property data. Maturity report functionality use this information in the report.*/
);

#include <mfg/libmfg_undef.h>
#endif
