Open Search
    Published Objects Declaration

    Table of Contents

    About

    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 (see 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.
    // ---------------------------------------------------------------------
    {
    public:
    {
    };
    };
    // 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"
    [published_objects_declaration]
    Definition: example_declarations.h:23
    maxon::Int _neutronCnt
    number of neutrons
    Definition: example_declarations.h:33
    maxon::Int _electronCnt
    number of electrons
    Definition: example_declarations.h:34
    SimpleAtom()
    Definition: example_declarations.h:25
    maxon::Int _protonCnt
    number of protons
    Definition: example_declarations.h:30
    Int64 Int
    signed 32/64 bit int, size depends on the platform
    Definition: apibase.h:187
    #define MAXON_DATATYPE(type, id,...)
    Definition: datatype.h:296
    #define MAXON_DECLARATION(T, Name, id,...)
    Definition: module.h:939

    Further Reading