DataDescriptionObjectInterface Manual

内容表

关于

maxon::DataDescriptionObjectInterface is an interface that can be used as a base for custom interfaces. It allows to add data descriptions to the reference object.

接口

The maxon::DataDescriptionObjectInterface defines the maxon::DataDescriptionObjectInterface::GetObjectDescription() function. This function can be used to access the description from the given object. The needed argument can be constructed with maxon::CreateDataDictionaryReferenceObject() .

// This example creates a new object of a custom type. GetObjectDescription() is used to // get the data description of that instance. The attributes are printed to the console.

// create new object

const DescriptionElementRef element = DescriptionElementClass().Create() iferr_return ; element.SetAttributeCount(2);

// get description data maxon::DataDescription description;

maxon::DataDictionary settings; maxon::DataDictionaryObjectRef dataRef = maxon::CreateDataDictionaryReferenceObject (&settings) iferr_return ; const maxon::Id category = maxon::DATADESCRIPTION_CATEGORY_DATA ; const maxon::LanguageRef language = maxon::Resource::GetDefaultLanguage (); description = element.GetObjectDescription(category, language, dataRef) iferr_return ;

// list all attributes const auto attributes = description.GetEntries() iferr_return ; for ( const auto & attribute : attributes) { const maxon::InternedId ID = attribute. Get (maxon::DESCRIPTION::BASE::IDENTIFIER) iferr_return ; const maxon::Id dataType = attribute. Get (maxon::DESCRIPTION::DATA::BASE::DATATYPE) iferr_return ; const maxon::Data defaultData = attribute. Get ( maxon::DESCRIPTION::DATA::BASE::DEFAULTVALUE ) iferr_return ; DiagnosticOutput ( "Attribute \"@\", of type @. Default value: @" , ID, dataType, defaultData); }

Another function is maxon::DataDescriptionObjectInterface::GetObjectName() , which returns the name of the objects (maxon::OBJECT::BASE::NAME) for the given language.

Implementation

A custom interface can be based on maxon::DataDescriptionObjectInterface . The resulting reference object will store a data description. The default implementation of maxon::DataDescriptionObjectInterface is maxon::DataDescriptionObjectClass.

A custom implementation can re-implement maxon::DataDescriptionObjectInterface::GetObjectDescription() to modify the returned description.

// This example shows an implementation of an interface based on DataDescriptionObjectInterface. // It implements GetObjectDescription() to edit the returned DataDescription.

// implementation of DescriptionElementInterface class DescriptionElementImpl : public maxon::Component <DescriptionElementImpl, DescriptionElementInterface> { // use the default implementation "DataDescriptionObjectClass" MAXON_COMPONENT ( NORMAL , maxon::DataDescriptionObjectClass); public : MAXON_METHOD void SetAttributeCount( maxon::Int count) { _count = count; } MAXON_METHOD maxon::Result<maxon::DataDescription> GetObjectDescription( const maxon::Id & category, const maxon::LanguageRef& language, const maxon::DataDictionaryObjectRef& objectData) const { iferr_scope ;

// load default description maxon::DataDescription description = super.GetObjectDescription(category, language, objectData) iferr_return ;

// check category if (category == maxon::DATADESCRIPTION_CATEGORY_DATA ) { // add dynamic attributes of the type "maxon::String" for ( maxon::Int i = 0; i < _count; ++i) { // generate dynamic ID const maxon::String number = maxon::String::IntToString(i); const maxon::String identifier( "net.maxonexample.class.descriptionElement.dynamic_" _s + number); maxon::InternedId dynamicID; dynamicID. Init (identifier) iferr_return ; const maxon::Id stringDataType = maxon::GetDataType<maxon::String>()->GetId();

// set attribute settings maxon::DataDictionary dynamicAttribute; dynamicAttribute.Set(maxon::DESCRIPTION::BASE::IDENTIFIER, dynamicID) iferr_return ; dynamicAttribute.Set(maxon::DESCRIPTION::DATA::BASE::DATATYPE, stringDataType) iferr_return ; dynamicAttribute.Set( maxon::DESCRIPTION::DATA::BASE::DEFAULTVALUE , "Hello World" _s) iferr_return ;

// add new attribute description.SetEntry(dynamicAttribute) iferr_return ; } } return description; } private : maxon::Int _count = 0; };

延伸阅读

maxon::ComponentWithBase
定义: objectbase.h:2472
maxon::Resource::GetDefaultLanguage
static MAXON_METHOD LanguageRef GetDefaultLanguage()
maxon::Tuple::Get
std::add_const< typename Pack::template At< I >::type >::type & Get() const
Returns the element at index I. Equivalent to TupleGet<I>(*this).
定义: tuple.h:747
MAXON_COMPONENT
#define MAXON_COMPONENT(KIND,...)
定义: objectbase.h:2036
maxon::String
定义: string.h:1197
maxon::Data
定义: datatypebase.h:1143
maxon::Id
定义: apibaseid.h:250
iferr_return
#define iferr_return
定义: resultbase.h:1434
maxon::Data::Get
Result< typename std::conditional< GetCollectionKind< T >::value==COLLECTION_KIND::ARRAY, T, typename ByValueParam< T >::type >::type > Get() const
定义: datatypebase.h:1352
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
maxon::InternedId::Init
Result< void > Init(const Id &i)
maxon::DATADESCRIPTION_CATEGORY_DATA
const Id DATADESCRIPTION_CATEGORY_DATA
定义: datadescriptiondatabase.h:17
maxon::Result
定义: apibase.h:314
MAXON_METHOD
#define MAXON_METHOD
定义: interfacebase.h:855
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
定义: apibase.h:184
iferr_scope
#define iferr_scope
定义: resultbase.h:1343
SCULPTBRUSHMODE::NORMAL
@ NORMAL
Samples the surface as the user moves over it the SculptObject and returns a new hit point and normal...
maxon::InternedId
定义: datatypelib.h:26
DEFAULTVALUE
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
定义: c4d_gedata.h:65
maxon::InternedId::Get
const Id & Get() const
定义: datatypelib.h:138
maxon::CreateDataDictionaryReferenceObject
Result< DataDictionaryObjectRef > CreateDataDictionaryReferenceObject(DataDictionary *reference)

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1