Wt::WVarBase< VARTYPE > Class Template Reference

Watched variable avoids the need for get/set methods. More...

#include <wvar.h>

Inherited by Wt::WVar< VARTYPE, PARENT >, and Wt::WVar< VARTYPE, WVarBase< int >::RW >.

List of all members.

Public Member Functions

 WVarBase (VARTYPE value=0)
VARTYPE readValue () const
VARTYPE get (VARTYPE) const
 usefull for overrides and variables connection
void set (VARTYPE value)
void connect (WVarBase &var)
 connect as a proxy to another WVar
 operator VARTYPE () const
 operator const std::string () const
WVarBaseoperator+= (const VARTYPE &value)
WVarBaseoperator-= (const VARTYPE &value)
WVarBaseoperator++ ()
 prefix operator
WVarBaseoperator-- ()
WVarBaseoperator++ (int)
 postfix operator
WVarBaseoperator-- (int)

Public Attributes

Signal012M< bool, VARTYPE,
VARTYPE, Blocker
aboutToChange
Signal012< void, VARTYPE,
VARTYPE > 
changed
Signal01< void, VARTYPE > read
sigc::signal1< VARTYPE, VARTYPE,
Overrider
override

Protected Types

typedef std::pair< bool, VARTYPE > ValidValue

Protected Member Functions

const VARTYPE & getValue () const
 avoids emitting read signal
void setValue (const VARTYPE &value)
 avoids emitting aboutToChange, changed signal
WVarBaseoperator= (VARTYPE value)
WVarBaseoperator= (const WVarBase &value)

Classes

class  Blocker
 Marshaler. More...
class  OverideValue
class  Overrider
 Marshaler to override all values but the last. More...
class  RW


Detailed Description

template<typename VARTYPE>
class Wt::WVarBase< VARTYPE >

Watched variable avoids the need for get/set methods.

A WVar watched variable is a templated attempt to vanquish the get set methods that accompanies object oriented programming.

Note:
The WVar class is good only for arithmetic (builtin) types and not generic classes due to c++'s C ish background. Maybe later we will build a WClass class. The problem is that WVar has a value of VARTYPE instead of inheriting from VARTYPE. This has the ugly effect that VARTYPE's members cannot be accessed through WVar without ugly casts, and of course in C++ is not possible to inherit from builtin types (int, bool) etc.
A WVar variable can be read through the cast operator and be written through the assign operator. The WVar variable emits a signal when it is about to change, after it has been changed, and when it is accessed for read.

if a slot from the ones that are called during aboutToChange returns true then the change is aborted.

A WVar variable can be publically read/write or protected. The default is to be publically read/write. If you do not wish for your variable to be publically readable just make your damn variable protected/private.

WVar<int> a is a read/write int variable. WVar<int, C> a is a publically readable and read/write for class C.

Example: see test/vars.c


Member Typedef Documentation

template<typename VARTYPE>
typedef std::pair<bool, VARTYPE> Wt::WVarBase< VARTYPE >::ValidValue [protected]


Constructor & Destructor Documentation

template<typename VARTYPE>
Wt::WVarBase< VARTYPE >::WVarBase ( VARTYPE  value = 0  )  [inline]


Member Function Documentation

template<typename VARTYPE>
void Wt::WVarBase< VARTYPE >::connect ( WVarBase< VARTYPE > &  var  )  [inline]

connect as a proxy to another WVar

template<typename VARTYPE>
VARTYPE Wt::WVarBase< VARTYPE >::get ( VARTYPE   )  const [inline]

usefull for overrides and variables connection

Todo:
get, set and other they should really

template<typename VARTYPE>
const VARTYPE& Wt::WVarBase< VARTYPE >::getValue (  )  const [inline, protected]

avoids emitting read signal

template<typename VARTYPE>
Wt::WVarBase< VARTYPE >::operator const std::string (  )  const [inline]

template<typename VARTYPE>
Wt::WVarBase< VARTYPE >::operator VARTYPE (  )  const [inline]

template<typename VARTYPE>
WVarBase& Wt::WVarBase< VARTYPE >::operator++ ( int   )  [inline]

postfix operator

template<typename VARTYPE>
WVarBase& Wt::WVarBase< VARTYPE >::operator++ (  )  [inline]

prefix operator

template<typename VARTYPE>
WVarBase& Wt::WVarBase< VARTYPE >::operator+= ( const VARTYPE &  value  )  [inline]

template<typename VARTYPE>
WVarBase& Wt::WVarBase< VARTYPE >::operator-- ( int   )  [inline]

template<typename VARTYPE>
WVarBase& Wt::WVarBase< VARTYPE >::operator-- (  )  [inline]

template<typename VARTYPE>
WVarBase& Wt::WVarBase< VARTYPE >::operator-= ( const VARTYPE &  value  )  [inline]

template<typename VARTYPE>
WVarBase& Wt::WVarBase< VARTYPE >::operator= ( const WVarBase< VARTYPE > &  value  )  [inline, protected]

template<typename VARTYPE>
WVarBase& Wt::WVarBase< VARTYPE >::operator= ( VARTYPE  value  )  [inline, protected]

template<typename VARTYPE>
VARTYPE Wt::WVarBase< VARTYPE >::readValue (  )  const [inline]

template<typename VARTYPE>
void Wt::WVarBase< VARTYPE >::set ( VARTYPE  value  )  [inline]

template<typename VARTYPE>
void Wt::WVarBase< VARTYPE >::setValue ( const VARTYPE &  value  )  [inline, protected]

avoids emitting aboutToChange, changed signal


Member Data Documentation

template<typename VARTYPE>
Signal012M<bool, VARTYPE, VARTYPE, Blocker> Wt::WVarBase< VARTYPE >::aboutToChange

template<typename VARTYPE>
Signal012<void, VARTYPE, VARTYPE> Wt::WVarBase< VARTYPE >::changed

template<typename VARTYPE>
sigc::signal1<VARTYPE, VARTYPE, Overrider> Wt::WVarBase< VARTYPE >::override [mutable]

template<typename VARTYPE>
Signal01<void, VARTYPE> Wt::WVarBase< VARTYPE >::read [mutable]


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

Generated Fri Jul 28 19:22:39 2006.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.