HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pluginRenderDelegateUniqueHandle.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 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_IMAGING_HD_PLUGIN_RENDER_DELEGATE_UNIQUE_HANDLE_H
8 #define PXR_IMAGING_HD_PLUGIN_RENDER_DELEGATE_UNIQUE_HANDLE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
13 
14 #include <cstddef>
15 
17 
18 class HdRenderDelegate;
19 
20 ///
21 /// A (movable) handle for a render delegate that was created using a
22 /// a plugin.
23 ///
24 /// The handle owns the render delegate (render delegate is destroyed
25 /// when handle is dropped). The handle also can be queried what
26 /// plugin was used to create the render delegate and ensures the
27 /// plugin is kept alive until the render delegate is destroyed.
28 /// In other words, the handle can be used just like a std::unique_ptr.
29 ///
31 {
32 public:
33  HdPluginRenderDelegateUniqueHandle() : _delegate(nullptr) { }
34  HdPluginRenderDelegateUniqueHandle(const std::nullptr_t &)
35  : _delegate(nullptr) { }
36 
37  /// Transfer ownership
38  HD_API
40 
41  HD_API
43 
44  /// Transfer ownership
45  HD_API
48 
49  HD_API
51  const std::nullptr_t &);
52 
53  /// Get render delegate
54  HdRenderDelegate *Get() const { return _delegate; }
55 
56  HdRenderDelegate *operator->() const { return _delegate; }
57  HdRenderDelegate &operator*() const { return *_delegate; }
58 
59  /// Is the wrapped HdRenderDelegate valid?
60  explicit operator bool() const { return _delegate; }
61 
62  /// Get the id of the plugin used to create render delegate
63  HD_API
64  TfToken GetPluginId() const;
65 
66 private:
67  friend class HdRendererPlugin;
68 
70  const HdRendererPluginHandle &plugin, HdRenderDelegate * delegate)
71  : _plugin(plugin), _delegate(delegate) { }
72 
73  HdRendererPluginHandle _plugin;
74  HdRenderDelegate *_delegate;
75 };
76 
78 
79 #endif
HD_API TfToken GetPluginId() const
Get the id of the plugin used to create render delegate.
#define HD_API
Definition: api.h:23
OutGridT const XformOp bool bool
Definition: token.h:70
HD_API HdPluginRenderDelegateUniqueHandle & operator=(HdPluginRenderDelegateUniqueHandle &&)
Transfer ownership.
HdRenderDelegate * Get() const
Get render delegate.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74