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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDHOUDINI_GENERATED_HOUDINIEDITABLEAPI_H
25 #define USDHOUDINI_GENERATED_HOUDINIEDITABLEAPI_H
26 
27 /// \file usdHoudini/houdiniEditableAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "./api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "./tokens.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // HOUDINIEDITABLEAPI //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdHoudiniHoudiniEditableAPI
54 ///
55 /// Houdini API schema for marking primitives as editable or not.
56 ///
57 class
60 {
61 public:
62  /// Compile time constant representing what kind of schema this class is.
63  ///
64  /// \sa UsdSchemaKind
65  static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
66 
67  /// Construct a UsdHoudiniHoudiniEditableAPI on UsdPrim \p prim .
68  /// Equivalent to UsdHoudiniHoudiniEditableAPI::Get(prim.GetStage(), prim.GetPath())
69  /// for a \em valid \p prim, but will not immediately throw an error for
70  /// an invalid \p prim
72  : UsdAPISchemaBase(prim)
73  {
74  }
75 
76  /// Construct a UsdHoudiniHoudiniEditableAPI on the prim held by \p schemaObj .
77  /// Should be preferred over UsdHoudiniHoudiniEditableAPI(schemaObj.GetPrim()),
78  /// as it preserves SchemaBase state.
79  explicit UsdHoudiniHoudiniEditableAPI(const UsdSchemaBase& schemaObj)
80  : UsdAPISchemaBase(schemaObj)
81  {
82  }
83 
84  /// Destructor.
85  virtual ~UsdHoudiniHoudiniEditableAPI() override;
86 
87  /// Return a vector of names of all pre-declared attributes for this schema
88  /// class and all its ancestor classes. Does not include attributes that
89  /// may be authored by custom/extended methods of the schemas involved.
90  static const TfTokenVector &
91  GetSchemaAttributeNames(bool includeInherited=true);
92 
93  /// Return a UsdHoudiniHoudiniEditableAPI holding the prim adhering to this
94  /// schema at \p path on \p stage. If no prim exists at \p path on
95  /// \p stage, or if the prim at that path does not adhere to this schema,
96  /// return an invalid schema object. This is shorthand for the following:
97  ///
98  /// \code
99  /// UsdHoudiniHoudiniEditableAPI(stage->GetPrimAtPath(path));
100  /// \endcode
101  ///
103  Get(const UsdStagePtr &stage, const SdfPath &path);
104 
105 
106  /// Returns true if this <b>single-apply</b> API schema can be applied to
107  /// the given \p prim. If this schema can not be a applied to the prim,
108  /// this returns false and, if provided, populates \p whyNot with the
109  /// reason it can not be applied.
110  ///
111  /// Note that if CanApply returns false, that does not necessarily imply
112  /// that calling Apply will fail. Callers are expected to call CanApply
113  /// before calling Apply if they want to ensure that it is valid to
114  /// apply a schema.
115  ///
116  /// \sa UsdPrim::GetAppliedSchemas()
117  /// \sa UsdPrim::HasAPI()
118  /// \sa UsdPrim::CanApplyAPI()
119  /// \sa UsdPrim::ApplyAPI()
120  /// \sa UsdPrim::RemoveAPI()
121  ///
122  static bool
123  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
124 
125  /// Applies this <b>single-apply</b> API schema to the given \p prim.
126  /// This information is stored by adding "HoudiniEditableAPI" to the
127  /// token-valued, listOp metadata \em apiSchemas on the prim.
128  ///
129  /// \return A valid UsdHoudiniHoudiniEditableAPI object is returned upon success.
130  /// An invalid (or empty) UsdHoudiniHoudiniEditableAPI object is returned upon
131  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
132  /// resulting in failure.
133  ///
134  /// \sa UsdPrim::GetAppliedSchemas()
135  /// \sa UsdPrim::HasAPI()
136  /// \sa UsdPrim::CanApplyAPI()
137  /// \sa UsdPrim::ApplyAPI()
138  /// \sa UsdPrim::RemoveAPI()
139  ///
141  Apply(const UsdPrim &prim);
142 
143 protected:
144  /// Returns the kind of schema this class belongs to.
145  ///
146  /// \sa UsdSchemaKind
147  UsdSchemaKind _GetSchemaKind() const override;
148 
149 private:
150  // needs to invoke _GetStaticTfType.
151  friend class UsdSchemaRegistry;
152  static const TfType &_GetStaticTfType();
153 
154  static bool _IsTypedSchema();
155 
156  // override SchemaBase virtuals.
157  const TfType &_GetTfType() const override;
158 
159 public:
160  // --------------------------------------------------------------------- //
161  // HOUDINIEDITABLE
162  // --------------------------------------------------------------------- //
163  /// If true, then any LOP node is permitted to modify this
164  /// primitive. If false, LOP nodes which respect this flag
165  /// should produce a warning if they are asked to modify this
166  /// primitive.
167  ///
168  /// | ||
169  /// | -- | -- |
170  /// | Declaration | `uniform bool houdini:editable = 1` |
171  /// | C++ Type | bool |
172  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
173  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
174  UsdAttribute GetHoudiniEditableAttr() const;
175 
176  /// See GetHoudiniEditableAttr(), and also
177  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
178  /// If specified, author \p defaultValue as the attribute's default,
179  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
180  /// the default for \p writeSparsely is \c false.
181  UsdAttribute CreateHoudiniEditableAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
182 
183 public:
184  // ===================================================================== //
185  // Feel free to add custom code below this line, it will be preserved by
186  // the code generator.
187  //
188  // Just remember to:
189  // - Close the class declaration with };
190  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
191  // - Close the include guard with #endif
192  // ===================================================================== //
193  // --(BEGIN CUSTOM CODE)--
194 };
195 
197 
198 #endif
#define USDHOUDINI_API
Definition: api.h:47
Single Apply API schema.
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
UsdHoudiniHoudiniEditableAPI(const UsdSchemaBase &schemaObj)
Definition: prim.h:133
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
Definition: path.h:290
UsdSchemaKind
Definition: common.h:129
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: type.h:64
Definition: value.h:164
UsdHoudiniHoudiniEditableAPI(const UsdPrim &prim=UsdPrim())