Yate
MatchingItemRandom Class Reference

Random number matching. More...

#include <yateclass.h>

Inheritance diagram for MatchingItemRandom:
MatchingItemBase GenObject

Public Member Functions

 MatchingItemRandom (uint32_t val, uint32_t maxVal, bool negated=false, const char *name=0)
 
uint32_t value () const
 
uint32_t maxValue () const
 
bool randomMatch () const
 
virtual bool runMatchString (const String &str, MatchingParams *params=0) const
 
virtual bool runMatchListParam (const NamedList &list, MatchingParams *params=0) const
 
virtual MatchingItemBasecopy () const
 
virtual const MatchingItemRandomitemRandom () const
 
- Public Member Functions inherited from MatchingItemBase
 MatchingItemBase (const char *name, bool negated=false)
 
const Stringname () const
 
bool negated () const
 
bool matchString (const String &str, MatchingParams *params=0) const
 
bool matchListParam (const NamedList &list, MatchingParams *params=0) const
 
virtual const MatchingItemStringitemString () const
 
virtual const MatchingItemRegexpitemRegexp () const
 
virtual const MatchingItemListitemList () const
 
virtual const MatchingItemCustomitemCustom () const
 
virtual Stringdump (String &buf, const MatchingItemDump *dump=0, const String &indent=String::empty(), const String &origIndent=String::empty(), unsigned int depth=0) const
 
virtual StringdumpValue (String &buf, const MatchingItemDump *dump=0, const String &indent=String::empty(), const String &origIndent=String::empty(), unsigned int depth=0) const
 
virtual GenObjectdumpXml (const MatchingItemDump *dump=0, unsigned int depth=0) const
 
virtual const StringtoString () const
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtraceId () const
 
virtual void * getObject (const String &name) const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Additional Inherited Members

- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Detailed Description

Random number matching.

Match using a random number Implements a matching of a reference value greater than RANDOM[0..MAX - 1] List match and item name set: Parameter present: use random match Parameter not present: no match (return false)

Constructor & Destructor Documentation

◆ MatchingItemRandom()

MatchingItemRandom ( uint32_t val,
uint32_t maxVal,
bool negated = false,
const char * name = 0 )
inline

Constructor Random percent match: val=[PERCENT] maxVal=100

Parameters
valReference value. 0: never match, 'maxVal' is ignored
maxValUpper interval value. 0, 1, less than / equal to 'val': always match
negatedTrue if matching is negated (return the opposite of match in public methods), false otherwise
nameItem name

Member Function Documentation

◆ copy()

virtual MatchingItemBase * copy ( ) const
inlinevirtual

Copy this item

Returns
MatchingItemBase pointer

Reimplemented from MatchingItemBase.

◆ itemRandom()

virtual const MatchingItemRandom * itemRandom ( ) const
inlinevirtual

Check if this item is a MatchingItemRandom one

Returns
MatchingItemRandom pointer

Reimplemented from MatchingItemBase.

◆ maxValue()

uint32_t maxValue ( ) const
inline

Retrieve the maximum value for random number

Returns
The maximum value for random number

◆ randomMatch()

bool randomMatch ( ) const
inline

Run the match. Ignore the 'negated' property

Returns
True if matched, false otherwise

References Random::random().

◆ runMatchListParam()

virtual bool runMatchListParam ( const NamedList & list,
MatchingParams * params = 0 ) const
inlinevirtual

NamedList parameter match

Parameters
listList to search for parameter match
paramsOptional parameters used during match
Returns
True if matches, false otherwise

Reimplemented from MatchingItemBase.

References NamedList::getParam().

◆ runMatchString()

virtual bool runMatchString ( const String & str,
MatchingParams * params = 0 ) const
inlinevirtual

String match

Parameters
strString to match
paramsOptional parameters used during match
Returns
True if matched, false otherwise

Reimplemented from MatchingItemBase.

◆ value()

uint32_t value ( ) const
inline

Retrieve the reference value used to make a decision

Returns
The reference value used to make a decision

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