Skip to content

Commit 5736a0f

Browse files
committed
Move IRandomGenerator to public API
1 parent 1a68af0 commit 5736a0f

File tree

6 files changed

+29
-22
lines changed

6 files changed

+29
-22
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ target_sources(scratchcpp
6060
include/scratchcpp/textbubble.h
6161
include/scratchcpp/itimer.h
6262
include/scratchcpp/istacktimer.h
63+
include/scratchcpp/irandomgenerator.h
6364
include/scratchcpp/keyevent.h
6465
include/scratchcpp/rect.h
6566
include/scratchcpp/igraphicseffect.h
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
#pragma once
4+
5+
#include "global.h"
6+
7+
namespace libscratchcpp
8+
{
9+
10+
/*! \brief The IRandomGenerator interface represents a random number generator that can be received e. g. from an ExecutionContext. */
11+
class LIBSCRATCHCPP_EXPORT IRandomGenerator
12+
{
13+
public:
14+
virtual ~IRandomGenerator() { }
15+
16+
/*! Returns a random integer in the given range (inclusive). */
17+
virtual long randint(long start, long end) const = 0;
18+
19+
/*! Returns a random double in the given range (inclusive). */
20+
virtual double randintDouble(double start, double end) const = 0;
21+
22+
/*! Returns a random integer in the given range (inclusive) except the given integer. */
23+
virtual long randintExcept(long start, long end, long except) const = 0;
24+
};
25+
26+
} // namespace libscratchcpp

src/engine/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ target_sources(scratchcpp
2020
internal/stacktimer.h
2121
internal/randomgenerator.h
2222
internal/randomgenerator.cpp
23-
internal/irandomgenerator.h
2423
)
2524

2625
if(NOT LIBSCRATCHCPP_USE_LLVM)

src/engine/internal/irandomgenerator.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/engine/internal/randomgenerator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
#pragma once
44

5+
#include <scratchcpp/irandomgenerator.h>
56
#include <memory>
67
#include <random>
78

8-
#include "irandomgenerator.h"
9-
109
namespace libscratchcpp
1110
{
1211

test/mocks/randomgeneratormock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <engine/internal/irandomgenerator.h>
3+
#include <scratchcpp/irandomgenerator.h>
44
#include <gmock/gmock.h>
55

66
using namespace libscratchcpp;

0 commit comments

Comments
 (0)