Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Config Class Reference

#include <Config.h>

Inheritance diagram for Config:

Inheritance graph
[legend]
List of all members.

Detailed Description

the root configuration object, provides some global functionality like porting pathnames (portPath())

Definition at line 86 of file Config.h.

Public Types

 UDP
 TCP
enum  transports { UDP, TCP }

Public Member Functions

 Config (const std::string &filename="")
void setFileSystemRoot (const std::string &fsr)
 sets fsRoot
const std::string & getFileSystemRoot () const
 returns fsRoot
std::string portPath (const std::string &path) const
 returns a portable version of path which should be usable on either the simulator or the robot
virtual void saveXML (xmlNode *node, bool onlyOverwrite, std::set< std::string > &seen) const
 saves the dictionary into the specified node
virtual unsigned int loadBuffer (const char buf[], unsigned int len)
 Load from a saved buffer in memory.
virtual unsigned int loadFile (const char *filename)
 initiate opening of the specified file and loading/saving of all appropriate information.
virtual unsigned int loadFileStream (FILE *f)
 Used recursively on member objects once a file is already open - DON'T CLOSE the file in your overridden functions.
void * setValue (const std::string &section, std::string key, const std::string &value)
 pass the section, item name string, item value string - sets the value and returns pointer to the item changed

Public Attributes

Config::behaviors_config behaviors
 place for users to put their own configuration
Config::wireless_config wireless
 wireless configuration options
Config::main_config main
 general configuration options
Config::controller_config controller
 controller information
Config::vision_config vision
 vision configuration options (this is a *big* section, with sub-sections)
Config::motion_config motion
 motion information
Config::sound_config sound
 sound information

Static Public Attributes

static const unsigned int NUM_TRANSPORTS = 2
 number of transports available
static const char * transport_names [NUM_TRANSPORTS+1] = { "UDP", "TCP", "" }
 string names for transports

Protected Member Functions

unsigned int loadOldFormat (const char buf[], unsigned int len)
unsigned int loadOldFormat (FILE *f)
void parseLine (const char buf[], unsigned int lineno, std::vector< std::string > &modelStack, bool &ignoring, std::string &section)

Static Protected Member Functions

static char localeToLower (char c)

Protected Attributes

std::string fsRoot
 a prefix representing the file system root, usually indicating the robot's storage root.

Static Protected Attributes

static const char * xmlIntro1 = "<?xml version"
static const char * xmlIntro2 = "<!DOCTYPE "
static const char * xmlIntro3 = "<plist"
static const std::locale & curLocale = std::locale::classic()

Classes

class  behaviors_config
 place for users to put their own configuration More...
class  controller_config
 controller information More...
class  main_config
 general configuration options More...
class  motion_config
 motion information More...
class  sound_config
 sound information More...
class  vision_config
 vision configuration options (this is a *big* section, with sub-sections) More...
class  wireless_config
 wireless configuration options More...


Member Function Documentation

unsigned int Config::loadBuffer ( const char  buf[],
unsigned int  len 
) [virtual]

Load from a saved buffer in memory.

Parameters:
buf pointer to the memory where you should begin loading
len length of buf available (this isn't necessarily all yours, there might be other things following your data)
Returns:
the number of bytes actually used

Reimplemented from XMLLoadSave.

Definition at line 221 of file Config.cc.

unsigned int Config::loadFile ( const char *  filename  )  [virtual]

initiate opening of the specified file and loading/saving of all appropriate information.

Parameters:
filename the file to load/save
Returns:
number of bytes read/written, 0 if error (or empty)

Reimplemented from XMLLoadSave.

Definition at line 227 of file Config.cc.

Referenced by Config().

unsigned int Config::loadFileStream ( FILE *  f  )  [virtual]

Used recursively on member objects once a file is already open - DON'T CLOSE the file in your overridden functions.

Parameters:
f a pointer to the file to load
Returns:
number of bytes read, 0 if error (or empty)

Reimplemented from XMLLoadSave.

Definition at line 253 of file Config.cc.

void Config::saveXML ( xmlNode node,
bool  onlyOverwrite,
std::set< std::string > &  seen 
) const [virtual]

saves the dictionary into the specified node

Parameters:
[in] node the xml node which should be saved into
[in] onlyOverwrite if is true, only saves entries for keys already found in the node
[in] seen used to keep track of which nodes have been seen in node -- may be of particular interest with onlyOverride set
seen is not cleared before being used.

Reimplemented from plist::Dictionary.

Definition at line 176 of file Config.cc.

void * Config::setValue ( const std::string &  section,
std::string  key,
const std::string &  value 
)

pass the section, item name string, item value string - sets the value and returns pointer to the item changed

this is the older deprecated interface -- use the inherited resolveEntry() instead to support sub-sections

Definition at line 315 of file Config.cc.

Referenced by parseLine(), and Controller::setConfig().


Member Data Documentation

place for users to put their own configuration

you can dynamically "link in" external configuration settings by passing them to the addEntry() of the plist::Dictionary superclass. You may want to call writeParseTree() first to flush current settings, and then readParseTree() afterward to pull any pre-existing values from the configuration file into the instances you've just registered.

Of course, you could also just write your values into the configuration file first, and just rely on getEntry/setEntry to read/write the value. This may be more convenient if you use the value infrequently and don't need an instance of it sitting around.

Referenced by Config().

std::string Config::fsRoot [protected]

a prefix representing the file system root, usually indicating the robot's storage root.

When running in the simulator, this is used to pretend that a subdirectory in the project folder (e.g. 'ms') is the root file system

Definition at line 687 of file Config.h.

Referenced by getFileSystemRoot(), portPath(), and setFileSystemRoot().


The documentation for this class was generated from the following files:

Tekkotsu v3.0
Generated Fri May 11 20:07:50 2007 by Doxygen 1.4.7