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

LoopSpec< T > Class Template Reference

#include <loopspec.h>

Collaboration diagram for LoopSpec< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class LoopSpec< T >

Loop counter specification.

Useful for implementing loops with arbitrary run-time modifiable nesting.

Could be made to inherit from ValueGen if the overhead of a virtual function call will always be considered small inside the innermost loop; this happens to be true at present but might not remain so.

Definition at line 27 of file loopspec.h.

Public Types

typedef LoopSpec self
typedef T value_type

Public Methods

 LoopSpec (const string &name_, const int max_count_, const bool exclusive=true, ValueGenerator< T > *g=0, const int discrete_levels_=-1)
 The max_count determines how many times next() can be called before valid() becomes false.

bool next ()
void reset ()
bool valid () const
int count () const
int num () const
operator * () const
string name () const
value () const


Constructor & Destructor Documentation

template<class T>
LoopSpec< T >::LoopSpec const string &    name_,
const int    max_count_,
const bool    exclusive = true,
ValueGenerator< T > *    g = 0,
const int    discrete_levels_ = -1
[inline]
 

The max_count determines how many times next() can be called before valid() becomes false.

If a non-empty name string is provided, it will be used for stream output.

If a ValueGenerator is supplied, the value() of the ValueGenerator is returned for the value() of this object (after modification by discrete_levels, if any, below). The ValueGenerator is advanced once for every reset (to ensure that a valid value exists for e.g. random distributions) and again once per next(). The ValueGenerator should returna number in the range 0 to 1.0.

Usually, however, no ValueGenerator is needed. If none is supplied, the value() will be a number from 0 to 1.0 reflecting the number of times next() has been called so far out of the total count specified. If the total count is zero, the value() will be 0.

If discrete_inputs is present and greater than zero, the value() will be discretized to the given number of levels before it is returned, which can be useful with Random valuegenerators, e.g. to discretize to max_count levels. The discretization is done by multiplying by discrete_levels, truncating to an integer, and then dividing by discrete_levels; this procedure is meaningful for real variables 0..1.0 but may not be useful for other ranges of values. To avoid any spurious rounding errors, discretization is skipped even if specified, if discrete_levels happens to be the same as max_count and there is no ValueGenerator.

If exclusive is true, then the max_count is taken to be exclusive, and valid() counts will range from 0 to max_count-1, inclusively. Otherwise valid counts will range from 0 to max_count, inclusively. The conversion to a continuous value() does not depend on the exclusivity or inclusivity.

Definition at line 70 of file loopspec.h.


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