HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_PathPattern.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_PathPattern_h__
19 #define __HUSD_PathPattern_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 #include "HUSD_TimeCode.h"
24 #include "HUSD_Utils.h"
25 #include <UT/UT_PathPattern.h>
26 
27 class UT_AutoInterrupt;
28 
30 {
31 public:
33  HUSD_AutoAnyLock &lock,
35  bool case_sensitive,
36  bool assume_wildcards,
37  bool allow_instance_indices,
38  int nodeid,
39  const HUSD_TimeCode &timecode);
40  ~HUSD_PathPattern() override;
41 
42  bool getMayBeTimeVarying() const;
43 
44 protected:
45  // Clone-only constructor used by createEmptyClone() to build the reduced
46  // patterns for createPruningPattern()/createPrecedingGroupPattern(). It has
47  // no lock or time code, so the resulting pattern MUST only be used for
48  // boolean (path) matching, never for point-instance id collection: with a
49  // null lock, instanceMatchData() produces no instance payload. If a clone
50  // is ever used in a collectInstanceIds context (e.g. to add instance id
51  // support to preceding-group tokens), the lock and time code must be
52  // threaded through createEmptyClone() and the pruning/preceding-group
53  // builders first.
54  HUSD_PathPattern(bool case_sensitive,
55  bool assume_wildcards,
56  bool allow_instance_indices);
57 
58  UT_PathPattern *createEmptyClone() const override;
59  bool matchSpecialToken(
60  const UT_StringRef &path,
61  const Token &token,
62  bool *excludes_branch) const override;
64  const UT_StringRef &path,
65  const Token &token,
66  bool *excludes_branch,
67  UT_PathPatternMatchDataPtr &match_data)
68  const override;
70  const UT_StringRef &path,
71  const Token &token) const override;
73  MatchOp op,
74  const UT_PathPatternMatchDataPtr &lhs,
75  const UT_PathPatternMatchDataPtr &rhs)
76  const override;
77  bool matchDataIsEmpty(
78  const UT_PathPatternMatchDataPtr &match_data)
79  const override;
80 
81 private:
82  void initializeSpecialTokens(HUSD_AutoAnyLock &lock,
84  int nodeid,
85  const HUSD_TimeCode &timecode,
86  UT_AutoInterrupt &boss);
87 
88  // Returns the set of matched instance ids for an instancer prim as a match
89  // payload: the ids selected by an explicit instance-id pattern, or all of
90  // the instancer's ids when no pattern is supplied. Returns null when the
91  // path is not a point instancer (or we have no lock for stage access), so
92  // that non-instancer matches stay purely boolean.
93  UT_PathPatternMatchDataPtr instanceMatchData(const UT_StringRef &path,
94  const UT_StringRef &instance_id_pattern) const;
95 
96  // Lock and time code retained for stage access during matching (the match
97  // pass runs within the same lock scope that built this pattern). Null for
98  // the lightweight clones used to build pruning/preceding-group patterns,
99  // which never perform instance matching.
100  HUSD_AutoAnyLock *myLock;
101  HUSD_TimeCode myMatchTimeCode;
102 };
103 
104 #endif
105 
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define HUSD_API
Definition: HUSD_API.h:31
virtual bool matchDataIsEmpty(const UT_PathPatternMatchDataPtr &match_data) const
HUSD_PrimTraversalDemands
Definition: HUSD_Utils.h:39
virtual UT_PathPatternMatchDataPtr combineMatchData(MatchOp op, const UT_PathPatternMatchDataPtr &lhs, const UT_PathPatternMatchDataPtr &rhs) const
Wrapper around hboost::intrusive_ptr.
GLushort pattern
Definition: glad.h:2583
virtual UT_PathPatternMatchDataPtr makeLeafMatchData(const UT_StringRef &path, const Token &token) const
virtual bool matchSpecialTokenWithData(const UT_StringRef &path, const Token &token, bool *excludes_branch, UT_PathPatternMatchDataPtr &match_data) const
virtual bool matchSpecialToken(const UT_StringRef &path, const Token &token, bool *excludes_branch) const
virtual UT_PathPattern * createEmptyClone() const