-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomImplementation.h
More file actions
40 lines (32 loc) · 1.09 KB
/
Copy pathRandomImplementation.h
File metadata and controls
40 lines (32 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef _RANDOM_IMPLEMENTATION_H_
#define _RANDOM_IMPLEMENTATION_H_
#include <OB/CORBA.h>
#include <random>
#include "RandomInterface_skel.h"
class RandomImplementation : virtual public POA_Genetic::RandomProvider,
virtual public PortableServer::RefCountServantBase
{
public:
RandomImplementation(CORBA::ORB_var orb)
{
_orb = orb;
std::random_device rd; // Will be used to obtain a seed for the
// random number engine
_gen.seed(rd());
}
virtual ::Genetic::RandomSeq* getRandomLong(::CORBA::Long num) throw(
::CORBA::SystemException) override
{
::Genetic::RandomSeq* rands = new ::Genetic::RandomSeq;
rands->length(num);
for (int i = 0; i < num; ++i) {
(*rands)[i] = _dist(_gen);
}
return rands;
}
private:
CORBA::ORB_var _orb;
std::mt19937 _gen;
std::uniform_int_distribution<int> _dist;
};
#endif