nx_metadata_sdk 1.0 Metadata SDK

random_state_changer.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <random>
6
7 namespace nx {
8 namespace vms_server_plugins {
9 namespace analytics {
10 namespace stub {
11
12 class RandomStateChanger
13 {
14 public:
15 RandomStateChanger(int randModulus = 7, int maxNumberOfStateChanges = 4):
16 m_randModulus(randModulus),
17 m_maxStateChanges(maxNumberOfStateChanges)
18 {
19 }
20
21 void update()
22 {
23 m_stateChanged = m_maxStateChanges >= 0 && rand() % m_randModulus == 0;
24
25 if (m_stateChanged)
26 --m_maxStateChanges;
27 }
28
29 bool stateChanged() const
30 {
31 return m_stateChanged;
32 }
33
34 private:
35 const int m_randModulus;
36 int m_maxStateChanges;
37 bool m_stateChanged = false;
38 };
39
40 } // namespace stub
41 } // namespace analytics
42 } // namespace vms_server_plugins
43 } // namespace nx
nx
Definition: apple_utils.h:6
nx::vms_server_plugins::analytics::stub::RandomStateChanger
Definition: random_state_changer.h:12