You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
14 KiB

// Copyright 2020 Siemens Digital Industries Software
// ==================================================
// Copyright 2011.
// Siemens Product Lifecycle Management Software Inc.
// All Rights Reserved.
// ==================================================
// Copyright 2020 Siemens Digital Industries Software
/**
EquivalenceService.hxx
file describing the interface for EquivalenceService.
*/
#ifndef TC_AC_EQUIVALENCE_SERVICE_INTERFACE_H
#define TC_AC_EQUIVALENCE_SERVICE_INTERFACE_H
#include <string>
#include <set>
#include <vector>
#include <map>
#include <unidefs.h>
#include <pom/pom/pom.h>
#include <fclasses/libfclasses_exports.h>
namespace Teamcenter
{
class EquivalenceCriteria;
class EquivalenceService;
typedef int (*Equivalence_criteria_creator_fn_t)(const EquivalenceService*, EquivalenceCriteria **);
struct FCLASSES_API EquivalenceServiceInfo
{
std::string sourceClosureRule;
std::string targetClosureRule;
int srcDepth;//-1 means none
int targetDepth;// -1 means none
bool bSrcExpanded;
bool bTargetExpanded;
bool bForceTargetExpand;
std::set<std::string> criteria;//disallow duplicates
std::vector<tag_t> srcScopeNodes;
std::vector<tag_t> targetScopeNodes;
tag_t srcContextObj;
tag_t targetContextObj;
EquivalenceServiceInfo():srcDepth(-1),targetDepth(-1),bSrcExpanded(false),bTargetExpanded(false),bForceTargetExpand(false),
srcContextObj(NULLTAG), targetContextObj(NULLTAG)
{
}
};
/**
Defines maps in which key is representation of a type of property or any equivalence criteria
and the value is comma separated list of property names or criteria names or attribute IDs.
<br/>The maps are used for passing different types of properties like Attribute group,
Managed Attribute Group,Basic through appropriate representation of keys like
Mfg0attribute_groups, Mfg0properties.
<br/>This can be used for any such applications like 4gd.
*/
struct FCLASSES_API EquivalenceServiceInfo2
{
std::map<std::string, std::vector<std::string> > m_additionalCriteria; /**< Map of type of property to vector of property names */
std::map<std::string, std::vector<int> > m_additionalCriteriaInt; /**< Map of type of property to vector of property IDs */
std::map<std::string, std::vector<double> > m_additionalCriteriaDbl; /**< Map of type of property to vector of property IDs */
std::map<std::string, std::vector<tag_t> > m_additionalCriteriaObj; /**< Map of type of Business Object to vector of objects */
};
class FCLASSES_API EquivalenceService
{
public:
virtual ~EquivalenceService();
//getEquivalent objects between 2 structures, while expanding them using the closure rules provided.
//The expansion starts at each srcScope and targetScope. Output is a map of src tag to its<74>
// set of equivalent target nodes. Any previous data will be cleared and reinitialized.
//PRE:must supply the source and targetScopes and the closure rules. The depth should be set to -1 if unused.
// Otherwise, they have to indicate how many levels below each scope line the traversal has to proceed.
// Criteria names must be names registered with install_callback ( the last argument ).
// If bForceExpandTarget is true - target will be expanded. If false, target is may or maynot be expanded
// and the target closure rule will be used to see if a target line instantiated is reachable.
//POST: Any equivalent lines are returned as a map - the key is the src node, and value is a set of equivalent target nodes.
//Return: ErrorCode.
virtual int getEquivalentNodes(const std::vector<tag_t> &srcScopes,
const std::string& closureRuleName,
const std::vector<tag_t>& targetScopes,
const std::string& targetClosureRuleName,
const std::set<std::string> &criteriaNames,
int srcDepth,
int targetDepth,
bool bForceTargetExpand,
std::map<tag_t, std::set<tag_t> > & targetMatches,
std::map<tag_t, std::set<tag_t> > * srcMatches=0,
tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/
) =0;
//Same as above - except the source is already expanded (expandedSrcNodes).
virtual int getEquivalentNodes(const std::set<tag_t> & expandedSrcNodes,
const std::vector<tag_t>& targetScopes,
const std::string& targetClosureRuleName,
const std::set<std::string> &criteriaNames,
bool bForceTargetExpand,
int targetDepth,
std::map<tag_t, std::set<tag_t> > & targetMatches,
std::map<tag_t, std::set<tag_t> > * srcMatches=0,
tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
//To be used when both the source and target structures are already expanded.
virtual int getEquivalentNodes(const std::set<tag_t> & expandedSrcNodes,
const std::set<tag_t> & expandedTargetNodes,
const std::set<std::string> &criteriaNames,
std::map<tag_t, std::set<tag_t> > & targetMatches,
std::map<tag_t, std::set<tag_t> > * srcMatches=0,
tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
//To be used when both the source is expanded, but target is not. In this case
// target expansion will be a side effect of finding equivalences using the supplied criteria (ID in conext - top level)
// Very rare usage.
virtual int getEquivalentNodes(const std::vector<tag_t> &srcScopes,
const std::string& closureRuleName,
const std::vector<tag_t> & targetScopes,
int srcDepth,
const std::set<std::string> &criteriaNames,
std::map<tag_t, std::set<tag_t> > & targetMatches,
std::map<tag_t, std::set<tag_t> > * srcMatches=0,
tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
//To be used when the source is expanded, but target is not. In this case
// target expansion will be a side effect of finding equivalences using the supplied criteria
// (eg: ID in conext - top level)
virtual int getEquivalentNodes(const std::set<tag_t> &/*srcNodes*/,
const std::vector<tag_t> & /*targetScopes*/,
const std::set<std::string> &/*criteriaNamesv*/,
std::map<tag_t, std::set<tag_t> > & /*targetMatches*/,
std::map<tag_t, std::set<tag_t> > * /*srcMatches*/=0,
tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
/**
Retrieves the Equivalent Nodes when the source is expanded but the target is not.
@returns
<ul>
<li>#ITK_ok on success.</li>
<li>#RLZ0REALIZATION_invalid_input if @p srcNodes or @p tgtScopes is invalid.</li>
<li>#MDL0MODEL_null_tag if @p srcNodes or @p tgtScopes is #NULLTAG.</li>
<li>#COLLABCTX_no_property_specified_for_comparison if no property is specified for comparison in the map @p additionalCriteria.</li>
<li>#COLLABCTX_invalid_property_for_object_type if the properties specified in the map @p additionalCriteria are invalid.</li>
</ul>
*/
virtual int getEquivalentNodes(
const std::set<tag_t> & srcNodes, /**< (I) The source nodes */
const std::vector<tag_t> & tgtScopes, /**< (I) The targets scopes */
const std::set<std::string> & criteriaNames, /**< (I) The criteria names */
std::map<tag_t, std::set<tag_t> > & tgtMatch, /**< (O) The targets matching each input source */
std::map<tag_t, std::set<tag_t> > * srcMatch = 0, /**< (O) The matching sources to each target */
std::map<std::string, std::vector<std::string> > * additionalCriteria=0, /**< (I) A map of property type to list of properties */
tag_t srcCtxt=NULLTAG, /**< (I) The Source Context */
tag_t targetCtxt=NULLTAG, /**< (I) The Target Context. */
int targetDepth=0 /**< (I) The Target depth to represent the level of target structure. */
)=0;
//Returns all the lines that are expanded in src structure.
//PRE: one of the getEquivalentNodes method should have been called. If not expanded already - will expand the source structure
// if a closureRule was passed in, or if closure rule service can expand based on context (eg: cpd expansion).
//POST: return any lines expanded in the source structure. Note for non-closure rule mode and not any structure expansion
// understood by mfg layer expansion ( like cpd) - this will return empty set.
virtual int getExpandedSrcNodes(std::set<tag_t>& nodes) =0;
//This returns all the lines expanded in the target ( if passed in - that list is returned, else
// if targetclosure rule was used - only those expanded using that closure rule are returned.
// This is to avoid needless target expansion for performance reasons.)
// This may not be needed, unless there are special cases - like the case of finding missing in src.
// If such a case arises, the caller would then call findTargetInSource repeatedly for each line returned here.
//PRE: one of the getEquivalentMethods should have been called.
//POST: if expanded lines are passed in - there are returned, else if a closure rule was provided - will expand
// using that (if not done already) and return those lines. The caller must be careful in calling this - as it will
// always expand target. If caller does not want it to be expanded - should use their own partial expand mechanisms
// instead of calling this method.
virtual int getExpandedTargetNodes(std::set<tag_t>& nodes ) =0;
virtual int getEquivalenceParameters(EquivalenceServiceInfo& info) const = 0;
/**
Retrieves the results of the criteria as defined in the provided structure.
@returns
<ul>
<li>#ITK_ok on success.</li>
<li>#COLLABCTX_no_property_specified_for_comparison if no property is specified for comparison in the criteria of the structure @p info2.</li>
<li>#COLLABCTX_invalid_property_for_object_type if the properties specified in the criteria of the structure @p info2 are invalid.</li>
</ul>
*/
virtual int getEquivalenceParameters(
EquivalenceServiceInfo2& info2 /**< (IO) The results of the criteria as defined in the provided structure */
) const = 0;
virtual int populateTargetNodes(std::set<tag_t> &) = 0;
// SPECIAL BEHAVIOR: Not to be used by normal callers. Special case.
// To be used when both source and target structures are already expanded.
// This method is not meant to clear any prior data. It is meant to reuse
// some of the data from the existing service and create a new instance of
// equivalenceService and get results. The input src and targetNodes will
// not be the same as the original service object. This is to be used in those
// rare cases where the registration does not allow client to register more than
// than one equivalence service.
virtual int getEquivalentNodes(const std::set<tag_t> & expandedSrcNodes,
const std::set<tag_t> & expandedTargetNodes,
std::map<tag_t, std::set<tag_t> > & targetMatches,
std::set<tag_t>* missingInTarget=0,
std::set<tag_t>* missingInSrc=0,
std::map<tag_t, std::set<tag_t> > * srcMatches=0,
const std::set<std::string> *criteriaNames=0,
tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
};
}
#include <fclasses/libfclasses_undef.h>
#endif