SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Static Public Member Functions | List of all members
qrtplib::RTPRandom Class Referenceabstract

#include <rtprandom.h>

+ Inheritance diagram for qrtplib::RTPRandom:

Public Member Functions

 RTPRandom ()
 
virtual ~RTPRandom ()
 
virtual uint8_t GetRandom8 ()=0
 
virtual uint16_t GetRandom16 ()=0
 
virtual uint32_t GetRandom32 ()=0
 
virtual double GetRandomDouble ()=0
 
uint32_t PickSeed ()
 

Static Public Member Functions

static RTPRandomCreateDefaultRandomNumberGenerator ()
 

Detailed Description

Interface for generating random numbers.

Definition at line 53 of file rtprandom.h.

Constructor & Destructor Documentation

◆ RTPRandom()

qrtplib::RTPRandom::RTPRandom ( )
inline

Definition at line 56 of file rtprandom.h.

57  {
58  }

◆ ~RTPRandom()

virtual qrtplib::RTPRandom::~RTPRandom ( )
inlinevirtual

Definition at line 59 of file rtprandom.h.

60  {
61  }

Member Function Documentation

◆ CreateDefaultRandomNumberGenerator()

RTPRandom * qrtplib::RTPRandom::CreateDefaultRandomNumberGenerator ( )
static

Allocate a default random number generator based on your platform.

Definition at line 73 of file rtprandom.cpp.

References qrtplib::RTPRandomURandom::Init().

Referenced by qrtplib::RTPSession::GetRandomNumberGenerator().

74 {
75  RTPRandomURandom *r = new RTPRandomURandom();
76  RTPRandom *rRet = r;
77 
78  if (r->Init() < 0) // fall back to rand48
79  {
80  delete r;
81  rRet = new RTPRandomRand48();
82  }
83 
84  return rRet;
85 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRandom16()

virtual uint16_t qrtplib::RTPRandom::GetRandom16 ( )
pure virtual

Returns a random sixteen bit value.

Implemented in qrtplib::RTPRandomRandS, qrtplib::RTPRandomURandom, and qrtplib::RTPRandomRand48.

Referenced by qrtplib::RTPPacketBuilder::CreateNewSSRC().

+ Here is the caller graph for this function:

◆ GetRandom32()

virtual uint32_t qrtplib::RTPRandom::GetRandom32 ( )
pure virtual

Returns a random thirty-two bit value.

Implemented in qrtplib::RTPRandomRandS, qrtplib::RTPRandomURandom, and qrtplib::RTPRandomRand48.

Referenced by qrtplib::RTPPacketBuilder::CreateNewSSRC().

+ Here is the caller graph for this function:

◆ GetRandom8()

virtual uint8_t qrtplib::RTPRandom::GetRandom8 ( )
pure virtual

Returns a random eight bit value.

Implemented in qrtplib::RTPRandomRandS, qrtplib::RTPRandomURandom, and qrtplib::RTPRandomRand48.

◆ GetRandomDouble()

virtual double qrtplib::RTPRandom::GetRandomDouble ( )
pure virtual

Returns a random number between $0.0$ and $1.0$.

Implemented in qrtplib::RTPRandomRandS, qrtplib::RTPRandomURandom, and qrtplib::RTPRandomRand48.

Referenced by qrtplib::RTCPScheduler::CalculateBYETransmissionInterval(), and qrtplib::RTCPScheduler::CalculateTransmissionInterval().

+ Here is the caller graph for this function:

◆ PickSeed()

uint32_t qrtplib::RTPRandom::PickSeed ( )

Can be used by subclasses to generate a seed for a random number generator.

Definition at line 54 of file rtprandom.cpp.

Referenced by qrtplib::RTPRandomRand48::RTPRandomRand48().

55 {
56  uint32_t x;
57 #ifdef _MSC_VER
58  x = GetCurrentProcessId();
59 #else
60  x = (uint32_t) getpid();
61 #endif
62  QDateTime currentDateTime = QDateTime::currentDateTime();
63  x += currentDateTime.toTime_t();
64 #if defined(WIN32)
65  x += QDateTime::currentMSecsSinceEpoch() % 1000;
66 #else
67  x += (uint32_t)clock();
68 #endif
69  x ^= (uint32_t)((uint8_t *)this - (uint8_t *)0);
70  return x;
71 }
unsigned int uint32_t
Definition: rtptypes_win.h:46
unsigned char uint8_t
Definition: rtptypes_win.h:42
+ Here is the caller graph for this function:

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