HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
houdiniEditableAPI.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef USDHOUDINI_GENERATED_HOUDINIEDITABLEAPI_H
8 #define USDHOUDINI_GENERATED_HOUDINIEDITABLEAPI_H
9 
10 /// \file usdHoudini/houdiniEditableAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "./api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "./tokens.h"
18 
19 #include "pxr/base/vt/value.h"
20 
21 #include "pxr/base/gf/vec3d.h"
22 #include "pxr/base/gf/vec3f.h"
23 #include "pxr/base/gf/matrix4d.h"
24 
25 #include "pxr/base/tf/token.h"
26 #include "pxr/base/tf/type.h"
27 
29 
30 class SdfAssetPath;
31 
32 // -------------------------------------------------------------------------- //
33 // HOUDINIEDITABLEAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdHoudiniHoudiniEditableAPI
37 ///
38 /// Houdini API schema for marking primitives as editable or not.
39 ///
40 class
43 {
44 public:
45  /// Compile time constant representing what kind of schema this class is.
46  ///
47  /// \sa UsdSchemaKind
48  static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
49 
50  /// Construct a UsdHoudiniHoudiniEditableAPI on UsdPrim \p prim .
51  /// Equivalent to UsdHoudiniHoudiniEditableAPI::Get(prim.GetStage(), prim.GetPath())
52  /// for a \em valid \p prim, but will not immediately throw an error for
53  /// an invalid \p prim
55  : UsdAPISchemaBase(prim)
56  {
57  }
58 
59  /// Construct a UsdHoudiniHoudiniEditableAPI on the prim held by \p schemaObj .
60  /// Should be preferred over UsdHoudiniHoudiniEditableAPI(schemaObj.GetPrim()),
61  /// as it preserves SchemaBase state.
62  explicit UsdHoudiniHoudiniEditableAPI(const UsdSchemaBase& schemaObj)
63  : UsdAPISchemaBase(schemaObj)
64  {
65  }
66 
67  /// Destructor.
68  virtual ~UsdHoudiniHoudiniEditableAPI() override;
69 
70  /// Return a vector of names of all pre-declared attributes for this schema
71  /// class and all its ancestor classes. Does not include attributes that
72  /// may be authored by custom/extended methods of the schemas involved.
73  static const TfTokenVector &
74  GetSchemaAttributeNames(bool includeInherited=true);
75 
76  /// Return a UsdHoudiniHoudiniEditableAPI holding the prim adhering to this
77  /// schema at \p path on \p stage. If no prim exists at \p path on
78  /// \p stage, or if the prim at that path does not adhere to this schema,
79  /// return an invalid schema object. This is shorthand for the following:
80  ///
81  /// \code
82  /// UsdHoudiniHoudiniEditableAPI(stage->GetPrimAtPath(path));
83  /// \endcode
84  ///
86  Get(const UsdStagePtr &stage, const SdfPath &path);
87 
88 
89  /// Returns true if this <b>single-apply</b> API schema can be applied to
90  /// the given \p prim. If this schema can not be a applied to the prim,
91  /// this returns false and, if provided, populates \p whyNot with the
92  /// reason it can not be applied.
93  ///
94  /// Note that if CanApply returns false, that does not necessarily imply
95  /// that calling Apply will fail. Callers are expected to call CanApply
96  /// before calling Apply if they want to ensure that it is valid to
97  /// apply a schema.
98  ///
99  /// \sa UsdPrim::GetAppliedSchemas()
100  /// \sa UsdPrim::HasAPI()
101  /// \sa UsdPrim::CanApplyAPI()
102  /// \sa UsdPrim::ApplyAPI()
103  /// \sa UsdPrim::RemoveAPI()
104  ///
105  static bool
106  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
107 
108  /// Applies this <b>single-apply</b> API schema to the given \p prim.
109  /// This information is stored by adding "HoudiniEditableAPI" to the
110  /// token-valued, listOp metadata \em apiSchemas on the prim.
111  ///
112  /// \return A valid UsdHoudiniHoudiniEditableAPI object is returned upon success.
113  /// An invalid (or empty) UsdHoudiniHoudiniEditableAPI object is returned upon
114  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
115  /// resulting in failure.
116  ///
117  /// \sa UsdPrim::GetAppliedSchemas()
118  /// \sa UsdPrim::HasAPI()
119  /// \sa UsdPrim::CanApplyAPI()
120  /// \sa UsdPrim::ApplyAPI()
121  /// \sa UsdPrim::RemoveAPI()
122  ///
124  Apply(const UsdPrim &prim);
125 
126 protected:
127  /// Returns the kind of schema this class belongs to.
128  ///
129  /// \sa UsdSchemaKind
130  UsdSchemaKind _GetSchemaKind() const override;
131 
132 private:
133  // needs to invoke _GetStaticTfType.
134  friend class UsdSchemaRegistry;
135  static const TfType &_GetStaticTfType();
136 
137  static bool _IsTypedSchema();
138 
139  // override SchemaBase virtuals.
140  const TfType &_GetTfType() const override;
141 
142 public:
143  // --------------------------------------------------------------------- //
144  // HOUDINIEDITABLE
145  // --------------------------------------------------------------------- //
146  /// If true, then any LOP node is permitted to modify this
147  /// primitive. If false, LOP nodes which respect this flag
148  /// should produce a warning if they are asked to modify this
149  /// primitive.
150  ///
151  /// | ||
152  /// | -- | -- |
153  /// | Declaration | `uniform bool houdini:editable = 1` |
154  /// | C++ Type | bool |
155  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
156  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
157  UsdAttribute GetHoudiniEditableAttr() const;
158 
159  /// See GetHoudiniEditableAttr(), and also
160  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
161  /// If specified, author \p defaultValue as the attribute's default,
162  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
163  /// the default for \p writeSparsely is \c false.
164  UsdAttribute CreateHoudiniEditableAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
165 
166 public:
167  // ===================================================================== //
168  // Feel free to add custom code below this line, it will be preserved by
169  // the code generator.
170  //
171  // Just remember to:
172  // - Close the class declaration with };
173  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
174  // - Close the include guard with #endif
175  // ===================================================================== //
176  // --(BEGIN CUSTOM CODE)--
177 };
178 
180 
181 #endif
#define USDHOUDINI_API
Definition: api.h:23
Single Apply API schema.
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UsdHoudiniHoudiniEditableAPI(const UsdSchemaBase &schemaObj)
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
UsdSchemaKind
Definition: common.h:112
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
Definition: value.h:146
UsdHoudiniHoudiniEditableAPI(const UsdPrim &prim=UsdPrim())