Base API nvidia_logo_transpbg.gif Up
interface_merger.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2023 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
69 static bool compare_iid( const Uuid& iid) {
70 if( MAJOR::compare_iid( iid))
71 return true;
72 return MINOR::compare_iid( iid);
73 }
74
79 const IInterface* get_interface( const Uuid& interface_id) const;
80
84 template <class T>
85 const T* get_interface() const {
86 return static_cast<const T*>( get_interface( typename T::IID()));
87 }
88
93 IInterface* get_interface( const Uuid& interface_id);
94
98 template <class T>
100 return static_cast<T*>( get_interface( typename T::IID()));
101 }
102
106 Uuid get_iid() const {
107 return MAJOR::get_iid();
108 }
109
114 return MAJOR::retain();
115 }
116
121 return MAJOR::release();
122 }
123
134 const MAJOR* cast_to_major() const {
135 return static_cast<const MAJOR*>( this);
136 }
137
148 MAJOR* cast_to_major() {
149 return static_cast<MAJOR*>( this);
150 }
151};
152
153template <typename MAJOR, typename MINOR>
155 const Uuid& interface_id) const
156{
157 const IInterface* iinterface = MAJOR::get_interface( interface_id);
158 if( iinterface)
159 return iinterface;
160 return MINOR::get_interface_static( static_cast<const MINOR*>( this), interface_id);
161}
162
163template <typename MAJOR, typename MINOR>
165 const Uuid& interface_id)
166{
167 IInterface* iinterface = MAJOR::get_interface( interface_id);
168 if( iinterface)
169 return iinterface;
170 return MINOR::get_interface_static( static_cast<MINOR*>( this), interface_id);
171}
172 // end group mi_base_iinterface
174
175} // namespace base
176} // namespace mi
177
178#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:113
const T * get_interface() const
Reimplements mi::base::IInterface::get_interface() const.
Definition: interface_merger.h:85
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:69
Uuid get_iid() const
Reimplements mi::base::IInterface::get_iid().
Definition: interface_merger.h:106
mi::Uint32 release() const
Reimplements mi::base::IInterface::release().
Definition: interface_merger.h:120
const MAJOR * cast_to_major() const
Returns a pointer to the MAJOR base class.
Definition: interface_merger.h:134
MAJOR * cast_to_major()
Returns a pointer to the MAJOR base class.
Definition: interface_merger.h:148
T * get_interface()
Reimplements mi::base::IInterface::get_interface().
Definition: interface_merger.h:99
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