Evoplex  0.2.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
evoplex::AttributeRange Class Reference

The AttributeRange base class. More...

#include <attributerange.h>

Inheritance diagram for evoplex::AttributeRange:
evoplex::AttributeRangeInterface evoplex::IntervalOfValues evoplex::SetOfValues evoplex::SingleValue

Public Types

enum  Type {
  Invalid, Double_Range, Int_Range, Bool,
  Double_Set, Int_Set, String_Set, String,
  NonEmptyString, DirPath, FilePath
}
 An enum for the attribute range types. More...
 

Public Member Functions

 ~AttributeRange () override=default
 Destructor.
 
Value validate (const QString &valueStr) const
 Checks if the valueStr belongs to this attribute range. More...
 
bool isValid () const
 Checks if this AttributeRange is valid. More...
 
int id () const
 Gets the attribute id.
 
const QString & attrName () const
 Gets the attribute name.
 
const QString & attrRangeStr () const
 Gets the original attribute's range string. More...
 
Type type () const
 Gets the current attribute's range type.
 
const Valuemin () const
 Gets the minimum value in the range.
 
const Valuemax () const
 Gets the maximum value in the range.
 
- Public Member Functions inherited from evoplex::AttributeRangeInterface
virtual ~AttributeRangeInterface ()=default
 Destructor.
 
virtual Value rand (PRG *prg) const =0
 Gets a random value in the attribute range. More...
 
virtual Value next (const Value &v) const =0
 Gets the value after v. More...
 
virtual Value prev (const Value &v) const =0
 Gets the value before v. More...
 

Static Public Member Functions

static AttributeRangePtr parse (int attrId, const QString &attrName, const QString &attrRangeStr)
 Creates an AttributeRange object from a valid attrRangeStr string. More...
 

Protected Member Functions

 AttributeRange (int id, const QString &attrName, Type type)
 AttributeRange constructor. More...
 

Protected Attributes

const int m_id
 
const QString m_attrName
 
const Type m_type
 
QString m_attrRangeStr
 
Value m_min
 
Value m_max
 

Detailed Description

The AttributeRange base class.

See also
SingleValue, IntervalOfValues, SetOfValues

Member Enumeration Documentation

◆ Type

An enum for the attribute range types.

Enumerator
Invalid 

Invalid type.

Double_Range 

A range of real numbers.

Int_Range 

A range of integers.

Bool 

A boolean.

Double_Set 

A set of real numbers.

Int_Set 

A set of intergers.

String_Set 

A set of strings.

String 

A string.

NonEmptyString 

A non-empty string.

DirPath 

A directory path.

FilePath 

A file path.

Constructor & Destructor Documentation

◆ AttributeRange()

evoplex::AttributeRange::AttributeRange ( int  id,
const QString &  attrName,
Type  type 
)
explicitprotected

AttributeRange constructor.

Parameters
idThe attribute's id.
attrNameThe attribute's name.
typeThe attribute's type.
See also
AttributeRange::parse

Member Function Documentation

◆ attrRangeStr()

const QString & evoplex::AttributeRange::attrRangeStr ( ) const
inline

Gets the original attribute's range string.

See also
AttributeRange::parse

◆ isValid()

bool evoplex::AttributeRange::isValid ( ) const
inline

Checks if this AttributeRange is valid.

Returns
true if it is valid.

◆ parse()

static AttributeRangePtr evoplex::AttributeRange::parse ( int  attrId,
const QString &  attrName,
const QString &  attrRangeStr 
)
static

Creates an AttributeRange object from a valid attrRangeStr string.

Parameters
attrIdThe attribute id.
attrNameThe attribute name.
attrRangeStrThe attribute range string.
Returns
Returns a null object if attrRangeStr is invalid.

The accepted 'attrRangeStr' strings are listed in the table below.

Attribute Range Description
"bool" a boolean
"dirpath" a string containing a valid dirpath (use forward slashes)
"filepath" a string containing a valid filepath (use forward slashes)
"string" a string (empty string is also valid)
"non-empty-string" a non-empty string
"string{aaa,bbb}" set of strings
"int[min,max]" integers from min to max (including min and max)
"int{1,2,3}" set of integers
"double[min,max]" doubles from min to max (including min and max)
"double{1.1,1.2}" set of doubles
Note
You can use 'max' to take the maximum value for the type. For instance, 'int[0,max]' corresponds to an integer from 0 to 2147483647, which is the largest integer.
Warning
Do NOT add spaces before/after the commas.

◆ validate()

Value evoplex::AttributeRange::validate ( const QString &  valueStr) const

Checks if the valueStr belongs to this attribute range.

Parameters
valueStrA value as a string.
Returns
An empty/invalid Value if valueStr is not within this range.

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