neuray API Programmer's Manual

iattribute_set.h File Reference

Description

Base class for database elements with attributes.

Code Example

iattribute_set.h

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

#ifndef MI_NEURAYLIB_IATTRIBUTE_SET_H
#define MI_NEURAYLIB_IATTRIBUTE_SET_H

#include <mi/base/interface_declare.h>
#include <mi/neuraylib/idata.h>
#include <mi/neuraylib/type_traits.h>

namespace mi {
namespace neuraylib {


































enum Propagation_type {
    PROPAGATION_STANDARD, 
    PROPAGATION_OVERRIDE, 
    PROPAGATION_FORCE_32_BIT = 0xffffffffU
};

mi_static_assert( sizeof( Propagation_type) == sizeof( Uint32));

class IAttribute_set :
    public base::Interface_declare<0x1bcb8d48,0x10c1,0x4b3e,0x9b,0xfa,0x06,0x23,0x61,0x81,0xd3,0xe1>
{
public:
    virtual IData* create_attribute( const char* name, const char* type) = 0;

    template<class T>
    T* create_attribute( const char* name, const char* type)
    {
        IData* ptr_iinterface = create_attribute( name, type);
        if ( !ptr_iinterface)
            return 0;
        T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
        ptr_iinterface->release();
        return ptr_T;
    }

    template<class T>
    T* create_attribute( const char* name)
    {
        return create_attribute<T>( name, Type_traits< T>::get_type_name());
    }

    virtual bool destroy_attribute( const char* name) = 0;

    virtual const IData* access_attribute( const char* name) const = 0;

    template<class T>
    const T* access_attribute( const char* name) const
    {
        const IData* ptr_iinterface = access_attribute( name);
        if ( !ptr_iinterface)
            return 0;
        const T* ptr_T = static_cast<const T*>( ptr_iinterface->get_interface( typename T::IID()));
        ptr_iinterface->release();
        return ptr_T;
    }

    virtual IData* edit_attribute( const char* name) = 0;

    template<class T>
    T* edit_attribute( const char* name)
    {
        IData* ptr_iinterface = edit_attribute( name);
        if ( !ptr_iinterface)
            return 0;
        T* ptr_T = static_cast<T*>( ptr_iinterface->get_interface( typename T::IID()));
        ptr_iinterface->release();
        return ptr_T;
    }

    virtual bool is_attribute( const char* name) const = 0;

    virtual const char* get_attribute_type_name( const char* name) const = 0;

    virtual Sint32 
               set_attribute_propagation( const char* name, Propagation_type value) = 0;

    virtual Propagation_type 
               get_attribute_propagation( const char* name) const = 0;

    virtual const char* enumerate_attributes( Sint32 index) const = 0;
};
 // end group mi_neuray_scene_element

} // namespace neuraylib

} // namespace mi

#endif // MI_NEURAYLIB_IATTRIBUTE_SET_H

Namespaces

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

Classes

class 
The attribute set comprises all attributes attached to a database element. More...

Enumerations

enum  {PROPAGATION_STANDARD, PROPAGATION_OVERRIDE, PROPAGATION_FORCE_32_BIT = 0xffffffffU }
Propagation types for attribute inheritance. More...