neuray Services API Programmer's Manual

mi::nservices::IFactory Class Reference

[Factory]

Description

Factory class for managing neuray services objects. This class provides the ability to create objects and convenience methods for conversion between compatible interface types.

Public Member Functions

virtual base::IInterfacecreate( const char* class_name, Uint32 argc = 0, const base::IInterface* argv = 0) const =0
Create a class. More...
template< class T>T* create( const char* class_name, Uint32 argc = 0, const base::IInterface* argv = 0) const
Create a class. More...
virtual base::IInterfaceget_element( neuraylib::ITransaction* transaction, const char* name, const char* type_name) const =0
Obtains a neuray services object from the database. More...
template< class T>T* get_element( neuraylib::ITransaction* transaction, const char* name, const char* type_name) const
Obtains a neuray services object from the database. More...

Member Functions

virtual base::IInterface* mi::​nservices::​IFactory::create( const char* class_name, Uint32 argc = 0, const base::IInterface* argv = 0) const [pure virtual]

Create a class. see Factory and Types for a list of supported class names.

Parameters

class_name
the name of the class to create
argc
The number of elements in argv
argv
The array of arguments passed to the constructor

Returns

a pointer to the created class or NULL if the class name is unknown.

template< class T>

T* mi::​nservices::​IFactory::create( const char* class_name, Uint32 argc = 0, const base::IInterface* argv = 0) const [inline]

Create a class. see Factory and Types for a list of supported class names.

This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const Uuid&) on the returned pointer, since the return type already is a pointer to the type T specified as template parameter.

Parameters

class_name
the name of the class to create
argc
The number of elements in argv
argv
The array of arguments passed to the constructor

Returns

a pointer to the created class or NULL if the class name is unknown or T is not an interface to the class.

virtual base::IInterface* mi::​nservices::​IFactory::get_element( neuraylib::ITransaction* transaction, const char* name, const char* type_name) const [pure virtual]

Obtains a neuray services object from the database. As it is not possible to retrieve custom neuray services objects from the database directly this method should be used instead of mi::neuraylib::ITransaction::access() or mi::neuraylib::ITransaction::edit() when such objects are required. It will extract the database object, create the appropriate implementation and wrappers and return the interface. The returned object can then be used in the same manner as any normal database object. The following types are supported.

Type name

Interface

Description

"Scene"

mi::nservices::IScene

Neuray services scene abstraction

Parameters

transaction
the transaction to retrieve the object from.
name
the name of the element to return.
type_name
the type of the element to return.

Returns

The named element in the database or NULL if a parameter is NULL , type_name is not a supported type, no such element exists or transaction is already closed.

template< class T>

T* mi::​nservices::​IFactory::get_element( neuraylib::ITransaction* transaction, const char* name, const char* type_name) const [inline]

Obtains a neuray services object from the database. As it is not possible to retrieve custom neuray services objects from the database directly this method should be used instead of mi::neuraylib::ITransaction::access() or mi::neuraylib::ITransaction::edit() when such objects are required. It will extract the database object, create the appropriate implementation and wrappers and return the interface. The returned object can then be used in the same manner as any normal database object. The following types are supported.

Type name

Interface

Description

"Scene"

mi::nservices::IScene

Neuray services scene abstraction

This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const Uuid&) on the returned pointer, since the return type already is a pointer to the type T specified as template parameter.

Parameters

transaction
the transaction to retrieve the object from.
name
the name of the element to return.
type_name
the type of the element to return.

Returns

The named element in the database or NULL if a parameter is NULL , type_name is not a supported type, no such element exists or transaction is already closed.