Panda3D
Classes | Public Types | Public Member Functions

DCNumericRange< NUM > Class Template Reference

Represents a range of legal integer or floating-point values. More...

#include "dcNumericRange.h"

List of all members.

Classes

class  MinMax

Public Types

typedef NUM Number

Public Member Functions

 DCNumericRange (Number min, Number max)
 DCNumericRange (const DCNumericRange &copy)
bool add_range (Number min, Number max)
 Adds a new minmax to the list of ranges.
void clear ()
void generate_hash (HashGenerator &hashgen) const
Number get_max (int n) const
 Returns the maximum value defined by the nth component.
Number get_min (int n) const
 Returns the minimum value defined by the nth component.
int get_num_ranges () const
 Returns the number of minmax components in the range description.
Number get_one_value () const
 If has_one_value() returns true, this returns the one legal value accepted by the numeric range.
bool has_one_value () const
 Returns true if the numeric range specifies exactly one legal value, false if multiple values are legal.
bool is_empty () const
 Returns true if the range contains no elements (and thus allows all numbers), false if it contains at least one.
bool is_in_range (Number num) const
 Returns true if the indicated number is within the specified range, false otherwise.
void operator= (const DCNumericRange &copy)
void output (ostream &out, Number divisor=1) const
void output_char (ostream &out, Number divisor=1) const
 Outputs the range, formatting the numeric values as quoted ASCII characters.
void validate (Number num, bool &range_error) const
 Convenience function to validate the indicated number.

Detailed Description

template<class NUM>
class DCNumericRange< NUM >

Represents a range of legal integer or floating-point values.

This is used to constrain simple numeric types, as well as array sizes.

Definition at line 29 of file dcNumericRange.h.


Member Function Documentation

template<class NUM >
bool DCNumericRange< NUM >::add_range ( Number  min,
Number  max 
)

Adds a new minmax to the list of ranges.

This is normally called only during dc file parsing. Returns true if successful, or false if the new minmax overlaps an existing minmax.

Definition at line 213 of file dcNumericRange.I.

template<class NUM >
DCNumericRange< NUM >::Number DCNumericRange< NUM >::get_max ( int  n) const [inline]

Returns the maximum value defined by the nth component.

Definition at line 281 of file dcNumericRange.I.

Referenced by DCSimpleParameter::set_range().

template<class NUM >
DCNumericRange< NUM >::Number DCNumericRange< NUM >::get_min ( int  n) const [inline]

Returns the minimum value defined by the nth component.

Definition at line 269 of file dcNumericRange.I.

Referenced by DCArrayParameter::pack_default_value(), and DCSimpleParameter::set_range().

template<class NUM >
int DCNumericRange< NUM >::get_num_ranges ( ) const [inline]

Returns the number of minmax components in the range description.

Definition at line 258 of file dcNumericRange.I.

Referenced by DCSimpleParameter::set_range().

template<class NUM >
DCNumericRange< NUM >::Number DCNumericRange< NUM >::get_one_value ( ) const [inline]

If has_one_value() returns true, this returns the one legal value accepted by the numeric range.

Definition at line 119 of file dcNumericRange.I.

template<class NUM >
bool DCNumericRange< NUM >::has_one_value ( ) const [inline]

Returns true if the numeric range specifies exactly one legal value, false if multiple values are legal.

Definition at line 107 of file dcNumericRange.I.

template<class NUM >
bool DCNumericRange< NUM >::is_empty ( ) const [inline]

Returns true if the range contains no elements (and thus allows all numbers), false if it contains at least one.

Definition at line 246 of file dcNumericRange.I.

Referenced by DCArrayParameter::pack_default_value().

template<class NUM >
bool DCNumericRange< NUM >::is_in_range ( Number  num) const

Returns true if the indicated number is within the specified range, false otherwise.

Definition at line 68 of file dcNumericRange.I.

template<class NUM >
void DCNumericRange< NUM >::output_char ( ostream &  out,
Number  divisor = 1 
) const

Outputs the range, formatting the numeric values as quoted ASCII characters.

Definition at line 173 of file dcNumericRange.I.

template<class NUM >
void DCNumericRange< NUM >::validate ( Number  num,
bool &  range_error 
) const [inline]

Convenience function to validate the indicated number.

If the number is within the specified range, does nothing; otherwise, if it is outside the range, sets range_error to true.

Definition at line 93 of file dcNumericRange.I.

Referenced by DCArrayParameter::pack_string(), and DCArrayParameter::validate_num_nested_fields().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations