//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 SubordinateDEFinder

*/

#ifndef TEAMCENTER_SUBORDINATE_DE_FINDER
#define TEAMCENTER_SUBORDINATE_DE_FINDER

#include <string>
#include <vector>


#include <cpd0cd/libcpd0cd_exports.h>


/**
    @brief A convenient C++ class to find corresponding Design Elements for BOMLines under given Reuse Design Element.

    <br/>This is required if the caller wish to find the corresponding Design Element for BOMLines under given Reuse Design Element.
    
   
    Use as follows :
    try catch is required as it throw the IFail exception.
    @code
    try
    {
        vector< tag_t > subDEs;
        Teamcenter::SubordinateDEFinder::findSubordinateDEs( reuseDE, bomlines, subDEs );

    }
    catch( const IFail& ex )
    {
    
    }

    
    @endcode
*/
namespace Teamcenter
{
class CPD0CD_API SubordinateDEFinder
{
    public:
        /**
            Finds the corresponding Design Elements for BOMLines under given Reuse Design Element.
            @throw an IFail exception
            <ul>
            <li>#CXPOM_invalid_tag if an invalid tag is specified for @p reuseDE or @p bomlines.
            <li>#PROP_invalid_descriptor if an issue happened internally with the property.
            </ul>
        */
        static void findSubordinateDEs(  
            tag_t                       reuseDE,     /**< (I) Reuse Design Elemnet */
            const std::vector< tag_t >& bomlines,    /**< (I) BOMLines corresponding to which subordinates Design Element need to be find */
            std::vector< tag_t >&       subDEs       /** < (O) vector which will be populated with corresponding design element for bomlines if 
                                                               no design element find for corresponding bomline then it will contain NULLTAG at same index */
            );
    private:
        
        /**
            Finds the corresponding Design Elements for BOMLines.
            @throw an IFail exception
            <ul>
            <li>#CXPOM_invalid_tag if an invalid tag is specified for @p bomlines.
            <li>#PROP_invalid_descriptor if an issue happened internally with the property.
            </ul>
        */
        static void getDEsCorrespondingToBomLines( 
            const std::map< std::string, tag_t >& occThreadIDs,   /**< (I) Map of occthread chain (key) and Design Element tag (value) */
            const std::vector< tag_t >& bomlines,                 /**< (I) BOMLines corresponding to which subordinates Design Element need to be find */
            tag_t srcItemRev,                                     /**< (I) Source item revision corresponding to reuse DE */
            std::vector< tag_t >& subDEs                          /** < (O) vector which will be populated with corresponding design element for bomlines */
            );
        
        /** 
            Creates the occthread uid chain for given bomline.
            @Returns It returns occthread uid chain of bomline.
            @throw an IFail exception
            <ul>
            <li>#CXPOM_invalid_tag if an invalid tag is specified for @p bomLine.
            <li>#PROP_invalid_descriptor if an issue happened internally with the property.
            </ul>
        */
        static std::string getClonestableIdForBomline( 
            tag_t bomLine,   /**< (I) BOMLine for which occthread uid chain is required */
            tag_t srcItemRev     /**< (I) Source item revision corresponding to reuse DE */
            );
};
}
#include <cpd0cd/libcpd0cd_undef.h>
#endif
