32.2 Configuring OEInterface

Configuring an OEInterface is the process of telling the name, type and other details of all the command line parameters the program is going to use. It does not include the process of parsing the command line to set the parameter values however.

When initially constructed the OEInterface object does not know about any command line parameters. This is demonstrated using the following program.

Chapter 32 - Example 2: cpp file

#include "oeplatform.h"
#include "oesystem.h"

using namespace OEPlatform;
using namespace OESystem;

int main(int, char**)
{
  OEInterface itf;
  OEWriteSettings(itf,oeout,true);
  return 0;
}

The function OEWriteSettings lists the current settings of all the parameters the OEInterface class knows about. Since it was just constructed the OEInterface class doesn't know about any parameters and when the output of the program when run looks like this

Chapter 32 - Example 2: output

> ch32-2
#Interface settings
>

indicating the OEInterface doesn't know anything about any parameters yet.

The OEInterface class can be configured either by explicitly calling the various member functions of the class (detailed in the API documentation), or by using the OEConfigure free function. Taking our previous example we can add an OEConfigure call as follows

Chapter 32 - Example 3: cpp file

#include "oeplatform.h"
#include "oesystem.h"

//Defines static const unsigned char* array InterfaceData
#include "ch32-3.itf"

using namespace OEPlatform;
using namespace OESystem;

int main(int , char** )
{
  OEInterface itf;
  OEConfigure(itf,InterfaceData);
  OEWriteSettings(itf,oeout,true);
  return 0;
}

The OEConfigure function is passed the itf object, and a pointer to a text file compiled into the program at compile time using the method described in the first section of this chapter. For this example the text file is

Chapter 32 - Example 3: txt file

!PARAMETER -x
  !TYPE float
!END

!PARAMETER -y
  !TYPE float
!END

!PARAMETER -op
  !TYPE string
!END

and given the output of the program is

Chapter 32 - Example 3: output

> ch32-3
#Interface settings
#-op (Not set, no default)
#-x (Not set, no default)
#-y (Not set, no default)
>

The example program now lists the three parameters that were configured by the OEConfigure function, using the txt file listed above. (Rules for the format of this file are listed in the API documentation of OEConfigure). Note that because all we have done is configure the OEInterface these parameters have no value set, even though the parameters are now known to the OEInterface class.