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.
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; };
// register as MAXON data type MAXON_DATATYPE (SimpleAtom, "net.maxonexample.datatype.simpleatom" );
// 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"