Publishing variables
[Runtime module API]


Detailed Description

Modules must register public variables that are accessed by other modules, and the core by publishing them.

The typical modules will register a class, and immediately publish the variables supported by the class:

    EXPORT CLASS *init(CALLBACKS *fntable, MODULE *module, int argc, char *argv[])
    {
        extern CLASS* node_class; // defined globally in the module
        if (set_callback(fntable)==NULL)
        {
            errno = EINVAL;
            return NULL;
        }

        node_class = gl_register_class(module,"node",PC_BOTTOMUP); 
        PUBLISH_CLASS(node,complex,V);
        PUBLISH_CLASS(node,complex,S);

        return node_class; // always return the *first* class registered
    }


Defines

#define PUBLISH_CLASS(C, T, N)   {class C _t;if (gl_publish_variable(C##_class,PT_##T,#N,(char*)&_t.N-(char*)&_t,NULL)<1) return NULL;}
 The PUBLISH_CLASS macro is used to publish a member of a class (C++ only).
#define PUBLISH_CLASSX(C, T, N, V)   {class C _t;if (gl_publish_variable(C##_class,PT_##T,V,(char*)&_t.N-(char*)&_t,NULL)<1) return NULL;}
 The PUBLISH_CLASSX macro is used to publish a member of a class (C++ only) using a different name from the member name.
#define PUBLISH_DELEGATED(C, T, N)   {class C _t;if (gl_publish_variable(C##_class,PT_delegated,T,#N,(char*)&_t.N-(char*)&_t,NULL)<1) return NULL;}
 The PUBLISH_DELEGATED macro is used to publish a variable that uses a delegated type.
#define PUBLISH_STRUCT(C, T, N)   {struct C _t;if (gl_publish_variable(C##_class,PT_##T,#N,(char*)&_t.N-(char*)&_t,NULL)<1) return NULL;}
 The PUBLISH_STRUCT macro is used to publish a member of a structure.


GridLAB-DTM Version 1.0
An open-source project initiated by the US Department of Energy