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"
16#include "pxr/base/tf/token.h"
18#include "pxr/base/js/types.h"
19
20#include <memory>
21#include <string>
22#include <utility>
23#include <vector>
24
25PXR_NAMESPACE_OPEN_SCOPE
26
39class UsdProfileRegistry : public TfSingleton<UsdProfileRegistry>
40{
42 UsdProfileRegistry& operator=(const UsdProfileRegistry&) = delete;
43 public:
46 enum class QueryStatus {
48 NoPath,
63 };
64
66 USDPROFILES_API static bool HasCapability(const TfToken& capability);
67
72 USDPROFILES_API static bool IsProfile(const TfToken& capability);
73
78 USDPROFILES_API
79 static VtDictionary GetCapabilityMetadata(const TfToken& capability);
80
83 TfToken capability;
84 QueryStatus status;
85 };
86
92 USDPROFILES_API static
93 std::vector<CapabilityResult> GetPredecessors(const TfToken& capability);
94
102 USDPROFILES_API static
103 std::vector<CapabilityResult> GetTransitivePredecessors(const TfToken& capability);
104
112 USDPROFILES_API static
113 std::pair<TfToken, int> ParseCapabilityVersion(const TfToken& capability);
114
124 USDPROFILES_API static TfToken ResolveCapability(const TfToken& capability);
125
131 USDPROFILES_API static QueryStatus HasPredecessor(const TfToken& capabilityA,
132 const TfToken& capabilityB);
133
161 USDPROFILES_API static QueryStatus CoversCapabilities(
162 const TfToken& perspective,
163 const std::vector<TfToken>& required,
164 const std::vector<TfToken>& excepted = {},
165 std::vector<CapabilityResult>* results = nullptr);
166
168 USDPROFILES_API static std::vector<TfToken> GetAllCapabilities();
169
173 USDPROFILES_API static std::vector<TfToken> GetAllProfiles();
174
175 // Style, Subgraph, DocString, and DisplayName are all meant for
176 // visualization purposes. Styles can be used to give a capability a distinct
177 // appearance, subgraph can be used to group capabilities into a box.
178
180 USDPROFILES_API static TfToken GetStyleForCapability(const TfToken& capability);
181
183 USDPROFILES_API static TfToken GetSubgraphForCapability(const TfToken& capability);
184
186 USDPROFILES_API static std::string GetDocString(const TfToken& capability);
187
189 USDPROFILES_API static std::string GetDisplayName(const TfToken& capability);
190
192 USDPROFILES_API static std::map<TfToken, std::string> GetCapabilityStyles();
193
194private:
195 friend class Usd_ProfilesRegistryTestAccess;
196 friend class TfSingleton<UsdProfileRegistry>;
197
200
202 static UsdProfileRegistry& GetInstance();
203
204 void _RegisterFromPlugins();
205
209 bool _LoadCapabilitiesFromProfileData(const JsObject& profileData);
210
211 class _CapabilityGraph;
212 std::unique_ptr<_CapabilityGraph> _capabilityGraph;
213
214 // Store styles and groups defined in plugins
215 std::map<TfToken, std::string> _capabilityStyles;
216};
217
218USDPROFILES_API_TEMPLATE_CLASS(TfSingleton<UsdProfileRegistry>);
219
220PXR_NAMESPACE_CLOSE_SCOPE
221
222#endif // PXR_USD_PROFILE_REGISTRY_H
223
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
A singleton that manages profile capabilities and their relationships.
static USDPROFILES_API std::vector< TfToken > GetAllProfiles()
Return an unordered vector of all profiles known to the registry.
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 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 VtDictionary GetCapabilityMetadata(const TfToken &capability)
Return metadata associated with capability as a VtDictionary with keys name, docstring,...
static USDPROFILES_API std::vector< CapabilityResult > GetPredecessors(const TfToken &capability)
Return all direct predecessors (incoming edges) of capability.
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 std::vector< CapabilityResult > GetTransitivePredecessors(const TfToken &capability)
Return the full transitive closure of all ancestors of capability.
static USDPROFILES_API QueryStatus CoversCapabilities(const TfToken &perspective, const std::vector< TfToken > &required, const std::vector< TfToken > &excepted={}, std::vector< CapabilityResult > *results=nullptr)
Return whether perspective transitively reaches every capability in required, and with what deprecati...
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::vector< TfToken > GetAllCapabilities()
Return an unordered vector of all capabilities known to the registry.
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.
Per-capability query result.
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.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...