GUIParameterTableItem< T > Class Template Reference

#include <GUIParameterTableItem.h>

Inheritance diagram for GUIParameterTableItem< T >:

GUIParameterTableItemInterface

Detailed Description

template<class T>
class GUIParameterTableItem< T >

Instance of a single line in a parameter window.

This class represents a single item of a parameter table and is an implementation of the GUIParameterTableItemInterface that allows different value-types.

As some values may change over the simulation, this class holds the information whether they change and how to ask for new values if they do.

See also:
GUIParameterTracker

GUIParameterTableItemInterface

Definition at line 118 of file GUIParameterTableItem.h.


Public Member Functions

bool dynamic () const throw ()
 Returns the information whether this item may change.
const std::string & getName () const throw ()
 Returns the name of this value.
ValueSource< T > * getSourceCopy () const throw ()
 Returns a copy of the source if the value is dynamic.
ValueSource< SUMOReal > * getSUMORealSourceCopy () const throw ()
 Returns a SUMOReal-typed copy of the source if the value is dynamic.
 GUIParameterTableItem (FXTable *table, unsigned pos, const std::string &name, bool dynamic, std::string value) throw ()
 Constructor for string-typed, non-changing (static) values.
 GUIParameterTableItem (FXTable *table, unsigned pos, const std::string &name, bool dynamic, T value) throw ()
 Constructor for non-changing (static) values.
 GUIParameterTableItem (FXTable *table, unsigned pos, const std::string &name, bool dynamic, ValueSource< T > *src) throw ()
 Constructor for changing (dynamic) values.
void init (bool dynamic, std::string value) throw ()
 Initialises the line.
void update () throw ()
 Resets the value if it's dynamic.
 ~GUIParameterTableItem () throw ()
 Destructor.

Private Attributes

bool myAmDynamic
 Information whether the value may change.
std::string myName
 The name of this value.
ValueSource< T > * mySource
 The source to gain new values from; this source is==0 if the values are not dynamic.
FXTablemyTable
 The table this entry belongs to.
FXint myTablePosition
 The position within the table.
myValue
 A backup of the value to avoid the redrawing when nothing has changed.

Constructor & Destructor Documentation

template<class T>
GUIParameterTableItem< T >::GUIParameterTableItem ( FXTable table,
unsigned  pos,
const std::string &  name,
bool  dynamic,
ValueSource< T > *  src 
) throw () [inline]

Constructor for changing (dynamic) values.

Parameters:
[in] table The table this item belongs to
[in] pos The row of the table this item fills
[in] name The name of the represented value
[in] dynamic Information whether this value changes over time
[in] src The value source
Todo:
Consider using a reference to the table
Todo:
Check whether the name should be stored in GUIParameterTableItemInterface

Definition at line 130 of file GUIParameterTableItem.h.

References GUIParameterTableItemInterface::dynamic().

00133             : myAmDynamic(dynamic), myName(name), myTablePosition((FXint) pos), mySource(src),
00134             myValue(src->getValue()), myTable(table) {
00135         init(dynamic, toString<T>(src->getValue()));
00136     }

template<class T>
GUIParameterTableItem< T >::GUIParameterTableItem ( FXTable table,
unsigned  pos,
const std::string &  name,
bool  dynamic,
value 
) throw () [inline]

Constructor for non-changing (static) values.

Parameters:
[in] table The table this item belongs to
[in] pos The row of the table this item fills
[in] name The name of the represented value
[in] dynamic Information whether this value changes over time
[in] value The value
Todo:
Consider using a reference to the table
Todo:
Check whether the name should be stored in GUIParameterTableItemInterface
Todo:
Should never be dynamic!?

Definition at line 150 of file GUIParameterTableItem.h.

References GUIParameterTableItemInterface::dynamic().

00153             : myAmDynamic(dynamic), myName(name), myTablePosition((FXint) pos), mySource(0),
00154             myValue(value), myTable(table) {
00155         init(dynamic, toString<T>(value));
00156     }

template<class T>
GUIParameterTableItem< T >::GUIParameterTableItem ( FXTable table,
unsigned  pos,
const std::string &  name,
bool  dynamic,
std::string  value 
) throw () [inline]

Constructor for string-typed, non-changing (static) values.

Parameters:
[in] table The table this item belongs to
[in] pos The row of the table this item fills
[in] name The name of the represented value
[in] dynamic Information whether this value changes over time
[in] value The value
Todo:
Consider using a reference to the table
Todo:
Check whether the name should be stored in GUIParameterTableItemInterface
Todo:
Should never be dynamic!?

Definition at line 170 of file GUIParameterTableItem.h.

References GUIParameterTableItemInterface::dynamic().

00173             : myAmDynamic(dynamic), myName(name), myTablePosition((FXint) pos), mySource(0),
00174             myValue(0), myTable(table) {
00175         init(dynamic, value);
00176     }

template<class T>
GUIParameterTableItem< T >::~GUIParameterTableItem (  )  throw () [inline]

Destructor.

Definition at line 180 of file GUIParameterTableItem.h.

00180                                      {
00181         delete mySource;
00182     }


Member Function Documentation

template<class T>
bool GUIParameterTableItem< T >::dynamic (  )  const throw () [inline, virtual]

Returns the information whether this item may change.

Returns:
Whether this item changes over time

Implements GUIParameterTableItemInterface.

Definition at line 213 of file GUIParameterTableItem.h.

00213                                  {
00214         return myAmDynamic;
00215     }

template<class T>
const std::string& GUIParameterTableItem< T >::getName (  )  const throw () [inline, virtual]

Returns the name of this value.

Returns:
The name of this value

Implements GUIParameterTableItemInterface.

Definition at line 222 of file GUIParameterTableItem.h.

00222                                              {
00223         return myName;
00224     }

template<class T>
ValueSource<T>* GUIParameterTableItem< T >::getSourceCopy (  )  const throw () [inline]

Returns a copy of the source if the value is dynamic.

Returns:
A copy of the value source

Definition at line 250 of file GUIParameterTableItem.h.

00250                                                   {
00251         if (mySource==0) {
00252             return 0;
00253         }
00254         return mySource->copy();
00255     }

template<class T>
ValueSource<SUMOReal>* GUIParameterTableItem< T >::getSUMORealSourceCopy (  )  const throw () [inline, virtual]

Returns a SUMOReal-typed copy of the source if the value is dynamic.

Returns:
A SUMOReal-typed copy of the value source

Implements GUIParameterTableItemInterface.

Definition at line 262 of file GUIParameterTableItem.h.

References ValueSource< T >::makeSUMORealReturningCopy().

00262                                                                  {
00263         if (mySource==0) {
00264             return 0;
00265         }
00266         return mySource->makeSUMORealReturningCopy();
00267     }

template<class T>
void GUIParameterTableItem< T >::init ( bool  dynamic,
std::string  value 
) throw () [inline]

Initialises the line.

Fills the line using the name, the current value, and the information whether the value changes over time.

Parameters:
[in] dynamic Information whether this value changes over time
[in] value The current (initial) value

Definition at line 193 of file GUIParameterTableItem.h.

References GUIParameterTableItemInterface::dynamic(), GUIIconSubSys::getIcon(), ICON_NO, and ICON_YES.

00193                                                      {
00194         myTable->setItemText(myTablePosition, 0, myName.c_str());
00195         myTable->setItemText(myTablePosition, 1, value.c_str());
00196         if (dynamic) {
00197             myTable->setItemIcon(myTablePosition, 2,
00198                                  GUIIconSubSys::getIcon(ICON_YES));
00199         } else {
00200             myTable->setItemIcon(myTablePosition, 2,
00201                                  GUIIconSubSys::getIcon(ICON_NO));
00202         }
00203         myTable->setItemJustify(myTablePosition, 2,
00204                                 FXTableItem::CENTER_X|FXTableItem::CENTER_Y);
00205     }

template<class T>
void GUIParameterTableItem< T >::update (  )  throw () [inline, virtual]

Resets the value if it's dynamic.

If the value is dynamic, the current value is retrieved from the value source. If it is different from the previous one (stored in myValue), it is stored in myValue and set as the current value text within the according table cell.

Implements GUIParameterTableItemInterface.

Definition at line 234 of file GUIParameterTableItem.h.

References GUIParameterTableItemInterface::dynamic().

00234                           {
00235         if (!dynamic()||mySource==0) {
00236             return;
00237         }
00238         T value = mySource->getValue();
00239         if (value!=myValue) {
00240             myValue = value;
00241             myTable->setItemText(myTablePosition, 1, toString<T>(myValue).c_str());
00242         }
00243     }


Field Documentation

template<class T>
bool GUIParameterTableItem< T >::myAmDynamic [private]

Information whether the value may change.

Definition at line 272 of file GUIParameterTableItem.h.

template<class T>
std::string GUIParameterTableItem< T >::myName [private]

The name of this value.

Definition at line 275 of file GUIParameterTableItem.h.

template<class T>
ValueSource<T>* GUIParameterTableItem< T >::mySource [private]

The source to gain new values from; this source is==0 if the values are not dynamic.

Definition at line 281 of file GUIParameterTableItem.h.

template<class T>
FXTable* GUIParameterTableItem< T >::myTable [private]

The table this entry belongs to.

Definition at line 287 of file GUIParameterTableItem.h.

template<class T>
FXint GUIParameterTableItem< T >::myTablePosition [private]

The position within the table.

Definition at line 278 of file GUIParameterTableItem.h.

template<class T>
T GUIParameterTableItem< T >::myValue [private]

A backup of the value to avoid the redrawing when nothing has changed.

Definition at line 284 of file GUIParameterTableItem.h.


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

Generated on Wed May 5 00:06:44 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6