NVIDIA Iray: Base API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
interface_declare.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright 1986, 2014 NVIDIA Corporation. All rights reserved.
3 //*****************************************************************************
6 //*****************************************************************************
7 
8 #ifndef MI_BASE_INTERFACE_DECLARE_H
9 #define MI_BASE_INTERFACE_DECLARE_H
10 
11 #include <mi/base/iinterface.h>
12 #include <mi/base/types.h>
13 #include <mi/base/uuid.h>
14 
15 namespace mi {
16 namespace base {
17 
22 // Forward declaration
23 class IInterface;
24 
39 template <Uint32 id1, Uint16 id2, Uint16 id3
40  , Uint8 id4, Uint8 id5, Uint8 id6, Uint8 id7
41  , Uint8 id8, Uint8 id9, Uint8 id10, Uint8 id11
42  , class I = IInterface>
43 class Interface_declare : public I
44 {
45 public:
48 
51 
57  static bool compare_iid( const Uuid& iid) {
58  if( iid == IID())
59  return true;
60  return I::compare_iid( iid);
61  }
62 
63 protected:
64  // Acquires a const interface.
65  //
66  // Static helper function for implementing #get_interface(const Uuid&).
67  //
68  // \param iinterfac The interface to act on.
69  // \param interface_id Interface ID of the interface to acquire.
70  static const IInterface* get_interface_static(
71  const IInterface* iinterface,
72  const Uuid& interface_id)
73  {
74  if( interface_id == IID()) {
75  const Self* self = static_cast<const Self *>( iinterface);
76  self->retain();
77  return self;
78  }
79  return I::get_interface_static( iinterface, interface_id);
80  }
81 
82  // Acquires a mutable interface.
83  //
84  // Static helper function for implementing #get_interface(const Uuid&).
85  //
86  // \param iinterface The interface to act on.
87  // \param interface_id Interface ID of the interface to acquire.
88  static IInterface* get_interface_static(
89  IInterface* iinterface,
90  const Uuid& interface_id)
91  {
92  if( interface_id == IID()) {
93  Self* self = static_cast<Self*>( iinterface);
94  self->retain();
95  return self;
96  }
97  return I::get_interface_static( iinterface, interface_id);
98  }
99 };
100  // end group mi_base_iinterface
102 
103 } // namespace base
104 } // namespace mi
105 
106 #endif // MI_BASE_INTERFACE_DECLARE_H