HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
registry.h
Go to the documentation of this file.
1 //
2 // Copyright 2024 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_VALIDATION_USD_VALIDATION_REGISTRY_H
8 #define PXR_USD_VALIDATION_USD_VALIDATION_REGISTRY_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/base/tf/singleton.h"
15 
16 #include <memory>
17 #include <shared_mutex>
18 #include <unordered_map>
19 
20 /// \file
21 
23 
24 /// \class UsdValidationRegistry
25 ///
26 /// UsdValidationRegistry manages and provides access to UsdValidationValidator
27 /// / UsdValidationValidatorSuite for USD Validation.
28 ///
29 /// UsdValidationRegistry is a singleton class, which serves as a central
30 /// registry to hold / own all validators and validatorSuites by their names.
31 /// UsdValidationRegistry is also immortal and its singleton instance is never
32 /// destroyed. This is to ensure that all validators and suites registered with
33 /// the registry are available throughout the lifetime of the application.
34 ///
35 /// Both Core USD and client-provided validators are registered with the
36 /// registry. Validators can be registered and retrieved dynamically, supporting
37 /// complex validation scenarios across different modules or plugins.
38 ///
39 /// Clients of USD can register validators either via plugin infrastructure,
40 /// which results in lazy loading of the validators, or explicitly register
41 /// validators in their code via appropriate APIs.
42 ///
43 /// As discussed in UsdValidationValidator, validators are associated with
44 /// UsdValidateLayerTaskFn, UsdValidateStageTaskFn or UsdValidatePrimTaskFn,
45 /// which govern how a layer, stage or a prim needs to be validated.
46 /// UsdValidationValidator / UsdValidationValidatorSuite also have metadata,
47 /// which can either be provided in the plugInfo.json when registering the
48 /// validators via plugin mechanism, or by providing metadata field when
49 /// registering validators.
50 ///
51 /// Example of registering a validator named "StageMetadataValidator" with
52 /// doc metadata using plufInfo.json:
53 ///
54 /// \code
55 /// {
56 /// "Plugins": [
57 /// {
58 /// "Info": {
59 /// "Name": "usd"
60 /// "LibraryPath": "@PLUG_INFO_LIBRARY_PATH",
61 /// ....
62 /// ....
63 /// ....
64 /// "Validators": {
65 /// "keywords" : ["UsdCoreValidators"],
66 /// ...
67 /// "StageMetadataValidator": {
68 /// "doc": "Validates stage metadata."
69 /// },
70 /// ...
71 /// ...
72 /// ...
73 /// }
74 /// }
75 /// } ]
76 /// }
77 /// \endcode
78 ///
79 /// The above example can then be registered in the plugin:
80 ///
81 /// ```cpp
82 /// TF_REGISTRY_FUNCTION(UsdValidationRegistry)
83 /// {
84 /// UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance();
85 /// const TfToken validatorName("usdValidation:StageMetadataValidator");
86 /// const UsdValidateStageTaskFn stageTaskFn =
87 /// [](const UsdStagePtr &usdStage,
88 /// const UsdValidationTimeRange &timeRange) {
89 /// UsdValidationErrorVector errors;
90 /// if (!usdStage->GetDefaultPrim()) {
91 /// errors.emplace_back(UsdValidationErrorType::Error,
92 /// {UsdValidationErrorSite(usdStage, SdfPath("/"))},
93 /// "Stage has missing or invalid defaultPrim.");
94 /// }
95 /// if (!usdStage->HasAuthoredMetadata(
96 /// UsdGeomTokens->metersPerUnit)) {
97 /// errors.emplace_back(UsdValidationErrorType::Error,
98 /// {UsdValidationErrorSite(usdStage, SdfPath("/"))},
99 /// "Stage does not specify its linear scale in "
100 /// "metersPerUnit.");
101 /// }
102 /// if (!usdStage->HasAuthoredMetadata(
103 /// UsdGeomTokens->upAxis)) {
104 /// errors.emplace_back(UsdValidationErrorType::Error,
105 /// {UsdValidationErrorSite(usdStage, SdfPath("/"))},
106 /// "Stage does not specify an upAxis.");
107 /// }
108 /// return errors;
109 /// };
110 /// registry.RegisterPluginValidator(validatorName, stageTaskFn);
111 /// }
112 /// ```
113 ///
114 /// Clients can also register validators by explicitly providing
115 /// UsdValidationValidatorMetadata, instead of relying on plugInfo.json for the
116 /// same. Though it's recommended to use appropriate APIs when validator metadata
117 /// is being provided in the plugInfo.json.
118 ///
119 /// Example of validator registration by explicitly providing metadata, when it's
120 /// not available in the plugInfo.json:
121 ///
122 /// ```cpp
123 /// {
124 /// UsdValidationRegistry& registry = UsdValidationRegistry::GetInstance();
125 /// const UsdValidationValidatorMetadata &metadata =
126 /// GetMetadataToBeRegistered();
127 /// const UsdValidateLayerTaskFn &layerTask =
128 /// GetLayerTaskForValidator();
129 /// registry.RegisterValidator(metadata, layerTask);
130 /// }
131 /// ```
132 ///
133 /// Usage:
134 ///
135 /// As shown above, UsdValidationValidator or UsdValidationValidatorSuite can be
136 /// registered using specific metadata or names, and retrieved by their name.
137 /// The registry also provides functionality to check the existence of a
138 /// validator / suite, load validators / suites dynamically if they are not in
139 /// the registry.
140 ///
141 /// Clients can also retrieve metadata for validators associated with a
142 /// specific plugin, keywords or schemaTypes, this can help clients filter out
143 /// relevant validators they need to validate their context / scene.
144 ///
145 /// Note that this class is designed to be thread-safe:
146 /// Querying of validator metadata, registering new validator (hence mutating
147 /// the registry) or retrieving previously registered validator are designed to
148 /// be thread-safe.
149 ///
150 /// Validators may also have a number of fixers associated with them, which
151 /// can provide potential fixes for various validation errors associated with a
152 /// validation task. Fixers can be retrieved from the UsdValidationValidator or
153 /// the UsdValidationError itself. Note that UsdValidationRegistry does not
154 /// manage fixers directly, and these are held by respective
155 /// UsdValidationValidator(s). It's the responsibility of the client to retrieve
156 /// appropriate fixers for a given error and apply them, on a provided
157 /// UsdEditTarget. UsdValidationErrorSite(s) associated with a validation error
158 /// provide the context of the error, which may be used while applying a fix on
159 /// a UsdEditTarget, or a stronger layer can be used as an edit target to apply
160 /// the fix.
161 ///
162 /// \sa UsdValidationValidator
163 /// \sa UsdValidationValidatorSuite
164 /// \sa UsdValidationFixer
166 {
168  UsdValidationRegistry &operator=(const UsdValidationRegistry &) = delete;
169 
170 public:
173  {
175  }
176 
177  /// Register UsdValidationValidator defined in a plugin using \p
178  /// validatorName and \p layerTaskFn with the UsdValidationRegistry.
179  ///
180  /// Here \p validatorName should include the name of the plugin the
181  /// validator belongs to, delimited by ":".
182  ///
183  /// Note calling RegisterPluginValidator with a validatorName which is
184  /// already registered will result in a coding error. HasValidator can be
185  /// used to determine if a validator is already registered and associated
186  /// with validatorName.
187  ///
188  /// Also note any other failure to register a validator results in a coding
189  /// error.
190  ///
191  /// \p fixers can be provided to associate fixers with the validator.
192  ///
193  /// \sa HasValidator
195  void RegisterPluginValidator(const TfToken &validatorName,
196  const UsdValidateLayerTaskFn &layerTaskFn,
197  std::vector<UsdValidationFixer> fixers = {});
198 
199  /// Register UsdValidationValidator defined in a plugin using \p
200  /// validatorName and \p stageTaskFn with the UsdValidationRegistry.
201  ///
202  /// Here \p validatorName should include the name of the plugin the
203  /// validator belongs to, delimited by ":".
204  ///
205  /// Note calling RegisterPluginValidator with a validatorName which is
206  /// already registered will result in a coding error. HasValidator can be
207  /// used to determine if a validator is already registered and associated
208  /// with validatorName.
209  ///
210  /// Also note any other failure to register a validator results in a coding
211  /// error.
212  ///
213  /// \p fixers can be provided to associate fixers with the validator.
214  ///
215  /// \sa HasValidator
217  void RegisterPluginValidator(const TfToken &validatorName,
218  const UsdValidateStageTaskFn &stageTaskFn,
219  std::vector<UsdValidationFixer> fixers = {});
220 
221  /// Register UsdValidationValidator defined in a plugin using \p
222  /// validatorName and \p primTaskFn with the UsdValidationRegistry.
223  ///
224  /// Here \p validatorName should include the name of the plugin the
225  /// validator belongs to, delimited by ":".
226  ///
227  /// Note calling RegisterPluginValidator with a validatorName which is
228  /// already registered will result in a coding error. HasValidator can be
229  /// used to determine if a validator is already registered and associated
230  /// with validatorName.
231  ///
232  /// Also note any other failure to register a validator results in a coding
233  /// error.
234  ///
235  /// \p fixers can be provided to associate fixers with the validator.
236  ///
237  /// \sa HasValidator
239  void RegisterPluginValidator(const TfToken &validatorName,
240  const UsdValidatePrimTaskFn &primTaskFn,
241  std::vector<UsdValidationFixer> fixers = {});
242 
243  /// Register UsdValidationValidator using \p metadata and \p layerTaskFn
244  /// with the UsdValidationRegistry.
245  ///
246  /// Clients can explicitly provide validator metadata, which is then used to
247  /// register a validator and associate it with name metadata. The metadata
248  /// here is not specified in a plugInfo.
249  ///
250  /// Note calling RegisterValidator with a validator name which is already
251  /// registered will result in a coding error. HasValidator can be used to
252  /// determine if a validator is already registered and associated with
253  /// validatorName.
254  ///
255  /// Also note any other failure to register a validator results in a coding
256  /// error.
257  ///
258  /// \p fixers can be provided to associate fixers with the validator.
259  ///
260  /// \sa HasValidator
263  const UsdValidateLayerTaskFn &layerTaskFn,
264  std::vector<UsdValidationFixer> fixers = {});
265 
266  /// Register UsdValidationValidator using \p metadata and \p stageTaskFn
267  /// with the UsdValidationRegistry.
268  ///
269  /// Clients can explicitly provide validator metadata, which is then used to
270  /// register a validator and associate it with name metadata. The metadata
271  /// here is not specified in a plugInfo.
272  ///
273  /// Note calling RegisterValidator with a validator name which is already
274  /// registered will result in a coding error. HasValidator can be used to
275  /// determine if a validator is already registered and associated with
276  /// validatorName.
277  ///
278  /// Also note any other failure to register a validator results in a coding
279  /// error.
280  ///
281  /// \p fixers can be provided to associate fixers with the validator.
282  ///
283  /// \sa HasValidator
286  const UsdValidateStageTaskFn &stageTaskFn,
287  std::vector<UsdValidationFixer> fixers = {});
288 
289  /// Register UsdValidationValidator using \p metadata and \p primTaskFn
290  /// with the UsdValidationRegistry.
291  ///
292  /// Clients can explicitly provide validator metadata, which is then used to
293  /// register a validator and associate it with name metadata. The metadata
294  /// here is not specified in a plugInfo.
295  ///
296  /// Note calling RegisterValidator with a validator name which is already
297  /// registered will result in a coding error. HasValidator can be used to
298  /// determine if a validator is already registered and associated with
299  /// validatorName.
300  ///
301  /// Also note any other failure to register a validator results in a coding
302  /// error.
303  ///
304  /// \p fixers can be provided to associate fixers with the validator.
305  ///
306  /// \sa HasValidator
309  const UsdValidatePrimTaskFn &primTaskFn,
310  std::vector<UsdValidationFixer> fixers = {});
311 
312  /// Register UsdValidationValidatorSuite defined in a plugin using
313  /// \p validatorSuiteName and \p containedValidators with the
314  /// UsdValidationRegistry.
315  ///
316  /// Here \p validatorSuiteName should include the name of the plugin the
317  /// validator belongs to, delimited by ":".
318  ///
319  /// Note UsdValidationValidatorMetadata::isSuite must be set to true in the
320  /// plugInfo, else the validatorSuite will not be registered.
321  ///
322  /// Note calling RegisterPluginValidatorSuite with a validatorSuiteName
323  /// which is already registered will result in a coding error.
324  /// HasValidatorSuite can be used to determine if a validator is already
325  /// registered and associated with validatorName.
326  ///
327  /// Also note any other failure to register a validator results in a coding
328  /// error.
329  ///
330  /// \sa HasValidatorSuite
333  const TfToken &validatorSuiteName,
334  const std::vector<const UsdValidationValidator *> &containedValidators);
335 
336  /// Register UsdValidationValidatorSuite using \p metadata and
337  /// \p containedValidators with the UsdValidationRegistry.
338  ///
339  /// Clients can explicitly provide validator metadata, which is then used to
340  /// register a suite and associate it with name metadata. The metadata
341  /// here is not specified in a plugInfo.
342  ///
343  /// Note UsdValidationValidatorMetadata::isSuite must be set to true in the
344  /// plugInfo, else the validatorSuite will not be registered.
345  ///
346  /// Note calling RegisterPluginValidatorSuite with a validatorSuiteName
347  /// which is already registered will result in a coding error.
348  /// HasValidatorSuite can be used to determine if a validator is already
349  /// registered and associated with validatorName.
350  ///
351  /// Also note any other failure to register a validator results in a coding
352  /// error.
353  ///
354  /// \sa HasValidatorSuite
357  const UsdValidationValidatorMetadata &metadata,
358  const std::vector<const UsdValidationValidator *> &containedValidators);
359 
360  /// Return true if a UsdValidationValidator is registered with the name \p
361  /// validatorName; false otherwise.
363  bool HasValidator(const TfToken &validatorName) const;
364 
365  /// Return true if a UsdValidationValidatorSuite is registered with the name
366  /// \p validatorSuiteName; false otherwise.
368  bool HasValidatorSuite(const TfToken &suiteName) const;
369 
370  /// Returns a vector of const pointer to UsdValidationValidator
371  /// corresponding to all validators registered in the UsdValidationRegistry.
372  ///
373  /// If a validator is not found in the registry, this method will load
374  /// appropriate plugins, if the validator is made available via a plugin.
375  ///
376  /// Note that this call will load in many plugins which provide a
377  /// UsdValidationValidator, if not already loaded. Also note that returned
378  /// validators will only include validators defined in plugins or any
379  /// explicitly registered validators before this call.
381  std::vector<const UsdValidationValidator *> GetOrLoadAllValidators();
382 
383  /// Returns a const pointer to UsdValidationValidator if \p validatorName is
384  /// found in the registry.
385  ///
386  /// If a validator is not found in the registry, this method will load
387  /// appropriate plugins, if the validator is made available via a plugin.
388  ///
389  /// Returns a nullptr if no validator is found.
391  const UsdValidationValidator *
392  GetOrLoadValidatorByName(const TfToken &validatorName);
393 
394  /// Returns a vector of const pointer to UsdValidationValidator
395  /// corresponding to \p validatorNames found in the registry.
396  ///
397  /// If a validator is not found in the registry, this method will load
398  /// appropriate plugins, if the validator is made available via a plugin.
399  ///
400  /// Size of returned vector might be less than the size of the input
401  /// validatorNames, in case of missing validators.
403  std::vector<const UsdValidationValidator *>
404  GetOrLoadValidatorsByName(const TfTokenVector &validatorNames);
405 
406  /// Returns a vector of const pointer to UsdValidationValidatorSuite
407  /// corresponding to all validator suites registered in the
408  /// UsdValidationRegistry.
409  ///
410  /// If a suite is not found in the registry, this method will load
411  /// appropriate plugins, if the suite is made available via a plugin.
412  ///
413  /// Note that this call might load in many plugins which provide a
414  /// UsdValidationValidatorSuite, if not already loaded. Also note that
415  /// returned suites will only include suites defined in plugins or any
416  /// explicitly registered suites before this call.
418  std::vector<const UsdValidationValidatorSuite *>
420 
421  /// Returns a const pointer to UsdValidationValidatorSuite if \p suiteName
422  /// is found in the registry.
423  ///
424  /// If a suite is not found in the registry, this method will load
425  /// appropriate plugins, if the suite is made available via a plugin.
426  ///
427  /// Returns a nullptr if no validator is found.
430  GetOrLoadValidatorSuiteByName(const TfToken &suiteName);
431 
432  /// Returns a vector of const pointer to UsdValidationValidatorSuite
433  /// corresponding to \p suiteNames found in the registry.
434  ///
435  /// If a suite is not found in the registry, this method will load
436  /// appropriate plugins, if the suite is made available via a plugin.
437  ///
438  /// Size of returned vector might be less than the size of the input
439  /// suiteNames, in case of missing validators.
441  std::vector<const UsdValidationValidatorSuite *>
443 
444  /// Returns true if metadata is found in the _validatorNameToMetadata for
445  /// a validator/suite name, false otherwise.
446  ///
447  /// \p metadata parameter is used as an out parameter here.
449  bool GetValidatorMetadata(const TfToken &name,
450  UsdValidationValidatorMetadata *metadata) const;
451 
452  /// Return vector of all UsdValidationValidatorMetadata known to the
453  /// registry
456 
457  /// Returns vector of UsdValidationValidatorMetadata associated with the
458  /// Validators which belong to the \p pluginName.
459  ///
460  /// This API can be used to curate a vector of validator metadata, that
461  /// clients may want to load and use in their validation context.
462  ///
463  /// Note that this method does not result in any plugins to be loaded.
466  GetValidatorMetadataForPlugin(const TfToken &pluginName) const;
467 
468  /// Returns vector of UsdValidationValidatorMetadata associated with the
469  /// Validators which has the \p keyword.
470  ///
471  /// This API can be used to curate a vector of validator metadata, that
472  /// clients may want to load and use in their validation context.
473  ///
474  /// Note that this method does not result in any plugins to be loaded.
477  GetValidatorMetadataForKeyword(const TfToken &keyword) const;
478 
479  /// Returns vector of UsdValidationValidatorMetadata associated with the
480  /// Validators which has the \p schemaType.
481  ///
482  /// This API can be used to curate a vector of validator metadata, that
483  /// clients may want to load and use in their validation context.
484  ///
485  /// Note that this method does not result in any plugins to be loaded.
488  GetValidatorMetadataForSchemaType(const TfToken &schemaType) const;
489 
490  /// Returns vector of UsdValidationValidatorMetadata associated with the
491  /// Validators which belong to the \p pluginNames.
492  ///
493  /// The returned vector is a union of all UsdValidationValidatorMetadata
494  /// associated with the plugins.
495  ///
496  /// This API can be used to curate a vector of validator metadata, that
497  /// clients may want to load and use in their validation context.
498  ///
499  /// Note that this method does not result in any plugins to be loaded.
502  GetValidatorMetadataForPlugins(const TfTokenVector &pluginNames) const;
503 
504  /// Returns vector of UsdValidationValidatorMetadata associated with the
505  /// Validators which has at least one of the \p keywords.
506  ///
507  /// The returned vector is a union of all UsdValidationValidatorMetadata
508  /// associated with the keywords.
509  ///
510  /// This API can be used to curate a vector of validator metadata, that
511  /// clients may want to load and use in their validation context.
512  ///
513  /// Note that this method does not result in any plugins to be loaded.
516  GetValidatorMetadataForKeywords(const TfTokenVector &keywords) const;
517 
518  /// Returns vector of UsdValidationValidatorMetadata associated with the
519  /// Validators which has at least one of the \p schameTypes.
520  ///
521  /// The returned vector is a union of all UsdValidationValidatorMetadata
522  /// associated with the schemaTypes.
523  ///
524  /// This API can be used to curate a vector of validator metadata, that
525  /// clients may want to load and use in their validation context.
526  ///
527  /// Note that this method does not result in any plugins to be loaded.
530  GetValidatorMetadataForSchemaTypes(const TfTokenVector &schemaTypes) const;
531 
532 private:
534 
536 
537  // Initialize _validatorNameToMetadata, _keywordToValidatorNames and
538  // _schemaTypeToValidatorNames by parsing all plugInfo.json, find all
539  // Validators.
540  void _PopulateMetadataFromPlugInfo();
541 
542  // Templated method to register validator, called by appropriate
543  // RegisterValidator methods, providing UsdValidateLayerTaskFn,
544  // UsdValidateStageTaskFn or UsdValidatePrimTaskFn.
545  template <typename ValidateTaskFn>
546  void _RegisterPluginValidator(const TfToken &validatorName,
547  const ValidateTaskFn &taskFn,
548  std::vector<UsdValidationFixer> fixers);
549 
550  // Overloaded templated _RegisterValidator, where metadata is explicitly
551  // provided.
552  template <typename ValidateTaskFn>
553  void _RegisterValidator(const UsdValidationValidatorMetadata &metadata,
554  const ValidateTaskFn &taskFn,
555  std::vector<UsdValidationFixer> fixers,
556  bool addMetadata = true);
557 
558  void _RegisterValidatorSuite(
559  const UsdValidationValidatorMetadata &metadata,
560  const std::vector<const UsdValidationValidator *> &containedValidators,
561  bool addMetadata = true);
562 
563  // makes sure metadata provided is legal
564  // checkForPrimTask parameter is used to determine if schemaTypes metadata
565  // is provided and if the task being registered for the validator is
566  // UsdValidatePrimTaskFn.
567  // expectSuite parameter is used to determine if the isSuite metadata is
568  // appropriately set (for UsdValidationValidatorSuite) or not (for
569  // UsdValidationValidator).
570  static bool _CheckMetadata(const UsdValidationValidatorMetadata &metadata,
571  bool checkForPrimTask, bool expectSuite = false);
572 
573  // Add validator metadata to _validatorNameToMetadata, also updates
574  // _schemaTypeToValidatorNames and _keywordToValidatorNames, for easy access
575  // to what validators are linked to specific schemaTypes or keywords.
576  // _mutex must be acquired before calling this method.
577  bool _AddValidatorMetadata(const UsdValidationValidatorMetadata &metadata);
578 
579  using _ValidatorNameToValidatorMap
580  = std::unordered_map<TfToken, std::unique_ptr<UsdValidationValidator>,
582  using _ValidatorSuiteNameToValidatorSuiteMap
583  = std::unordered_map<TfToken,
584  std::unique_ptr<UsdValidationValidatorSuite>,
586  using _ValidatorNameToMetadataMap
587  = std::unordered_map<TfToken, UsdValidationValidatorMetadata,
589  using _TokenToValidatorNamesMap
590  = std::unordered_map<TfToken, TfTokenVector, TfToken::HashFunctor>;
591 
592  // Helper to query
593  UsdValidationValidatorMetadataVector _GetValidatorMetadataForToken(
594  const _TokenToValidatorNamesMap &tokenToValidatorNames,
595  const TfTokenVector &tokens) const;
596 
597  // Helper to populate _keywordToValidatorNames and
598  // _schemaTypeToValidatorNames
599  // _mutex must be acquired before calling this method.
600  static void
601  _UpdateValidatorNamesMappings(_TokenToValidatorNamesMap &tokenMap,
602  const TfToken &validatorName,
603  const TfTokenVector &tokens);
604 
605  // Main datastructure which holds validatorName to
606  // std::unique_ptr<UsdValidationValidator>
607  _ValidatorNameToValidatorMap _validators;
608  // Main datastructure which holds suiteName to
609  // std::unique_ptr<UsdValidationValidatorSuite>
610  _ValidatorSuiteNameToValidatorSuiteMap _validatorSuites;
611 
612  // ValidatorName to ValidatorMetadata map
613  _ValidatorNameToMetadataMap _validatorNameToMetadata;
614 
615  // Following 3 are helper data structures to easy lookup for Validators,
616  // when queried for keywords, schemaType or pluginName.
617 
618  // This map stores the mapping from keyword to validator names. It may get
619  // updated as validators can be registered dynamically outside of the plugin
620  // infrastructure.
621  _TokenToValidatorNamesMap _keywordToValidatorNames;
622 
623  // This map stores the mapping from schemaTypes to validator names. It may
624  // get updated as validators can be registered dynamically outside of the
625  // plugin infrastructure.
626  _TokenToValidatorNamesMap _schemaTypeToValidatorNames;
627 
628  // This map stores the mapping from plugin names to validator names.
629  // It is populated during the initialization of UsdValidationRegistry
630  // and remains constant thereafter.
631  _TokenToValidatorNamesMap _pluginNameToValidatorNames;
632 
633  // Mutex to protect access to all data members.
634  mutable std::shared_mutex _mutex;
635 };
636 
637 // Specialize and delete the DeleteInstance function to prevent destruction.
638 // This will prevent the singleton instance for UsdValidationRegistry from
639 // being destroyed and hence making it immortal.
640 template <> void TfSingleton<UsdValidationRegistry>::DeleteInstance() = delete;
641 
643 
645 
646 #endif // PXR_USD_VALIDATION_USD_VALIDATION_REGISTRY_H
USDVALIDATION_API std::vector< const UsdValidationValidator * > GetOrLoadAllValidators()
static T & GetInstance()
Definition: singleton.h:122
USDVALIDATION_API UsdValidationValidatorMetadataVector GetValidatorMetadataForKeywords(const TfTokenVector &keywords) const
USDVALIDATION_API_TEMPLATE_CLASS(TfSingleton< UsdValidationRegistry >)
std::vector< UsdValidationValidatorMetadata > UsdValidationValidatorMetadataVector
Definition: validator.h:92
USDVALIDATION_API UsdValidationValidatorMetadataVector GetAllValidatorMetadata() const
USDVALIDATION_API const UsdValidationValidator * GetOrLoadValidatorByName(const TfToken &validatorName)
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
static USDVALIDATION_API UsdValidationRegistry & GetInstance()
Definition: registry.h:172
Functor to use for hash maps from tokens to other things.
Definition: token.h:149
USDVALIDATION_API bool HasValidator(const TfToken &validatorName) const
std::function< UsdValidationErrorVector(const UsdStagePtr &, const UsdValidationTimeRange)> UsdValidateStageTaskFn
UsdValidateStageTaskFn: Validation logic operating on a given UsdStage.
Definition: validator.h:108
#define USDVALIDATION_API
Definition: api.h:25
USDVALIDATION_API void RegisterValidator(const UsdValidationValidatorMetadata &metadata, const UsdValidateLayerTaskFn &layerTaskFn, std::vector< UsdValidationFixer > fixers={})
std::function< UsdValidationErrorVector(const SdfLayerHandle &)> UsdValidateLayerTaskFn
UsdValidateLayerTaskFn: Validation logic operating on a given SdfLayerHandle.
Definition: validator.h:105
USDVALIDATION_API UsdValidationValidatorMetadataVector GetValidatorMetadataForKeyword(const TfToken &keyword) const
Definition: token.h:70
USDVALIDATION_API void RegisterPluginValidatorSuite(const TfToken &validatorSuiteName, const std::vector< const UsdValidationValidator * > &containedValidators)
USDVALIDATION_API bool HasValidatorSuite(const TfToken &suiteName) const
USDVALIDATION_API std::vector< const UsdValidationValidatorSuite * > GetOrLoadAllValidatorSuites()
USDVALIDATION_API void RegisterValidatorSuite(const UsdValidationValidatorMetadata &metadata, const std::vector< const UsdValidationValidator * > &containedValidators)
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GLuint const GLchar * name
Definition: glcorearb.h:786
USDVALIDATION_API UsdValidationValidatorMetadataVector GetValidatorMetadataForPlugin(const TfToken &pluginName) const
USDVALIDATION_API UsdValidationValidatorMetadataVector GetValidatorMetadataForSchemaType(const TfToken &schemaType) const
USDVALIDATION_API bool GetValidatorMetadata(const TfToken &name, UsdValidationValidatorMetadata *metadata) const
USDVALIDATION_API std::vector< const UsdValidationValidatorSuite * > GetOrLoadValidatorSuitesByName(const TfTokenVector &suiteNames)
std::function< UsdValidationErrorVector(const UsdPrim &, const UsdValidationTimeRange)> UsdValidatePrimTaskFn
UsdValidatePrimTaskFn: Validation logic operating on a given UsdPrim.
Definition: validator.h:111
USDVALIDATION_API void RegisterPluginValidator(const TfToken &validatorName, const UsdValidateLayerTaskFn &layerTaskFn, std::vector< UsdValidationFixer > fixers={})
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDVALIDATION_API std::vector< const UsdValidationValidator * > GetOrLoadValidatorsByName(const TfTokenVector &validatorNames)
USDVALIDATION_API UsdValidationValidatorMetadataVector GetValidatorMetadataForSchemaTypes(const TfTokenVector &schemaTypes) const
USDVALIDATION_API UsdValidationValidatorMetadataVector GetValidatorMetadataForPlugins(const TfTokenVector &pluginNames) const
static void DeleteInstance()
USDVALIDATION_API const UsdValidationValidatorSuite * GetOrLoadValidatorSuiteByName(const TfToken &suiteName)