示例#1
0
  ConfigExample():
    myIntParam(0),
    myDoubleParam(0.5),
    myBoolParam(false),
    myProcessConfigCB(this, &ConfigExample::processConfigFile)
  {
    // The global Aria class contains an ArConfig object.  You can create
    // other instances of ArConfig, but this is how you can share one ArConfig
    // among various program modules.
    // If you want to store a config parameter in ArConfig, first you must add 
    // it to the ArConfig object.  Parameters are stored in sections, and
    // they affect a variable via a pointer provided in an ArConfigArg
    // object:
    ArConfig* config = Aria::getConfig();
    config->setSectionComment("Example Section", "Contains parameters created by the configExample");

    // Add an integer which ranges from -10 to 10:
    config->addParam( ArConfigArg("ExampleIntegerParameter", &myIntParam, "Example parameter integer.", -10, 10), "Example Section", ArPriority::NORMAL);
    
    // Add a floating point number which ranges from 0.0 to 1.0:
    config->addParam( ArConfigArg("ExampleDoubleParameter", &myDoubleParam, "Example double precision floating point number.", 0.0, 1.0), "Example Section", ArPriority::NORMAL);

    // Essential parameters can be placed in the "Important" priority level:
    config->addParam( ArConfigArg("ExampleBoolParameter", &myBoolParam, "Example boolean parameter."), "Example Section", ArPriority::IMPORTANT);

    // Unimportant parameters can be placed in the "Trivial" priority level:
    myStringParam[0] = '\0';  // make string empty
    config->addParam( ArConfigArg("ExampleStringParameter", myStringParam, "Example string parameter.", 256), "Example Section", ArPriority::TRIVIAL);

    // You can set a callback to be invoked when the configuration changes, in
    // case you need to respond to any changes in the parameter values:
    config->addProcessFileCB(&myProcessConfigCB, 0);
  }