MDL SDK API nvidia_logo_transpbg.gif Up
factory.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2024 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>
14
15namespace mi {
16
17namespace neuraylib {
18
19class IAllocator;
20class INeuray;
21
22} // namespace neuraylib
23
24namespace base {
25
26class IInterface;
27
28} // namespace base
29
30} // namespace mi
31
36extern "C"
37{
38
63MI_DLL_EXPORT
66
84MI_DLL_EXPORT
86
87}
88
89namespace mi {
90
91namespace neuraylib {
92
97template <class T>
98T* 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
113
114#endif // MI_NEURAYLIB_FACTORY_H
Handle class template for interfaces, automatizing the lifetime control via reference counting.
Definition: handle.h:113
The basic extensible interface.
Definition: iinterface.h:103
The Allocator interface class supports allocating and releasing memory dynamically and querying the a...
Definition: iallocator.h:32
This is an object representing the MDL SDK library.
Definition: ineuray.h:44
Handle<New_interface> get_interface() const
Returns a new handle for a possibly different interface type, similar to a dynamic cast,...
Definition: handle.h:353
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
mi::neuraylib::INeuray * mi_neuray_factory_deprecated(mi::neuraylib::IAllocator *allocator=0, mi::Uint32 version=MI_NEURAYLIB_API_VERSION)
Unique public access point to the MDL SDK API.
mi::base::IInterface * mi_factory(const mi::base::Uuid &iid)
Unique public access point to the MDL SDK API.
#define MI_NEURAYLIB_API_VERSION
ABI version number.
Definition: version.h:32
Smart-pointer handle class for interfaces, const and non-const version.
T * mi_factory(void *symbol)
Convenience function to ease the use of mi_factory().
Definition: factory.h:98
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: example_derivatives.dox:5
Major and minor version number and an optional qualifier.
A 128 bit representation of a universally unique identifier (UUID or GUID).
Definition: uuid.h:26
Basic types.
A 128 bit representation of a universally unique identifier (UUID or GUID).