Global variables
[GridLAB-D Core]


Detailed Description

The GridLAB-D core maintains a group of global variables that can be accessed by both core functions and runtime modules using the core API.


Classes

struct  s_globalvar

Defines

#define FALSE   (0)
#define GLOBAL   extern
#define INIT(A)
#define TRUE   (!FALSE)

Enumerations

enum  STATUS { FAILED = FALSE, SUCCESS = TRUE }

Functions

GLOBALVARglobal_create (char *name,...)
 Creates a user-defined global variable.
void global_dump (void)
GLOBALVARglobal_find (char *name)
 Find a global variable.
GLOBALVARglobal_getnext (GLOBALVAR *previous)
 Get global variable list.
char * global_getvar (char *name, char *buffer, int size)
 Get the value of a global variable in a safer fashion.
STATUS global_init (void)
 Register global variables.
STATUS global_setvar (char *def,...)
 Sets a user-defined global variable.
GLOBAL char global_object_scan[32] INIT ("%[^:]:%d")
 the format to use when scanning for object ids
GLOBAL char global_complex_format[256] INIT ("%+lg%+lg%c")
 the format to use when processing complex numbers
GLOBAL char global_double_format[32] INIT ("%+lg")
 the format to use when processing real numbers
GLOBAL TIMESTAMP global_stoptime INIT (TS_NEVER)
 The simulation stop time.
GLOBAL TIMESTAMP global_clock INIT (TS_ZERO)
 The main clock timestamp.
GLOBAL int global_xml_encoding INIT (8)
 Specifies XML encoding (default is 8).
GLOBAL int global_profiler INIT (0)
 Flags the profiler to process class performance data.
GLOBAL int global_threadcount INIT (1)
 the maximum thread limit, zero means automagically determine best thread count
GLOBAL char global_savefile[1024] INIT ("")
 The save file name.
GLOBAL char global_dumpfile[1024] INIT ("gridlabd.xml")
 The dump file name.
GLOBAL char global_workdir[1024] INIT (".")
 The current working directory.
GLOBAL unsigned global_iteration_limit INIT (100)
 The global iteration limit.
GLOBAL int global_quiet_mode INIT (FALSE)
 The quiet mode flag.
GLOBAL char global_environment[1024] INIT ("batch")
 The processing environment in use.
GLOBAL unsigned global_version_minor INIT (REV_MINOR)
 The software's minor version.
GLOBAL unsigned global_version_major INIT (REV_MAJOR)
 The software's major version.

Variables

GLOBAL char global_command_line [1024]
 The current command-line.


Enumeration Type Documentation

enum STATUS

Enumerator:
FAILED 
SUCCESS 

Definition at line 29 of file globals.h.


Function Documentation

GLOBALVAR * global_create ( char *  name,
  ... 
)

Creates a user-defined global variable.

Returns:
a pointer to GLOBALVAR struct or NULL is failed
User defined variables can be created using a syntax similar to that of class_define_map(). However

Todo:
this does not support module globals but needs to (no ticket)

Definition at line 116 of file globals.c.

References _PT_LAST, arg(), s_keyword::name, s_globalvar::name, s_keyword::next, s_globalvar::next, PA_PRIVATE, PA_PROTECTED, PA_PUBLIC, PA_REFERENCE, s_globalvar::prop, property_size(), PT_ACCESS, PT_delegated, PT_enumeration, PT_KEYWORD, PT_set, PT_SIZE, throw_exception(), unit_find(), and s_keyword::value.

Referenced by cmex_global(), global_init(), and global_setvar().

GLOBALVAR * global_find ( char *  name  ) 

Find a global variable.

Returns:
a pointer to the GLOBALVAR struct if found, NULL if not found
Parameters:
name  name of global variable to find

Definition at line 80 of file globals.c.

References global_getnext(), and s_globalvar::name.

Referenced by cmex_get(), global_getvar(), global_setvar(), and module_getvar_addr().

GLOBALVAR * global_getnext ( GLOBALVAR previous  ) 

Get global variable list.

This function retrieves global variable names. The first time it should be called with a NULL pointer to retrieve the first variable name. Subsequent calls should return the pointer to the previous variable name (and not a pointer to a copy).

Returns:
a pointer to the first character in the next variable name, or NULL of none found.
Parameters:
previous  a pointer to the previous variable name (NULL for first)

Definition at line 99 of file globals.c.

References s_globalvar::next.

Referenced by global_dump(), and global_find().

char * global_getvar ( char *  name,
char *  buffer,
int  size 
)

Get the value of a global variable in a safer fashion.

Returns:
a char * pointer to the buffer holding the buffer where we wrote the data, NULL if insufficient buffer space or if the name was not found.
This function searches global, user-defined, and module variables for a match.

Definition at line 316 of file globals.c.

References PROPERTY::addr, class_property_to_string(), global_find(), and s_globalvar::prop.

Referenced by module_getvar(), and output_test().

STATUS global_init ( void   ) 

Register global variables.

Returns:
SUCCESS or FAILED

Definition at line 65 of file globals.c.

References global_create(), output_error(), PT_ACCESS, and SUCCESS.

Referenced by exec_init().

STATUS global_setvar ( char *  def,
  ... 
)

Sets a user-defined global variable.

Returns:
STATUS value
User defined global variables can be set using a syntax similar to that of putenv(). The definition must be of the form "NAME=VALUE". If there is no '=' in the first argument, then it is used as a name and the second argument is read as a pointer to a string the contains the new value.

Todo:
autotype global variables when creating them (ticket #26)

Definition at line 260 of file globals.c.

References PROPERTY::addr, class_string_to_property(), FAILED, global_create(), global_find(), output_error(), PA_PUBLIC, s_globalvar::prop, PT_ACCESS, PT_char1024, PT_SIZE, and SUCCESS.

Referenced by cmdarg_load(), cmex_set(), load_module_list(), and module_setvar().

GLOBAL int global_threadcount INIT (  ) 

the maximum thread limit, zero means automagically determine best thread count

Todo:
Set the threadcount to zero to automatically use the maximum system resources (tickets 180)


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