Yate: MatchingItemRandom Class Reference

Yate

Public Member Functions | List of all members
MatchingItemRandom Class Reference

Random number matching. More...

`#include <yateclass.h>`

Inheritance diagram for MatchingItemRandom:

## 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 MatchingItemBase * | copy () const
virtual const MatchingItemRandom * | itemRandom () const
Public Member Functions inherited from MatchingItemBase
| MatchingItemBase (const char *name, bool negated=false)
const String & | name () const
bool | negated () const
bool | matchString (const String &str, MatchingParams *params=0) const
bool | matchListParam (const NamedList &list, MatchingParams *params=0) const
virtual const MatchingItemString * | itemString () const
virtual const MatchingItemRegexp * | itemRegexp () const
virtual const MatchingItemList * | itemList () const
virtual const MatchingItemCustom * | itemCustom () const
virtual String & | dump (String &buf, const MatchingItemDump *dump=0, const String &indent=String::empty(), const String &origIndent=String::empty(), unsigned int depth=0) const
virtual String & | dumpValue (String &buf, const MatchingItemDump *dump=0, const String &indent=String::empty(), const String &origIndent=String::empty(), unsigned int depth=0) const
virtual GenObject * | dumpXml (const MatchingItemDump *dump=0, unsigned int depth=0) const
virtual const String & | toString () const
Public Member Functions inherited from GenObject
| GenObject ()
virtual | ~GenObject ()
virtual bool | alive () const
virtual void | destruct ()
virtual const String & | traceId () const
virtual void * | getObject (const String &name) const
NamedCounter * | getObjCounter () const
NamedCounter * | setObjCounter (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 NamedCounter * | getObjCounter (const String &name, bool create=true)
static ObjList & | getObjCounters ()

## 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

  val | Reference value. 0: never match, 'maxVal' is ignored
  maxVal | Upper interval value. 0, 1, less than / equal to 'val': always match
  negated | True if matching is negated (return the opposite of match in public methods), false otherwise
  name | Item 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

  list | List to search for parameter match
  params | Optional 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

  str | String to match
  params | Optional 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:

- yateclass.h