Material Definition Language API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
factory.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2020 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
6 
7 #ifndef MI_NEURAYLIB_FACTORY_H
8 #define MI_NEURAYLIB_FACTORY_H
9 
10 #include <mi/base/types.h>
11 #include <mi/base/uuid.h>
12 #include <mi/base/handle.h>
13 #include <mi/neuraylib/version.h>
14 
15 namespace mi {
16 
17 namespace neuraylib {
18 
19 class IAllocator;
20 class INeuray;
21 
22 } // namespace neuraylib
23 
24 namespace base {
25 
26 class IInterface;
27 
28 } // namespace base
29 
30 } // namespace mi
31 
36 extern "C"
37 {
38 
63 MI_DLL_EXPORT
66 
84 MI_DLL_EXPORT
86 
87 }
88 
89 namespace mi {
90 
91 namespace neuraylib {
92 
97 template <class T>
98 T* mi_factory( void* symbol)
99 {
100  typedef mi::base::IInterface* INeuray_factory( const mi::base::Uuid& iid);
101  INeuray_factory* factory = reinterpret_cast<INeuray_factory*>( symbol);
102  mi::base::Handle<mi::base::IInterface> iinterface( factory( typename T::IID()));
103  if( !iinterface)
104  return 0;
105  return iinterface->get_interface<T>();
106 }
107 }
108 
109 } // end group mi_neuray_ineuray
111 
112 #endif // MI_NEURAYLIB_FACTORY_H