Loading...
Searching...
No Matches
profileRegistry.h
Go to the documentation of this file.
1//
2// Copyright 2026 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_PROFILE_REGISTRY_H
8#define PXR_USD_PROFILE_REGISTRY_H
9
11
12#include "pxr/usd/usdProfiles/api.h"
13#include "pxr/base/tf/type.h"
17#include "pxr/base/tf/token.h"
19#include "pxr/base/js/types.h"
20
21#include <memory>
22#include <set>
23#include <string>
24#include <utility>
25
26PXR_NAMESPACE_OPEN_SCOPE
27
40class UsdProfileRegistry : public TfSingleton<UsdProfileRegistry>
41{
43 UsdProfileRegistry& operator=(const UsdProfileRegistry&) = delete;
44 public:
47 enum class QueryStatus {
49 NoPath,
64 };
65
67 USDPROFILES_API static bool HasCapability(const TfToken& capability);
68
73 USDPROFILES_API static bool IsProfile(const TfToken& capability);
74
79 USDPROFILES_API
80 static VtDictionary GetCapabilityMetadata(const TfToken& capability);
81
85 TfToken capability;
86 QueryStatus status;
87
88 bool operator<(const CapabilityResult& rhs) const {
89 return capability < rhs.capability;
90 }
91 };
92
98 USDPROFILES_API static
99 std::set<CapabilityResult> GetPredecessors(const TfToken& capability);
100
108 USDPROFILES_API static
109 std::set<CapabilityResult> GetTransitivePredecessors(const TfToken& capability);
110
118 USDPROFILES_API static
119 std::pair<TfToken, int> ParseCapabilityVersion(const TfToken& capability);
120
130 USDPROFILES_API static TfToken ResolveCapability(const TfToken& capability);
131
137 USDPROFILES_API static QueryStatus HasPredecessor(const TfToken& capabilityA,
138 const TfToken& capabilityB);
139
166 USDPROFILES_API static QueryStatus CoversCapabilities(
167 const TfToken& perspective,
168 const std::set<TfToken>& required,
169 const std::set<TfToken>& excepted = {},
170 std::set<CapabilityResult>* results = nullptr);
171
184 USDPROFILES_API
185 static std::set<TfToken>
187
198 USDPROFILES_API
199 static std::set<TfToken>
201
203 USDPROFILES_API static std::set<TfToken> GetAllCapabilities();
204
207 USDPROFILES_API static std::set<TfToken> GetAllProfiles();
208
211 static std::set<TfToken>
212 CapabilityResultsToTokens(const std::set<CapabilityResult>& results) {
213 std::set<TfToken> tokens;
214 for (const auto& r : results) {
215 tokens.insert(r.capability);
216 }
217 return tokens;
218 }
219
220 // Style, Subgraph, DocString, and DisplayName are all meant for
221 // visualization purposes. Styles can be used to give a capability a distinct
222 // appearance, subgraph can be used to group capabilities into a box.
223
225 USDPROFILES_API static TfToken GetStyleForCapability(const TfToken& capability);
226
228 USDPROFILES_API static TfToken GetSubgraphForCapability(const TfToken& capability);
229
231 USDPROFILES_API static std::string GetDocString(const TfToken& capability);
232
234 USDPROFILES_API static std::string GetDisplayName(const TfToken& capability);
235
237 USDPROFILES_API static std::map<TfToken, std::string> GetCapabilityStyles();
238
239private:
240 friend class Usd_ProfilesRegistryTestAccess;
241 friend class TfSingleton<UsdProfileRegistry>;
242
245
247 static UsdProfileRegistry& GetInstance();
248
249 void _RegisterFromPlugins();
250
254 bool _LoadCapabilitiesFromProfileData(const JsObject& profileData);
255
256 class _CapabilityGraph;
257 std::unique_ptr<_CapabilityGraph> _capabilityGraph;
258
259 // Store styles and groups defined in plugins
260 std::map<TfToken, std::string> _capabilityStyles;
261};
262
263USDPROFILES_API_TEMPLATE_CLASS(TfSingleton<UsdProfileRegistry>);
264
265PXR_NAMESPACE_CLOSE_SCOPE
266
267#endif // PXR_USD_PROFILE_REGISTRY_H
268
Manage a single instance of an object (see.
Definition singleton.h:107
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:71
TfType represents a dynamic runtime type.
Definition type.h:48
A singleton that manages profile capabilities and their relationships.
QueryStatus
Result of a predecessor reachability query.
@ Deprecated
All paths to the candidate pass through at least one deprecated edge.
@ Excepted
The capability is reachable but was explicitly excluded by the caller via the excepted parameter of C...
@ ValidPath
A non-deprecated path exists.
@ DeprecationConflict
Both deprecated and non-deprecated paths exist.
@ NoPath
No path exists from capability to the candidate.
@ CycleFound
A cycle was detected in the graph (indicates malformed data).
static USDPROFILES_API QueryStatus HasPredecessor(const TfToken &capabilityA, const TfToken &capabilityB)
Return whether capabilityA has capabilityB anywhere in its predecessor DAG (i.e., A transitively depe...
static std::set< TfToken > CapabilityResultsToTokens(const std::set< CapabilityResult > &results)
Extract just the capability tokens from a CapabilityResult set, discarding the per-entry status.
static USDPROFILES_API std::set< CapabilityResult > GetPredecessors(const TfToken &capability)
Return all direct predecessors (incoming edges) of capability.
static USDPROFILES_API bool IsProfile(const TfToken &capability)
Return true if capability is tagged as a profile node (i.e., declared with "isProfile": true in plugI...
static USDPROFILES_API std::set< TfToken > GetAllProfiles()
Return the set of all profiles known to the registry.
static USDPROFILES_API std::set< TfToken > GetFileFormatImpliedCapabilities(const TfType &formatType)
Return the union of impliesCapabilities declared on formatType and all of its ancestor types,...
static USDPROFILES_API VtDictionary GetCapabilityMetadata(const TfToken &capability)
Return metadata associated with capability as a VtDictionary with keys name, docstring,...
static USDPROFILES_API TfToken GetStyleForCapability(const TfToken &capability)
Get the style token for a given capability.
static USDPROFILES_API bool HasCapability(const TfToken &capability)
Test whether capability is known to the registry.
static USDPROFILES_API std::map< TfToken, std::string > GetCapabilityStyles()
Get all capability styles.
static USDPROFILES_API QueryStatus CoversCapabilities(const TfToken &perspective, const std::set< TfToken > &required, const std::set< TfToken > &excepted={}, std::set< CapabilityResult > *results=nullptr)
Return whether perspective transitively reaches every capability in required, and with what deprecati...
static USDPROFILES_API std::set< TfToken > GetAllCapabilities()
Return the set of all capabilities known to the registry.
static USDPROFILES_API TfToken GetSubgraphForCapability(const TfToken &capability)
Get the subgraph name for a given capability.
static USDPROFILES_API TfToken ResolveCapability(const TfToken &capability)
Return the preferred registered capability for the given token, applying the versioning precedence ru...
static USDPROFILES_API std::set< TfToken > GetSchemaImpliedCapabilities(const TfType &schemaType)
Return the union of impliesCapabilities declared on schemaType and all of its ancestor types,...
static USDPROFILES_API std::set< CapabilityResult > GetTransitivePredecessors(const TfToken &capability)
Return the full transitive closure of all ancestors of capability.
static USDPROFILES_API std::pair< TfToken, int > ParseCapabilityVersion(const TfToken &capability)
Parse the _vN version suffix from a capability token.
static USDPROFILES_API std::string GetDocString(const TfToken &capability)
Get docstring for a given capability.
static USDPROFILES_API std::string GetDisplayName(const TfToken &capability)
Get display name for a given capability.
A map with string keys and VtValue values.
Definition dictionary.h:52
Manage a single instance of an object.
This file defines some macros that are useful for declaring and using static TfTokens.
Per-capability query result.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...