24 #ifndef PXR_USD_SDF_PATH_EXPRESSION_EVAL_H
25 #define PXR_USD_SDF_PATH_EXPRESSION_EVAL_H
38 #include <type_traits>
44 template <
class DomainType>
48 template <
class DomainType>
63 void (SdfPathExpression::PathPattern
const &)> translatePattern);
76 void (SdfPathExpression::PathPattern
const &)> translatePattern);
85 explicit operator bool()
const {
96 void _Init(SdfPathExpression::PathPattern
const &
pattern,
103 bool (
int,
SdfPath const &)> runNthPredicate)
const;
162 template <
class DomainType>
165 struct _DefaultToPath {
166 auto operator()(DomainType obj)
const {
167 return SdfPathExpressionObjectToPath(obj);
171 struct _DefaultToObj {
173 return SdfPathExpressionPathToObject(
174 path,
static_cast<std::decay_t<DomainType>
const *
>(
nullptr));
182 SdfMakePathExpressionEval<DomainType>(
190 return Match(obj, _DefaultToPath {}, _DefaultToObj {});
195 template <
class ObjectToPath,
class PathToObject>
197 ObjectToPath
const &objToPath,
198 PathToObject
const &pathToObj)
const {
199 auto matchIter = _matches.cbegin();
200 auto patternMatch = [&](
bool skip) {
205 return (*matchIter++)(obj, objToPath, pathToObj);
207 return _Match(patternMatch);
213 class _PatternMatch :
public _PatternMatchBase {
215 _PatternMatch(SdfPathExpression::PathPattern
const &
pattern,
219 _predicates.push_back(
221 return _predicates.size()-1;
223 _Init(pattern, linkPredicate);
227 template <
class ObjectToPath,
class PathToObject>
228 bool operator()(DomainType obj,
229 ObjectToPath
const &objToPath,
230 PathToObject
const &pathToObj)
const {
231 auto runNthPredicate =
233 return _predicates[i](pathToObj(
path));
235 return _Match(objToPath(obj), runNthPredicate);
239 std::vector<SdfPredicateProgram<DomainType>> _predicates;
242 std::vector<_PatternMatch> _matches;
256 template <
class DomainType>
266 auto translatePattern = [&](Expr::PathPattern
const &
pattern) {
269 eval._matches.emplace_back(pattern, lib);
270 eval._ops.push_back(Eval::PatternMatch);
282 #endif // PXR_USD_SDF_PATH_EXPRESSION_EVAL_H
size_t _numMatchingComponents
SDF_API bool _Match(TfFunctionRef< bool(bool)> patternMatch) const
SdfPredicateProgram< DomainType > SdfLinkPredicateExpression(SdfPredicateExpression const &expr, SdfPredicateLibrary< DomainType > const &lib)
GLsizei const GLchar *const * path
friend bool Sdf_MakePathExpressionEvalImpl(Sdf_PathExpressionEvalBase &eval, SdfPathExpression const &expr, TfFunctionRef< void(SdfPathExpression::PathPattern const &)> translatePattern)
SDF_API bool Sdf_MakePathExpressionEvalImpl(Sdf_PathExpressionEvalBase &eval, SdfPathExpression const &expr, TfFunctionRef< void(SdfPathExpression::PathPattern const &)> translatePattern)
SDF_API void _Init(SdfPathExpression::PathPattern const &pattern, TfFunctionRef< int(SdfPredicateExpression const &)> linkPredicate)
HUSD_API bool eval(VtValue &val, T &ret_val)
SDF_API bool _Match(SdfPath const &path, TfFunctionRef< bool(int, SdfPath const &)> runNthPredicate) const
std::vector< _Component > _components
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
SdfPathExpressionEval< DomainType > SdfMakePathExpressionEval(SdfPathExpression const &expr, SdfPredicateLibrary< DomainType > const &lib)
#define PXR_NAMESPACE_CLOSE_SCOPE
bool Match(DomainType obj)
std::vector< std::string > _explicitNames
bool Match(DomainType obj, ObjectToPath const &objToPath, PathToObject const &pathToObj) const
std::vector< ArchRegex > _regexes