The app_pat parameter is a case-insensitive glob-pattern specifying which applications the value is available to. The application name is set during application initialization, typically by either tk appname or else constructed from the Tcl script filename (cf. Oc_Main GetAppName in oommf/app/oc/main.tcl).Oc_Option Add app_pat class_name option value
The class_name parameter refers to either an Oc_Class (cf. oommf/app/oc/class.tcl) or is a general descriptor. The option parameter is the name of the option and value is the value to associate with the option.
In principle the Oc_Option Add command can be called at any time, but primarily it is used in the oommf/config/options.tcl and oommf/config/local/options.tcl files read during application initialization. As an example,
sets the Menu + show_console_option to 1 in any application that queries the Oc_Option database for this value. The query is made with the Oc_Option Get or Oc_Option GetValue commands. The latter simply returns the value, i.e.,Oc_Option Add * Menu show_console_option 1
would set foo to 1, or throw an error if Menu show_console_option had not been declared. The Oc_Option Get command supports more general interrogation of the database:set foo [Oc_Option GetValue Menu show_console_option]
In the above example Menu is a general descriptor, not an Oc_Class, and so the Menu options are only accessible via Oc_Option Get or Oc_Option GetValue calls. On the other hand, when the class constructor of an Oc_Class is run it interrogates the Oc_Option database and automatically sets any matching class common variables to values from the database. For example, if
appears in oommf/config/local/options.tcl, then the Oc_LockFile wait_time class common variable “wait_time” would be automatically set to 20, overriding the default value 10 declared in the Oc_LockFile definition.Oc_Option Add * Oc_LockFile wait_time 20
As a more complex example, suppose oommf/config/local/options.tcl contains
Oc_Option Add * Oc_LockFile wait_time 20 Oc_Option Add boxsi Oc_LockFile wait_time 30 Oc_Option Add oxsii Oc_LockFile wait_time 40Then Oc_LockFile wait_time would be set to 30 inside the boxsi application, 40 inside oxsii, and 20 elsewhere. If the * pattern were not included then Oc_LockFile wait_time database entry would be undefined in any application other than boxsi or oxsii. Moreover, the statement order is important. As the Add statements are processed only those passing the app_pat check are entered into the database. So in the above Oc_LockFile + wait_time is first set to 20 regardless of the application. Next the Add boxsi line sets the value to 30 if the application is boxsi, but is otherwise ignored. The Add oxsii line is treated in like manner. If the Add * line were instead last then it would overwrite any earlier settings for Oc_LockFile + wait_time, in which case the value would be 20 in all applications.
As a final note, although the oommf/config/options.tcl and local/options.tcl files are intended primarily for platform-agnostic configuration, in contrast to the platform-specific files under oommf/config/platforms/, the options.tcl files are nonetheless Tcl scripts, and so Tcl introspection commands can be use to adjust Oc_Option database settings based on any number of factors. For example, if you wanted to control debug builds via an environment variable, you could place a stanza like
if {[info exists env(OOMMF_DEBUG)] && $env(OOMMF_DEBUG)} { # Debug build Oc_Option Add * Platform cflags {-warn 1 -debug 1} } else { # Normal build Oc_Option Add * Platform cflags {-def NDEBUG} }inside oommf/config/local/options.tcl. In a similar vein one could query [info hostname] to affect behavior based on the machine name.