//Copyright 2020 Siemens Digital Industries Software
//==================================================
//Copyright $2015.
//Siemens Product Lifecycle Management Software Inc.
//All Rights Reserved.
//==================================================
//Copyright 2020 Siemens Digital Industries Software

/**
    @file

    This file contains the declaration for the ImpliedEffectivityCalc

*/

#ifndef TEAMCENTER_CFM_IMPLIEDEFFECTIVITYCALC
#define TEAMCENTER_CFM_IMPLIEDEFFECTIVITYCALC

#include <string>
#include <vector>

#include <cfm/libcfm_exports.h>

/**
    @brief A convenient C++ class to calculate implied effectivity of item revisions.

    <br>This is required if the caller wish to calculate implied effectivity of item revisions.
    
   
    Use as follows :
    try catch is required as it throw the IFail exception.
    @code
    try
    {
        vector< string > effecs;
        ImpliedEffectivityCalc::getImpliedEffectivity( revRule, items, effecs);
    }
    catch( const IFail& ex )
    {
    
    }

    
    @endcode
*/

namespace Teamcenter
{
class CFM_API ImpliedEffectivityCalc
{
    public:
        /**
            Calculates the Implied Effectivity of the each input Item Revision.
            <br/>To do so, it retrieves  the Effectivity from the Release Status (Has Status, Any Status) objects of each Item Revision.
            @throws IFail exception with following errors.
            <ul>
            <li>#CFM_rev_rule_not_supported if the specified Revision Rule does not have "Has Status" or "Any Status" clause.
            <li>#PROP_invalid_object if an invalid object instance is used in conjunction with the property.
            </ul>
        */
         static void getImpliedEffectivity( 
            tag_t                       revRule,        /**< (I) Revison Rule based on which the Effectivities are to be calculated */ 
            const std::vector<tag_t>&   itemRevs,       /**< (I) Item Revisions for which the Effectivities needs to be calculated */
            std::vector< std::string >& effectivities   /**< (O) Array of Effectivities for the Item Revision  */
            );
    private:
        
        /** 
            Creates pair of item revision and release status object, pairs belong to one item are put into one vector.
            @throws IFail exception with following errors.
            <ul>
            <li>#CFM_rev_rule_not_supported if the specified Revision Rule does not have "Has Status" or "Any Status" clause.
            <li>#PROP_invalid_object if an invalid object instance is used in conjunction with the property.
            </ul>
        */
        static void populateStatusWithRevision( 
            tag_t                                                    revisionRule, /**< (I) Revison Rule based on which effectivity will be calculated */ 
            const std::vector<tag_t>&                                items, /**< (I) Array of Items */ 
            std::vector< std::vector< std::pair< tag_t, tag_t > > >& revStats /**< (O) This will be populated by this function. Each vector will contain pairs (item revision - release status) belong to one item */ 
                                       ); 

};
}


#include <cfm/libcfm_undef.h>
#endif

