neuray API Programmer's Manual

factory.h File Reference

Description

Main factory function.

Code Example

factory.h

‎/***************************************************************************************************
 * Copyright 2023 NVIDIA Corporation. All rights reserved.
 **************************************************************************************************/

#ifndef MI_NEURAYLIB_FACTORY_H
#define MI_NEURAYLIB_FACTORY_H

#include <mi/base/types.h>
#include <mi/base/uuid.h>
#include <mi/base/handle.h>
#include <mi/neuraylib/version.h>

namespace mi {

namespace neuraylib {

class IAllocator;
class INeuray;

} // namespace neuraylib

namespace base {
    
class IInterface;

} // namespace base

} // namespace mi

extern "C"
{

MI_DLL_EXPORT
mi::neuraylib::INeuray* mi_neuray_factory_deprecated(
    mi::neuraylib::IAllocator* allocator = 0, mi::Uint32 version = MI_NEURAYLIB_API_VERSION);
    
MI_DLL_EXPORT
mi::base::IInterface* mi_factory(const mi::base::Uuid& iid);

}

namespace mi {

namespace neuraylib {

template <class T>
T* mi_factory( void* symbol)
{
    typedef mi::base::IInterface* INeuray_factory( const mi::base::Uuid& iid);
    INeuray_factory* factory = reinterpret_cast<INeuray_factory*>( symbol);
    mi::base::Handle< mi::base::IInterface> iinterface( factory( typename T::IID()));
    if( !iinterface)
        return 0;
    return iinterface->get_interface<T>();
}
}

} // end group mi_neuray_ineuray

#endif // MI_NEURAYLIB_FACTORY_H

Namespaces

namespace 
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH. More...
namespace 
Namespace for the Base API. More...
namespace 
Namespace for the neuray API. More...

Typedefs

typedef unsigned int  
32-bit unsigned integer. More...

Functions

template< class T>T*  ( void* symbol)
Convenience function to ease the use of mi_factory(). More...
mi::​base::​IInterface ( const mi::​base::​Uuid& iid)
Unique public access point to the neuray API. More...
mi::​neuraylib::​INeuray ( mi::​neuraylib::​IAllocator* allocator = 0, mi::​Uint32 version = MI_NEURAYLIB_API_VERSION)
Unique public access point to the neuray API. More...