Published Objects Declaration

内容表

关于

A published object is declared in a header file. Every source code file that includes this header file can then access this published object.

Declaration

A published object is declared with the MAXON_DECLARATION attribute. Only instances of MAXON API data types can be published this way. A custom class has to be registered as a data type using MAXON_DATATYPE and MAXON_DATATYPE_REGISTER (见 MAXON Data Type ). Implementations of interfaces are a data type so they can be shared as a published object.

// This example declares some custom data type. Individual instances // of this data type are presented as published objects.

// --------------------------------------------------------------------- // The custom data type SimpleAtom represents a simple atom model. // --------------------------------------------------------------------- class SimpleAtom { public : SimpleAtom() { _protonCnt = 1; _neutronCnt = 0; _electronCnt = 1; };

maxon::Int _protonCnt; maxon::Int _neutronCnt; maxon::Int _electronCnt; };

// register as MAXON data type MAXON_DATATYPE (SimpleAtom, "net.maxonexample.datatype.simpleatom" );

#include "example_declarations1.hxx"

// register individual instances of the data type as published objects MAXON_DECLARATION (SimpleAtom, Carbon, "net.maxonexample.atoms.carbon" ); MAXON_DECLARATION (SimpleAtom, Oxygen, "net.maxonexample.atoms.oxygen" ); MAXON_DECLARATION (SimpleAtom, Iron, "net.maxonexample.atoms.iron" ); #include "example_declarations2.hxx"

延伸阅读

MAXON_DATATYPE
#define MAXON_DATATYPE(type, id)
定义: datatype.h:309
MAXON_DECLARATION
#define MAXON_DECLARATION(T, Name, id)
定义: module.h:797
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
定义: apibase.h:184

Copyright  © 2014-2025 乐数软件    

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