Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPerStrokeRandomSource::Private Struct Reference

Public Member Functions

qint64 fetchInt (const QString &key)
 
 Private (const Private &rhs)
 
 Private (int _seed)
 

Public Attributes

qint64 generatorMax = 0
 
QMutex mutex
 
int seed = 0
 
QHash< QString, qint64 > valuesCache
 

Detailed Description

Definition at line 18 of file KisPerStrokeRandomSource.cpp.

Constructor & Destructor Documentation

◆ Private() [1/2]

KisPerStrokeRandomSource::Private::Private ( int _seed)
inline

Definition at line 20 of file KisPerStrokeRandomSource.cpp.

21 : seed(_seed)
22 {
23 boost::taus88 tempGenerator(seed);
24 generatorMax = tempGenerator.max();
25 }

References generatorMax, and seed.

◆ Private() [2/2]

KisPerStrokeRandomSource::Private::Private ( const Private & rhs)
inline

Definition at line 27 of file KisPerStrokeRandomSource.cpp.

28 : seed(rhs.seed),
29 generatorMax(rhs.generatorMax),
30 valuesCache(rhs.valuesCache)
31 {
32 }

Member Function Documentation

◆ fetchInt()

qint64 KisPerStrokeRandomSource::Private::fetchInt ( const QString & key)

Definition at line 59 of file KisPerStrokeRandomSource.cpp.

60{
61 QMutexLocker l(&mutex);
62
63 auto it = valuesCache.find(key);
64 if (it != valuesCache.end()) {
65 return it.value();
66 }
67
68 boost::taus88 oneTimeGenerator(seed + qHash(key));
69 const qint64 newValue = oneTimeGenerator();
70
71 valuesCache.insert(key, newValue);
72
73 return newValue;
74}
uint qHash(const KoInputDevice &key)

References mutex, qHash(), seed, and valuesCache.

Member Data Documentation

◆ generatorMax

qint64 KisPerStrokeRandomSource::Private::generatorMax = 0

Definition at line 37 of file KisPerStrokeRandomSource.cpp.

◆ mutex

QMutex KisPerStrokeRandomSource::Private::mutex

Definition at line 39 of file KisPerStrokeRandomSource.cpp.

◆ seed

int KisPerStrokeRandomSource::Private::seed = 0

Definition at line 36 of file KisPerStrokeRandomSource.cpp.

◆ valuesCache

QHash<QString, qint64> KisPerStrokeRandomSource::Private::valuesCache

Definition at line 38 of file KisPerStrokeRandomSource.cpp.


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