Panda3D
Classes | Public Types | Public Member Functions | List of all members
DCNumericRange< NUM > Class Template Reference

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

#include "dcNumericRange.h"

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

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 26 of file dcNumericRange.h.

Member Function Documentation

◆ add_range()

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

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 183 of file dcNumericRange.I.

◆ get_max()

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 241 of file dcNumericRange.I.

◆ get_min()

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 231 of file dcNumericRange.I.

Referenced by DCArrayParameter::pack_default_value().

◆ get_num_ranges()

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

Returns the number of minmax components in the range description.

Definition at line 222 of file dcNumericRange.I.

Referenced by DCSimpleParameter::set_range().

◆ get_one_value()

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 100 of file dcNumericRange.I.

◆ has_one_value()

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 90 of file dcNumericRange.I.

◆ is_empty()

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 213 of file dcNumericRange.I.

Referenced by DCArrayParameter::pack_default_value().

◆ is_in_range()

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

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

Definition at line 56 of file dcNumericRange.I.

◆ output_char()

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

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

Definition at line 148 of file dcNumericRange.I.

◆ validate()

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 78 of file dcNumericRange.I.

Referenced by DCArrayParameter::validate_num_nested_fields().


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