MDL SDK API nvidia_logo_transpbg.gif Up
interface_merger.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2024 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 typedef MAJOR MAJOR_BASE;
61
63 typedef MINOR MINOR_BASE;
64
67
68#if __cplusplus >= 201103L
70 using MAJOR::MAJOR;
71#endif
72
77 static bool compare_iid( const Uuid& iid)
78 {
79 if( MAJOR::compare_iid( iid))
80 return true;
81 return MINOR::compare_iid( iid);
82 }
83
88 const IInterface* get_interface( const Uuid& interface_id) const;
89
93 template <class T>
94 const T* get_interface() const
95 {
96 return static_cast<const T*>( get_interface( typename T::IID()));
97 }
98
103 IInterface* get_interface( const Uuid& interface_id);
104
108 template <class T>
110 {
111 return static_cast<T*>( get_interface( typename T::IID()));
112 }
113
117 Uuid get_iid() const { return MAJOR::get_iid(); }
118
122 mi::Uint32 retain() const { return MAJOR::retain(); }
123
127 mi::Uint32 release() const { return MAJOR::release(); }
128
139 const MAJOR* cast_to_major() const { return static_cast<const MAJOR*>( this); }
140
151 MAJOR* cast_to_major() { return static_cast<MAJOR*>( this); }
152};
153
154template <typename MAJOR, typename MINOR>
156 const Uuid& interface_id) const
157{
158 const IInterface* iinterface = MAJOR::get_interface( interface_id);
159 if( iinterface)
160 return iinterface;
161 return MINOR::get_interface_static( static_cast<const MINOR*>( this), interface_id);
162}
163
164template <typename MAJOR, typename MINOR>
166 const Uuid& interface_id)
167{
168 IInterface* iinterface = MAJOR::get_interface( interface_id);
169 if( iinterface)
170 return iinterface;
171 return MINOR::get_interface_static( static_cast<MINOR*>( this), interface_id);
172}
173 // end group mi_base_iinterface
175
176} // namespace base
177} // namespace mi
178
179#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:122
const T * get_interface() const
Reimplements mi::base::IInterface::get_interface() const.
Definition: interface_merger.h:94
MINOR MINOR_BASE
Typedef for the MINOR base class.
Definition: interface_merger.h:63
MAJOR MAJOR_BASE
Typedef for the MAJOR base class.
Definition: interface_merger.h:60
static bool compare_iid(const Uuid &iid)
Reimplements mi::base::IInterface::compare_iid().
Definition: interface_merger.h:77
Interface_merger<MAJOR, MINOR> Self
Typedef for this type.
Definition: interface_merger.h:66
Uuid get_iid() const
Reimplements mi::base::IInterface::get_iid().
Definition: interface_merger.h:117
mi::Uint32 release() const
Reimplements mi::base::IInterface::release().
Definition: interface_merger.h:127
const MAJOR * cast_to_major() const
Returns a pointer to the MAJOR base class.
Definition: interface_merger.h:139
MAJOR * cast_to_major()
Returns a pointer to the MAJOR base class.
Definition: interface_merger.h:151
T * get_interface()
Reimplements mi::base::IInterface::get_interface().
Definition: interface_merger.h:109
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: example_derivatives.dox:5
A 128 bit representation of a universally unique identifier (UUID or GUID).
Definition: uuid.h:26