gui2::tformula< T > Class Template Reference

Template class can hold a value or a formula calculating the value. More...

#include <formula.hpp>

Collaboration diagram for gui2::tformula< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 tformula (const std::string &str)
operator() () const
 Returns the value, can only be used it the data is no formula.
operator() (const game_logic::map_formula_callable &variables) const
 Returns the value, can always be used.
bool has_formula () const
 Determine whether the class contains a formula.
template<>
bool execute (const game_logic::map_formula_callable &variables) const
template<>
int execute (const game_logic::map_formula_callable &variables) const
template<>
unsigned execute (const game_logic::map_formula_callable &variables) const
template<>
std::string execute (const game_logic::map_formula_callable &variables) const
template<>
t_string execute (const game_logic::map_formula_callable &variables) const
template<>
void convert (const std::string &str)
template<>
void convert (const std::string &str)
template<>
void convert (const std::string &str)

Private Member Functions

void convert (const std::string &str)
 Converts the string ot the template value.
execute (const game_logic::map_formula_callable &variables) const

Private Attributes

std::string formula_
 If there is a formula it's stored in this string, empty if no formula.
value_
 If no formula it contains the value.


Detailed Description

template<class T>
class gui2::tformula< T >

Template class can hold a value or a formula calculating the value.

Definition at line 30 of file gui/widgets/formula.hpp.


Constructor & Destructor Documentation

template<class T>
gui2::tformula< T >::tformula ( const std::string &  str  )  [inline]


Member Function Documentation

template<class T>
T gui2::tformula< T >::operator() (  )  const [inline]

Returns the value, can only be used it the data is no formula.

Another option would be to cache the output of the formula in value_ and always allow this function. But for now decided that the caller needs to do the caching. It might be changed later.

Definition at line 42 of file gui/widgets/formula.hpp.

template<class T>
T gui2::tformula< T >::operator() ( const game_logic::map_formula_callable variables  )  const [inline]

template<class T>
bool gui2::tformula< T >::has_formula (  )  const [inline]

Determine whether the class contains a formula.

Definition at line 52 of file gui/widgets/formula.hpp.

Referenced by gui2::tformula< T >::operator()(), and gui2::tformula< unsigned >::operator()().

template<class T>
void gui2::tformula< T >::convert ( const std::string &  str  )  [inline, private]

Converts the string ot the template value.

Definition at line 155 of file gui/widgets/formula.hpp.

References gui2::tformula< T >::value_.

Referenced by gui2::tformula< T >::tformula().

template<class T>
T gui2::tformula< T >::execute ( const game_logic::map_formula_callable variables  )  const [inline, private]

Definition at line 128 of file gui/widgets/formula.hpp.

Referenced by gui2::tformula< T >::operator()().

template<>
bool gui2::tformula< bool >::execute ( const game_logic::map_formula_callable variables  )  const [inline]

Definition at line 98 of file gui/widgets/formula.hpp.

References gui2::tformula< T >::formula_.

template<>
int gui2::tformula< int >::execute ( const game_logic::map_formula_callable variables  )  const [inline]

Definition at line 104 of file gui/widgets/formula.hpp.

References gui2::tformula< T >::formula_.

template<>
unsigned gui2::tformula< unsigned >::execute ( const game_logic::map_formula_callable variables  )  const [inline]

Definition at line 110 of file gui/widgets/formula.hpp.

References gui2::tformula< T >::formula_.

template<>
std::string gui2::tformula< std::string >::execute ( const game_logic::map_formula_callable variables  )  const [inline]

Definition at line 116 of file gui/widgets/formula.hpp.

References gui2::tformula< T >::formula_.

template<>
t_string gui2::tformula< t_string >::execute ( const game_logic::map_formula_callable variables  )  const [inline]

Definition at line 122 of file gui/widgets/formula.hpp.

References gui2::tformula< T >::formula_.

template<>
void gui2::tformula< bool >::convert ( const std::string &  str  )  [inline]

Definition at line 137 of file gui/widgets/formula.hpp.

References utils::string_bool(), and gui2::tformula< T >::value_.

template<>
void gui2::tformula< std::string >::convert ( const std::string &  str  )  [inline]

Definition at line 143 of file gui/widgets/formula.hpp.

References gui2::tformula< T >::value_.

template<>
void gui2::tformula< t_string >::convert ( const std::string &  str  )  [inline]

Definition at line 149 of file gui/widgets/formula.hpp.

References gui2::tformula< T >::value_.


Member Data Documentation

template<class T>
std::string gui2::tformula< T >::formula_ [private]

If there is a formula it's stored in this string, empty if no formula.

Definition at line 62 of file gui/widgets/formula.hpp.

Referenced by gui2::tformula< T >::execute(), gui2::tformula< unsigned >::has_formula(), gui2::tformula< T >::operator()(), and gui2::tformula< T >::tformula().

template<class T>
T gui2::tformula< T >::value_ [private]

If no formula it contains the value.

Definition at line 65 of file gui/widgets/formula.hpp.

Referenced by gui2::tformula< T >::convert(), gui2::tformula< T >::operator()(), and gui2::tformula< unsigned >::operator()().


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

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs