[ Home : Programs | libCVD | Hardware hacks | Publications | Teaching | TooN | Research ]

Gvars3

Gvars3 - configuration system library

GVars3 is also hosted as a subsidiary project of libCVD.

News

Downloading

The use of git or the most recent snapshot is strongly reccomended. Note that the old CVS repositorw will remain available, but will not receive further updates:

Documentation

Mailing list
Mailing list archives

A simple example

The following program will illustrate many of the major features of GVars3. In partucular, it shows how to load values from a configuration file, or the commandline arguments, how to retrieve a value in the program, and how to create a simple GUI for manipulating the values.
#include <gvars3/instances.h>
#include <iostream>
#include <cstdlib>

using namespace GVars3;
using namespace std;

int main(int argc, char** argv)
{
    //Load a configuration file (optional)
    GUI.LoadFile("foo.cfg");

    //Process commandline arguments (optional)
    cout << "An integer = " << GV3::get<int>("wurble") << endl;
    cout << "A float = " << GV3::get<float>("fobble") << endl;

    //Make an easier to use binding to a gvar:
    gvar3<int> an_integer("i");

    //An illustration of using the graphical
    //components.
    while(1)
    {
        //Process the GUI. This can be done in another thread if
        //need be.
        GUI_Widgets.process_in_crnt_thread();

        cout << "\r" << *an_integer << "     " << flush;
        usleep(10000);
    }
}
Then create the configuration file foo.cfg with the following contents:
//Set some variables
wurble=10
fobble=6.66666
i=54

//Create a simple GUI for controlling i
GUI.InitXInterface
GUI.AddWindow iwin "This window controls i" 
iwin.AddMonitor "The value of i" i
iwin.AddSlider i 0 1000
iwin.AddPushButton "Set i=88" "i=88"

//Create a simple function
function strange
. echo "Setting i to 279"
. i=279
. echo "Hello. world"
endfunction

//Run the function from a pushbutton:
iwin.AddPushButton "Strange function" strange

//Another pushbutton to list all commands:
iwin.AddPushButton "Command list" "commandlist"
Now try running the program. Also, try running ./prog --wurble 79

Dependencies

Requirements

There are no requirements.

Options


Updated September 10th 2012, 03:26