NVIDIA Iray: Math API Home  Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
interface_merger.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright 1986, 2016 NVIDIA Corporation. All rights reserved.
3 //*****************************************************************************
6 //*****************************************************************************
7 
8 #ifndef MI_BASE_INTERFACE_MERGER_H
9 #define MI_BASE_INTERFACE_MERGER_H
10 
11 #include <mi/base/iinterface.h>
12 
13 namespace mi {
14 namespace base {
15 
20 template <typename MAJOR, typename MINOR>
56  : public MAJOR,
57  public MINOR
58 {
59 public:
61  typedef MAJOR MAJOR_BASE;
62 
64  typedef MINOR MINOR_BASE;
65 
70  static bool compare_iid( const Uuid& iid) {
71  if( MAJOR::compare_iid( iid))
72  return true;
73  return MINOR::compare_iid( iid);
74  }
75 
80  const IInterface* get_interface( const Uuid& interface_id) const;
81 
85  template <class T>
86  const T* get_interface() const {
87  return static_cast<const T*>( get_interface( typename T::IID()));
88  }
89 
94  IInterface* get_interface( const Uuid& interface_id);
95 
99  template <class T>
101  return static_cast<T*>( get_interface( typename T::IID()));
102  }
103 
107  Uuid get_iid() const {
108  return MAJOR::get_iid();
109  }
110 
114  mi::Uint32 retain() const {
115  return MAJOR::retain();
116  }
117 
121  mi::Uint32 release() const {
122  return MAJOR::release();
123  }
124 
135  const MAJOR* cast_to_major() const {
136  return static_cast<const MAJOR*>( this);
137  }
138 
149  MAJOR* cast_to_major() {
150  return static_cast<MAJOR*>( this);
151  }
152 };
153 
154 template <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 
164 template <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