aboutsummaryrefslogtreecommitdiff
path: root/Src/Agave/Random/api_random.h
blob: d0618f1647da4558e7d383b0a68a4d266e3bd76c (plain) (blame)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef NULLSOFT_API_RANDOM_H
#define NULLSOFT_API_RANDOM_H

#include <bfc/dispatch.h>
#include <bfc/platform/types.h>

typedef int (*RandomGenerator)(void);
typedef unsigned long (*UnsignedRandomGenerator)(void);

class api_random : public Dispatchable
{
protected:
	api_random() {}
	~api_random() {}
public:
	RandomGenerator  GetFunction();
	UnsignedRandomGenerator GetUnsignedFunction();
	int GetNumber();
	int GetPositiveNumber();
	float GetFloat(); // [0-1]
	float GetFloat_LessThanOne(); // [0-1)
	float GetFloat_LessThanOne_NotZero(); // (0-1)
	double GetDouble(); // [0-1)
public:
	DISPATCH_CODES
	{
	    API_RANDOM_GETFUNCTION = 10,
				API_RANDOM_GETFUNCTION_UNSIGNED = 11,
	    API_RANDOM_GETNUMBER = 20,
	    API_RANDOM_GETPOSITIVENUMBER = 30,
	    API_RANDOM_GETFLOAT = 40,
	    API_RANDOM_GETFLOAT2 = 41,
	    API_RANDOM_GETFLOAT3 = 42,
	    API_RANDOM_GETDOUBLE = 50,
	};
};

inline RandomGenerator api_random::GetFunction()
{
	return _call(API_RANDOM_GETFUNCTION, (RandomGenerator )0);
}
inline UnsignedRandomGenerator api_random::GetUnsignedFunction()
{
	return _call(API_RANDOM_GETFUNCTION_UNSIGNED, (UnsignedRandomGenerator )0);
}

inline int api_random::GetNumber()
{
	return _call(API_RANDOM_GETNUMBER, 0);
}
inline int api_random::GetPositiveNumber()
{
	return _call(API_RANDOM_GETPOSITIVENUMBER, 0);
}
inline float api_random::GetFloat()
{
	return _call(API_RANDOM_GETFLOAT, 0.f);
}
inline float api_random::GetFloat_LessThanOne()
{
	return _call(API_RANDOM_GETFLOAT2, 0.f);
}
inline float api_random::GetFloat_LessThanOne_NotZero()
{
	return _call(API_RANDOM_GETFLOAT3, 0.f);
}
inline double api_random::GetDouble()
{
	return _call(API_RANDOM_GETDOUBLE, 0.);
}

// {CB401CAB-CC10-48f7-ADB7-9D1D24B40E0C}
static const GUID randomApiGUID = 
{ 0xcb401cab, 0xcc10, 0x48f7, { 0xad, 0xb7, 0x9d, 0x1d, 0x24, 0xb4, 0xe, 0xc } };


#endif