Base API nvidia_logo_transpbg.gif Up
interface_merger.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2025 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
6
7#ifndef MI_BASE_INTERFACE_MERGER_H
8#define MI_BASE_INTERFACE_MERGER_H
9
10#include <mi/base/iinterface.h>
11
12namespace mi {
13namespace base {
14
53template <typename MAJOR, typename MINOR>
55 : public MAJOR,
56 public MINOR
57{
58public:
60 using MAJOR_BASE = MAJOR;
61
63 using MINOR_BASE = MINOR;
64
67
69 using MAJOR::MAJOR;
70
75 static bool compare_iid( const Uuid& iid)
76 {
77 if( MAJOR::compare_iid( iid))
78 return true;
79 return MINOR::compare_iid( iid);
80 }
81
86 const IInterface* get_interface( const Uuid& interface_id) const;
87
91 template <class T>
92 const T* get_interface() const
93 {
94 return static_cast<const T*>( get_interface( typename T::IID()));
95 }
96
101 IInterface* get_interface( const Uuid& interface_id);
102
106 template <class T>
108 {
109 return static_cast<T*>( get_interface( typename T::IID()));
110 }
111
115 Uuid get_iid() const { return MAJOR::get_iid(); }
116
120 mi::Uint32 retain() const { return MAJOR::retain(); }
121
125 mi::Uint32 release() const { return MAJOR::release(); }
126
137 const MAJOR* cast_to_major() const { return static_cast<const MAJOR*>( this); }
138
149 MAJOR* cast_to_major() { return static_cast<MAJOR*>( this); }
150};
151
152template <typename MAJOR, typename MINOR>
154 const Uuid& interface_id) const
155{
156 const IInterface* iinterface = MAJOR::get_interface( interface_id);
157 if( iinterface)
158 return iinterface;
159 return MINOR::get_interface_static( static_cast<const MINOR*>( this), interface_id);
160}
161
162template <typename MAJOR, typename MINOR>
164 const Uuid& interface_id)
165{
166 IInterface* iinterface = MAJOR::get_interface( interface_id);
167 if( iinterface)
168 return iinterface;
169 return MINOR::get_interface_static( static_cast<MINOR*>( this), interface_id);
170}
171 // end group mi_base_iinterface
173
174} // namespace base
175} // namespace mi
176
177#endif // MI_BASE_INTERFACE_MERGER_H
The basic extensible interface.
Definition: iinterface.h:103
This mixin merges the implementation of one interface with a second interface.
Definition: interface_merger.h:57
mi::Uint32 retain() const
Reimplements mi::base::IInterface::retain().
Definition: interface_merger.h:120
const T * get_interface() const
Reimplements mi::base::IInterface::get_interface() const.
Definition: interface_merger.h:92
static bool compare_iid(const Uuid &iid)
Reimplements mi::base::IInterface::compare_iid().
Definition: interface_merger.h:75
MAJOR MAJOR_BASE
Typedef for the MAJOR base class.
Definition: interface_merger.h:60
Uuid get_iid() const
Reimplements mi::base::IInterface::get_iid().
Definition: interface_merger.h:115
mi::Uint32 release() const
Reimplements mi::base::IInterface::release().
Definition: interface_merger.h:125
const MAJOR * cast_to_major() const
Returns a pointer to the MAJOR base class.
Definition: interface_merger.h:137
MAJOR * cast_to_major()
Returns a pointer to the MAJOR base class.
Definition: interface_merger.h:149
T * get_interface()
Reimplements mi::base::IInterface::get_interface().
Definition: interface_merger.h:107
MINOR MINOR_BASE
Typedef for the MINOR base class.
Definition: interface_merger.h:63
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
The basic extensible interface.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: base.h:34
A 128 bit representation of a universally unique identifier (UUID or GUID).
Definition: uuid.h:26