HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
object.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 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_EXEC_ESF_OBJECT_H
8 #define PXR_EXEC_ESF_OBJECT_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/esf/api.h"
17 #include "pxr/exec/esf/stage.h"
18 
19 #include "pxr/usd/sdf/path.h"
20 
22 
23 class EsfAttribute;
24 class EsfJournal;
25 class EsfObject;
26 class EsfPrim;
27 class EsfRelationship;
28 class TfToken;
29 class TfType;
30 class VtValue;
31 
32 /// Scene object abstraction for scene adapter implementations.
33 ///
34 /// The scene object abstraction closely resembles the read-only interface of
35 /// UsdObject.
36 ///
37 /// The public methods of this class are called by the exec network compiler.
38 /// Each method takes an argument of type EsfJournal* which captures the
39 /// conditions for recompilation.
40 ///
41 /// This class and all classes derived from it are compatible with
42 /// EsfFixedSizePolymorphicHolder.
43 ///
45 {
46 public:
47  ESF_API ~EsfObjectInterface() override;
48 
49  /// \see UsdObject::IsValid
50  ESF_API bool IsValid(EsfJournal *journal) const;
51 
52  /// \see UsdObject::GetPath
53  ESF_API SdfPath GetPath(EsfJournal *journal) const;
54 
55  /// \see UsdObject::GetName
56  ESF_API TfToken GetName(EsfJournal *journal) const;
57 
58  /// \see UsdObject::GetPrim
59  ESF_API EsfPrim GetPrim(EsfJournal *journal) const;
60 
61  /// Returns the paths of all attributes that have connections that target
62  /// the object.
63  ///
64  ESF_API SdfPathVector GetIncomingConnections(EsfJournal *journal) const;
65 
66  /// \see UsdObject::GetStage
67  EsfStage GetStage() const {
68  return _GetStage();
69  }
70 
71  /// Returns an opaque value that is guaranteed to be unique and stable.
72  ///
73  /// Any prims that have the same typed schema and the same list of applied
74  /// schemas will have the same schema config key.
75  ///
76  ESF_API EsfSchemaConfigKey GetSchemaConfigKey(EsfJournal *journal) const;
77 
78  /// \name Metadata
79  /// @{
80 
81  /// Returns the value of the metadata field indicated by \p key.
82  ///
83  /// Emits an error if \p key is not a valid metadata key.
84  ///
85  ESF_API VtValue GetMetadata(const TfToken &key) const;
86 
87  /// Returns true if the field indicated by \p key is a valid metadata field
88  /// for this object.
89  ///
90  ESF_API bool IsValidMetadataKey(const TfToken &key) const;
91 
92  /// Returns the value type for the indicated \p key.
93  ///
94  /// Emits an error if \p key is not a valid metadata key.
95  ///
96  ESF_API TfType GetMetadataValueType(const TfToken &key) const;
97 
98  /// @}
99 
100  /// \see UsdObject::Is
101  virtual bool IsPrim() const = 0;
102 
103  /// \see UsdObject::Is
104  virtual bool IsAttribute() const = 0;
105 
106  /// \see UsdObject::Is
107  virtual bool IsRelationship() const = 0;
108 
109  /// \see UsdObject::As
110  virtual EsfObject AsObject() const = 0;
111 
112  /// \see UsdObject::As
113  virtual EsfAttribute AsAttribute() const = 0;
114 
115  /// \see UsdObject::As
116  virtual EsfRelationship AsRelationship() const = 0;
117 
118  /// \see UsdObject::As
119  virtual EsfPrim AsPrim() const = 0;
120 
121 protected:
122  /// This constructor may only be called by the scene adapter implementation.
123  EsfObjectInterface(const SdfPath &path) : _path(path) {}
124 
125  /// Gets the path to this object used for journaling.
126  const SdfPath &_GetPath() const { return _path; }
127 
128  virtual EsfStage _GetStage() const = 0;
129 
130  static EsfSchemaConfigKey CreateSchemaConfigKey(const void *const id) {
131  return EsfSchemaConfigKey(id);
132  }
133 
134 private:
135  // Object path that will be added to EsfJournals.
136  SdfPath _path;
137 
138  // These methods must be implemented by the scene adapter implementation.
139  virtual bool _IsValid() const = 0;
140  virtual TfToken _GetName() const = 0;
141  virtual EsfPrim _GetPrim() const = 0;
142  virtual SdfPathVector _GetIncomingConnections() const = 0;
143  virtual EsfSchemaConfigKey _GetSchemaConfigKey() const = 0;
144  virtual VtValue _GetMetadata(const TfToken &key) const = 0;
145  virtual bool _IsValidMetadataKey(const TfToken &key) const = 0;
146  virtual TfType _GetMetadataValueType(const TfToken &key) const = 0;
147 };
148 
149 /// Holds an implementation of EsfObjectInterface in a fixed-size buffer.
150 ///
151 /// The buffer is large enough to fit an implementation that wraps a UsdObject.
152 /// The size is specified as an integer literal to prevent introducing Usd as
153 /// a dependency.
154 ///
155 class EsfObject : public EsfFixedSizePolymorphicHolder<EsfObjectInterface, 48>
156 {
157 public:
159 };
160 
162 
163 #endif
const SdfPath & _GetPath() const
Gets the path to this object used for journaling.
Definition: object.h:126
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define ESF_API_TYPE
Definition: api.h:26
Definition: prim.h:84
Definition: token.h:70
static EsfSchemaConfigKey CreateSchemaConfigKey(const void *const id)
Definition: object.h:130
std::vector< class SdfPath > SdfPathVector
EsfStage GetStage() const
Definition: object.h:67
Definition: path.h:280
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
#define ESF_API
Definition: api.h:25
Definition: value.h:89
EsfObjectInterface(const SdfPath &path)
This constructor may only be called by the scene adapter implementation.
Definition: object.h:123