Teamcenter C++ API Reference  2312
EquivalenceService.hxx
Go to the documentation of this file.
1 // Copyright 2022 Siemens Digital Industries Software
2 // ==================================================
3 // Copyright 2011.
4 // Siemens Product Lifecycle Management Software Inc.
5 // All Rights Reserved.
6 // ==================================================
7 // Copyright 2022 Siemens Digital Industries Software
8 
15 #ifndef TC_AC_EQUIVALENCE_SERVICE_INTERFACE_H
16 #define TC_AC_EQUIVALENCE_SERVICE_INTERFACE_H
17 
18 #include <string>
19 #include <set>
20 #include <vector>
21 #include <map>
22 
23 #include <unidefs.h>
24 #include <pom/pom/pom.h>
25 
26 #include <fclasses/libfclasses_exports.h>
27 namespace Teamcenter
28 {
29  class EquivalenceCriteria;
30  class EquivalenceService;
31 
33 
34  struct FCLASSES_API EquivalenceServiceInfo
35  {
36  std::string sourceClosureRule;
37  std::string targetClosureRule;
38  int srcDepth;//-1 means none
39  int targetDepth;// -1 means none
43  std::set<std::string> criteria;//disallow duplicates
44  std::vector<tag_t> srcScopeNodes;
45  std::vector<tag_t> targetScopeNodes;
48 
49  EquivalenceServiceInfo():srcDepth(-1),targetDepth(-1),bSrcExpanded(false),bTargetExpanded(false),bForceTargetExpand(false),
50  srcContextObj(NULLTAG), targetContextObj(NULLTAG)
51  {
52  }
53  };
54 
63  struct FCLASSES_API EquivalenceServiceInfo2
64  {
65  std::map<std::string, std::vector<std::string> > m_additionalCriteria;
66  std::map<std::string, std::vector<int> > m_additionalCriteriaInt;
67  std::map<std::string, std::vector<double> > m_additionalCriteriaDbl;
68  std::map<std::string, std::vector<tag_t> > m_additionalCriteriaObj;
69  };
70 
71  class FCLASSES_API EquivalenceService
72  {
73  public:
74  virtual ~EquivalenceService();
75  //getEquivalent objects between 2 structures, while expanding them using the closure rules provided.
76  //The expansion starts at each srcScope and targetScope. Output is a map of src tag to its�
77  // set of equivalent target nodes. Any previous data will be cleared and reinitialized.
78  //PRE:must supply the source and targetScopes and the closure rules. The depth should be set to -1 if unused.
79  // Otherwise, they have to indicate how many levels below each scope line the traversal has to proceed.
80  // Criteria names must be names registered with install_callback ( the last argument ).
81  // If bForceExpandTarget is true - target will be expanded. If false, target is may or maynot be expanded
82  // and the target closure rule will be used to see if a target line instantiated is reachable.
83  //POST: Any equivalent lines are returned as a map - the key is the src node, and value is a set of equivalent target nodes.
84 
85  //Return: ErrorCode.
86  virtual int getEquivalentNodes(const std::vector<tag_t> &srcScopes,
87  const std::string& closureRuleName,
88  const std::vector<tag_t>& targetScopes,
89  const std::string& targetClosureRuleName,
90  const std::set<std::string> &criteriaNames,
91  int srcDepth,
92  int targetDepth,
93  bool bForceTargetExpand,
94  std::map<tag_t, std::set<tag_t> > & targetMatches,
95  std::map<tag_t, std::set<tag_t> > * srcMatches=0,
96  tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
97  tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/
98  ) =0;
99 
100  //Same as above - except the source is already expanded (expandedSrcNodes).
101  virtual int getEquivalentNodes(const std::set<tag_t> & expandedSrcNodes,
102  const std::vector<tag_t>& targetScopes,
103  const std::string& targetClosureRuleName,
104  const std::set<std::string> &criteriaNames,
105  bool bForceTargetExpand,
106  int targetDepth,
107  std::map<tag_t, std::set<tag_t> > & targetMatches,
108  std::map<tag_t, std::set<tag_t> > * srcMatches=0,
109  tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
110  tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
111 
112  //To be used when both the source and target structures are already expanded.
113  virtual int getEquivalentNodes(const std::set<tag_t> & expandedSrcNodes,
114  const std::set<tag_t> & expandedTargetNodes,
115  const std::set<std::string> &criteriaNames,
116  std::map<tag_t, std::set<tag_t> > & targetMatches,
117  std::map<tag_t, std::set<tag_t> > * srcMatches=0,
118  tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
119  tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
120 
121 
122  //To be used when both the source is expanded, but target is not. In this case
123  // target expansion will be a side effect of finding equivalences using the supplied criteria (ID in conext - top level)
124  // Very rare usage.
125  virtual int getEquivalentNodes(const std::vector<tag_t> &srcScopes,
126  const std::string& closureRuleName,
127  const std::vector<tag_t> & targetScopes,
128  int srcDepth,
129  const std::set<std::string> &criteriaNames,
130  std::map<tag_t, std::set<tag_t> > & targetMatches,
131  std::map<tag_t, std::set<tag_t> > * srcMatches=0,
132  tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
133  tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
134 
135  //To be used when the source is expanded, but target is not. In this case
136  // target expansion will be a side effect of finding equivalences using the supplied criteria
137  // (eg: ID in conext - top level)
138  virtual int getEquivalentNodes(const std::set<tag_t> &/*srcNodes*/,
139  const std::vector<tag_t> & /*targetScopes*/,
140  const std::set<std::string> &/*criteriaNamesv*/,
141  std::map<tag_t, std::set<tag_t> > & /*targetMatches*/,
142  std::map<tag_t, std::set<tag_t> > * /*srcMatches*/=0,
143  tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
144  tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
145 
157  virtual int getEquivalentNodes(
158  const std::set<tag_t> & srcNodes,
159  const std::vector<tag_t> & tgtScopes,
160  const std::set<std::string> & criteriaNames,
161  std::map<tag_t, std::set<tag_t> > & tgtMatch,
162  std::map<tag_t, std::set<tag_t> > * srcMatch = 0,
163  std::map<std::string, std::vector<std::string> > * additionalCriteria=0,
164  tag_t srcCtxt=NULLTAG,
165  tag_t targetCtxt=NULLTAG,
166  int targetDepth=0
167  )=0;
168 
169  //Returns all the lines that are expanded in src structure.
170  //PRE: one of the getEquivalentNodes method should have been called. If not expanded already - will expand the source structure
171  // if a closureRule was passed in, or if closure rule service can expand based on context (eg: cpd expansion).
172  //POST: return any lines expanded in the source structure. Note for non-closure rule mode and not any structure expansion
173  // understood by mfg layer expansion ( like cpd) - this will return empty set.
174  virtual int getExpandedSrcNodes(std::set<tag_t>& nodes) =0;
175 
176  //This returns all the lines expanded in the target ( if passed in - that list is returned, else
177  // if targetclosure rule was used - only those expanded using that closure rule are returned.
178  // This is to avoid needless target expansion for performance reasons.)
179  // This may not be needed, unless there are special cases - like the case of finding missing in src.
180  // If such a case arises, the caller would then call findTargetInSource repeatedly for each line returned here.
181  //PRE: one of the getEquivalentMethods should have been called.
182  //POST: if expanded lines are passed in - there are returned, else if a closure rule was provided - will expand
183  // using that (if not done already) and return those lines. The caller must be careful in calling this - as it will
184  // always expand target. If caller does not want it to be expanded - should use their own partial expand mechanisms
185  // instead of calling this method.
186  virtual int getExpandedTargetNodes(std::set<tag_t>& nodes ) =0;
187 
188  virtual int getEquivalenceParameters(EquivalenceServiceInfo& info) const = 0;
189 
199  virtual int getEquivalenceParameters(
201  ) const = 0;
202 
203  virtual int populateTargetNodes(std::set<tag_t> &) = 0;
204 
205 
206  // SPECIAL BEHAVIOR: Not to be used by normal callers. Special case.
207  // To be used when both source and target structures are already expanded.
208  // This method is not meant to clear any prior data. It is meant to reuse
209  // some of the data from the existing service and create a new instance of
210  // equivalenceService and get results. The input src and targetNodes will
211  // not be the same as the original service object. This is to be used in those
212  // rare cases where the registration does not allow client to register more than
213  // than one equivalence service.
214  virtual int getEquivalentNodes(const std::set<tag_t> & expandedSrcNodes,
215  const std::set<tag_t> & expandedTargetNodes,
216  std::map<tag_t, std::set<tag_t> > & targetMatches,
217  std::set<tag_t>* missingInTarget=0,
218  std::set<tag_t>* missingInSrc=0,
219  std::map<tag_t, std::set<tag_t> > * srcMatches=0,
220  const std::set<std::string> *criteriaNames=0,
221  tag_t srcCtxt=NULLTAG,/* in cases like cdp - this can be the subset tag.*/
222  tag_t targetCtxt=NULLTAG/*in case it is needed for some future cases.*/)=0;
223  };
224 }
225 #include <fclasses/libfclasses_undef.h>
226 #endif