Sirikata
Public Member Functions | Static Private Member Functions | Private Attributes | Friends
Sirikata::OptionValue Class Reference

A class that holds a particular option value, readable by other parts of the program as well as settable by those parts. More...

#include <OptionValue.hpp>

Collaboration diagram for Sirikata::OptionValue:

List of all members.

Public Member Functions

const Anyoperator-> () const
Anyoperator-> ()
const Anyget () const
Anyget ()
template<class T >
T & as ()
template<class T >
const T & as () const
template<class T >
T & unsafeAs ()
template<class T >
const T & unsafeAs () const
const char * description () const
const char * defaultValue () const
OptionValueoperator= (const OptionValue &other)
 changes the option value and invokes mChangeFunction message
 OptionValue ()
template<class T >
 OptionValue (const char *option, const std::string &defaultValue, T type, const char *description, OptionValue **pointer=NULL)
 Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.
template<class T >
 OptionValue (const char *option, const std::string &defaultValue, T xtype, const char *description, std::tr1::function< void(const std::string &, Any, Any)> &changeFunction, OptionValue **pointer=NULL)
 Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.
 OptionValue (const char *option, const std::string &defaultValue, const char *description, const std::tr1::function< Any(std::string)> &parser, OptionValue **pointer=NULL)
 Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.
 OptionValue (const char *option, const std::string &defaultValue, const char *description, const std::tr1::function< Any(std::string)> &parser, const std::tr1::function< void(const std::string &, Any, Any)> &changeFunction, OptionValue **pointer=NULL)
 Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.
template<class T >
 OptionValue (const char *option, const char *defaultValue, T type, const char *description, OptionValue **pointer=NULL)
 Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.
template<class T >
 OptionValue (const char *option, const char *defaultValue, T xtype, const char *description, std::tr1::function< void(const std::string &, Any, Any)> &changeFunction, OptionValue **pointer=NULL)
 Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.
 OptionValue (const char *option, const char *defaultValue, const char *description, const std::tr1::function< Any(std::string)> &parser, OptionValue **pointer=NULL)
 Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.
 OptionValue (const char *option, const char *defaultValue, const char *description, const std::tr1::function< Any(std::string)> &parser, const std::tr1::function< void(const std::string &, Any, Any)> &changeFunction, OptionValue **pointer=NULL)
 Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Static Private Member Functions

static void noop (const std::string &, Any, Any)

Private Attributes

Any mValue
std::string mDefaultValue
const char * mDefaultChar
const char * mDescription
std::tr1::function< Any(std::string)> mParser
std::tr1::function< void(const
std::string &, Any, Any)> 
mChangeFunction
const char * mName

Friends

class OptionRegistration
 Option Registration needs to have access to mValue to set it for the very first time without triggering event.
class OptionSet
 OptionSet needs to have access to the members directly to return them.

Detailed Description

A class that holds a particular option value, readable by other parts of the program as well as settable by those parts.


Constructor & Destructor Documentation

Sirikata::OptionValue::OptionValue ( ) [inline]
template<class T >
Sirikata::OptionValue::OptionValue ( const char *  option,
const std::string &  defaultValue,
type,
const char *  description,
OptionValue **  pointer = NULL 
) [inline]

Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Parameters:
optionis the name of the option in the config or text files
defaultValueis the string representation of the default value as if a user typed it in
typeis a class that contains a static lexical_cast function that transforms a string into an Sirikata::Any of the appropirate type
descriptionis the textual description for the user when looking through the command line help
pointerholds a pointer to an OptionValue that will get set to the newly constructed class

References defaultValue(), description(), mChangeFunction, mDefaultValue, mDescription, mName, mParser, and noop().

template<class T >
Sirikata::OptionValue::OptionValue ( const char *  option,
const std::string &  defaultValue,
xtype,
const char *  description,
std::tr1::function< void(const std::string &, Any, Any)> &  changeFunction,
OptionValue **  pointer = NULL 
) [inline]

Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Parameters:
optionis the name of the option in the config or text files
defaultValueis the string representation of the default value as if a user typed it in
xtypeis a class that contains a static lexical_cast function that transforms a string into an Sirikata::Any of the appropirate type
descriptionis the textual description for the user when looking through the command line help
changeFunctionis the function that will be invoked if someone atomically changes the OptionValue type by invoking =
pointerholds a pointer to an OptionValue that will get set to the newly constructed class

References defaultValue(), description(), mChangeFunction, mDefaultValue, mDescription, mName, mParser, and noop().

Sirikata::OptionValue::OptionValue ( const char *  option,
const std::string &  defaultValue,
const char *  description,
const std::tr1::function< Any(std::string)> &  parser,
OptionValue **  pointer = NULL 
) [inline]

Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Parameters:
optionis the name of the option in the config or text files
defaultValueis the string representation of the default value as if a user typed it in
descriptionis the textual description for the user when looking through the command line help
parseris the function that can convert a string to the Sirikata::Any of the appropriate type
pointerholds a pointer to an OptionValue that will get set to the newly constructed class

References defaultValue(), description(), mChangeFunction, mDefaultValue, mDescription, mName, mParser, and noop().

Sirikata::OptionValue::OptionValue ( const char *  option,
const std::string &  defaultValue,
const char *  description,
const std::tr1::function< Any(std::string)> &  parser,
const std::tr1::function< void(const std::string &, Any, Any)> &  changeFunction,
OptionValue **  pointer = NULL 
) [inline]

Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Parameters:
optionis the name of the option in the config or text files
defaultValueis the string representation of the default value as if a user typed it in
descriptionis the textual description for the user when looking through the command line help
parseris the function that can convert a string to the Sirikata::Any of the appropriate type
changeFunctionis the function that will be invoked if someone atomically changes the OptionValue type by invoking =
pointerholds a pointer to an OptionValue that will get set to the newly constructed class

References defaultValue(), description(), mChangeFunction, mDefaultValue, mDescription, mName, and mParser.

template<class T >
Sirikata::OptionValue::OptionValue ( const char *  option,
const char *  defaultValue,
type,
const char *  description,
OptionValue **  pointer = NULL 
) [inline]

Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Parameters:
optionis the name of the option in the config or text files
defaultValueis the string representation of the default value as if a user typed it in
typeis a class that contains a static lexical_cast function that transforms a string into an Sirikata::Any of the appropirate type
descriptionis the textual description for the user when looking through the command line help
pointerholds a pointer to an OptionValue that will get set to the newly constructed class

References defaultValue(), description(), mChangeFunction, mDefaultChar, mDescription, mName, mParser, and noop().

template<class T >
Sirikata::OptionValue::OptionValue ( const char *  option,
const char *  defaultValue,
xtype,
const char *  description,
std::tr1::function< void(const std::string &, Any, Any)> &  changeFunction,
OptionValue **  pointer = NULL 
) [inline]

Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Parameters:
optionis the name of the option in the config or text files
defaultValueis the string representation of the default value as if a user typed it in
xtypeis a class that contains a static lexical_cast function that transforms a string into an Sirikata::Any of the appropirate type
descriptionis the textual description for the user when looking through the command line help
changeFunctionis the function that will be invoked if someone atomically changes the OptionValue type by invoking =
pointerholds a pointer to an OptionValue that will get set to the newly constructed class

References defaultValue(), description(), mChangeFunction, mDefaultChar, mDescription, mName, mParser, and noop().

Sirikata::OptionValue::OptionValue ( const char *  option,
const char *  defaultValue,
const char *  description,
const std::tr1::function< Any(std::string)> &  parser,
OptionValue **  pointer = NULL 
) [inline]

Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Parameters:
optionis the name of the option in the config or text files
defaultValueis the string representation of the default value as if a user typed it in
descriptionis the textual description for the user when looking through the command line help
parseris the function that can convert a string to the Sirikata::Any of the appropriate type
pointerholds a pointer to an OptionValue that will get set to the newly constructed class

References defaultValue(), description(), mChangeFunction, mDefaultChar, mDescription, mName, mParser, and noop().

Sirikata::OptionValue::OptionValue ( const char *  option,
const char *  defaultValue,
const char *  description,
const std::tr1::function< Any(std::string)> &  parser,
const std::tr1::function< void(const std::string &, Any, Any)> &  changeFunction,
OptionValue **  pointer = NULL 
) [inline]

Invoke an option, setting its default value with a particular lexiccal cast function, a description and optionally a pointer to set to the result.

Parameters:
optionis the name of the option in the config or text files
defaultValueis the string representation of the default value as if a user typed it in
descriptionis the textual description for the user when looking through the command line help
parseris the function that can convert a string to the Sirikata::Any of the appropriate type
changeFunctionis the function that will be invoked if someone atomically changes the OptionValue type by invoking =
pointerholds a pointer to an OptionValue that will get set to the newly constructed class

References defaultValue(), description(), mChangeFunction, mDefaultChar, mDescription, mName, and mParser.


Member Function Documentation

template<class T >
T& Sirikata::OptionValue::as ( ) [inline]
template<class T >
const T& Sirikata::OptionValue::as ( ) const [inline]

References Sirikata::Any::as(), and mValue.

const char* Sirikata::OptionValue::defaultValue ( ) const [inline]

References mDefaultChar, and mDefaultValue.

Referenced by OptionValue().

const char* Sirikata::OptionValue::description ( ) const [inline]

References mDescription.

Referenced by OptionValue().

Any* Sirikata::OptionValue::get ( ) [inline]

References mValue.

const Any* Sirikata::OptionValue::get ( ) const [inline]
static void Sirikata::OptionValue::noop ( const std::string &  ,
Any  ,
Any   
) [inline, static, private]

Referenced by OptionValue().

const Any* Sirikata::OptionValue::operator-> ( ) const [inline]

References mValue.

Any* Sirikata::OptionValue::operator-> ( ) [inline]

References mValue.

OptionValue & Sirikata::OptionValue::operator= ( const OptionValue other)

changes the option value and invokes mChangeFunction message

References mChangeFunction, mDefaultChar, mDefaultValue, mDescription, mName, mParser, and mValue.

template<class T >
const T& Sirikata::OptionValue::unsafeAs ( ) const [inline]
template<class T >
T& Sirikata::OptionValue::unsafeAs ( ) [inline]

Friends And Related Function Documentation

friend class OptionRegistration [friend]

Option Registration needs to have access to mValue to set it for the very first time without triggering event.

friend class OptionSet [friend]

OptionSet needs to have access to the members directly to return them.


Member Data Documentation

std::tr1::function<void(const std::string&,Any,Any)> Sirikata::OptionValue::mChangeFunction [private]
const char* Sirikata::OptionValue::mDefaultChar [private]
std::string Sirikata::OptionValue::mDefaultValue [private]
const char* Sirikata::OptionValue::mDescription [private]
const char* Sirikata::OptionValue::mName [private]
std::tr1::function<Any(std::string)> Sirikata::OptionValue::mParser [private]

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