Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ValueGenerator< T > Class Template Reference

#include <valuegen.h>

Inheritance diagram for ValueGenerator< T >:

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

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T = double>
class ValueGenerator< T >

This heads a class hierarchy of objects which primarily contain a variable of the given type, but which also contain operations for automatically generating a new value from a given distribution or by some other means.

Semantics for a value "a" of this type and a value "b" of the numeric type "T" which it contains:

    ValueGenerator<T>  a;
    T b;
    T* c;
    ValueGenerator<T>* d;

    a = b;           // Assign the value b to a
    b = a.value();   // Assign the value of a to b
                     // (can omit .value() if conversion operator defined)
    a.next();        // Choose a new value for a; returns false if unsuccessful
    a.reset();       // Reset a to its initial value, if any
    c = a.valueptr();// Returns address of data in a
    c = a.genptr();  // Returns address of a
    d = a.clone();   // d points to an identical but independent copy of a
                     // (i.e., d may outlive a.  This helps support
		     // polymorphism, since a may be of a subtype of d, yet
		     // the duplicate is of the subtype, not d's type.
  

Various derived types are used to support different distributions by reimplementing "next()" and "reset()"; their interface should differ only by their constructors and not by their usage.

The operator relink() is supported for the rare instances when one might wish to change a stored external value pointer to point to a different location. If an internal storage location is actually being used, the operation has no effect.

This base class is a basic version that acts just like an ordinary variable or reference.

Definition at line 96 of file valuegen.h.

Public Methods

 ValueGenerator (T value=T())
 Constructor for an internally-allocated variable.

 ValueGenerator (T *value)
 Constructor for a reference to an external value.

 ValueGenerator (StringArgs &args)
virtual string stringrep () const
 Returns the value as a scalar.

operator * () const
 Returns the current underlying value.

value () const
 Returns the current underlying value.

T * valueptr () const
 Returns a pointer to the underlying value; use with caution.

Operations that may be overridden by derived classes
virtual void relink (T *ptr)
virtual bool next ()
 Advance to the next state (whatever that means for this object).

virtual void reset ()
 Reset to the starting state.

virtual ValueGenerator< T > * clone () const
 Constructs an identical copy of self and returns it.


Member Function Documentation

template<class T = double>
virtual string ValueGenerator< T >::stringrep   const [inline, virtual]
 

Returns the value as a scalar.

Derived classes will usually want to provide a more specific representation, namely what the StringArgs constructor will accept for that class.

At present it cannot be guaranteed that the value returned is actually what was used to create the object; perhaps the StringArgs passed to the constructor should be saved instead. If so, the StringArgs constructor above would have to be changed to include a string specifying the ValueGenerator type.

Reimplemented in ValueGenerator_Random< T, RandomGen >, ValueGenerator_Correlate< T, RandomGen, crop >, ValueGenerator_Opposite< T >, ValueGenerator_Increment< T >, and ValueGenerator_Expression< T >.

Definition at line 120 of file valuegen.h.

References String::stringrep(), and ValueGenerator< T >::value().

Referenced by Retinal_Object::vargen_stringrep().


The documentation for this class was generated from the following file:
Generated on Mon Jan 20 02:37:26 2003 for RF-LISSOM by doxygen1.3-rc2