nConfItem< T > Class Template Reference

#include <nConfig.h>

Inheritance diagram for nConfItem< T >:

Inheritance graph
[legend]
Collaboration diagram for nConfItem< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 nConfItem (const char *title, const char *help, T &t)
virtual ~nConfItem ()
virtual void NetReadVal (nMessage &m)
virtual void NetWriteVal (nMessage &m)
void Set (const T &newval)
virtual void OnRevertToDefaults ()
 revert this setting to its default
virtual void OnSaveValue ()
 saves value for later restoring
virtual void OnRevertToSavedValue ()
 reverts to the saved value

Protected Member Functions

 nConfItem (T &t)

Private Member Functions

void WasChanged ()

Private Attributes

default_
 default value
saved_
 a saved value


Detailed Description

template<class T>
class nConfItem< T >

Definition at line 111 of file nConfig.h.


Constructor & Destructor Documentation

template<class T>
nConfItem< T >::nConfItem ( T &  t  )  [inline, protected]

Definition at line 117 of file nConfig.h.

00118             :tConfItemBase(""), tConfItem<T>("", t),default_(t),saved_(t){}

template<class T>
nConfItem< T >::nConfItem ( const char *  title,
const char *  help,
T &  t 
) [inline]

Definition at line 121 of file nConfig.h.

00122             :tConfItem<T>(t),
00123             tConfItemBase(title, help ),
00124             default_(t),
00125     saved_(t){}

template<class T>
virtual nConfItem< T >::~nConfItem (  )  [inline, virtual]

Definition at line 126 of file nConfig.h.

00126 {}


Member Function Documentation

template<class T>
virtual void nConfItem< T >::NetReadVal ( nMessage m  )  [inline, virtual]

Implements nConfItemBase.

Definition at line 129 of file nConfig.h.

00129                                         {
00130         T dummy;
00131         m >> dummy;
00132         if (sn_compare(dummy,*this->target)){
00133             if (printChange)
00134             {
00135                 tOutput o;
00136                 o.SetTemplateParameter(1, title);
00137                 o.SetTemplateParameter(2, *this->target);
00138                 o.SetTemplateParameter(3, dummy);
00139                 o << "$nconfig_value_changed";
00140                 con << con.ColorString(1,.3,.3) << o;
00141             }
00142             *this->target=dummy;
00143             this->ExecuteCallback();
00144             changed=true;
00145         }
00146     }

template<class T>
virtual void nConfItem< T >::NetWriteVal ( nMessage m  )  [inline, virtual]

Implements nConfItemBase.

Definition at line 148 of file nConfig.h.

00148                                          {
00149         m << *this->target;
00150     }

template<class T>
void nConfItem< T >::Set ( const T &  newval  )  [inline]

Definition at line 152 of file nConfig.h.

Referenced by nConfItem< tString >::OnRevertToDefaults(), nConfItem< tString >::OnRevertToSavedValue(), and gCycle::SetWallsStayUpDelay().

00153     {
00154         bool changed = ( newval != *this->target );
00155         *this->target = newval;
00156 
00157         if ( changed )
00158         {
00159             WasChanged();
00160         }
00161     }

Here is the caller graph for this function:

template<class T>
virtual void nConfItem< T >::OnRevertToDefaults (  )  [inline, virtual]

revert this setting to its default

Implements nConfItemBase.

Definition at line 163 of file nConfig.h.

00164     {
00165         Set( default_ );
00166     }

template<class T>
virtual void nConfItem< T >::OnSaveValue (  )  [inline, virtual]

saves value for later restoring

Implements nConfItemBase.

Definition at line 168 of file nConfig.h.

00169     {
00170         saved_ = *this->target;
00171     }

template<class T>
virtual void nConfItem< T >::OnRevertToSavedValue (  )  [inline, virtual]

reverts to the saved value

Implements nConfItemBase.

Definition at line 173 of file nConfig.h.

00174     {
00175         Set( saved_ );
00176     }

template<class T>
void nConfItem< T >::WasChanged (  )  [inline, private, virtual]

Reimplemented from tConfItemBase.

Definition at line 178 of file nConfig.h.

Referenced by nConfItem< tString >::Set().

00179     {
00180         nConfItemBase::WasChanged( ! (*this->target == default_) );
00181     }

Here is the caller graph for this function:


Member Data Documentation

template<class T>
T nConfItem< T >::default_ [private]

default value

Definition at line 183 of file nConfig.h.

Referenced by nConfItem< tString >::OnRevertToDefaults(), and nConfItem< tString >::WasChanged().

template<class T>
T nConfItem< T >::saved_ [private]

a saved value

Definition at line 184 of file nConfig.h.

Referenced by nConfItem< tString >::OnRevertToSavedValue(), and nConfItem< tString >::OnSaveValue().


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:47:16 2008 for Armagetron Advanced by  doxygen 1.5.4