HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pluginRendererUniqueHandle.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_IMAGING_HD_PLUGIN_RENDERER_UNIQUE_HANDLE_H
8 #define PXR_IMAGING_HD_PLUGIN_RENDERER_UNIQUE_HANDLE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
13 
14 #include <cstddef>
15 
17 
18 class HdRenderer;
19 
20 ///
21 /// A handle for a renderer that was created by a renderer plugin.
22 /// Its semantics are similar to std::unique_ptr.
23 ///
24 /// The handle owns the renderer and ensures that the plugin is kept alive
25 /// until the renderer is destroyed. The handle can also be queried for the
26 /// id of the plugin used to create the renderer.
27 ///
29 {
30 public:
31  HD_API
33 
34  HD_API
35  HdPluginRendererUniqueHandle(HdPluginRendererUniqueHandle &&);
36 
37  HD_API
38  HdPluginRendererUniqueHandle(const std::nullptr_t &);
39 
40  HD_API
42 
43  HD_API
44  HdPluginRendererUniqueHandle &operator=(HdPluginRendererUniqueHandle &&);
45 
46  HD_API
47  HdPluginRendererUniqueHandle &operator=(const std::nullptr_t &);
48 
49  HdRenderer *Get() const { return _renderer.get(); }
50 
51  HdRenderer *operator->() const { return _renderer.get(); }
52  HdRenderer &operator*() const { return *_renderer; }
53 
54  /// Is the wrapped HdRenderer valid?
55  explicit operator bool() const { return bool(_renderer); }
56 
57  /// Id of the plugin used to create the renderer.
58  HD_API
59  TfToken GetPluginId() const;
60 
61 private:
62  friend class HdRendererPlugin;
63 
66  std::unique_ptr<HdRenderer> renderer);
67 
68  HdRendererPluginHandle _plugin;
69  std::unique_ptr<HdRenderer> _renderer;
70 };
71 
73 
74 #endif
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
#define HD_API
Definition: api.h:23
OutGridT const XformOp bool bool
HD_API TfToken GetPluginId() const
Id of the plugin used to create the renderer.
Definition: token.h:70
HD_API HdPluginRendererUniqueHandle & operator=(HdPluginRendererUniqueHandle &&)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74