MDL SDK API nvidia_logo_transpbg.gif Up
ifactory.h
Go to the documentation of this file.
1/***************************************************************************************************
2 * Copyright 2024 NVIDIA Corporation. All rights reserved.
3 **************************************************************************************************/
6
7#ifndef MI_NEURAYLIB_IFACTORY_H
8#define MI_NEURAYLIB_IFACTORY_H
9
11#include <mi/neuraylib/idata.h>
13
14namespace mi {
15
16class IEnum_decl;
17class IString;
18class IStructure_decl;
19
20namespace neuraylib {
21
22class ITransaction;
23
33class IFactory : public
34 mi::base::Interface_declare<0x8afad838,0xe597,0x4a81,0x92,0x34,0x51,0xfe,0xa4,0xff,0x04,0x31>
35{
36public:
61 const char* type_name,
62 Uint32 argc = 0,
63 const base::IInterface* argv[] = 0) = 0;
64
104 template<class T>
106 const char* type_name,
107 Uint32 argc = 0,
108 const base::IInterface* argv[] = 0)
109 {
110 base::IInterface* ptr_iinterface = create( type_name, argc, argv);
111 if ( !ptr_iinterface)
112 return 0;
113 T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
114 ptr_iinterface->release();
115 return ptr_T;
116 }
117
152 template<class T>
154 {
155 return create<T>( Type_traits<T>::get_type_name());
156 }
157
163 {
167
174
179
182
185
191
197
203
207
211
214
217
218 // Undocumented, for alignment only
219 FORCE_32_BIT_RESULT = 0xffffffffU
220 };
221
227 {
234
238
239 // Undocumented, for alignment only
240 FORCE_32_BIT_OPTIONS = 0xffffffffU
241 };
242
264 virtual Uint32 assign_from_to( const IData* source, IData* target, Uint32 options = 0) = 0;
265
273 virtual IData* clone( const IData* source, Uint32 options = 0) = 0;
274
289 template<class T>
290 T* clone( const IData* source, Uint32 options = 0)
291 {
292 mi::base::IInterface* ptr_iinterface = clone( source, options);
293 if ( !ptr_iinterface)
294 return 0;
295 T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
296 ptr_iinterface->release();
297 return ptr_T;
298 }
299
332 virtual Sint32 compare( const IData* lhs, const IData* rhs) = 0;
333
345 virtual const IString* dump( const IData* data, const char* name = 0, Size depth = 0) = 0;
346
352 virtual const IString* dump(
353 neuraylib::ITransaction* transaction,
354 const IData* data,
355 const char* name = 0,
356 Size depth = 0) = 0;
357
363 virtual const IStructure_decl* get_structure_decl( const char* structure_name) const = 0;
364
370 virtual const IEnum_decl* get_enum_decl( const char* enum_name) const = 0;
371};
372
373mi_static_assert( sizeof( IFactory::Assign_result) == sizeof( Uint32));
375 // end group mi_neuray_types
377
378} // namespace neuraylib
379
380} // namespace mi
381
382#endif // MI_NEURAYLIB_IFACTORY_H
This interface is the base interface of all types.
Definition: idata.h:297
An enum declaration is used to describe enum types.
Definition: ienum_decl.h:36
A simple string class.
Definition: istring.h:22
A structure declaration is used to describe structure types.
Definition: istructure_decl.h:34
The basic extensible interface.
Definition: iinterface.h:103
Mixin class template for deriving new interface declarations.
Definition: interface_declare.h:43
This API component allows the creation, assignment, and cloning of instances of types.
Definition: ifactory.h:35
T * clone(const IData *source, Uint32 options=0)
Creates a clone of a type.
Definition: ifactory.h:290
virtual const IEnum_decl * get_enum_decl(const char *enum_name) const =0
Returns a registered enum declaration.
virtual IData * clone(const IData *source, Uint32 options=0)=0
Creates a clone of a type.
virtual const IString * dump(neuraylib::ITransaction *transaction, const IData *data, const char *name=0, Size depth=0)=0
Returns a textual representation of a type.
virtual Sint32 compare(const IData *lhs, const IData *rhs)=0
Compares two instances of mi::IData.
T * create()
Creates an object of the type T.
Definition: ifactory.h:153
Assign_clone_options
This enum represents various options for the assignment or cloning of types.
Definition: ifactory.h:227
@ DEEP_ASSIGNMENT_OR_CLONE
By default, assignment or cloning of instances of mi::IPointer and mi::IConst_pointer is shallow,...
Definition: ifactory.h:233
@ FIX_SET_OF_TARGET_KEYS
By default, assignment might change the set of keys if the for target is a dynamic array or map.
Definition: ifactory.h:237
virtual Uint32 assign_from_to(const IData *source, IData *target, Uint32 options=0)=0
Assigns the value(s) of source to target.
T * create(const char *type_name, Uint32 argc=0, const base::IInterface *argv[]=0)
Creates an object of the type type_name.
Definition: ifactory.h:105
virtual const IString * dump(const IData *data, const char *name=0, Size depth=0)=0
Returns a textual representation of a type.
virtual const IStructure_decl * get_structure_decl(const char *structure_name) const =0
Returns a registered structure declaration.
Assign_result
This enum represents possible events that can happen during assignment of types.
Definition: ifactory.h:163
@ DIFFERENT_COLLECTIONS
Both arguments source and target (or the types of at least one key thereof) are collections,...
Definition: ifactory.h:190
@ NULL_POINTER
One of the arguments source or target is NULL.
Definition: ifactory.h:166
@ INCOMPATIBLE_ENUM_TYPES
The assignment failed due to incompatible enum types.
Definition: ifactory.h:213
@ STRUCTURAL_MISMATCH
There is a structural mismatch between source and target.
Definition: ifactory.h:173
@ DEEP_ASSIGNMENT_TO_CONST_POINTER
Deep assignment was requested and target is an instance of mi::IConst_pointer (or a key of target is ...
Definition: ifactory.h:206
@ NO_CONVERSION
Both arguments (or at least one key thereof) are of different interfaces derived from mi::IData_simpl...
Definition: ifactory.h:178
@ INCOMPATIBLE_POINTER_TYPES
Shallow assignment (the default) was requested and the assignment failed due to incompatible pointer ...
Definition: ifactory.h:202
@ SOURCE_KEY_MISSING
There is at least one key in target which does not exist in source.
Definition: ifactory.h:184
@ TARGET_KEY_MISSING
There is at least one key in source which does not exist in target.
Definition: ifactory.h:181
@ INCOMPATIBLE_PRIVACY_LEVELS
The assignment failed due to incompatible privacy levels, i.e., mi::IRef::set_reference() returned er...
Definition: ifactory.h:210
@ NON_IDATA_VALUES
The argument source is a collection and contains at least one key which is not of type mi::IData,...
Definition: ifactory.h:196
@ INCOMPATIBLE_OPTIONS
The assignment failed due to incompatible options.
Definition: ifactory.h:216
virtual base::IInterface * create(const char *type_name, Uint32 argc=0, const base::IInterface *argv[]=0)=0
Creates an object of the type type_name.
A transaction provides a consistent view on the database.
Definition: itransaction.h:83
#define mi_static_assert(expr)
Compile time assertion that raises a compilation error if the constant expression expr evaluates to f...
Definition: assert.h:58
virtual const IInterface * get_interface(const Uuid &interface_id) const =0
Acquires a const interface from another.
virtual Uint32 release() const =0
Decrements the reference count.
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
signed int Sint32
32-bit signed integer.
Definition: types.h:46
Types.
Mixin class template for deriving new interface declarations.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: example_derivatives.dox:5
Type traits relating interfaces, corresponding primitive types, and their type names.
Definition: type_traits.h:162
Type traits.