Last active
July 6, 2017 01:18
-
-
Save MikeLing/f29d8a39551734a3bd3fb202b40542ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CSGObject | |
{ | |
public: | |
void CSGObject::init() | |
{ | |
m_rng = std::unique_ptr<CRandom>(new CRandom(m_seed)); | |
} | |
static void set_global_seed(uint32_t seed) | |
{ | |
CSGObject::m_seed = seed; | |
} | |
static uint32_t get_global_seed() | |
{ | |
uint32_t seed = CSGObject::m_seed; | |
return seed; | |
} | |
private: | |
static uint32_t m_seed; | |
} | |
uint32_t CSGObject::m_seed = CRandom::generate_seed(); | |
class subclassOfSGObject:public CSGObject | |
{ | |
void dosomething() | |
{ | |
... | |
m_rng->random(); | |
... | |
} | |
static void dosomething() | |
{ | |
... | |
auto m_rng = std::unique_ptr<CRandom>(new CRandom(CSGObject::get_global_seed())); | |
m_rng->random(); | |
... | |
} | |
} | |
//in the test | |
TEST(dosomething, random) | |
{ | |
CSGObject::set_global_seed(12345) | |
...... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment