|
goptions
|
Example program showing how to define and use GOptions : . More...

Go to the source code of this file.
Functions | |
| GOptions | defineOptions () |
| Builds and returns a set of example options (definitions only). | |
| int | main (int argc, char *argv[]) |
| Example entry point: parse inputs and read back resolved values. | |
This example demonstrates an end-to-end pattern commonly used in GEMC-style modules:
main() using: GOptions(argc, argv, user_defined_options) .It also shows:
Definition in file define_options.cc.
| GOptions defineOptions | ( | ) |
This function intentionally does not parse any inputs. Instead, it returns a GOptions : populated with registrations:
The returned object is then passed into the parsing constructor:
This pattern allows multiple components (modules/plugins) to contribute their own option definitions and then combine them before parsing.
What this example defines:
log: dummy switch that can be toggled by -log.runno: an integer option set via -runno=<value>.nthreads: an integer option controlling thread usage, with 0 meaning "use all cores".gparticle: a schema representing generator particles as a sequence of maps, including mandatory keys flagged using goptions::NODFLT.Definition at line 55 of file define_options.cc.
| int main | ( | int | argc, |
| char * | argv[] ) |
This main() illustrates the common consumption flow:
argc/argv and the definitions provided by defineOptions().Example invocations:
| argc | Number of command-line arguments. |
| argv | Array of command-line argument strings. |
EXIT_SUCCESS on success). Definition at line 116 of file define_options.cc.